Generating Page Versions difference programmatically | Community
Skip to main content
Satish_Jadhav
New Participant
December 2, 2020
Solved

Generating Page Versions difference programmatically

  • December 2, 2020
  • 2 replies
  • 1257 views

Referring to the URL -> https://experienceleague.adobe.com/docs/experience-manager-65/authoring/siteandpage/working-with-page-versions.html?lang=en#timewarp 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 ?

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by BrianKasingli

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

 

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(); }

 

 

2 replies

New Participant
January 24, 2024

@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.

BrianKasingli
BrianKasingliAccepted solution
New Participant
July 14, 2023

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

 

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(); }