private Node getMetadataNode( Node outputNode ) throws RepositoryException { if (outputNode.isNew()) { outputNode.setPrimaryType(METADATA_NODE); return outputNode; } return outputNode.addNode(METADATA_NODE, METADATA_NODE); }
private Node getImageMetadataNode( Node outputNode ) throws RepositoryException { if (outputNode.isNew()) { outputNode.setPrimaryType(ImageMetadataLexicon.METADATA_NODE); return outputNode; } return outputNode.addNode(ImageMetadataLexicon.METADATA_NODE, ImageMetadataLexicon.METADATA_NODE); }
private Node getMetadataNode( Node outputNode ) throws RepositoryException { if (outputNode.isNew()) { outputNode.setPrimaryType(METADATA_NODE); return outputNode; } return outputNode.addNode(METADATA_NODE, METADATA_NODE); }
private Node getMetadataNode( Node outputNode ) throws RepositoryException { if (outputNode.isNew()) { outputNode.setPrimaryType(OdfMetadataLexicon.METADATA_NODE); return outputNode; } return outputNode.addNode(OdfMetadataLexicon.METADATA_NODE, OdfMetadataLexicon.METADATA_NODE); }
private Node createTopLevelNode( Node outputNode ) throws RepositoryException { // Create top-level node if (!outputNode.isNew()) { outputNode = outputNode.addNode(ZipLexicon.CONTENT); } outputNode.setPrimaryType(ZipLexicon.FILE); return outputNode; }
private Node getPdfMetadataNode( Node outputNode ) throws RepositoryException { if (outputNode.isNew()) { outputNode.setPrimaryType(PdfMetadataLexicon.METADATA_NODE); return outputNode; } return outputNode.addNode(PdfMetadataLexicon.METADATA_NODE, PdfMetadataLexicon.METADATA_NODE); }
/** * {@inheritDoc} */ @Override public void startDocument() throws SAXException { try { stack = new StackElement(parentNode, parentNode.isNew()); } catch (RepositoryException e) { throw new SAXException(e); } }
private static void dumpChanges(Node node, PrintWriter out) throws RepositoryException { if (node.isModified()) { out.println(node.getPath() + " is modified"); } else if (node.isNew()) { out.println(node.getPath() + " is new"); } for (Iterator iter = node.getNodes(); iter.hasNext(); ) { Node child = (Node) iter.next(); dumpChanges(child, out); } }
@Override public void move(String srcAbsPath, String destAbsPath) throws PathNotFoundException, VersionException, ConstraintViolationException, LockException, ItemExistsException, RepositoryException { Node node = getNode(srcAbsPath); // we want to remove mixin when copying node via NodeUtil if (node.isNew() && TEMPORARY_NODE.matcher(srcAbsPath).matches() && NodeUtil.hasMixin(node, NodeTypes.HasVersion.NAME)) { node.removeMixin(NodeTypes.HasVersion.NAME); } getWrappedSession().move(srcAbsPath, destAbsPath); } }
protected void assertNumberOfModifiedOrNewChildren( Node node, int expected ) throws Exception { int numModifiedOrNewChildren = 0; for (NodeIterator iter = node.getNodes(); iter.hasNext();) { Node child = iter.nextNode(); if (child.isNew() || child.isModified()) ++numModifiedOrNewChildren; } assertThat(numModifiedOrNewChildren, is(expected)); } }
private void saveParent(Node node) throws RepositoryException { Node parent = node.getParent(); if (parent.isNew()) { saveParent(parent); } else if (parent.isModified()) { parent.save(); } }
protected void assertNoModifiedOrNewOrRemovedChildren( Node node ) throws Exception { for (NodeIterator iter = node.getNodes(); iter.hasNext();) { Node child = iter.nextNode(); assertThat(child.isNew(), is(false)); assertThat(child.isModified(), is(false)); } }
@Test public void testIsNew() throws RepositoryException, InterruptedException { Session session = getAdminSession(); Node root = session.getRootNode(); Node node1 = root.addNode("node1"); session.save(); node1.remove(); Node node2 = root.addNode("node2"); assertTrue("The Node is just added", node2.isNew()); Node node1Again = root.addNode("node1"); assertTrue("The Node is just added but has a remove in same commit", node1Again.isNew()); }
/** * Test if a node, that has be transiently added and removed is not 'New'. */ public void testNotNewRemovedNode() throws RepositoryException { removeNode.remove(); assertFalse("Removed transient node must not be 'new'.", removeNode.isNew()); }
public void testCheckoutWithPendingChanges() throws Exception { Node node = testRootNode.addNode(nodeName1, testNodeType); node.addMixin(mixVersionable); superuser.save(); node.checkin(); Node newNode = testRootNode.addNode(nodeName2, testNodeType); assertTrue(newNode.isNew()); node.checkout(); assertTrue(node.isCheckedOut()); assertTrue(newNode.isNew()); }
@Test public void testIsNewReturnsFalseByDefault() throws Exception { Node newNode = new MockNode("qux"); assertFalse(newNode.isNew()); }
public void testMove() throws RepositoryException { String srcPath = moveNode.getPath(); testRootNode.getSession().move(srcPath, destinationPath); assertTrue(destParentNode.isNew()); assertTrue(moveNode.isModified()); assertTrue(testRootNode.getSession().itemExists(destinationPath)); assertFalse(testRootNode.getSession().itemExists(srcPath)); }
@Test public void savedNodeShouldHaveNoNewOrModifiedProperties() throws Exception { assertThat(savedNode.isNew(), is(false)); assertThat(savedNode.isModified(), is(false)); assertNoModifiedOrNewProperties(savedNode); assertNoModifiedOrNewOrRemovedChildren(savedNode); }
public void testMoveSaved() throws RepositoryException { String srcPath = moveNode.getPath(); testRootNode.getSession().move(srcPath, destinationPath); testRootNode.save(); assertFalse(destParentNode.isNew()); assertFalse(srcParentNode.isModified()); assertFalse(moveNode.isModified()); assertTrue(testRootNode.getSession().itemExists(destinationPath)); assertFalse(testRootNode.getSession().itemExists(srcPath)); }
public void testRemoveDestParent() throws RepositoryException { String srcPath = moveNode.getPath(); testRootNode.getSession().move(srcPath, destinationPath); destParentNode.remove(); assertFalse(destParentNode.isNew()); assertFalse(destParentNode.isModified()); assertFalse(moveNode.isModified()); assertTrue(srcParentNode.isModified()); assertFalse(testRootNode.getSession().itemExists(srcPath)); }