本文整理了Java中javax.jcr.Node.getCorrespondingNodePath()
方法的一些代码示例,展示了Node.getCorrespondingNodePath()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Node.getCorrespondingNodePath()
方法的具体详情如下:
包路径:javax.jcr.Node
类名称:Node
方法名:getCorrespondingNodePath
[英]Returns the absolute path of the node in the specified workspace that corresponds to this
node.
[中]返回指定工作区中与this
节点对应的节点的绝对路径。
代码示例来源:origin: org.onehippo.cms7/hippo-repository-connector
/**
* @inheritDoc
*/
public String getCorrespondingNodePath(String workspaceName) throws ItemNotFoundException,
NoSuchWorkspaceException, AccessDeniedException, RepositoryException {
return node.getCorrespondingNodePath(workspaceName);
}
代码示例来源:origin: net.adamcin.oakpal/oakpal-core
@Override
public String getCorrespondingNodePath(String workspaceName) throws RepositoryException {
return delegate.getCorrespondingNodePath(workspaceName);
}
代码示例来源:origin: net.adamcin.commons/net.adamcin.commons.jcr
public String getCorrespondingNodePath(String s) throws RepositoryException {
return this.item.getCorrespondingNodePath(s);
}
代码示例来源:origin: info.magnolia/magnolia-core
@Override
public String getCorrespondingNodePath(String workspaceName) throws ItemNotFoundException, NoSuchWorkspaceException, AccessDeniedException, RepositoryException {
return getWrappedNode().getCorrespondingNodePath(workspaceName);
}
代码示例来源:origin: nl.vpro/jcr-criteria
@Override
public String getCorrespondingNodePath(String workspaceName) throws RepositoryException {
return getNode().getCorrespondingNodePath(workspaceName);
}
代码示例来源:origin: apache/jackrabbit
/** {@inheritDoc} */
public String getCorrespondingNodePath(String workspace)
throws RepositoryException, RemoteException {
try {
return node.getCorrespondingNodePath(workspace);
} catch (RepositoryException ex) {
throw getRepositoryException(ex);
}
}
代码示例来源:origin: brix-cms/brix-cms
public String execute() throws Exception {
return getDelegate().getCorrespondingNodePath(workspaceName);
}
});
代码示例来源:origin: brix-cms/brix-cms
public String getCorrespondingNodePath(String workspaceName) throws RepositoryException {
return getDelegate().getCorrespondingNodePath(workspaceName);
}
代码示例来源:origin: apache/jackrabbit
/**
* Creates a node with same path in both workspaces to check if {@link
* javax.jcr.Node#getCorrespondingNodePath(String)} works properly.
*/
public void testGetCorrespondingNodePath() throws RepositoryException, NotExecutableException {
// make sure the repository supports multiple workspaces
super.ensureMultipleWorkspacesSupported();
// get default workspace test root node using superuser session
Node defaultRootNode = (Node) superuser.getItem(testRootNode.getPath());
// create test node in default workspace
Node defaultTestNode = defaultRootNode.addNode(nodeName1, testNodeType);
// save changes
superuser.save();
// get the root node in the second workspace
Node rootNodeW2 = (Node) superuserW2.getItem(testRootNode.getPath());
// create test node in second workspace
rootNodeW2.addNode(nodeName1, testNodeType);
// save changes
superuserW2.save();
// call the update method on test node in default workspace
defaultTestNode.getCorrespondingNodePath(workspaceName);
// ok, works as expected
}
代码示例来源:origin: apache/jackrabbit
/**
* Calls {@link javax.jcr.Node#getCorrespondingNodePath(String )} with a non
* existing workspace.
* <p>
* This should throw an {@link javax.jcr.NoSuchWorkspaceException }.
*/
public void testGetCorrespondingNodePathNoSuchWorkspaceException() throws RepositoryException {
// get default workspace test root node using superuser session
Node defaultRootNode = (Node) superuser.getItem(testRootNode.getPath());
// create testNode in default workspace
Node defaultTestNode = defaultRootNode.addNode(nodeName1, testNodeType);
// save changes
superuser.save();
try {
defaultTestNode.getCorrespondingNodePath(getNonExistingWorkspaceName(superuser));
fail("Calling Node.getCorrespondingNodePath(workspace) with invalid workspace should throw NoSuchWorkspaceException");
} catch (NoSuchWorkspaceException e) {
// ok, works as expected
}
}
代码示例来源:origin: apache/jackrabbit
/**
* Calls {@link javax.jcr.Node#getCorrespondingNodePath(String)} on a node
* that has no corresponding node in second workspace
*/
public void testGetCorrespondingNodePathItemNotFoundException() throws RepositoryException, NotExecutableException {
// make sure the repository supports multiple workspaces
super.ensureMultipleWorkspacesSupported();
// get default workspace test root node using superuser session
Node defaultRootNode = (Node) superuser.getItem(testRootNode.getPath());
// create testNode in default workspace
Node defaultTestNode = defaultRootNode.addNode(nodeName1, testNodeType);
// save changes
superuser.save();
try {
// call the update method on test node in default workspace
defaultTestNode.getCorrespondingNodePath(workspaceName);
fail("Calling Node.getCorrespondingNodePath() on node that has no correspondend node should throw ItemNotFoundException");
} catch (ItemNotFoundException e) {
// ok, works as expected
}
}
代码示例来源:origin: apache/jackrabbit
testRootNode.getCorrespondingNodePath(workspaceName);
} catch (ItemNotFoundException e) {
versionableNode.getCorrespondingNodePath(workspaceName);
} catch (ItemNotFoundException e) {
versionableNode2.getCorrespondingNodePath(workspaceName);
} catch (ItemNotFoundException e) {
代码示例来源:origin: apache/jackrabbit
public void testUpdateAddsMissingSubtree() throws RepositoryException, NotExecutableException {
String srcWorkspace = getAnotherWorkspace();
// get the root node in the second workspace
Session session2 = getHelper().getSuperuserSession(srcWorkspace);
try {
// make sure the source-session has the corresponding node.
Node testRootW2 = (Node) session2.getItem(testRootNode.getCorrespondingNodePath(srcWorkspace));
// create test node in second workspace
Node aNode2 = testRootW2.addNode(nodeName1, testNodeType);
aNode2.addNode(nodeName2, testNodeType);
aNode2.setProperty(propertyName2, "test");
Property p2 = testRootW2.setProperty(propertyName1, "test");
testRootW2.save();
// call the update method on test node in default workspace
testRootNode.update(srcWorkspace);
// ok check if the child has been added
boolean allPresent = testRootNode.hasNode(nodeName1) &&
testRootNode.hasNode(nodeName1+"/"+nodeName2) &&
testRootNode.hasProperty(nodeName1+"/"+propertyName2) &&
testRootNode.hasProperty(propertyName1);
assertTrue("Node updated with Node.update() should have received childrens", allPresent);
} catch (PathNotFoundException e) {
throw new NotExecutableException();
} catch (ItemNotFoundException e) {
throw new NotExecutableException();
} finally {
session2.logout();
}
}
代码示例来源:origin: apache/jackrabbit
public void testUpdateRemovesExtraProperty() throws RepositoryException, NotExecutableException {
// create test node in default workspace
testRootNode.setProperty(propertyName2, "test");
testRootNode.save();
String srcWorkspace = getAnotherWorkspace();
// get the root node in the second workspace
Session session2 = getHelper().getSuperuserSession(srcWorkspace);
try {
// make sure the source-session has the corresponding node.
Node testRootW2 = (Node) session2.getItem(testRootNode.getCorrespondingNodePath(srcWorkspace));
if (testRootW2.hasProperty(propertyName2)) {
throw new NotExecutableException();
}
// call the update method on test node in default workspace
testRootNode.update(srcWorkspace);
// ok first check if node has no longer properties
assertFalse("Node updated with Node.update() should have property removed", testRootNode.hasProperty(propertyName2));
} catch (PathNotFoundException e) {
throw new NotExecutableException();
} catch (ItemNotFoundException e) {
throw new NotExecutableException();
} finally {
session2.logout();
}
}
代码示例来源:origin: ModeShape/modeshape
@Override
public void run( Node node ) throws Exception {
final String path = node.getPath();
final NodeKey key = ((AbstractJcrNode)node).key();
assertThat(key.getWorkspaceKey(), is(expectedWorkspaceKey));
if (node.isNodeType("mix:referenceable")) {
for (String otherWorkspace : otherWorkspaces) {
String correspondingPath = node.getCorrespondingNodePath(otherWorkspace);
assertThat(correspondingPath, is(path));
// Check that the node keys are actually different ...
final Node correspondingNode = otherWorkspaceSessions.get(otherWorkspace).getNode(correspondingPath);
final NodeKey correspondingKey = ((AbstractJcrNode)correspondingNode).key();
assertThat(correspondingKey, is(not(key)));
assertThat(correspondingKey.getIdentifier(), is(key.getIdentifier()));
assertThat(correspondingKey.getSourceKey(), is(key.getSourceKey()));
assertThat(correspondingKey.getWorkspaceKey(), is(not(key.getWorkspaceKey()))); // this is what
// differs
}
}
}
});
代码示例来源:origin: apache/jackrabbit
public void testNoCorrespondingNode() throws RepositoryException, NotExecutableException {
Node n = testRootNode.addNode(nodeName2, testNodeType);
testRootNode.save();
String srcWorkspace = null;
String wspName = getHelper().getProperty("org.apache.jackrabbit.jcr2spi.workspace2.name");
if (wspName == null) {
throw new NotExecutableException("Cannot run update. Missing config param.");
}
try {
n.getCorrespondingNodePath(wspName);
} catch (ItemNotFoundException e) {
srcWorkspace = wspName;
} catch (RepositoryException e) {
throw new NotExecutableException("Cannot run update. Workspace " + srcWorkspace + " does not exist or is not accessible.");
}
if (srcWorkspace == null) {
throw new NotExecutableException("Cannot run update. No workspace found, that misses the corresponding node.");
}
try {
// update without corresponding node must be a nop
testRootNode.update(srcWorkspace);
} catch (RepositoryException e) {
fail("Update with workspace that doesn't contain the corresponding node must work.");
}
}
代码示例来源:origin: apache/jackrabbit
/**
* Retrieve the href of the corresponding resource in the indicated workspace.
*
* @param resource
* @param session Session object used to access the {@link Node} object
* represented by the given resource.
* @param workspaceHref
* @return
* @throws RepositoryException
*/
private static String getCorrespondingResourceHref(DavResource resource, Session session, String workspaceHref) throws RepositoryException {
DavResourceLocator rLoc = resource.getLocator();
String itemPath = rLoc.getRepositoryPath();
Item item = session.getItem(itemPath);
if (item.isNode()) {
String workspaceName = rLoc.getFactory().createResourceLocator(rLoc.getPrefix(), workspaceHref).getWorkspaceName();
String corrPath = ((Node)item).getCorrespondingNodePath(workspaceName);
DavResourceLocator corrLoc = rLoc.getFactory().createResourceLocator(rLoc.getPrefix(), "/" + workspaceName, corrPath, false);
return corrLoc.getHref(true);
} else {
throw new PathNotFoundException("Node with path " + itemPath + " does not exist.");
}
}
}
内容来源于网络,如有侵权,请联系作者删除!