javax.jcr.version.Version.getPredecessors()方法的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(8.5k)|赞(0)|评价(0)|浏览(104)

本文整理了Java中javax.jcr.version.Version.getPredecessors()方法的一些代码示例,展示了Version.getPredecessors()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Version.getPredecessors()方法的具体详情如下:
包路径:javax.jcr.version.Version
类名称:Version
方法名:getPredecessors

Version.getPredecessors介绍

[英]In both simple and full versioning repositories, this method returns the predecessor versions of this version. This corresponds to returning all the nt:version nodes whose jcr:successors property includes a reference to the nt:version node that represents this version.
[中]在简单版本控制存储库和完整版本控制存储库中,此方法都会返回此版本的先前版本。这相当于返回所有nt:version节点,这些节点的jcr:successors属性包含对表示此版本的nt:version节点的引用。

代码示例

代码示例来源:origin: info.magnolia/magnolia-core

/**
 * @return the first predecessor or null if no previous version exists.
 */
public static Version getPreviousVersion(Version version) throws RepositoryException {
  if (version == null) {
    return null;
  }
  Version[] predecessors = version.getPredecessors();
  if (predecessors.length > 0) {
    return predecessors[0];
  }
  return null;
}

代码示例来源:origin: info.magnolia/magnolia-core

public Version[] getPredecessors() throws RepositoryException {
  // would prefer to return the above version (List of ContentVersions), but since our other APIs return jcr Version as well ...
  return this.state.getPredecessors();
}

代码示例来源:origin: org.onehippo.cms7/hippo-repository-connector

/**
 * @inheritDoc
 */
public Version[] getPredecessors() throws RepositoryException {
  Version[] predecessors = version.getPredecessors();
  for (int i = 0; i < predecessors.length; i++) {
    predecessors[i] = factory.getVersionDecorator(session, predecessors[i]);
  }
  return predecessors;
}

代码示例来源:origin: net.adamcin.oakpal/oakpal-core

@Override
public Version[] getPredecessors() throws RepositoryException {
  Version[] internalVersions = delegate.getPredecessors();
  if (internalVersions == null) {
    return null;
  }
  for (int i = 0; i < internalVersions.length; i++) {
    internalVersions[i] = new VersionFacade<>(internalVersions[i], session);
  }
  return internalVersions;
}

代码示例来源:origin: apache/jackrabbit

/** {@inheritDoc} */
public RemoteVersion[] getPredecessors() throws RepositoryException, RemoteException {
  try {
    return getRemoteVersionArray(version.getPredecessors());
  } catch (RepositoryException ex) {
    throw getRepositoryException(ex);
  }
}

代码示例来源:origin: info.magnolia/magnolia-core

@Override
public Version[] getPredecessors() throws RepositoryException {
  return wrapVersions(getWrappedVersion().getPredecessors());
}

代码示例来源:origin: apache/jackrabbit

/**
 * Test if the root version does not have any predecessor versions.
 *
 * @throws RepositoryException
 */
public void testRootVersionHasNoPredecessorJcr2() throws RepositoryException {
  Version[] predec = versionableNode.getSession().getWorkspace().getVersionManager().getVersionHistory(versionableNode.getPath()).getRootVersion().getPredecessors();
  assertTrue("The root version may not have any predecessors.", predec.length == 0);
}

代码示例来源:origin: apache/jackrabbit

/**
 * Test if the root version does not have any predecessor versions.
 *
 * @throws RepositoryException
 */
public void testRootVersionHasNoPredecessor() throws RepositoryException {
  Version[] predec = versionableNode.getVersionHistory().getRootVersion().getPredecessors();
  assertTrue("The root version may not have any predecessors.", predec.length == 0);
}

代码示例来源:origin: apache/jackrabbit

/**
 * Returns the predecessor versions of this version. This corresponds to
 * returning all the nt:version nodes whose jcr:successors property includes
 * a reference to the nt:version node that represents this version. A
 * RepositoryException is thrown if an error occurs.
 */
public void testGetPredecessors() throws RepositoryException {
  // create a new version
  versionableNode.checkout();
  Version version = versionableNode.checkin();
  assertTrue("Version should have at minimum one predecessor version.", version.getPredecessors().length > 0);
}

代码示例来源:origin: apache/jackrabbit

/**
 * Test if the predecessors of the removed version are made predecessor of
 * its original successor version.
 *
 * @throws RepositoryException
 */
public void testRemoveVersionAdjustPredecessorSet() throws RepositoryException {
  // retrieve predecessors to test and remove the version
  List<String> predecPaths = new ArrayList<String>();
  Version[] predec = version.getPredecessors();
  for (int i = 0; i < predec.length; i++) {
    predecPaths.add(predec[i].getPath());
  }
  vHistory.removeVersion(version.getName());
  // new predecessors of the additional version
  Version[] predec2 = version2.getPredecessors();
  for (int i = 0; i < predec2.length; i++) {
    if (!predecPaths.remove(predec2[i].getPath())) {
      fail("All predecessors of the removed version must be made predecessors of it's original successor version.");
    }
  }
  if (!predecPaths.isEmpty()) {
    fail("All predecessors of the removed version must be made predecessors of it's original successor version.");
  }
}

代码示例来源:origin: brix-cms/brix-cms

public JcrVersion[] execute() throws Exception {
    return JcrVersion.Wrapper.wrap(getDelegate().getPredecessors(), getJcrSession());
  }
});

代码示例来源:origin: brix-cms/brix-cms

public Version[] getPredecessors() throws RepositoryException {
  return wrap(getDelegate().getPredecessors(), getSessionWrapper());
}

代码示例来源:origin: apache/jackrabbit

/**
 * Test removed version gets invalid
 */
public void testRemovedInvalid() throws Exception {
  versionableNode.getVersionHistory().removeVersion(version.getName());
  // assert: version has become invalid
  try {
    version.getPredecessors();
    fail("Removed version still operational.");
  } catch (RepositoryException e) {
    // expected
  }
}

代码示例来源:origin: org.apache.sling/org.apache.sling.servlets.get

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();
}

代码示例来源:origin: apache/jackrabbit

Version[] predecessors = nodeToMerge.getBaseVersion().getPredecessors();

代码示例来源:origin: apache/jackrabbit

private void assertPredecessors(String expected, Version version)
    throws Exception {
  Set predecessors = new HashSet();
  if (expected.length() > 0) {
    predecessors.addAll(Arrays.asList(expected.split(" ")));
  }
  Version[] versions = version.getPredecessors();
  for (int i = 0; i < versions.length; i++) {
    if (!predecessors.remove(versions[i].getName())) {
      fail("Version " + version.getName()
          + " has an unexpected predessor "
          + versions[i].getName());
    }
  }
  if (!predecessors.isEmpty()) {
    fail("Version " + version.getName()
        + " does not have all expected predecessors");
  }
}

代码示例来源:origin: apache/jackrabbit

/**
 * 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.");
    }
  }
}

代码示例来源:origin: info.magnolia/magnolia-core

@Test
  public void testPredecessorsAreWrapped() 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_2.getPredecessors();

    // THEN
    assertTrue(versions[0] instanceof ContentDecoratorVersionWrapper);
    assertTrue(versions[0].isSame(createdVersion_1));
  }
}

代码示例来源:origin: apache/jackrabbit

if (v.getPredecessors().length > 0) {
  if (!excludeReferenced || !v.getReferences().hasNext()) {
    allVersions.add(v);

代码示例来源:origin: apache/jackrabbit

vOther.getPredecessors();
  fail("Removed version still operational.");
} catch (RepositoryException e) {

相关文章