/** * Forwards the method call to the underlying workspace. */ public void copy(String srcAbsPath, String destAbsPath) throws ConstraintViolationException, VersionException, AccessDeniedException, PathNotFoundException, ItemExistsException, LockException, RepositoryException { workspace.copy(srcAbsPath, destAbsPath); }
/** * Forwards the method call to the underlying workspace. */ public void copy(String srcWorkspace, String srcAbsPath, String destAbsPath) throws NoSuchWorkspaceException, ConstraintViolationException, VersionException, AccessDeniedException, PathNotFoundException, ItemExistsException, LockException, RepositoryException { workspace.copy(srcWorkspace, srcAbsPath, destAbsPath); }
/** * copy content to the specified location. * * @param source source node path * @param destination node where the node has to be copied */ @Override public void copyTo(String source, String destination) throws PathNotFoundException, RepositoryException, AccessDeniedException { this.getWorkspace().copy(source, destination); }
/** {@inheritDoc} */ public void copy(String workspace, String from, String to) throws RepositoryException, RemoteException { try { this.workspace.copy(workspace, from, to); } catch (RepositoryException ex) { throw getRepositoryException(ex); } }
/** * Operation is performed entirely within the persistent workspace, it does * not involve transient storage and therefore does not require a save */ public void testCopyNodes() throws RepositoryException { // copy referenceable node below non-referenceable node String dstAbsPath = node2.getPath() + "/" + node1.getName(); workspace.copy(node1.getPath(), dstAbsPath); // there should not be any pending changes after copy assertFalse(superuser.hasPendingChanges()); }
@Override void run(int scale) throws RepositoryException { session.getWorkspace().copy("/large-copy/s" + scale, "/large-copy/t" + scale); } };
public void testCopyNode() throws Exception { Node n = (Node) readOnlySession.getItem(testNodePath); String destPath = testRootNode.getPath() + "/" + nodeName2; try { readOnlySession.getWorkspace().copy(n.getPath(), destPath); fail("A read only session must not be allowed to copy a node"); } catch (AccessDeniedException e) { // expected log.debug(e.getMessage()); } } }
/** * Operation is performed entirely within the persistent workspace, it does * not involve transient storage and therefore does not require a save */ public void testCopyNodes() throws RepositoryException { // copy referenceable node below non-referenceable node String dstAbsPath = node2W2.getPath() + "/" + node1.getName(); workspaceW2.copy(workspace.getName(), node1.getPath(), dstAbsPath); // there should not be any pending changes after copy assertFalse(superuserW2.hasPendingChanges()); }
public void run() { try { session.getWorkspace().copy(sourcePath, destPath); session.save(); randomSleep(); } catch (RepositoryException e) { // expected } finally { session.logout(); } } }
@Test public void testCopyNoWritePermissionAtTarget() throws Exception { try { testSession.getWorkspace().copy(path, destPath); fail("no write permission at copy target"); } catch (AccessDeniedException e) { // success } }
@Test public void hasVersionsMixinIsRemovedOnCopy2() throws Exception { // GIVEN Node sourceNode = websiteSession.getRootNode().addNode("src", NodeTypes.Page.NAME); websiteSession.save(); versionManager.addVersion(sourceNode); // WHEN websiteSession.getWorkspace().copy(RepositoryConstants.WEBSITE, sourceNode.getPath(), "/dest"); // THEN assertFalse(NodeUtil.hasMixin(websiteSession.getNode("/dest"), NodeTypes.HasVersion.NAME)); } }
@Test public void hasVersionsMixinIsRemovedOnCopy() throws Exception { // GIVEN Node sourceNode = websiteSession.getRootNode().addNode("src", NodeTypes.Page.NAME); websiteSession.save(); versionManager.addVersion(sourceNode); // WHEN websiteSession.getWorkspace().copy(sourceNode.getPath(), "/dest"); // THEN assertFalse(NodeUtil.hasMixin(websiteSession.getNode("/dest"), NodeTypes.HasVersion.NAME)); }
@Test public void testCopyNode() throws RepositoryException { Session session = getAdminSession(); session.getWorkspace().copy(TEST_PATH + "/source/node", TEST_PATH + "/target/copied"); assertTrue(testNode.hasNode("source/node")); assertTrue(testNode.hasNode("target/copied")); }
public void testCopyJson() throws Exception { Node test = createJsonNode("test.json"); test.getSession().getWorkspace().copy(test.getPath(), test.getParent().getPath() + "/target.json"); Session s = getHelper().getReadOnlySession(); try { Property p = s.getNode(testRoot).getNode("target.json").getNode(JcrConstants.JCR_CONTENT) .getProperty(JcrConstants.JCR_DATA); assertEquals(jsondata, IOUtils.toString(p.getBinary().getStream(), "UTF-8")); } finally { s.logout(); } }
@Test public void testCopyReferenceableChildNode() throws Exception { Session session = getAdminSession(); session.getNode(TEST_PATH + "/source/node").addNode("child").addMixin(JcrConstants.MIX_REFERENCEABLE); session.save(); session.getWorkspace().copy(TEST_PATH + "/source/node", TEST_PATH + "/target/copied"); assertTrue(testNode.hasNode("source/node")); assertTrue(testNode.hasNode("target/copied")); Node childCopy = testNode.getNode("target/copied/child"); assertTrue(childCopy.isNodeType(JcrConstants.MIX_REFERENCEABLE)); assertFalse(childCopy.getUUID().equals(testNode.getNode("source/node/child").getUUID())); }
@Test @FixFor( "MODE-1976" ) public void shouldBeAbleToCopyFromRepositoryToExternalSource() throws Exception { jcrSession().getRootNode().addNode("files").addNode("dir", "nt:folder"); jcrSession().save(); jcrSession().getWorkspace().copy("/files/dir", "/testRoot/store/dir"); Node dir = session.getNode("/testRoot/store/dir"); assertNotNull(dir); assertEquals("nt:folder", dir.getPrimaryNodeType().getName()); }
@Test public void testCopyWithFullPermissions() throws Exception { allow(targetPath, privilegesFromName(Privilege.JCR_ALL)); testSession.getWorkspace().copy(path, destPath); assertTrue(testSession.nodeExists(destPath)); }
@Test @FixFor( "MODE-1976" ) public void shouldCopyFromNonFederatedSourceToFederatedTargetSameWs() throws Exception { federationManager.createProjection("/testRoot", SOURCE_NAME, MockConnector.DOC1_LOCATION, "fed1"); jcrSession().getNode("/testRoot/fed1").addNode("federated1"); jcrSession().getRootNode().addNode("testRoot2").addNode("nonFederated2"); jcrSession().save(); jcrSession().getWorkspace().copy("/testRoot2", "/testRoot/fed1/federated2"); assertNodeFound("/testRoot/fed1/federated2"); assertNodeFound("/testRoot/fed1/federated2/nonFederated2"); assertEquals(2, jcrSession().getNode("/testRoot/fed1").getNodes().getSize()); }
@Test @FixFor( "MODE-1976" ) public void shouldAllowCopyWithinSameSource() throws Exception { federationManager.createProjection("/testRoot", SOURCE_NAME, MockConnector.DOC1_LOCATION, "fed1"); federationManager.createProjection("/testRoot", SOURCE_NAME, MockConnector.DOC2_LOCATION, "fed2"); jcrSession().getWorkspace().copy("/testRoot/fed1", "/testRoot/fed2/fed1"); assertNodeFound("/testRoot/fed2/fed1"); assertNodeFound("/testRoot/fed2/federated3"); }
@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()); }