本文整理了Java中javax.jcr.Node.getUUID()
方法的一些代码示例,展示了Node.getUUID()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Node.getUUID()
方法的具体详情如下:
包路径:javax.jcr.Node
类名称: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
/**
* @inheritDoc
*/
public String getUUID() throws UnsupportedRepositoryOperationException, RepositoryException {
return node.getUUID();
}
代码示例来源:origin: org.onehippo.cms7/hippo-cms-api
private static String getUUID(Node node) throws RepositoryException {
try {
return node.getUUID();
} catch (UnsupportedRepositoryOperationException e) {
return "";
}
}
代码示例来源:origin: org.onehippo.cms7/hippo-cms-yui
private static String getUUID(Node node) throws RepositoryException {
try {
return node.getUUID();
} catch (UnsupportedRepositoryOperationException e) {
return "";
}
}
代码示例来源:origin: info.magnolia/magnolia-core
@Override
public String getUUID() {
try {
return this.node.getUUID();
} catch (UnsupportedOperationException e) {
log.error(e.getMessage());
} catch (RepositoryException re) {
log.error("Exception caught", re);
}
return StringUtils.EMPTY;
}
代码示例来源:origin: apache/jackrabbit
/** {@inheritDoc} */
@SuppressWarnings("deprecation")
public String getUUID() throws RepositoryException, RemoteException {
try {
return node.getUUID();
} catch (RepositoryException ex) {
throw getRepositoryException(ex);
}
}
代码示例来源:origin: apache/jackrabbit
/**
* Tests if adding a property with <code>Node.setProperty(String,
* Node)</code> works with <code>Session.save()</code>
*/
public void testNewNodePropertySession() throws Exception {
testNode.setProperty(propertyName1, n1);
superuser.save();
assertEquals("Setting property with Node.setProperty(String, Node) and Session.save() not working",
n1.getUUID(),
testNode.getProperty(propertyName1).getString());
}
代码示例来源:origin: apache/jackrabbit
/**
* Tests if adding a property with <code>Node.setProperty(String,
* Node)</code> works with <code>parentNode.save()</code>
*/
public void testNewNodePropertyParent() throws Exception {
testNode.setProperty(propertyName1, n1);
testRootNode.getSession().save();
assertEquals("Setting property with Node.setProperty(String, Node) and parentNode.save() not working",
n1.getUUID(),
testNode.getProperty(propertyName1).getString());
}
代码示例来源:origin: org.onehippo.cms7/hippo-cms-editor-frontend
@Override
public void onClear() {
Node node = ((JcrNodeModel) FacetSelectTemplatePlugin.this.getDefaultModel()).getNode();
try {
node.setProperty("hippo:docbase", node.getSession().getRootNode().getUUID());
} catch (RepositoryException e) {
log.error("Unable to reset docbase to rootnode uuid", e);
}
redraw();
}
代码示例来源:origin: org.apache.sling/org.apache.sling.testing.sling-mock-oak
@Override @SuppressWarnings("deprecation")
public Value createValue(Node value, boolean weak) throws RepositoryException {
if (!value.isNodeType(NodeType.MIX_REFERENCEABLE)) {
throw new ValueFormatException(
"Node is not referenceable: " + value.getPath());
}
return weak
? newValue(GenericPropertyState.weakreferenceProperty("", value.getUUID()), namePathMapper)
: newValue(GenericPropertyState.referenceProperty("", value.getUUID()), namePathMapper);
}
代码示例来源:origin: apache/jackrabbit-oak
@NotNull
public Value createValue(@NotNull Node value, boolean weak) throws RepositoryException {
if (!value.isNodeType(NodeType.MIX_REFERENCEABLE)) {
throw new ValueFormatException(
"Node is not referenceable: " + value.getPath());
}
return weak
? newValue(GenericPropertyState.weakreferenceProperty("", value.getUUID()), namePathMapper, getBlobAccessProvider())
: newValue(GenericPropertyState.referenceProperty("", value.getUUID()), namePathMapper, getBlobAccessProvider());
}
代码示例来源:origin: org.onehippo.cms7/hippo-repository-connector
public WorkflowDescriptor getWorkflowDescriptor(String category, Node item) throws RepositoryException {
try {
RemoteWorkflowDescriptor remoteDescriptor = remote.getWorkflowDescriptor(category, item.getUUID());
if (remoteDescriptor != null) {
return new ClientWorkflowDescriptor(remoteDescriptor);
} else {
return null;
}
} catch(RemoteException ex) {
throw new RemoteRuntimeException(ex);
}
}
代码示例来源:origin: apache/jackrabbit-oak
protected String getExistingUUID() throws RepositoryException {
Node n = adminSession.getRootNode();
n.addMixin(JcrConstants.MIX_REFERENCEABLE);
//noinspection deprecation
return n.getUUID();
}
代码示例来源:origin: org.onehippo.cms7/hippo-addon-hst-configuration-editor-frontend
protected void saveNode(Node node) {
try {
getModel().setObject(node.getUUID());
} catch (RepositoryException ex) {
error(ex.getMessage());
}
}
代码示例来源:origin: pentaho/pentaho-platform
public Object doInJcr( final Session session ) throws RepositoryException {
Item item;
try {
item = session.getItem( absPath );
} catch ( PathNotFoundException e ) {
return null;
}
Assert.isTrue( item.isNode() );
return ( (Node) item ).getUUID();
}
} );
代码示例来源:origin: apache/jackrabbit
/**
* Tests if VersionHistory.getVersionableUUID() returns the uuid of the
* corresponding versionable node.
*/
public void testGetVersionableUUID() throws RepositoryException {
// create version
versionableNode.checkout();
Version version = versionableNode.checkin();
assertEquals("Method getVersionableUUID() must return the UUID of the corresponding Node.",
version.getContainingHistory().getVersionableUUID(),
versionableNode.getUUID());
}
代码示例来源:origin: apache/jackrabbit-oak
@Test
public void testCopyReferenceableChildNode() throws Exception {
Session session = getAdminSession();
session.getNode(TEST_PATH + "/source/node").addNode("child").addMixin(JcrConstants.MIX_REFERENCEABLE);
session.save();
session.getWorkspace().copy(TEST_PATH + "/source/node", TEST_PATH + "/target/copied");
assertTrue(testNode.hasNode("source/node"));
assertTrue(testNode.hasNode("target/copied"));
Node childCopy = testNode.getNode("target/copied/child");
assertTrue(childCopy.isNodeType(JcrConstants.MIX_REFERENCEABLE));
assertFalse(childCopy.getUUID().equals(testNode.getNode("source/node/child").getUUID()));
}
代码示例来源:origin: apache/jackrabbit
/**
* Same as {@link #testAccessMovedReferenceableByUUID()} but calls save()
* before accessing the node again.
*/
public void testAccessMovedReferenceableByUUID2() throws RepositoryException, NotExecutableException {
String uuid = moveNode.getUUID();
//move the node
doMove(moveNode.getPath(), destinationPath);
superuser.save();
Node n = superuser.getNodeByUUID(uuid);
assertTrue("After successful moving a referenceable node node, accessing the node by uuid must return the same node.", n.isSame(moveNode));
}
代码示例来源:origin: apache/jackrabbit
/**
* Test if a moved referenceable node returns the same item than the moved
* node.
*/
public void testAccessMovedReferenceableByUUID() throws RepositoryException, NotExecutableException {
String uuid = moveNode.getUUID();
//move the node
doMove(moveNode.getPath(), destinationPath);
Node n = superuser.getNodeByUUID(uuid);
assertTrue("After successful moving a referenceable node node, accessing the node by uuid must return the same node.", n.isSame(moveNode));
}
代码示例来源:origin: org.chromattic/chromattic.core
public void testQualifiedName() throws Exception {
ChromatticSessionImpl session = login();
Node rootNode = session.getRoot();
Node aNode = rootNode.addNode("jcr:foo", "nodeattribute:a");
String aId = aNode.getUUID();
//
TNA_A a = session.findById(TNA_A.class, aId);
assertEquals("foo", a.getName());
//
a.setName("bar");
assertEquals("jcr:bar", aNode.getName());
}
代码示例来源:origin: ModeShape/modeshape
@SuppressWarnings( "deprecation" )
@Test( expected = UnsupportedRepositoryOperationException.class )
public void shouldNotProvideUuidIfNotReferenceable() throws Exception {
initializeData();
// The b node was not set up to be referenceable in this test, but does have a mixin type
Node node = session.getRootNode().getNode("a").getNode("b").getNode("c");
node.getUUID();
}
内容来源于网络,如有侵权,请联系作者删除!