@Override public boolean isCurrent() { try { Version[] successors = version.getSuccessors(); if (successors == null || successors.length == 0) { return true; } } catch (RepositoryException e) { // no-op } return false; }
@Override public boolean isCurrent() { try { Version[] successors = version.getSuccessors(); if (successors == null || successors.length == 0) { return true; } } catch (RepositoryException e) { } return false; }
@Override public boolean isCurrent() { try { Version[] successors = version.getSuccessors(); if (successors == null || successors.length == 0) { return true; } } catch (RepositoryException e) { } return false; }
@Override public boolean isCurrent() { try { Version[] successors = version.getSuccessors(); if (successors == null || successors.length == 0) { return true; } } catch (RepositoryException e) { // no-op } return false; }
/** * @return the first successor or null if no next version exists. */ public static Version getNextVersion(Version version) throws RepositoryException { if (version == null) { return null; } Version[] successors = version.getSuccessors(); if (successors.length > 0) { return successors[0]; } return null; }
@Override public Version[] getSuccessors() throws RepositoryException { return version.getSuccessors(); }
@Override public Version[] getSuccessors() throws RepositoryException { Version[] internalVersions = delegate.getSuccessors(); if (internalVersions == null) { return null; } for (int i = 0; i < internalVersions.length; i++) { internalVersions[i] = new VersionFacade<>(internalVersions[i], session); } return internalVersions; }
/** * @inheritDoc */ public Version[] getSuccessors() throws RepositoryException { Version[] successors = version.getSuccessors(); for (int i = 0; i < successors.length; i++) { successors[i] = factory.getVersionDecorator(session, successors[i]); } return successors; }
/** {@inheritDoc} */ public RemoteVersion[] getSuccessors() throws RepositoryException, RemoteException { try { return getRemoteVersionArray(version.getSuccessors()); } catch (RepositoryException ex) { throw getRepositoryException(ex); } }
@Override public Version[] getSuccessors() throws RepositoryException { return wrapVersions(getWrappedVersion().getSuccessors()) ; }
public static Object getVersionSummaries( final Session session, final PentahoJcrConstants pentahoJcrConstants, final Serializable fileId, final boolean includeAclOnlyChanges ) throws RepositoryException { Node fileNode = session.getNodeByIdentifier( fileId.toString() ); VersionHistory versionHistory = session.getWorkspace().getVersionManager().getVersionHistory( fileNode.getPath() ); // get root version but don't include it in version summaries; from JSR-170 specification section 8.2.5: // [root version] is a dummy version that serves as the starting point of the version graph. Like all version // nodes, // it has a subnode called jcr:frozenNode. But, in this case that frozen node does not contain any state // information // about N Version version = versionHistory.getRootVersion(); Version[] successors = version.getSuccessors(); List<VersionSummary> versionSummaries = new ArrayList<VersionSummary>(); while ( successors != null && successors.length > 0 ) { version = successors[0]; // branching not supported VersionSummary sum = toVersionSummary( pentahoJcrConstants, versionHistory, version ); if ( !sum.isAclOnlyChange() || ( includeAclOnlyChanges && sum.isAclOnlyChange() ) ) { versionSummaries.add( sum ); } successors = version.getSuccessors(); } return versionSummaries; }
public JcrVersion[] execute() throws Exception { return JcrVersion.Wrapper.wrap(getDelegate().getSuccessors(), getJcrSession()); } });
public Version[] getSuccessors() throws RepositoryException { return wrap(getDelegate().getSuccessors(), getSessionWrapper()); }
private JsonObject getJsonObject(Resource resource, VersionManager vm) throws RepositoryException { final JsonObjectBuilder result = Json.createObjectBuilder(); final Node node = resource.adaptTo(Node.class); if (node == null || !node.isNodeType(JcrConstants.MIX_VERSIONABLE)) { return result.build(); } final String absPath = resource.getPath(); final VersionHistory history = vm.getVersionHistory(absPath); final Version baseVersion = vm.getBaseVersion(absPath); for (final VersionIterator it = history.getAllVersions(); it.hasNext();) { final Version v = it.nextVersion(); final JsonObjectBuilder obj = Json.createObjectBuilder(); obj.add("created", createdDate(v)); obj.add("successors", getArrayBuilder(getNames(v.getSuccessors()))); obj.add("predecessors", getArrayBuilder(getNames(v.getPredecessors()))); obj.add("labels", getArrayBuilder(history.getVersionLabels(v))); obj.add("baseVersion", baseVersion.isSame(v)); result.add(v.getName(), obj); } return Json.createObjectBuilder().add("versions", result).build(); }
/** * Test if the successors of the removed version are made successors of * all predecessors of the the removed version. * * @throws RepositoryException */ public void testRemoveVersionAdjustSucessorSet() throws RepositoryException { // retrieve predecessors to test and remove the version Version[] predec = version.getPredecessors(); vHistory.removeVersion(version.getName()); for (int i = 0; i < predec.length; i++) { boolean isContained = false; Version[] succ = predec[i].getSuccessors(); for (int j = 0; j < succ.length; j++) { isContained |= succ[j].isSame(version2); } if (!isContained) { fail("Removing a version must make all it's successor version to successors of the removed version's predecessors."); } } }
private void assertSuccessors(String expected, Version version) throws Exception { Set successors = new HashSet(); if (expected.length() > 0) { successors.addAll(Arrays.asList(expected.split(" "))); } Version[] versions = version.getSuccessors(); for (int i = 0; i < versions.length; i++) { if (!successors.remove(versions[i].getName())) { fail("Version " + version.getName() + " has an unexpected successor " + versions[i].getName()); } } if (!successors.isEmpty()) { fail("Version " + version.getName() + " does not have all expected successors"); } }
private static void assertSuccessors(VersionHistory history, Set<String> expectedSuccessors, String versionName) throws RepositoryException { assertEquals(expectedSuccessors, getNames(history.getVersion(versionName).getSuccessors())); }
while (v.getSuccessors().length > 0) { v = v.getSuccessors()[0];
/** * helper method for {@link #testXAVersionsThoroughly()} */ private void check(Version v, String phase, String name, int numSucc) { String vName; int vSucc = -1; try { vName = v.getName(); //vSucc = v.getProperty("jcr:successors").getValues().length; vSucc = v.getSuccessors().length; } catch (RepositoryException e) { // node is invalid after remove vName = name; } assertEquals(phase + " Version Name", name, vName); assertEquals(phase + " Num Successors", numSucc, vSucc); }
@Test public void testSuccessorsAreWrapped() throws Exception { // GIVEN Session session = MgnlContext.getJCRSession(RepositoryConstants.WEBSITE); VersionManager versionMan = Components.getComponent(VersionManager.class); Node node = session.getRootNode().addNode( "page", NodeTypes.Page.NAME); session.save(); Version createdVersion_1 = versionMan.addVersion(node); Version createdVersion_2 = versionMan.addVersion(node); // WHEN Version[] versions = createdVersion_1.getSuccessors(); // THEN assertTrue(versions[0] instanceof ContentDecoratorVersionWrapper); assertTrue(versions[0].isSame(createdVersion_2)); }