[MGNLCAMPU-103] Include referenced resources doesn't work Created: 12/Jan/23  Updated: 20/Mar/23  Resolved: 20/Mar/23

Status: Closed
Project: Campaign Publisher
Component/s: None
Affects Version/s: 2.0
Fix Version/s: 2.0.3

Type: Bug Priority: Neutral
Reporter: Jonathan Ayala Assignee: Miguel Martinez
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: 0.5h
Original Estimate: Not Specified

Issue Links:
Relates
relates to MGNLCAMPU-87 Migrate campaign publisher Selected
causality
Template:
Acceptance criteria:
Empty
Task DoD:
[X]* Doc/release notes changes? Comment present?
[X]* Downstream builds green?
[X]* Solution information and context easily available?
[X]* Tests
[X]* FixVersion filled and not yet released
[ ]  Architecture Decision Record (ADR)
Bug DoR:
[ ]* Steps to reproduce, expected, and actual results filled
[ ]* Affected version filled
Date of First Response:
Epic Link: AuthorX Support
Story Points: 5
Team: AuthorX
Work Started:

 Description   

Steps to reproduce

  1. In pages app, create a new page with basic template
  2. Add text and image element containing a reference to an asset
  3. Select the page in the tree view and press add to campaign (new)
  4. Mark checkbox include referenced resources and save changes.

Expected results

Both the page and the asset are added to campaign

Actual results

Only page is added to campaign

Workaround

Add the referred elements manually to the campaign in the corresponding content app (the asset in dam app in the example above)

Development notes

This is occurring when calling info.magnolia.campaignpublisher.ui.action.AddToCampaignFormAction.addReferencesFrom(Node, Node, String) as it always finds no references. This is because when calling getReferencesFrom there's a hardcoded null value in referenceProperties parameter, which would always result in no references.



 Comments   
Comment by Miguel Martinez [ 16/Jan/23 ]

Regarding this topic in the method that calls the class

Node baseItem = getOrAdd(jcrItem, workspace, targetSet);
baseItem.setProperty(Constants.Property.INCLUDE_DEPENDENCIES, true);
if (includeDependencies) {
    for (String repo : repoManager.getWorkspaceNames()) {
        if (repo.equals(RepositoryConstants.WEBSITE) || repo.equals(RepositoryConstants.VERSION_STORE)) {
            continue;
        }
        addReferencesFrom(jcrItem, targetSet, repo);
    }
} 

There is the default set included in the base item.

Also, the method that is called in null, it does not work as expected when calling with the specified references on the specified repo.

@Override
public Set<Node> getReferencesFrom(final Node nodeReferencedFrom, final String workspaceToSearchIn, final List<String> referenceProperties) throws RepositoryException {
    final Set<Node> referencesFrom = new HashSet<>();
    log.debug("Getting references from {}", nodeReferencedFrom.getPath());
    // Add all references found in properties of passed content
    Set<Node> referencesFromPropertiesOfNode = getReferencesFromProperties(nodeReferencedFrom, workspaceToSearchIn, referenceProperties);

    referencesFrom.addAll(referencesFromPropertiesOfNode);
    // and now find references in page areas and components
    for (Node node : getNodes(nodeReferencedFrom)) {
        log.debug("Getting references from {}", node.getPath());
        final Set<Node> referencesFromProperties = getReferencesFromProperties(node, workspaceToSearchIn, referenceProperties);
        referencesFrom.addAll(referencesFromProperties);
    }
    // duplicates, if any, are removed here.
    final Set<Node> referencesFromSorted = new TreeSet<>(new NodePathComparator());
    referencesFromSorted.addAll(referencesFrom);
    return referencesFromSorted;
} 

Which leads me to think that the reference part it was never working, or is not what it expected to from the very beginning. Will investigate further

Generated at Sun Feb 11 23:57:26 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.