Search code examples
aemjcr

AEM rollout configuration not working for blueprint to live copy flow triggered from code


I have a setup with blueprints and live copies but I am experiencing some weird behavior.

Example 1:

  • Edit the title of a page (blueprint) using the UI -> title gets also set in the live copy

Example 2:

  • Edit the title of a page (blueprint) using code -> title gets set in the blueprint but DOES NOT get set in the live copy

Code:

Session session = resourceResolver.adaptTo(Session.class);

Resource brandPageResource = resourceResolver.getResource("/content/platform-blueprints/company/nl/brands/439");
Page brandPage =  brandPageResource.adaptTo(Page.class);

Resource brandPageContentResource = brandPage.getContentResource();
Node brandPageContentNode = brandPageContentResource.adaptTo(Node.class);

try {
    brandPageContentNode.setProperty(JCR_TITLE, "NEW-TITLE-FROM-ENDPOINT");
} catch (RepositoryException e) {
    LOG.error("Error initializing components", e.getMessage(), e);
}

session.save();

Does somebody know why this is happening and how I can fix this?


Solution

  • When you change a node's property the surrounding page will not get an update on its cq:lastModified property and the page will not be marked as changed in the UI as well.

    You could use PageManager.touch() to update the cq:lastModified and cq:lastModifiedBy properties of the page.

    Using Resources instead of Nodes might also do the trick - but I am not sure about that one.