in core/src/main/java/org/apache/sling/cms/core/internal/listeners/AutoVersioningListener.java [145:167]
private void versionPage(Resource page, String user) {
log.debug("Versioning page {}", page);
ModifiableValueMap mvm = null;
Resource content = page.getChild(JcrConstants.JCR_CONTENT);
if (content != null) {
mvm = content.adaptTo(ModifiableValueMap.class);
}
Node node = page.adaptTo(Node.class);
if (mvm != null && node != null) {
try {
mvm.put(CMSConstants.PN_LAST_MODIFIED_BY, user);
mvm.put(JcrConstants.JCR_LASTMODIFIED, Calendar.getInstance());
node.addMixin(JcrConstants.MIX_VERSIONABLE);
page.getResourceResolver().commit();
node.getSession().getWorkspace().getVersionManager().checkpoint(node.getPath());
} catch (PersistenceException e) {
log.warn("Failed to save modification date on page: " + page, e);
} catch (RepositoryException e) {
log.warn("Failed to version page: " + page, e);
}
}
}