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

x33g5p2x  于2022-01-24 转载在 其他  
字(8.1k)|赞(0)|评价(0)|浏览(193)

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

Node.getUUID介绍

[英]Returns the UUID of this node as recorded in this node's jcr:uuid property. This method only works on nodes of mixin node type mix:referenceable.

On nonreferenceable nodes, this method throws an UnsupportedRepositoryOperationException. To avoid throwing an exception to determine whether a node has a UUID, a call to #isNodeType(String) can be made.
[中]返回此节点jcr:uuid属性中记录的该节点的UUID。此方法仅适用于mixin节点类型mix:referenceable的节点。
在不可引用的节点上,此方法抛出UnsupportedRepositoryOperationException。为了避免抛出异常以确定节点是否具有UUID,可以调用#isNodeType(String)。

代码示例

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

  1. /**
  2. * @inheritDoc
  3. */
  4. public String getUUID() throws UnsupportedRepositoryOperationException, RepositoryException {
  5. return node.getUUID();
  6. }

代码示例来源:origin: org.onehippo.cms7/hippo-cms-api

  1. private static String getUUID(Node node) throws RepositoryException {
  2. try {
  3. return node.getUUID();
  4. } catch (UnsupportedRepositoryOperationException e) {
  5. return "";
  6. }
  7. }

代码示例来源:origin: org.onehippo.cms7/hippo-cms-yui

  1. private static String getUUID(Node node) throws RepositoryException {
  2. try {
  3. return node.getUUID();
  4. } catch (UnsupportedRepositoryOperationException e) {
  5. return "";
  6. }
  7. }

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

  1. @Override
  2. public String getUUID() {
  3. try {
  4. return this.node.getUUID();
  5. } catch (UnsupportedOperationException e) {
  6. log.error(e.getMessage());
  7. } catch (RepositoryException re) {
  8. log.error("Exception caught", re);
  9. }
  10. return StringUtils.EMPTY;
  11. }

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

  1. /** {@inheritDoc} */
  2. @SuppressWarnings("deprecation")
  3. public String getUUID() throws RepositoryException, RemoteException {
  4. try {
  5. return node.getUUID();
  6. } catch (RepositoryException ex) {
  7. throw getRepositoryException(ex);
  8. }
  9. }

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

  1. /**
  2. * Tests if adding a property with <code>Node.setProperty(String,
  3. * Node)</code> works with <code>Session.save()</code>
  4. */
  5. public void testNewNodePropertySession() throws Exception {
  6. testNode.setProperty(propertyName1, n1);
  7. superuser.save();
  8. assertEquals("Setting property with Node.setProperty(String, Node) and Session.save() not working",
  9. n1.getUUID(),
  10. testNode.getProperty(propertyName1).getString());
  11. }

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

  1. /**
  2. * Tests if adding a property with <code>Node.setProperty(String,
  3. * Node)</code> works with <code>parentNode.save()</code>
  4. */
  5. public void testNewNodePropertyParent() throws Exception {
  6. testNode.setProperty(propertyName1, n1);
  7. testRootNode.getSession().save();
  8. assertEquals("Setting property with Node.setProperty(String, Node) and parentNode.save() not working",
  9. n1.getUUID(),
  10. testNode.getProperty(propertyName1).getString());
  11. }

代码示例来源:origin: org.onehippo.cms7/hippo-cms-editor-frontend

  1. @Override
  2. public void onClear() {
  3. Node node = ((JcrNodeModel) FacetSelectTemplatePlugin.this.getDefaultModel()).getNode();
  4. try {
  5. node.setProperty("hippo:docbase", node.getSession().getRootNode().getUUID());
  6. } catch (RepositoryException e) {
  7. log.error("Unable to reset docbase to rootnode uuid", e);
  8. }
  9. redraw();
  10. }

代码示例来源:origin: org.apache.sling/org.apache.sling.testing.sling-mock-oak

  1. @Override @SuppressWarnings("deprecation")
  2. public Value createValue(Node value, boolean weak) throws RepositoryException {
  3. if (!value.isNodeType(NodeType.MIX_REFERENCEABLE)) {
  4. throw new ValueFormatException(
  5. "Node is not referenceable: " + value.getPath());
  6. }
  7. return weak
  8. ? newValue(GenericPropertyState.weakreferenceProperty("", value.getUUID()), namePathMapper)
  9. : newValue(GenericPropertyState.referenceProperty("", value.getUUID()), namePathMapper);
  10. }

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

  1. @NotNull
  2. public Value createValue(@NotNull Node value, boolean weak) throws RepositoryException {
  3. if (!value.isNodeType(NodeType.MIX_REFERENCEABLE)) {
  4. throw new ValueFormatException(
  5. "Node is not referenceable: " + value.getPath());
  6. }
  7. return weak
  8. ? newValue(GenericPropertyState.weakreferenceProperty("", value.getUUID()), namePathMapper, getBlobAccessProvider())
  9. : newValue(GenericPropertyState.referenceProperty("", value.getUUID()), namePathMapper, getBlobAccessProvider());
  10. }

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

  1. public WorkflowDescriptor getWorkflowDescriptor(String category, Node item) throws RepositoryException {
  2. try {
  3. RemoteWorkflowDescriptor remoteDescriptor = remote.getWorkflowDescriptor(category, item.getUUID());
  4. if (remoteDescriptor != null) {
  5. return new ClientWorkflowDescriptor(remoteDescriptor);
  6. } else {
  7. return null;
  8. }
  9. } catch(RemoteException ex) {
  10. throw new RemoteRuntimeException(ex);
  11. }
  12. }

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

  1. protected String getExistingUUID() throws RepositoryException {
  2. Node n = adminSession.getRootNode();
  3. n.addMixin(JcrConstants.MIX_REFERENCEABLE);
  4. //noinspection deprecation
  5. return n.getUUID();
  6. }

代码示例来源:origin: org.onehippo.cms7/hippo-addon-hst-configuration-editor-frontend

  1. protected void saveNode(Node node) {
  2. try {
  3. getModel().setObject(node.getUUID());
  4. } catch (RepositoryException ex) {
  5. error(ex.getMessage());
  6. }
  7. }

代码示例来源:origin: pentaho/pentaho-platform

  1. public Object doInJcr( final Session session ) throws RepositoryException {
  2. Item item;
  3. try {
  4. item = session.getItem( absPath );
  5. } catch ( PathNotFoundException e ) {
  6. return null;
  7. }
  8. Assert.isTrue( item.isNode() );
  9. return ( (Node) item ).getUUID();
  10. }
  11. } );

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

  1. /**
  2. * Tests if VersionHistory.getVersionableUUID() returns the uuid of the
  3. * corresponding versionable node.
  4. */
  5. public void testGetVersionableUUID() throws RepositoryException {
  6. // create version
  7. versionableNode.checkout();
  8. Version version = versionableNode.checkin();
  9. assertEquals("Method getVersionableUUID() must return the UUID of the corresponding Node.",
  10. version.getContainingHistory().getVersionableUUID(),
  11. versionableNode.getUUID());
  12. }

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

  1. @Test
  2. public void testCopyReferenceableChildNode() throws Exception {
  3. Session session = getAdminSession();
  4. session.getNode(TEST_PATH + "/source/node").addNode("child").addMixin(JcrConstants.MIX_REFERENCEABLE);
  5. session.save();
  6. session.getWorkspace().copy(TEST_PATH + "/source/node", TEST_PATH + "/target/copied");
  7. assertTrue(testNode.hasNode("source/node"));
  8. assertTrue(testNode.hasNode("target/copied"));
  9. Node childCopy = testNode.getNode("target/copied/child");
  10. assertTrue(childCopy.isNodeType(JcrConstants.MIX_REFERENCEABLE));
  11. assertFalse(childCopy.getUUID().equals(testNode.getNode("source/node/child").getUUID()));
  12. }

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

  1. /**
  2. * Same as {@link #testAccessMovedReferenceableByUUID()} but calls save()
  3. * before accessing the node again.
  4. */
  5. public void testAccessMovedReferenceableByUUID2() throws RepositoryException, NotExecutableException {
  6. String uuid = moveNode.getUUID();
  7. //move the node
  8. doMove(moveNode.getPath(), destinationPath);
  9. superuser.save();
  10. Node n = superuser.getNodeByUUID(uuid);
  11. assertTrue("After successful moving a referenceable node node, accessing the node by uuid must return the same node.", n.isSame(moveNode));
  12. }

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

  1. /**
  2. * Test if a moved referenceable node returns the same item than the moved
  3. * node.
  4. */
  5. public void testAccessMovedReferenceableByUUID() throws RepositoryException, NotExecutableException {
  6. String uuid = moveNode.getUUID();
  7. //move the node
  8. doMove(moveNode.getPath(), destinationPath);
  9. Node n = superuser.getNodeByUUID(uuid);
  10. assertTrue("After successful moving a referenceable node node, accessing the node by uuid must return the same node.", n.isSame(moveNode));
  11. }

代码示例来源:origin: org.chromattic/chromattic.core

  1. public void testQualifiedName() throws Exception {
  2. ChromatticSessionImpl session = login();
  3. Node rootNode = session.getRoot();
  4. Node aNode = rootNode.addNode("jcr:foo", "nodeattribute:a");
  5. String aId = aNode.getUUID();
  6. //
  7. TNA_A a = session.findById(TNA_A.class, aId);
  8. assertEquals("foo", a.getName());
  9. //
  10. a.setName("bar");
  11. assertEquals("jcr:bar", aNode.getName());
  12. }

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

  1. @SuppressWarnings( "deprecation" )
  2. @Test( expected = UnsupportedRepositoryOperationException.class )
  3. public void shouldNotProvideUuidIfNotReferenceable() throws Exception {
  4. initializeData();
  5. // The b node was not set up to be referenceable in this test, but does have a mixin type
  6. Node node = session.getRootNode().getNode("a").getNode("b").getNode("c");
  7. node.getUUID();
  8. }

相关文章