javax.jcr.version.VersionIterator Java Examples
The following examples show how to use
javax.jcr.version.VersionIterator.
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: 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 #3
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()]); }