@Override public boolean hasNodes() throws RepositoryException { checkSession(); // this should check permissions via the resolver return getNodes().hasNext(); }
@Override public boolean hasNodes() throws RepositoryException { checkSession(); // this should check permissions via the resolver return getNodes().hasNext(); }
@Override public NodeIterator getNodes( String namePattern ) throws RepositoryException { CheckArg.isNotNull(namePattern, "namePattern"); checkSession(); if (namePattern.length() == 0) return JcrEmptyNodeIterator.INSTANCE; if ("*".equals(namePattern)) return getNodes(); return getNodes(patternStringToGlobArray(namePattern)); }
@Override public NodeIterator getNodes( String namePattern ) throws RepositoryException { CheckArg.isNotNull(namePattern, "namePattern"); checkSession(); if (namePattern.length() == 0) return JcrEmptyNodeIterator.INSTANCE; if ("*".equals(namePattern)) return getNodes(); return getNodes(patternStringToGlobArray(namePattern)); }
@Test @FixFor( "MODE-2115" ) public void copiedNodesShouldReplaceAutoCreatedChildren() throws Exception { tools.registerNodeTypes(session, "cnd/autocreated-child-nodes.cnd"); Node parent = session.getRootNode().addNode("parent", "test:autocreatedFolders"); session.save(); long folder1CreatedTs = parent.getNode("folder1").getProperty("jcr:created").getDate().getTimeInMillis(); long folder2CreatedTs = parent.getNode("folder2").getProperty("jcr:created").getDate().getTimeInMillis(); workspace.copy("/parent", "/new_parent"); AbstractJcrNode newParent = session.getNode("/new_parent"); assertEquals(2, newParent.getNodes().getSize()); Node folder1Copy = assertNode("/new_parent/folder1", "nt:folder"); assertEquals(folder1CreatedTs, folder1Copy.getProperty("jcr:created").getDate().getTimeInMillis()); Node folder2Copy = assertNode("/new_parent/folder2", "nt:folder"); assertEquals(folder2CreatedTs, folder2Copy.getProperty("jcr:created").getDate().getTimeInMillis()); }
@Test @FixFor( "MODE-2217" ) public void shouldKeepChildrenOrder() throws Exception { startRepositoryWithConfigurationFrom("config/repo-config-initial-content-children-order.json"); JcrSession session = repository.login(); try { NodeIterator children = session.getNode("/testRoot").getNodes(); assertEquals(3, children.getSize()); Node node3 = children.nextNode(); assertEquals("/testRoot/node3", node3.getPath()); NodeIterator subChildren = node3.getNodes(); assertEquals(2, subChildren.getSize()); assertEquals("/testRoot/node3/node3_2", subChildren.nextNode().getPath()); assertEquals("/testRoot/node3/node3_1", subChildren.nextNode().getPath()); assertEquals("/testRoot/node2", children.nextNode().getPath()); Node node1 = children.nextNode(); assertEquals("/testRoot/node1", node1.getPath()); subChildren = node1.getNodes(); assertEquals(2, subChildren.getSize()); assertEquals("/testRoot/node1/node1_2", subChildren.nextNode().getPath()); assertEquals("/testRoot/node1/node1_1", subChildren.nextNode().getPath()); } finally { session.logout(); } }
nodeIterator = session.getNode("/smallCol").getNodes(); assertEquals(allChildrenPaths.size(), nodeIterator.getSize()); iterableChildren = new HashSet<>(); allChildrenPaths.add(child1Path); nodeIterator = session.getNode("/smallCol").getNodes(); assertEquals(allChildrenPaths.size(), nodeIterator.getSize()); iterableChildren = new HashSet<>();
session.save(); NodeIterator nodes = session.getNode("/smallCol").getNodes(); assertEquals(1, nodes.getSize()); child = nodes.nextNode();
@Test @FixFor( "MODE-2115" ) public void clonedNodesWithAutoCreatedChildrenShouldPreserveIdentifiers() throws Exception { tools.registerNodeTypes(session, "cnd/autocreated-child-nodes.cnd"); Node parent = session.getRootNode().addNode("parent", "test:autocreatedFolders"); session.save(); Node folder1 = parent.getNode("folder1"); long folder1CreatedTs = folder1.getProperty("jcr:created").getDate().getTimeInMillis(); Node folder2 = parent.getNode("folder2"); long folder2CreatedTs = folder2.getProperty("jcr:created").getDate().getTimeInMillis(); otherWorkspace.clone(workspaceName, "/parent", "/parent", true); AbstractJcrNode otherParent = otherSession.getNode("/parent"); assertEquals(2, otherParent.getNodes().getSize()); Node otherFolder1 = otherSession.getNode("/parent/folder1"); assertEquals(folder1CreatedTs, otherFolder1.getProperty("jcr:created").getDate().getTimeInMillis()); assertEquals(folder1.getIdentifier(), otherFolder1.getIdentifier()); Node otherFolder2 = otherSession.getNode("/parent/folder2"); assertEquals(folder2.getIdentifier(), otherFolder2.getIdentifier()); assertEquals(folder2CreatedTs, otherFolder2.getProperty("jcr:created").getDate().getTimeInMillis()); }
@Test @FixFor( "MODE-2109 ") public void shouldNotSupportRenamingsButShouldSupportMove() throws Exception { Node col1 = session.getRootNode().addNode("col1", "test:smallCollection"); session.getRootNode().addNode("col2", "test:smallCollection"); col1.addNode("child1"); col1.addNode("child2"); session.save(); try { // reject renamings session.move("/col1/child1", "/col1/child3"); fail("Renamings should not be supported for large collections"); } catch (ConstraintViolationException e) { // expected } // but allow a normal move session.move("/col1/child1", "/col2/child1"); session.save(); NodeIterator nodes = session.getNode("/col1").getNodes(); assertEquals(1, nodes.getSize()); assertEquals("/col1/child2", nodes.nextNode().getPath()); nodes = session.getNode("/col2").getNodes(); assertEquals(1, nodes.getSize()); assertEquals("/col2/child1", nodes.nextNode().getPath()); }
@Test @FixFor( "MODE-2115" ) public void copiedNodesShouldReplaceReferenceableAutoCreatedChildren() throws Exception { tools.registerNodeTypes(session, "cnd/autocreated-child-nodes.cnd"); session.getRootNode().addNode("parent", "test:autocreatedReferenceableChildren"); session.save(); session.getNode("/parent/child1").addNode("child1_1"); session.save(); workspace.copy("/parent", "/new_parent"); AbstractJcrNode newParent = session.getNode("/new_parent"); assertEquals(2, newParent.getNodes().getSize()); // validate that the jcr:uuid is the same as the identifier of the node Node child1 = assertNode("/new_parent/child1", "test:subnodeReferenceable"); assertEquals(child1.getIdentifier(), child1.getProperty("jcr:uuid").getString()); Node child2 = assertNode("/new_parent/child2", "test:subnodeReferenceable"); assertEquals(child2.getIdentifier(), child2.getProperty("jcr:uuid").getString()); assertNode("/new_parent/child1/child1_1"); }
session.save(); tx1.commit(); assertEquals(1, parent.getNodes().getSize()); } catch (Exception e) { throw new RuntimeException(e);
NodeIterator nodes = otherSession.getNode("/col2").getNodes(); assertEquals(2, nodes.getSize()); } finally {
@Test public void shouldImportInitialContentForAllWorkspaceConfigurations() throws Exception { startRepositoryWithConfigurationFrom("config/repo-config-initial-content.json"); //preconfigured ws String ws1 = "ws1"; assertCarsWithMixins(ws1); //preconfigured ws String ws2 = "ws2"; assertFilesAndFolders(ws2); //default ws String defaultWs = "default"; assertCarsWithoutNamespace(defaultWs); //create a new ws that has been configured with an empty import String ws4 = "ws4"; session.getWorkspace().createWorkspace(ws4); JcrSession ws4Session = repository.login(ws4); NodeIterator rootIterator = ws4Session.getNode("/").getNodes(); assertEquals("Expected an empty workspace", 1, rootIterator.getSize()); //create a new ws that has been configured the same as ws2 String ws5 = "ws5"; session.getWorkspace().createWorkspace(ws5); assertFilesAndFolders(ws5); //create a new ws that doesn't have a dedicated config, but should fall back to default String ws6 = "ws6"; session.getWorkspace().createWorkspace(ws6); assertCarsWithMixins(ws6); }
assertEquals(2, session.getNode("/testRoot").getNodes().getSize());