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

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

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

Node.save介绍

暂无

代码示例

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

  1. /**
  2. * Add the mix:shareable mixin to a node (6.13.2).
  3. */
  4. public void testAddMixin() throws Exception {
  5. // setup parent node and first child
  6. Node a = testRootNode.addNode("a");
  7. Node b = a.addNode("b");
  8. testRootNode.getSession().save();
  9. ensureMixinType(b, mixShareable);
  10. b.save();
  11. }

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

  1. public Node createRoleBasedFolderNode( final Session session, final PentahoJcrConstants pentahoJcrConstants,
  2. final ITenant tenant ) throws RepositoryException {
  3. Node authzFolderNode = createAuthzFolderNode( session, pentahoJcrConstants, tenant );
  4. Node node = authzFolderNode.addNode( FOLDER_NAME_ROLEBASED, pentahoJcrConstants.getPHO_NT_INTERNALFOLDER() );
  5. authzFolderNode.save();
  6. session.save();
  7. return node;
  8. }

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

  1. /**
  2. * Test if Item.isModified() returns false for an already exixting and modified
  3. * NodeItem after the node is saved (persistent).
  4. * Modified means that a property is added with a string value.
  5. *
  6. * @see javax.jcr.Item#isModified()
  7. */
  8. public void testPersistentNodeItemIsModified () throws RepositoryException {
  9. Node testNode = testRootNode.addNode(nodeName1, testNodeType);
  10. testRootNode.getSession().save();
  11. // modify the persistent testNode
  12. testNode.setProperty(propertyName1, "test");
  13. testNode.save();
  14. Item testNodeItem = superuser.getItem(testNode.getPath());
  15. // check testNodeItem.isModified() after save
  16. assertFalse("Item.isModified() must return false after an existing Property is modified and the current Node is saved", testNodeItem.isModified());
  17. }

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

  1. /**
  2. * Tests if a {@link javax.jcr.RepositoryException} is thrown when calling
  3. * <code>Node.save()</code> on a newly added node
  4. */
  5. public void testSaveOnNewNodeRepositoryException() throws Exception {
  6. // get default workspace test root node using superuser session
  7. Node defaultRootNode = (Node) superuser.getItem(testRootNode.getPath());
  8. // create a node
  9. Node newNode = defaultRootNode.addNode(nodeName1, testNodeType);
  10. try {
  11. newNode.save();
  12. fail("Calling Node.save() on a newly added node should throw a RepositoryException");
  13. } catch (RepositoryException success) {
  14. // ok
  15. }
  16. }

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

  1. @Override
  2. protected void setUp() throws Exception {
  3. super.setUp();
  4. testNode = testRootNode.addNode(nodeName1);
  5. testNode.setProperty(propertyName1, "existingProp");
  6. testRootNode.save();
  7. }

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

  1. /**
  2. * Move a orderable child node and reorder the remaining nodes.
  3. */
  4. public void testMoveAndReorder() throws RepositoryException {
  5. Node[] children = createOrderableChildren(false);
  6. String oldName = children[2].getName();
  7. // move
  8. testRootNode.getSession().move(children[2].getPath(), destPath);
  9. // reorder
  10. srcParent.orderBefore(getRelPath(children[1]), null);
  11. testOrder(srcParent, new Node[] {children[0], children[3], children[1]});
  12. testRootNode.save();
  13. testOrder(srcParent, new Node[] {children[0], children[3], children[1]});
  14. assertFalse(srcParent.hasNode(oldName));
  15. }

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

  1. public void testRemoveMixin() throws RepositoryException, NotExecutableException {
  2. ((Node) superuser.getItem(childNode.getPath())).addMixin(mixinName);
  3. superuser.save();
  4. checkReadOnly(childNode.getPath());
  5. try {
  6. childNode.removeMixin(mixinName);
  7. childNode.save();
  8. fail("TestSession does not have sufficient privileges to remove a mixin type.");
  9. } catch (AccessDeniedException e) {
  10. // success
  11. }
  12. modifyPrivileges(childNode.getPath(), Privilege.JCR_NODE_TYPE_MANAGEMENT, true);
  13. childNode.removeMixin(mixinName);
  14. childNode.save();
  15. }

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

  1. /**
  2. * Creates the named test node. The node is created within a transaction
  3. * to avoid mixing transactional and non-transactional writes within a
  4. * concurrent test run.
  5. */
  6. private static synchronized Node createParentNode(Node test, String name)
  7. throws RepositoryException {
  8. try {
  9. UserTransaction utx = new UserTransactionImpl(test.getSession());
  10. utx.begin();
  11. Node parent = test.addNode(name);
  12. test.save();
  13. utx.commit();
  14. return parent;
  15. } catch (RepositoryException e) {
  16. throw e;
  17. } catch (Exception e) {
  18. throw new RepositoryException("Failed to add node: " + name, e);
  19. }
  20. }

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

  1. public NodeIterator execute() throws Exception {
  2. Node n = getNode();
  3. log.info(n.getPath());
  4. n.save();
  5. return wrapWithIterator(n);
  6. }
  7. }

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

  1. public void testRemovedProperty() throws RepositoryException, LockException, ConstraintViolationException, VersionException {
  2. Property p = testRootNode.setProperty(propertyName1, testValue);
  3. testRootNode.save();
  4. p.remove();
  5. testRootNode.refresh(false);
  6. // Property p must be reverted to 'existing' -> getString must succeed.
  7. p.getString();
  8. // similarly accessing the property again must succeed.
  9. testRootNode.getProperty(propertyName1);
  10. }

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

  1. @Override
  2. protected void setUp() throws Exception {
  3. super.setUp();
  4. if (testRootNode.hasProperty(propertyName1)) {
  5. testRootNode.getProperty(propertyName1).remove();
  6. testRootNode.save();
  7. }
  8. testValue = testRootNode.getSession().getValueFactory().createValue("anyString");
  9. if (!testRootNode.getPrimaryNodeType().canSetProperty(propertyName1, testValue)) {
  10. throw new NotExecutableException("");
  11. }
  12. }

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

  1. /**
  2. * Verify that invoking save() on a share-ancestor will save changes in
  3. * all share-descendants.
  4. */
  5. public void testModifyDescendantAndSave() throws Exception {
  6. // setup parent nodes and first child
  7. Node a1 = testRootNode.addNode("a1");
  8. Node a2 = testRootNode.addNode("a2");
  9. Node b1 = a1.addNode("b1");
  10. testRootNode.getSession().save();
  11. // add mixin
  12. ensureMixinType(b1, mixShareable);
  13. b1.save();
  14. // clone
  15. Workspace workspace = b1.getSession().getWorkspace();
  16. workspace.clone(workspace.getName(), b1.getPath(),
  17. a2.getPath() + "/b2", false);
  18. // add child node c to b1
  19. Node c = b1.addNode("c");
  20. b1.save();
  21. // add child d to c, this modifies c
  22. c.addNode("d");
  23. // save a2 (having path /testroot/a2): this should save c as well
  24. // since one of the paths to c is /testroot/a2/b2/c
  25. a2.save();
  26. assertFalse("Saving share-ancestor should save share-descendants",
  27. c.isModified());
  28. }

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

  1. @Override
  2. protected void setUp() throws Exception {
  3. super.setUp();
  4. // create parent node
  5. srcParentNode = testRootNode.addNode(nodeName1, testNodeType);
  6. // create node to be moved
  7. moveNode = srcParentNode.addNode(nodeName2, testNodeType);
  8. // create a node that will serve as new parent
  9. destParentNode = testRootNode.addNode(nodeName3, testNodeType);
  10. // save the new nodes
  11. testRootNode.save();
  12. destinationPath = destParentNode.getPath() + "/" + nodeName2;
  13. }

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

  1. public void testWrongCaseNeverMatches() throws RepositoryException {
  2. Node n = testRootNode.addNode("node");
  3. n.setProperty("foo", "Bar");
  4. testRootNode.save();
  5. executeXPathQuery(testPath + "/*[jcr:like(fn:lower-case(@foo), 'BA%')]", new Node[]{});
  6. }

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

  1. public void testReorder3() throws RepositoryException {
  2. String pathBefore = child3.getPath();
  3. testRootNode.orderBefore(getRelPath(child3), getRelPath(child1));
  4. testRootNode.save();
  5. Item itemIndex3 = testRootNode.getSession().getItem(pathBefore);
  6. assertTrue(itemIndex3.isSame(child2));
  7. Item item3 = testRootNode.getSession().getItem(child3.getPath());
  8. assertTrue(item3.isSame(child3));
  9. }
  10. }

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

  1. public Node createRuntimeRolesFolderNode( final Session session, final PentahoJcrConstants pentahoJcrConstants,
  2. final ITenant tenant ) throws RepositoryException {
  3. Node roleBasedFolderNode = createRoleBasedFolderNode( session, pentahoJcrConstants, tenant );
  4. Node node = roleBasedFolderNode.addNode( FOLDER_NAME_RUNTIMEROLES, pentahoJcrConstants.getPHO_NT_INTERNALFOLDER() );
  5. roleBasedFolderNode.save();
  6. session.save();
  7. return node;
  8. }

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

  1. public void testAddMixin() throws RepositoryException, NotExecutableException {
  2. checkReadOnly(childNode.getPath());
  3. try {
  4. childNode.addMixin(mixinName);
  5. childNode.save();
  6. fail("TestSession does not have sufficient privileges to add a mixin type.");
  7. } catch (AccessDeniedException e) {
  8. // success
  9. }
  10. modifyPrivileges(childNode.getPath(), Privilege.JCR_NODE_TYPE_MANAGEMENT, true);
  11. childNode.addMixin(mixinName);
  12. childNode.save();
  13. }

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

  1. protected void initNodesW2() throws RepositoryException {
  2. // testroot
  3. if (superuserW2.getRootNode().hasNode(testPath)) {
  4. testRootNodeW2 = superuserW2.getRootNode().getNode(testPath);
  5. // clean test root
  6. for (NodeIterator it = testRootNodeW2.getNodes(); it.hasNext(); ) {
  7. it.nextNode().remove();
  8. }
  9. testRootNodeW2.save();
  10. } else {
  11. testRootNodeW2 = superuserW2.getRootNode().addNode(testPath, testNodeType);
  12. superuserW2.save();
  13. }
  14. // some test nodes
  15. superuserW2.getWorkspace().copy(workspace.getName(), node1.getPath(), node1.getPath());
  16. node1W2 = testRootNodeW2.getNode(node1.getName());
  17. superuserW2.getWorkspace().copy(workspace.getName(), node2.getPath(), node2.getPath());
  18. node2W2 = testRootNodeW2.getNode(node2.getName());
  19. }
  20. }

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

  1. /**
  2. * Checks if {@link Node#isNew()} works correctly for new and existing,
  3. * unmodified nodes.
  4. */
  5. public void testIsNew() throws RepositoryException {
  6. // get default workspace test root node using superuser session
  7. Node defaultRootNode = (Node) superuser.getItem(testRootNode.getPath());
  8. // create a node
  9. Node testNode = defaultRootNode.addNode(nodeName1, testNodeType);
  10. assertTrue("Newly created node should return true on newNode.isNew()", testNode.isNew());
  11. defaultRootNode.save();
  12. assertFalse("Unmodified, exisiting node should return false on newNode.isNew()", testNode.isNew());
  13. }

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

  1. protected void setUp() throws Exception {
  2. super.setUp();
  3. for (int i = 0; i < INITIAL_NODE_NUM; i++) {
  4. testRootNode.addNode("node" + i).setProperty(propertyName1, i);
  5. }
  6. testRootNode.save();
  7. }

相关文章