Expand my Community achievements bar.

Enhance your AEM Assets & Boost Your Development: [AEM Gems | June 19, 2024] Improving the Developer Experience with New APIs and Events
SOLVED

Generating Page Versions difference programmatically

Avatar

Level 1

Referring to the URL -> https://experienceleague.adobe.com/docs/experience-manager-65/authoring/siteandpage/working-with-pag... where we can view the difference between two version of a page.

 

We want to implement similar functionality in workflow. Once the workflow is submitted by author group, we want to provide a link through email to the approver group where upon clicking this link, the approver group can view the difference as posted in above link.

 

Are there API exposed which would generate the link with difference between the current modified page and last version created ?

Topics

Topics help categorize Community content and increase your ability to discover relevant content.

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

You can use the Version Manager, https://developer.adobe.com/experience-manager/reference-materials/spec/jsr170/javadocs/jcr-2.0/java...

 

See the generic example code below to add versioning to a node.

 

try {
    Session session = resolver.adaptTo(Session.class);
    Node node = resource.adaptTo(Node.class);

    VersionManager versionManager = session.getWorkspace().getVersionManager();
    versionManager.checkout(node.getPath());

    // Perform modifications to the node here

    versionManager.checkin(node.getPath());
    Version newVersion = versionManager.getBaseVersion(node.getPath());

    // Access the information about the newly created version
    String versionName = newVersion.getName();
    String versionPath = newVersion.getPath();

    // Use the version information as needed
} catch (RepositoryException e) {
    // Handle exceptions
} finally {
    resolver.close();
}

 

 

View solution in original post

2 Replies

Avatar

Correct answer by
Community Advisor

You can use the Version Manager, https://developer.adobe.com/experience-manager/reference-materials/spec/jsr170/javadocs/jcr-2.0/java...

 

See the generic example code below to add versioning to a node.

 

try {
    Session session = resolver.adaptTo(Session.class);
    Node node = resource.adaptTo(Node.class);

    VersionManager versionManager = session.getWorkspace().getVersionManager();
    versionManager.checkout(node.getPath());

    // Perform modifications to the node here

    versionManager.checkin(node.getPath());
    Version newVersion = versionManager.getBaseVersion(node.getPath());

    // Access the information about the newly created version
    String versionName = newVersion.getName();
    String versionPath = newVersion.getPath();

    // Use the version information as needed
} catch (RepositoryException e) {
    // Handle exceptions
} finally {
    resolver.close();
}

 

 

Avatar

Level 3

@Satish_Jadhav : Even I have the same requirement as you. May I please know if your issue is solved. If yes, can you please reply about the approach you followed.