@Override public void restore(Version[] versions, boolean removeExisting) throws ItemExistsException, UnsupportedRepositoryOperationException, VersionException, LockException, InvalidItemStateException, RepositoryException { getWrappedWorkspace().restore(versions, removeExisting); }
/** * Forwards the method call to the underlying workspace. */ public void restore(Version[] versions, boolean removeExisting) throws ItemExistsException, UnsupportedRepositoryOperationException, VersionException, LockException, InvalidItemStateException, RepositoryException { Version[] tmp = new Version[versions.length]; for (int i = 0; i < versions.length; i++) { tmp[i] = VersionDecorator.unwrap(versions[i]); } workspace.restore(tmp, removeExisting); }
/** * @deprecated */ @Deprecated public void restore(Version[] versions, boolean removeExisting) throws RepositoryException { getDelegate().restore(versions, removeExisting); }
/** * Test if VersionException is thrown if the specified version array does * not contain a version that has a corresponding node in this workspace. */ @SuppressWarnings("deprecation") public void testWorkspaceRestoreHasCorrespondingNode() throws RepositoryException { try { superuser.getWorkspace().restore(new Version[]{wChildVersion}, false); fail("Workspace.restore(Version[], boolean) must throw VersionException if non of the specified versions has a corresponding node in the workspace."); } catch (VersionException e) { // success } }
public void execute() throws Exception { getDelegate().restore(versions, removeExisting); } });
/** * Test if workspace-restoring a node works on checked-in node. */ @SuppressWarnings("deprecation") public void testWorkspaceRestoreOnCheckedInNode() throws RepositoryException { if (versionableNode.isCheckedOut()) { versionableNode.checkin(); } superuser.getWorkspace().restore(new Version[]{version}, true); }
/** * Test if workspace-restoring a node works on checked-out node. */ @SuppressWarnings("deprecation") public void testWorkspaceRestoreOnCheckedOutNode() throws RepositoryException { if (!versionableNode.isCheckedOut()) { versionableNode.checkout(); } superuser.getWorkspace().restore(new Version[]{version}, true); }
public Object run() throws RepositoryException { Version[] versions = new Version[versionIds.length]; for (int i = 0; i < versions.length; i++) { Node n = getNode(versionIds[i], sInfo); if (n instanceof Version) { versions[i] = (Version) n; } else { throw new RepositoryException(n.getPath() + " does not reference a Version node"); } } sInfo.getSession().getWorkspace().restore(versions, removeExisting); return null; } }, sInfo);
public Object run() throws RepositoryException { Version[] versions = new Version[versionIds.length]; for (int i = 0; i < versions.length; i++) { Node n = getNode(versionIds[i], sInfo); if (n instanceof Version) { versions[i] = (Version) n; } else { throw new RepositoryException(n.getPath() + " does not reference a Version node"); } } sInfo.getSession().getWorkspace().restore(versions, removeExisting); return null; } }, sInfo);
/** * Test if the removeExisting-flag removes an existing node in case of uuid conflict. */ @SuppressWarnings("deprecation") public void testWorkspaceRestoreWithRemoveExisting() throws NotExecutableException, RepositoryException { // create version for parentNode of childNode superuser.getWorkspace().clone(workspaceName, wVersionableChildNode.getPath(), wVersionableChildNode.getPath(), false); Version parentV = versionableNode.checkin(); // move child node in order to produce the uuid conflict String newChildPath = wVersionableNode2.getPath() + "/" + wVersionableChildNode.getName(); wSuperuser.move(wVersionableChildNode.getPath(), newChildPath); wSuperuser.save(); // restore the parent with removeExisting == true >> moved child node // must be removed. wSuperuser.getWorkspace().restore(new Version[]{parentV}, true); if (wSuperuser.itemExists(newChildPath)) { fail("Workspace.restore(Version[], boolean) with the boolean flag set to true, must remove the existing node in case of Uuid conflict."); } }
/** * Test if Workspace.restore(Version[], boolean) succeeds if the following two * preconditions are fulfilled:<ul> * <li>For every version V in S that corresponds to a missing node in the workspace, * there must also be a parent of V in S.</li> * <li>S must contain at least one version that corresponds to an existing * node in the workspace.</li> * </ul> */ @SuppressWarnings("deprecation") public void testWorkspaceRestoreWithParent() throws RepositoryException { try { Version parentV = wVersionableNode.checkin(); superuser.getWorkspace().restore(new Version[]{parentV, wChildVersion}, false); } catch (RepositoryException e) { fail("Workspace.restore(Version[], boolean) with a version that has no corresponding node must succeed if a version of a parent with correspondance is present in the version array."); } }
/** * Test if InvalidItemStateException is thrown if the session affected by * Workspace.restore(Version[], boolean) has pending changes. */ @SuppressWarnings("deprecation") public void testWorkspaceRestoreWithPendingChanges() throws RepositoryException { versionableNode.checkout(); try { // modify node without calling save() versionableNode.setProperty(propertyName1, propertyValue); // create version in second workspace Version v = wVersionableNode.checkin(); // try to restore that version superuser.getWorkspace().restore(new Version[]{v}, false); fail("InvalidItemStateException must be thrown on attempt to call Workspace.restore(Version[], boolean) in a session having any unsaved changes pending."); } catch (InvalidItemStateException e) { // success } }
/** * Tests if restoring the <code>Version</code> of an existing node throws an * <code>ItemExistsException</code> if removeExisting is set to FALSE. */ @SuppressWarnings("deprecation") public void testWorkspaceRestoreWithUUIDConflict() throws RepositoryException, NotExecutableException { try { // Verify that nodes used for the test are indeed versionable NodeDefinition nd = wVersionableNode.getDefinition(); if (nd.getOnParentVersion() != OnParentVersionAction.COPY && nd.getOnParentVersion() != OnParentVersionAction.VERSION) { throw new NotExecutableException("Nodes must be versionable in order to run this test."); } Version v = wVersionableNode.checkin(); wVersionableNode.checkout(); wSuperuser.move(wVersionableChildNode.getPath(), wVersionableNode2.getPath() + "/" + wVersionableChildNode.getName()); wSuperuser.save(); wSuperuser.getWorkspace().restore(new Version[]{v}, false); fail("Node.restore( Version, boolean ): An ItemExistsException must be thrown if the node to be restored already exsits and removeExisting was set to false."); } catch (ItemExistsException e) { // success } }
session.getWorkspace().restore(versions, removeExisting);