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

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

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

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

  1. /**
  2. * @inheritDoc
  3. */
  4. public String getCorrespondingNodePath(String workspaceName) throws ItemNotFoundException,
  5. NoSuchWorkspaceException, AccessDeniedException, RepositoryException {
  6. return node.getCorrespondingNodePath(workspaceName);
  7. }

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

  1. @Override
  2. public String getCorrespondingNodePath(String workspaceName) throws RepositoryException {
  3. return delegate.getCorrespondingNodePath(workspaceName);
  4. }

代码示例来源:origin: net.adamcin.commons/net.adamcin.commons.jcr

  1. public String getCorrespondingNodePath(String s) throws RepositoryException {
  2. return this.item.getCorrespondingNodePath(s);
  3. }

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

  1. @Override
  2. public String getCorrespondingNodePath(String workspaceName) throws ItemNotFoundException, NoSuchWorkspaceException, AccessDeniedException, RepositoryException {
  3. return getWrappedNode().getCorrespondingNodePath(workspaceName);
  4. }

代码示例来源:origin: nl.vpro/jcr-criteria

  1. @Override
  2. public String getCorrespondingNodePath(String workspaceName) throws RepositoryException {
  3. return getNode().getCorrespondingNodePath(workspaceName);
  4. }

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

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

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

  1. public String execute() throws Exception {
  2. return getDelegate().getCorrespondingNodePath(workspaceName);
  3. }
  4. });

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

  1. public String getCorrespondingNodePath(String workspaceName) throws RepositoryException {
  2. return getDelegate().getCorrespondingNodePath(workspaceName);
  3. }

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

  1. /**
  2. * Creates a node with same path in both workspaces to check if {@link
  3. * javax.jcr.Node#getCorrespondingNodePath(String)} works properly.
  4. */
  5. public void testGetCorrespondingNodePath() throws RepositoryException, NotExecutableException {
  6. // make sure the repository supports multiple workspaces
  7. super.ensureMultipleWorkspacesSupported();
  8. // get default workspace test root node using superuser session
  9. Node defaultRootNode = (Node) superuser.getItem(testRootNode.getPath());
  10. // create test node in default workspace
  11. Node defaultTestNode = defaultRootNode.addNode(nodeName1, testNodeType);
  12. // save changes
  13. superuser.save();
  14. // get the root node in the second workspace
  15. Node rootNodeW2 = (Node) superuserW2.getItem(testRootNode.getPath());
  16. // create test node in second workspace
  17. rootNodeW2.addNode(nodeName1, testNodeType);
  18. // save changes
  19. superuserW2.save();
  20. // call the update method on test node in default workspace
  21. defaultTestNode.getCorrespondingNodePath(workspaceName);
  22. // ok, works as expected
  23. }

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

  1. /**
  2. * Calls {@link javax.jcr.Node#getCorrespondingNodePath(String )} with a non
  3. * existing workspace.
  4. * <p>
  5. * This should throw an {@link javax.jcr.NoSuchWorkspaceException }.
  6. */
  7. public void testGetCorrespondingNodePathNoSuchWorkspaceException() throws RepositoryException {
  8. // get default workspace test root node using superuser session
  9. Node defaultRootNode = (Node) superuser.getItem(testRootNode.getPath());
  10. // create testNode in default workspace
  11. Node defaultTestNode = defaultRootNode.addNode(nodeName1, testNodeType);
  12. // save changes
  13. superuser.save();
  14. try {
  15. defaultTestNode.getCorrespondingNodePath(getNonExistingWorkspaceName(superuser));
  16. fail("Calling Node.getCorrespondingNodePath(workspace) with invalid workspace should throw NoSuchWorkspaceException");
  17. } catch (NoSuchWorkspaceException e) {
  18. // ok, works as expected
  19. }
  20. }

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

  1. /**
  2. * Calls {@link javax.jcr.Node#getCorrespondingNodePath(String)} on a node
  3. * that has no corresponding node in second workspace
  4. */
  5. public void testGetCorrespondingNodePathItemNotFoundException() throws RepositoryException, NotExecutableException {
  6. // make sure the repository supports multiple workspaces
  7. super.ensureMultipleWorkspacesSupported();
  8. // get default workspace test root node using superuser session
  9. Node defaultRootNode = (Node) superuser.getItem(testRootNode.getPath());
  10. // create testNode in default workspace
  11. Node defaultTestNode = defaultRootNode.addNode(nodeName1, testNodeType);
  12. // save changes
  13. superuser.save();
  14. try {
  15. // call the update method on test node in default workspace
  16. defaultTestNode.getCorrespondingNodePath(workspaceName);
  17. fail("Calling Node.getCorrespondingNodePath() on node that has no correspondend node should throw ItemNotFoundException");
  18. } catch (ItemNotFoundException e) {
  19. // ok, works as expected
  20. }
  21. }

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

  1. testRootNode.getCorrespondingNodePath(workspaceName);
  2. } catch (ItemNotFoundException e) {
  3. versionableNode.getCorrespondingNodePath(workspaceName);
  4. } catch (ItemNotFoundException e) {
  5. versionableNode2.getCorrespondingNodePath(workspaceName);
  6. } catch (ItemNotFoundException e) {

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

  1. public void testUpdateAddsMissingSubtree() throws RepositoryException, NotExecutableException {
  2. String srcWorkspace = getAnotherWorkspace();
  3. // get the root node in the second workspace
  4. Session session2 = getHelper().getSuperuserSession(srcWorkspace);
  5. try {
  6. // make sure the source-session has the corresponding node.
  7. Node testRootW2 = (Node) session2.getItem(testRootNode.getCorrespondingNodePath(srcWorkspace));
  8. // create test node in second workspace
  9. Node aNode2 = testRootW2.addNode(nodeName1, testNodeType);
  10. aNode2.addNode(nodeName2, testNodeType);
  11. aNode2.setProperty(propertyName2, "test");
  12. Property p2 = testRootW2.setProperty(propertyName1, "test");
  13. testRootW2.save();
  14. // call the update method on test node in default workspace
  15. testRootNode.update(srcWorkspace);
  16. // ok check if the child has been added
  17. boolean allPresent = testRootNode.hasNode(nodeName1) &&
  18. testRootNode.hasNode(nodeName1+"/"+nodeName2) &&
  19. testRootNode.hasProperty(nodeName1+"/"+propertyName2) &&
  20. testRootNode.hasProperty(propertyName1);
  21. assertTrue("Node updated with Node.update() should have received childrens", allPresent);
  22. } catch (PathNotFoundException e) {
  23. throw new NotExecutableException();
  24. } catch (ItemNotFoundException e) {
  25. throw new NotExecutableException();
  26. } finally {
  27. session2.logout();
  28. }
  29. }

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

  1. public void testUpdateRemovesExtraProperty() throws RepositoryException, NotExecutableException {
  2. // create test node in default workspace
  3. testRootNode.setProperty(propertyName2, "test");
  4. testRootNode.save();
  5. String srcWorkspace = getAnotherWorkspace();
  6. // get the root node in the second workspace
  7. Session session2 = getHelper().getSuperuserSession(srcWorkspace);
  8. try {
  9. // make sure the source-session has the corresponding node.
  10. Node testRootW2 = (Node) session2.getItem(testRootNode.getCorrespondingNodePath(srcWorkspace));
  11. if (testRootW2.hasProperty(propertyName2)) {
  12. throw new NotExecutableException();
  13. }
  14. // call the update method on test node in default workspace
  15. testRootNode.update(srcWorkspace);
  16. // ok first check if node has no longer properties
  17. assertFalse("Node updated with Node.update() should have property removed", testRootNode.hasProperty(propertyName2));
  18. } catch (PathNotFoundException e) {
  19. throw new NotExecutableException();
  20. } catch (ItemNotFoundException e) {
  21. throw new NotExecutableException();
  22. } finally {
  23. session2.logout();
  24. }
  25. }

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

  1. @Override
  2. public void run( Node node ) throws Exception {
  3. final String path = node.getPath();
  4. final NodeKey key = ((AbstractJcrNode)node).key();
  5. assertThat(key.getWorkspaceKey(), is(expectedWorkspaceKey));
  6. if (node.isNodeType("mix:referenceable")) {
  7. for (String otherWorkspace : otherWorkspaces) {
  8. String correspondingPath = node.getCorrespondingNodePath(otherWorkspace);
  9. assertThat(correspondingPath, is(path));
  10. // Check that the node keys are actually different ...
  11. final Node correspondingNode = otherWorkspaceSessions.get(otherWorkspace).getNode(correspondingPath);
  12. final NodeKey correspondingKey = ((AbstractJcrNode)correspondingNode).key();
  13. assertThat(correspondingKey, is(not(key)));
  14. assertThat(correspondingKey.getIdentifier(), is(key.getIdentifier()));
  15. assertThat(correspondingKey.getSourceKey(), is(key.getSourceKey()));
  16. assertThat(correspondingKey.getWorkspaceKey(), is(not(key.getWorkspaceKey()))); // this is what
  17. // differs
  18. }
  19. }
  20. }
  21. });

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

  1. public void testNoCorrespondingNode() throws RepositoryException, NotExecutableException {
  2. Node n = testRootNode.addNode(nodeName2, testNodeType);
  3. testRootNode.save();
  4. String srcWorkspace = null;
  5. String wspName = getHelper().getProperty("org.apache.jackrabbit.jcr2spi.workspace2.name");
  6. if (wspName == null) {
  7. throw new NotExecutableException("Cannot run update. Missing config param.");
  8. }
  9. try {
  10. n.getCorrespondingNodePath(wspName);
  11. } catch (ItemNotFoundException e) {
  12. srcWorkspace = wspName;
  13. } catch (RepositoryException e) {
  14. throw new NotExecutableException("Cannot run update. Workspace " + srcWorkspace + " does not exist or is not accessible.");
  15. }
  16. if (srcWorkspace == null) {
  17. throw new NotExecutableException("Cannot run update. No workspace found, that misses the corresponding node.");
  18. }
  19. try {
  20. // update without corresponding node must be a nop
  21. testRootNode.update(srcWorkspace);
  22. } catch (RepositoryException e) {
  23. fail("Update with workspace that doesn't contain the corresponding node must work.");
  24. }
  25. }

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

  1. /**
  2. * Retrieve the href of the corresponding resource in the indicated workspace.
  3. *
  4. * @param resource
  5. * @param session Session object used to access the {@link Node} object
  6. * represented by the given resource.
  7. * @param workspaceHref
  8. * @return
  9. * @throws RepositoryException
  10. */
  11. private static String getCorrespondingResourceHref(DavResource resource, Session session, String workspaceHref) throws RepositoryException {
  12. DavResourceLocator rLoc = resource.getLocator();
  13. String itemPath = rLoc.getRepositoryPath();
  14. Item item = session.getItem(itemPath);
  15. if (item.isNode()) {
  16. String workspaceName = rLoc.getFactory().createResourceLocator(rLoc.getPrefix(), workspaceHref).getWorkspaceName();
  17. String corrPath = ((Node)item).getCorrespondingNodePath(workspaceName);
  18. DavResourceLocator corrLoc = rLoc.getFactory().createResourceLocator(rLoc.getPrefix(), "/" + workspaceName, corrPath, false);
  19. return corrLoc.getHref(true);
  20. } else {
  21. throw new PathNotFoundException("Node with path " + itemPath + " does not exist.");
  22. }
  23. }
  24. }

相关文章