javax.jcr.version.VersionHistory Java Examples
The following examples show how to use
javax.jcr.version.VersionHistory.
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 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 #3
Source File: BaseRepositoryService.java From urule with Apache License 2.0 | 5 votes |
@Override public List<VersionFile> getVersionFiles(String path) throws Exception{ path = processPath(path); Node rootNode=getRootNode(); if (!rootNode.hasNode(path)) { throw new RuleException("File [" + path + "] not exist."); } List<VersionFile> files = new ArrayList<VersionFile>(); Node fileNode = rootNode.getNode(path); VersionHistory versionHistory = versionManager.getVersionHistory(fileNode.getPath()); VersionIterator iterator = versionHistory.getAllVersions(); while (iterator.hasNext()) { Version version = iterator.nextVersion(); String versionName = version.getName(); if (versionName.startsWith("jcr:")) { continue; // skip root version } Node fnode = version.getFrozenNode(); VersionFile file = new VersionFile(); file.setName(version.getName()); file.setPath(fileNode.getPath()); Property prop = fnode.getProperty(CRATE_USER); file.setCreateUser(prop.getString()); prop = fnode.getProperty(CRATE_DATE); file.setCreateDate(prop.getDate().getTime()); if(fnode.hasProperty(VERSION_COMMENT)){ prop=fnode.getProperty(VERSION_COMMENT); file.setComment(prop.getString()); } files.add(file); } return files; }
Example #4
Source File: BaseRepositoryService.java From urule with Apache License 2.0 | 5 votes |
private InputStream readVersionFile(String path, String version) throws Exception{ path = processPath(path); Node rootNode=getRootNode(); if (!rootNode.hasNode(path)) { throw new RuleException("File [" + path + "] not exist."); } Node fileNode = rootNode.getNode(path); VersionHistory versionHistory = versionManager.getVersionHistory(fileNode.getPath()); Version v = versionHistory.getVersion(version); Node fnode = v.getFrozenNode(); Property property = fnode.getProperty(DATA); Binary fileBinary = property.getBinary(); return fileBinary.getStream(); }
Example #5
Source File: JcrStorageDao.java From nextreports-server with Apache License 2.0 | 5 votes |
public Entity getVersion(String id, String versionName) throws NotFoundException { // checkPath(path); Node node = getNodeById(id); if (!isVersionable(node)) { // TODO throws an custom exception return null; } try { VersionHistory versionHistory = getSession().getWorkspace().getVersionManager() .getVersionHistory(node.getPath()); Version baseVersion = getSession().getWorkspace().getVersionManager().getBaseVersion(node.getPath()); Version version = versionHistory.getVersion(versionName); Entity entity = getEntity(version.getNodes().nextNode()); // @todo another way ? // hack : otherwise name is "jcr:frozenNode" entity.setName(StorageUtil.getName(getEntity(node).getPath())); getJcrom().setBaseVersionInfo(entity, baseVersion.getName(), baseVersion.getCreated()); return entity; } catch (RepositoryException e) { throw convertJcrAccessException(e); } }
Example #6
Source File: VersionResourceImpl.java From document-management-software with GNU Lesser General Public License v3.0 | 4 votes |
@SuppressWarnings("unused") private VersionHistory getVersionHistoryItem() throws RepositoryException { return null; }
Example #7
Source File: NodeWrapper.java From sling-whiteboard with Apache License 2.0 | 4 votes |
@Override public VersionHistory getVersionHistory() throws UnsupportedRepositoryOperationException, RepositoryException { return this.delegate.getVersionHistory(); }
Example #8
Source File: NodeImpl.java From jackalope with Apache License 2.0 | 4 votes |
@Override public VersionHistory getVersionHistory() throws UnsupportedRepositoryOperationException, RepositoryException { throw new UnsupportedRepositoryOperationException(); }
Example #9
Source File: JcrStorageDao.java From nextreports-server with Apache License 2.0 | 4 votes |
public VersionInfo[] getVersionInfos(String id) throws NotFoundException { // checkPath(path); Node node = getNodeById(id); if (!isVersionable(node)) { // TODO throws an custom exception return new VersionInfo[0]; } List<VersionInfo> versionInfos = new ArrayList<VersionInfo>(); try { VersionHistory versionHistory = getSession().getWorkspace().getVersionManager() .getVersionHistory(node.getPath()); Version baseVersion = getSession().getWorkspace().getVersionManager().getBaseVersion(node.getPath()); VersionIterator versions = versionHistory.getAllVersions(); versions.skip(1); while (versions.hasNext()) { Version version = versions.nextVersion(); NodeIterator nodes = version.getNodes(); while (nodes.hasNext()) { VersionInfo versionInfo = new VersionInfo(); versionInfo.setName(version.getName()); try { Entity entity = getEntity(nodes.nextNode()); // after StorageUpdate20 when com.asf.nextserver package // was renamed with ro.nextreports.server // all version nodes remained with older className (they // cannot be changed because they are protected) // so they cannot be accessed anymore! if (entity == null) { continue; } String createdBy = entity.getLastUpdatedBy(); if (createdBy == null) { createdBy = entity.getCreatedBy(); } versionInfo.setCreatedBy(createdBy); versionInfo.setCreatedDate(version.getCreated().getTime()); versionInfo.setBaseVersion(baseVersion.getName().equals(version.getName())); versionInfos.add(versionInfo); } catch (JcrMappingException ex) { // getEntity version is not found??? // @todo why? } } } } catch (RepositoryException e) { throw convertJcrAccessException(e); } return versionInfos.toArray(new VersionInfo[versionInfos.size()]); }