javax.jcr.version.Version Java Examples
The following examples show how to use
javax.jcr.version.Version.
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 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 #2
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 #3
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 #4
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 #5
Source File: PageServiceImpl.java From mycollab with GNU Affero General Public License v3.0 | 5 votes |
private PageVersion convertNodeToPageVersion(Version node) { try { PageVersion version = new PageVersion(); version.setName(node.getName()); version.setIndex(node.getIndex()); version.setCreatedTime(node.getCreated()); return version; } catch (Exception e) { LOG.error("Error while get detail node version"); throw new MyCollabException(e); } }
Example #6
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 #7
Source File: NodeWrapper.java From sling-whiteboard with Apache License 2.0 | 4 votes |
@Override public void cancelMerge(Version version) throws VersionException, InvalidItemStateException, UnsupportedRepositoryOperationException, RepositoryException { this.delegate.cancelMerge(version); }
Example #8
Source File: NodeWrapper.java From sling-whiteboard with Apache License 2.0 | 4 votes |
@Override public void restore(Version version, boolean removeExisting) throws VersionException, ItemExistsException, InvalidItemStateException, UnsupportedRepositoryOperationException, LockException, RepositoryException { this.delegate.restore(version, removeExisting); }
Example #9
Source File: NodeWrapper.java From sling-whiteboard with Apache License 2.0 | 4 votes |
@Override public void restore(Version version, String relPath, boolean removeExisting) throws PathNotFoundException, ItemExistsException, VersionException, ConstraintViolationException, UnsupportedRepositoryOperationException, LockException, InvalidItemStateException, RepositoryException { this.delegate.restore(version, relPath, removeExisting); }
Example #10
Source File: NodeWrapper.java From sling-whiteboard with Apache License 2.0 | 4 votes |
@Override public Version getBaseVersion() throws UnsupportedRepositoryOperationException, RepositoryException { return this.delegate.getBaseVersion(); }
Example #11
Source File: NodeImpl.java From jackalope with Apache License 2.0 | 4 votes |
@Override public Version checkin() throws VersionException, UnsupportedRepositoryOperationException, InvalidItemStateException, LockException, RepositoryException { throw new UnsupportedRepositoryOperationException(); }
Example #12
Source File: NodeImpl.java From jackalope with Apache License 2.0 | 4 votes |
@Override public void doneMerge(Version version) throws VersionException, InvalidItemStateException, UnsupportedRepositoryOperationException, RepositoryException { throw new UnsupportedRepositoryOperationException(); }
Example #13
Source File: NodeImpl.java From jackalope with Apache License 2.0 | 4 votes |
@Override public void cancelMerge(Version version) throws VersionException, InvalidItemStateException, UnsupportedRepositoryOperationException, RepositoryException { throw new UnsupportedRepositoryOperationException(); }
Example #14
Source File: NodeImpl.java From jackalope with Apache License 2.0 | 4 votes |
@Override public void restore(Version version, boolean removeExisting) throws VersionException, ItemExistsException, InvalidItemStateException, UnsupportedRepositoryOperationException, LockException, RepositoryException { throw new UnsupportedRepositoryOperationException(); }
Example #15
Source File: NodeImpl.java From jackalope with Apache License 2.0 | 4 votes |
@Override public void restore(Version version, String relPath, boolean removeExisting) throws PathNotFoundException, ItemExistsException, VersionException, ConstraintViolationException, UnsupportedRepositoryOperationException, LockException, InvalidItemStateException, RepositoryException { throw new UnsupportedRepositoryOperationException(); }
Example #16
Source File: NodeImpl.java From jackalope with Apache License 2.0 | 4 votes |
@Override public Version getBaseVersion() throws UnsupportedRepositoryOperationException, RepositoryException { throw new UnsupportedRepositoryOperationException(); }
Example #17
Source File: WorkspaceImpl.java From jackalope with Apache License 2.0 | 4 votes |
@Override public void restore(Version[] versions, boolean removeExisting) throws ItemExistsException, UnsupportedRepositoryOperationException, VersionException, LockException, InvalidItemStateException, RepositoryException { }
Example #18
Source File: NodeWrapper.java From sling-whiteboard with Apache License 2.0 | 4 votes |
@Override public void doneMerge(Version version) throws VersionException, InvalidItemStateException, UnsupportedRepositoryOperationException, RepositoryException { this.delegate.doneMerge(version); }
Example #19
Source File: NodeWrapper.java From sling-whiteboard with Apache License 2.0 | 4 votes |
@Override public Version checkin() throws VersionException, UnsupportedRepositoryOperationException, InvalidItemStateException, LockException, RepositoryException { return this.delegate.checkin(); }
Example #20
Source File: WorkspaceWrapper.java From sling-whiteboard with Apache License 2.0 | 4 votes |
@Override public void restore(Version[] versions, boolean removeExisting) throws ItemExistsException, UnsupportedRepositoryOperationException, VersionException, LockException, InvalidItemStateException, RepositoryException { delegate.restore(versions, removeExisting); }
Example #21
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()]); }