javax.jcr.version.VersionManager Java Examples
The following examples show how to use
javax.jcr.version.VersionManager.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PageServiceImpl.java From mycollab with GNU Affero General Public License v3.0 | 6 votes |
@Override public List<PageVersion> getPageVersions(final String path) { return jcrTemplate.execute(session -> { Node rootNode = session.getRootNode(); Node node = JcrUtils.getNodeIfExists(rootNode, path); if (node != null) { VersionManager vm = session.getWorkspace().getVersionManager(); VersionHistory history = vm.getVersionHistory("/" + path); List<PageVersion> versions = new ArrayList<>(); for (VersionIterator it = history.getAllVersions(); it.hasNext(); ) { Version version = (Version) it.next(); if (!"jcr:rootVersion".equals(version.getName())) { versions.add(convertNodeToPageVersion(version)); } } return versions; } else { return null; } }); }
Example #2
Source File: PageServiceImpl.java From mycollab with GNU Affero General Public License v3.0 | 6 votes |
@Override public Page restorePage(final String path, final String versionName) { return jcrTemplate.execute(session -> { Node rootNode = session.getRootNode(); Node node = JcrUtils.getNodeIfExists(rootNode, path); if (node != null) { VersionManager vm = session.getWorkspace().getVersionManager(); try { vm.restore("/" + path, versionName, true); node = JcrUtils.getNodeIfExists(rootNode, path); return convertNodeToPage(node); } catch (Exception e) { LOG.error("Error when restore document {} to version {}", path, versionName, e); } } return null; }); }
Example #3
Source File: PageServiceImpl.java From mycollab with GNU Affero General Public License v3.0 | 6 votes |
@Override public Page getPageByVersion(final String path, final String versionName) { return jcrTemplate.execute(session -> { Node rootNode = session.getRootNode(); Node node = JcrUtils.getNodeIfExists(rootNode, path); if (node != null) { VersionManager vm = session.getWorkspace().getVersionManager(); VersionHistory history = vm.getVersionHistory("/" + path); Version version = history.getVersion(versionName); if (version != null) { Node frozenNode = version.getFrozenNode(); return convertNodeToPage(frozenNode); } else { return null; } } else { return null; } }); }
Example #4
Source File: WorkspaceWrapper.java From sling-whiteboard with Apache License 2.0 | 4 votes |
@Override public VersionManager getVersionManager() throws UnsupportedRepositoryOperationException, RepositoryException { return delegate.getVersionManager(); }
Example #5
Source File: WorkspaceImpl.java From jackalope with Apache License 2.0 | 4 votes |
@Override public VersionManager getVersionManager() throws UnsupportedRepositoryOperationException, RepositoryException { return null; }