private void assertNotFound( String absPath, JcrSession jcrSession ) throws RepositoryException { try { jcrSession.getNode(absPath); fail("Node " + absPath + " should not have been found in the session " + session); } catch (PathNotFoundException e) { // expected } } }
private void assertNodeNotFound( String absPath ) throws RepositoryException { try { session.getNode(absPath); fail("Node at " + absPath + " should not exist"); } catch (PathNotFoundException e) { // expected } }
@Override public void checkout( String absPath ) throws LockException, RepositoryException { if (LOGGER.isDebugEnabled()) LOGGER.debug("VersionManager.checkout('{0}')", absPath); checkout(session.getNode(absPath)); }
@Override public Version checkin( String absPath ) throws VersionException, UnsupportedRepositoryOperationException, InvalidItemStateException, LockException, RepositoryException { if (LOGGER.isDebugEnabled()) LOGGER.debug("VersionManager.checkin('{0}')", absPath); return checkin(session.getNode(absPath)); }
@Override public void doneMerge( String absPath, Version version ) throws VersionException, InvalidItemStateException, UnsupportedRepositoryOperationException, RepositoryException { if (LOGGER.isDebugEnabled()) LOGGER.debug("VersionManager.doneMerge('{0}',{1})", absPath, version); // Create a new session in which we'll finish the merge, so this session remains thread-safe ... JcrSession mergeSession = session.spawnSession(false); doneMerge(mergeSession.getNode(absPath), version); }
private boolean projectedPathExists( JcrSession session, RepositoryConfiguration.ProjectionConfiguration projectionCfg ) throws RepositoryException { try { session.getNode(projectionCfg.getProjectedPath()); repository.warn(JcrI18n.projectedPathPointsTowardsInternalNode, projectionCfg, projectionCfg.getSourceName(), projectionCfg.getProjectedPath()); return true; } catch (PathNotFoundException e) { return false; } }
@Override public void exportSystemView( String absPath, ContentHandler contentHandler, boolean skipBinary, boolean noRecurse ) throws PathNotFoundException, SAXException, RepositoryException { CheckArg.isNotNull(absPath, "absPath"); CheckArg.isNotNull(contentHandler, "contentHandler"); Node exportRootNode = getNode(absPath); AbstractJcrExporter exporter = new JcrSystemViewExporter(this); exporter.exportView(exportRootNode, contentHandler, skipBinary, noRecurse); }
@Override public void exportDocumentView( String absPath, OutputStream out, boolean skipBinary, boolean noRecurse ) throws IOException, PathNotFoundException, RepositoryException { CheckArg.isNotNull(absPath, "absPath"); CheckArg.isNotNull(out, "out"); Node exportRootNode = getNode(absPath); AbstractJcrExporter exporter = new JcrDocumentViewExporter(this); exporter.exportView(exportRootNode, out, skipBinary, noRecurse); }
private boolean projectedPathExists( JcrSession session, RepositoryConfiguration.ProjectionConfiguration projectionCfg ) throws RepositoryException { try { session.getNode(projectionCfg.getProjectedPath()); repository.warn(JcrI18n.projectedPathPointsTowardsInternalNode, projectionCfg, projectionCfg.getSourceName(), projectionCfg.getProjectedPath()); return true; } catch (PathNotFoundException e) { return false; } }
@Test @FixFor( "MODE-1972" ) public void shouldCopyEntireWorkspaces() throws Exception { otherWorkspace.copy(workspaceName, "/", "/"); assertNotNull(otherSession.getNode("/a")); assertNotNull(otherSession.getNode("/a/b")); assertNotNull(otherSession.getNode("/a/b/c")); assertNotNull(otherSession.getNode("/b")); }
@Test public void shouldAllowUpdatingNodesInWritableStoreBasedProjection() throws Exception { Node file = session.getNode("/testRoot/store/dir3/simple.json"); file.addMixin("flex:anyProperties"); file.setProperty("extraProp", "extraValue"); session.save(); assertNoSidecarFile(storeProjection, "dir3/simple.json.modeshape"); Node file2 = session.getNode("/testRoot/store/dir3/simple.json"); assertThat(file2.getProperty("extraProp").getString(), is("extraValue")); }
@Test @FixFor("MODE-2126") public void shouldAllowIteratorOverNamedNodesToBeUsedNominally() throws Exception { Node cars = session.getNode("/Cars"); NodeIterator iter = cars.getNodes("Hybrid"); while (iter.hasNext()) { Node child = iter.nextNode(); assertNotNull(child); // System.out.println("Child: " + child); } }
@Test @FixFor( "MODE-1972" ) public void shouldCloneEntireWorkspaces() throws Exception { otherWorkspace.clone(workspaceName, "/", "/", true); assertEquals(session.getNode("/a").getIdentifier(), otherSession.getNode("/a").getIdentifier()); assertEquals(session.getNode("/a/b").getIdentifier(), otherSession.getNode("/a/b").getIdentifier()); assertEquals(session.getNode("/a/b/c").getIdentifier(), otherSession.getNode("/a/b/c").getIdentifier()); assertEquals(session.getNode("/b").getIdentifier(), otherSession.getNode("/b").getIdentifier()); }
protected Node makeShareable( String absPath ) throws RepositoryException { Node node = session.getNode(absPath); if (!node.isNodeType(MIX_SHAREABLE)) { node.addMixin(MIX_SHAREABLE); } return node; }
@Test( expected = RepositoryException.class ) public void shouldNotAllowWritesIfReadonly() throws Exception { federationManager.createProjection("/testRoot", "mock-source-readonly", MockConnector.DOC1_LOCATION, "federated1"); Node doc1Federated = session.getNode("/testRoot/federated1"); Node externalNode1 = doc1Federated.addNode("federated1_1", null); externalNode1.addNode("federated1_1_1", null); session.save(); }
@Override public void exportDocumentView( String absPath, ContentHandler contentHandler, boolean skipBinary, boolean noRecurse ) throws PathNotFoundException, SAXException, RepositoryException { CheckArg.isNotNull(absPath, "absPath"); CheckArg.isNotNull(contentHandler, "contentHandler"); checkLive(); Node exportRootNode = getNode(absPath); AbstractJcrExporter exporter = new JcrDocumentViewExporter(this); exporter.exportView(exportRootNode, contentHandler, skipBinary, noRecurse); }
@Test public void onlyAccessControlAPIAllowsRemoveACL() throws Exception { Node node = session.getNode("/Cars/Luxury/mode:acl"); assertThat(node, is(notNullValue())); try { node.remove(); fail("Only Access Control API allows modification"); } catch (AccessDeniedException e) { //expected } }
@Test @FixFor( {"MODE-1971", "MODE-1976"} ) public void shouldBeAbleToCopyExternalNodesInTheSameSource() throws Exception { ((Workspace)session.getWorkspace()).copy("/testRoot/store/dir3/simple.json", "/testRoot/store/dir3/simple2.json"); Node file = session.getNode("/testRoot/store/dir3/simple2.json"); assertNotNull(file); assertEquals("nt:file", file.getPrimaryNodeType().getName()); ((Workspace)session.getWorkspace()).copy("/testRoot/store/dir3", "/testRoot/store/dir4"); Node folder = session.getNode("/testRoot/store/dir4"); assertNotNull(folder); assertEquals("nt:folder", folder.getPrimaryNodeType().getName()); }
@Test @FixFor( "MODE-2012" ) public void clonedUUIDsShouldBeTheSame() throws Exception { tools.registerNodeTypes(session, "cnd/references.cnd"); Node nodeA = session.getRootNode().addNode("A", "test:node"); Node nodeB = session.getRootNode().addNode("B", "test:node"); session.save(); otherWorkspace.clone("default", "/", "/", true); assertEquals(nodeA.getIdentifier(), otherSession.getNode("/A").getIdentifier()); assertEquals(nodeB.getIdentifier(), otherSession.getNode("/B").getIdentifier()); }