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

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

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

Version.getUUID介绍

暂无

代码示例

代码示例来源:origin: org.apache.jackrabbit/jackrabbit-ocm

public String getUuid()
{
  try
  {
    return version.getUUID();
  }
  catch (RepositoryException e)
  {
    throw new VersionException("Error while retrieving the version UUID", e);
  }
}

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

/** {@inheritDoc} */
public void doneMerge(Version version) throws RepositoryException {
  try {
    remote.doneMerge(version.getUUID());
  } catch (RemoteException ex) {
    throw new RemoteRepositoryException(ex);
  }
}

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

/** {@inheritDoc} */
public void restore(Version version, String path, boolean removeExisting)
    throws RepositoryException {
  try {
    remote.restore(version.getUUID(), path, removeExisting);
  } catch (RemoteException ex) {
    throw new RemoteRepositoryException(ex);
  }
}

代码示例来源:origin: org.apache.jackrabbit/jackrabbit-jcr2spi

/**
 * @see VersionHistory#getVersionLabels(Version)
 */
public String[] getVersionLabels(Version version) throws VersionException, RepositoryException {
  // check-status performed within checkValidVersion
  checkValidVersion(version);
  String vUUID = version.getUUID();
  List<String> vlabels = new ArrayList<String>();
  Name[] qLabels = getQLabels();
  for (int i = 0; i < qLabels.length; i++) {
    String uuid = getVersionByLabel(qLabels[i]).getUUID();
    if (vUUID.equals(uuid)) {
      vlabels.add(session.getNameResolver().getJCRName(qLabels[i]));
    }
  }
  return vlabels.toArray(new String[vlabels.size()]);
}

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

/** {@inheritDoc} */
public void restore(Version version, boolean removeExisting)
    throws RepositoryException {
  try {
    remote.restoreByUUID(version.getUUID(), removeExisting);
  } catch (RemoteException ex) {
    throw new RemoteRepositoryException(ex);
  }
}

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

/** {@inheritDoc} */
public void cancelMerge(Version version) throws RepositoryException {
  try {
    remote.cancelMerge(version.getUUID());
  } catch (RemoteException ex) {
    throw new RemoteRepositoryException(ex);
  }
}

代码示例来源:origin: org.apache.jackrabbit/jackrabbit-jcr2spi

/**
 * @see VersionHistory#hasVersionLabel(Version, String)
 */
public boolean hasVersionLabel(Version version, String label) throws VersionException, RepositoryException {
  // check-status performed within checkValidVersion
  checkValidVersion(version);
  String vUUID = version.getUUID();
  Name l = getQLabel(label);
  Name[] qLabels = getQLabels();
  for (int i = 0; i < qLabels.length; i++) {
    if (qLabels[i].equals(l)) {
      String uuid = getVersionByLabel(qLabels[i]).getUUID();
      return vUUID.equals(uuid);
    }
  }
  return false;
}

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

/**
 * @see VersionHistory#hasVersionLabel(Version, String)
 */
public boolean hasVersionLabel(Version version, String label) throws VersionException, RepositoryException {
  // check-status performed within checkValidVersion
  checkValidVersion(version);
  String vUUID = version.getUUID();
  Name l = getQLabel(label);
  Name[] qLabels = getQLabels();
  for (int i = 0; i < qLabels.length; i++) {
    if (qLabels[i].equals(l)) {
      String uuid = getVersionByLabel(qLabels[i]).getUUID();
      return vUUID.equals(uuid);
    }
  }
  return false;
}

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

/**
 * @see VersionHistory#getVersionLabels(Version)
 */
public String[] getVersionLabels(Version version) throws VersionException, RepositoryException {
  // check-status performed within checkValidVersion
  checkValidVersion(version);
  String vUUID = version.getUUID();
  List<String> vlabels = new ArrayList<String>();
  Name[] qLabels = getQLabels();
  for (int i = 0; i < qLabels.length; i++) {
    String uuid = getVersionByLabel(qLabels[i]).getUUID();
    if (vUUID.equals(uuid)) {
      vlabels.add(session.getNameResolver().getJCRName(qLabels[i]));
    }
  }
  return vlabels.toArray(new String[vlabels.size()]);
}

代码示例来源:origin: org.exoplatform.jcr/exo.jcr.component.core

/**
* {@inheritDoc}
*/
public boolean hasVersionLabel(Version version, String label) throws VersionException, RepositoryException
{
 checkValid();
 NodeData versionData = getVersionDataByLabel(label);
 if (versionData != null && version.getUUID().equals(versionData.getIdentifier()))
 {
   return true;
 }
 return false;
}

代码示例来源:origin: org.exoplatform.jcr/exo.jcr.component.core

public boolean isSuccessorOrSameOf(VersionImpl anotherVersion) throws RepositoryException
{
 Version[] prds = getPredecessors();
 for (int i = 0; i < prds.length; i++)
 {
   if (prds[i].getUUID().equals(anotherVersion.getUUID())
    || ((VersionImpl)prds[i]).isSuccessorOrSameOf(anotherVersion))
   {
    return true;
   }
 }
 return false;
}

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

/**
 * Test if the a label added with VersionHistory.addVersionLabel(String,
 * String, boolean) corresponds to adding a reference property to the
 * jcr:versionLabels node of this history node, with the label as name of
 * the property, and the reference targeting the version.
 *
 * @see VersionHistory#addVersionLabel(String, String, boolean)
 */
public void testAddVersionCheckVersionLabelsNodeJcr2() throws RepositoryException {
  vHistory.addVersionLabel(version.getName(), versionLabel, false);
  // get jcr:versionLabels node
  vHistory = versionableNode.getSession().getWorkspace().getVersionManager().getVersionHistory(versionableNode.getPath());
  Node versionLabelNode = vHistory.getNode(jcrVersionLabels);
  assertTrue("The version label that has been successfully added must be present in the node '" + jcrVersionLabels + "'.", versionLabelNode.getProperty(versionLabel).getString().equals(version.getUUID()));
}

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

/**
 * Test that {@link VersionHistory#getAllVersions()} returns an iterator
 * containing the root version and all versions that have been created by
 * Node.checkin().
 *
 * @see javax.jcr.version.VersionHistory#getAllVersions()
 */
@SuppressWarnings("deprecation")
public void testGetAllVersions() throws RepositoryException {
  int cnt = 5;
  Map<String, Version> versions = new HashMap<String, Version>();
  Version v = vHistory.getRootVersion();
  versions.put(v.getUUID(), v);
  for (int i = 0; i < cnt; i++) {
    v = versionableNode.checkin();
    versions.put(v.getUUID(), v);
    versionableNode.checkout();
  }
  VersionIterator it = vHistory.getAllVersions();
  while (it.hasNext()) {
    v = it.nextVersion();
    if (!versions.containsKey(v.getUUID())) {
      fail("VersionHistory.getAllVersions() must only contain the root version and versions, that have been created by a Node.checkin() call.");
    }
    versions.remove(v.getUUID());
  }
  assertTrue("VersionHistory.getAllVersions() must contain the root version and all versions that have been created with a Node.checkin() call.", versions.isEmpty());
}

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

/**
 * Node.merge(): versionable subNode N checked-in: If V' is a successor (to
 * any degree) of V, then the merge result for N is update<br> modify a node
 * on the workspace1 and then merge the one in workspace2 with the one in
 * workspace1 precondition is that the node in workspace2 is checked in
 */
@SuppressWarnings("deprecation")
public void disable_testMergeNodeFromUpdatedSourceWorkspace() throws RepositoryException {
  Node originalNode = testRootNode.getNode(nodeName1);
  // update nodeName1 on workspace1
  originalNode.checkout();
  originalNode.checkin();
  testRootNode.getSession().save();
  // "merge" the clonedNode with the newNode from the default workspace
  // besteffort set to false to stop at the first failure
  nodeToMerge.merge(workspace.getName(), false);
  final String originalBaseVersionUUID = originalNode.getBaseVersion().getUUID();
  final String clonedBaseVersionUUID = nodeToMerge.getBaseVersion().getUUID();
  assertTrue("clonedNode has different version UUID than expected, it should be updated with the newNode version UUID", originalBaseVersionUUID.equals(clonedBaseVersionUUID));
}

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

/**
 * Test if the a label added with VersionHistory.addVersionLabel(String,
 * String, boolean) corresponds to adding a reference property to the
 * jcr:versionLabels node of this history node, with the label as name of
 * the property, and the reference targeting the version.
 *
 * @see VersionHistory#addVersionLabel(String, String, boolean)
 */
@SuppressWarnings("deprecation")
public void testAddVersionCheckVersionLabelsNode() throws RepositoryException {
  vHistory.addVersionLabel(version.getName(), versionLabel, false);
  // get jcr:versionLabels node
  vHistory = versionableNode.getVersionHistory();
  Node versionLabelNode = vHistory.getNode(jcrVersionLabels);
  assertTrue("The version label that has been successfully added must be present in the node '" + jcrVersionLabels + "'.", versionLabelNode.getProperty(versionLabel).getString().equals(version.getUUID()));
}

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

/**
 * Node.merge(): versionable subNode N checked-in: If V' is a predecessor
 * (to any degree) of V or if V and V' are identical (i.e., are actually the
 * same version), then the merge result for N is leave<br> modify a node on
 * the workspace2 and then merge the one in workspace2 with the one in
 * workspace1<br> the node in workspace2 should be updated<br> precondition
 * is that the node in workspace2 is checked in
 */
@SuppressWarnings("deprecation")
public void testMergeNodeFromOlderSourceWorkspace() throws RepositoryException {
  // touch the version on workspace2
  nodeToMerge.checkin();
  nodeToMerge.checkout();
  String baseVersionUUIDbeforeMerge = nodeToMerge.getBaseVersion().getUUID();
  // "merge" the clonedNode with the newNode from the default workspace
  // besteffort set to false to stop at the first failure
  nodeToMerge.merge(workspace.getName(), false);
  assertTrue("clonedNode has different UUID than expected, it should be left unchanged", baseVersionUUIDbeforeMerge.equals(nodeToMerge.getBaseVersion().getUUID()));
}

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

/**
 * Node.merge(): versionable subNode N: If N has status leave but parent is
 * update, then the subnode N is removed<br> retrieve the initialised node
 * to perform operations we need before for this test<br>
 */
@SuppressWarnings("deprecation")
public void disable_testRemoveNodeFromSourceWorkspaceAndMergeWithUpdate() throws RepositoryException {
  // status 'update' for parent
  nodeToMerge.checkin();
  nodeToMerge.checkout();
  // status 'leave' for subnode
  Node originalNode = testRootNode.getNode(nodeName1);
  Node originalSubNode = originalNode.getNode(nodeName2);
  originalSubNode.checkout();
  originalSubNode.checkin();
  // "merge" the nodeToMerge with the newNode from the default workspace
  // besteffort set to false to stop at the first failure
  nodeToMerge.merge(workspace.getName(), false);
  // if merge passed newSubNode1 should be also removed from workspace2
  assertFalse("subNode1 not removed from " + workspaceW2.getName() + " as expected", nodeToMerge.hasNode(nodeName2));
  // return version info about the clonedNode as it must also be updated
  final String originalBaseVersionUUID = originalNode.getBaseVersion().getUUID();
  final String clonedBaseVersionUUID = nodeToMerge.getBaseVersion().getUUID();
  assertTrue("clonedNode has different version UUID than expected, it should be updated with the newNode version UUID", originalBaseVersionUUID.equals(clonedBaseVersionUUID));
}

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

@SuppressWarnings("deprecation")
public void testGetNodeByUUID() throws RepositoryException {
  Node n = testRootNode.addNode(nodeName1, testNodeType);
  n.addMixin(mixVersionable);
  superuser.save();
  VersionManager vMgr = superuser.getWorkspace().getVersionManager();
  String uuid = vMgr.getBaseVersion(n.getPath()).getUUID();
  assertTrue("Session.getNodeByUUID() did not return Version object for a nt:version node.",
      superuser.getNodeByUUID(uuid) instanceof Version);
}

代码示例来源:origin: ModeShape/modeshape

@SuppressWarnings( "deprecation" )
public void testShouldCreateProperVersionHistoryWhenSavingVersionedNode() throws Exception {
  session = getHelper().getReadWriteSession();
  Node node = session.getRootNode().addNode("test", "nt:unstructured");
  node.addMixin("mix:versionable");
  session.save();
  assertThat(node.hasProperty("jcr:isCheckedOut"), is(true));
  assertThat(node.getProperty("jcr:isCheckedOut").getBoolean(), is(true));
  assertThat(node.hasProperty("jcr:versionHistory"), is(true));
  Node history = node.getProperty("jcr:versionHistory").getNode();
  assertThat(history, is(notNullValue()));
  assertThat(node.hasProperty("jcr:baseVersion"), is(true));
  Node version = node.getProperty("jcr:baseVersion").getNode();
  assertThat(version, is(notNullValue()));
  assertThat(version.getParent(), is(history));
  assertThat(node.hasProperty("jcr:uuid"), is(true));
  assertThat(node.getProperty("jcr:uuid").getString(), is(history.getProperty("jcr:versionableUuid").getString()));
  assertThat(versionHistory(node).getUUID(), is(history.getUUID()));
  assertThat(versionHistory(node).getIdentifier(), is(history.getIdentifier()));
  assertThat(versionHistory(node).getPath(), is(history.getPath()));
  assertThat(baseVersion(node).getUUID(), is(version.getUUID()));
  assertThat(baseVersion(node).getIdentifier(), is(version.getIdentifier()));
  assertThat(baseVersion(node).getPath(), is(version.getPath()));
}

代码示例来源:origin: org.exoplatform.jcr/exo.jcr.component.core

/**
* {@inheritDoc}
*/
public void doneMerge(Version version) throws VersionException, InvalidItemStateException,
 UnsupportedRepositoryOperationException, RepositoryException
{
 if (!session.getAccessManager().hasPermission(getACL(),
   new String[]{PermissionType.ADD_NODE, PermissionType.SET_PROPERTY}, session.getUserState().getIdentity()))
 {
   throw new AccessDeniedException("Access denied: done merge operation " + getPath() + " for: "
    + session.getUserID() + " item owner " + getACL().getOwner());
 }
 PlainChangesLog changesLog = new PlainChangesLogImpl(session);
 VersionImpl base = (VersionImpl)getBaseVersion();
 base.addPredecessor(version.getUUID(), changesLog);
 removeMergeFailed(version, changesLog);
 dataManager.getTransactManager().save(changesLog);
}

相关文章