/** * @inheritDoc */ public void removeVersion(String versionName) throws ReferentialIntegrityException, AccessDeniedException, UnsupportedRepositoryOperationException, VersionException, RepositoryException { versionHistory.removeVersion(versionName); }
VersionHistory history = session.getWorkspace().getVersionManager() .getVersionHistory(info.getVersionedNodePath()); history.removeVersion(info.getVersionName()); session.save();
public Object run() throws RepositoryException { Node vHistory = getNode(versionHistoryId, sInfo); Node version = getNode(versionId, sInfo); if (vHistory instanceof VersionHistory) { ((VersionHistory) vHistory).removeVersion(version.getName()); } else { throw new RepositoryException("versionHistoryId does not reference a VersionHistor node"); } return null; } }, sInfo);
@Override public void removeVersion(String versionName) throws ReferentialIntegrityException, AccessDeniedException, UnsupportedRepositoryOperationException, VersionException, RepositoryException { getWrappedVersionHistory().removeVersion(versionName); } }
public Object run() throws RepositoryException { Node vHistory = getNode(versionHistoryId, sInfo); Node version = getNode(versionId, sInfo); if (vHistory instanceof VersionHistory) { ((VersionHistory) vHistory).removeVersion(version.getName()); } else { throw new RepositoryException("versionHistoryId does not reference a VersionHistor node"); } return null; } }, sInfo);
/** {@inheritDoc} */ public void removeVersion(String versionName) throws RepositoryException, RemoteException { try { versionHistory.removeVersion(versionName); } catch (RepositoryException ex) { throw getRepositoryException(ex); } }
public void removeVersion(String versionName) throws RepositoryException { getDelegate().removeVersion(versionName); }
private int purgeVersions() throws RepositoryException { int count = 0; Iterator<Version> versions = this.versionsToPurge.iterator(); while (versions.hasNext()) { Version version = versions.next(); if (!JcrConstants.JCR_ROOTVERSION.equals(version.getName())) { version.getContainingHistory().removeVersion(version.getName()); count++; } versions.remove(); } return count; }
protected void removeVersion(Node node, String versionName) { try { //VersionHistory versionHistory = node.getVersionHistory(); VersionHistory versionHistory = JcrUtils.getVersionManager(node.getSession()).getVersionHistory(node.getPath()); versionHistory.removeVersion(versionName); } catch (RepositoryException e) { throw new JcrMappingException("Could not remove version", e); } }
@Override public Object doInJcr( final Session session ) throws RepositoryException, IOException { RepositoryFile fileToBeDeleted = getFileById( fileId ); // Get repository file info and acl info of parent if ( fileToBeDeleted != null ) { RepositoryFileAcl toBeDeletedFileAcl = aclDao.getAcl( fileToBeDeleted.getId() ); // Invoke accessVoterManager to see if we have access to perform this operation if ( !accessVoterManager.hasAccess( fileToBeDeleted, RepositoryFilePermission.DELETE, toBeDeletedFileAcl, PentahoSessionHolder.getSession() ) ) { return null; } } Node fileToDeleteNode = session.getNodeByIdentifier( fileId.toString() ); session.getWorkspace().getVersionManager().getVersionHistory( fileToDeleteNode.getPath() ).removeVersion( versionId.toString() ); session.save(); return null; } } );
/** * Test removed version gets invalid */ public void testRemovedInvalid() throws Exception { versionableNode.getVersionHistory().removeVersion(version.getName()); // assert: version has become invalid try { version.getPredecessors(); fail("Removed version still operational."); } catch (RepositoryException e) { // expected } }
/** * Checks if all versions but the base and root one can be removed. */ public void testRemoveAllBut2() throws RepositoryException { String baseVersion = versionableNode.getBaseVersion().getName(); VersionHistory vh = versionableNode.getVersionHistory(); VersionIterator vi = vh.getAllVersions(); while (vi.hasNext()) { Version currenVersion = vi.nextVersion(); String versionName = currenVersion.getName(); if (!versionName.equals("jcr:rootVersion") && !versionName.equals(baseVersion)) { vh.removeVersion(versionName); } } }
/** * Test if the successors of the removed version are made successors of * all predecessors of the the removed version. * * @throws RepositoryException */ public void testRemoveVersionAdjustSucessorSet() throws RepositoryException { // retrieve predecessors to test and remove the version Version[] predec = version.getPredecessors(); vHistory.removeVersion(version.getName()); for (int i = 0; i < predec.length; i++) { boolean isContained = false; Version[] succ = predec[i].getSuccessors(); for (int j = 0; j < succ.length; j++) { isContained |= succ[j].isSame(version2); } if (!isContained) { fail("Removing a version must make all it's successor version to successors of the removed version's predecessors."); } } }
public void testSuccessorsPredecessorsMergedOnRemove() throws Exception { Node node = testRootNode.addNode(nodeName1, ntUnstructured); node.addMixin(mixVersionable); superuser.save(); VersionManager vm = superuser.getWorkspace().getVersionManager(); VersionHistory history = vm.getVersionHistory(node.getPath()); vm.checkpoint(node.getPath()); // 1.0 Version v11 = vm.checkpoint(node.getPath()); vm.checkpoint(node.getPath()); // 1.2 vm.checkpoint(node.getPath()); // 1.3 vm.restore(v11, true); vm.checkpoint(node.getPath()); // 1.1 vm.checkpoint(node.getPath()); // 1.1.0 assertSuccessors(history, of("1.1.0", "1.2"), "1.1"); vm.checkpoint(node.getPath()); // 1.1.1 history.removeVersion("1.2"); assertSuccessors(history, of("1.1.0", "1.3"), "1.1"); }
public NodeIterator execute() throws Exception { Node n = getNode(); Version v = getRandomVersion(true); if (v != null) { log.info(n.getPath() + ":" + v.getName()); n.getVersionHistory().removeVersion(v.getName()); } return wrapWithIterator(n); } }
private void removeAllVersions(VersionHistory history) throws RepositoryException { // delete all versions of node (to delete references to // files) VersionIterator it = history.getAllVersions(); while (it.hasNext()) { Version version = it.nextVersion(); history.removeVersion(version.getName()); } }
/** * @since oak (DIFF: jr required jcr:versionManagement privilege on the version store) */ @Test public void testRemoveVersion() throws Exception { Node n = createVersionableNode(superuser.getNode(path)); Node trn = testSession.getNode(path); modify(trn.getPath(), Privilege.JCR_VERSION_MANAGEMENT, true); Node testNode = trn.getNode(n.getName()); Version v = testNode.checkin(); testNode.checkout(); testNode.checkin(); // removing a version must be allowed testNode.getVersionHistory().removeVersion(v.getName()); }
public void testRemoveVersion2() throws RepositoryException, NotExecutableException { Node trn = getTestNode(); Node n = createVersionableNode(testRootNode); modifyPrivileges(trn.getPath(), Privilege.JCR_VERSION_MANAGEMENT, true); Node testNode = trn.getNode(nodeName1); Version v = testNode.checkin(); testNode.checkout(); testNode.checkin(); // -> VersionHistory.removeVersion must not be allowed. try { testNode.getVersionHistory().removeVersion(v.getName()); fail("TestSession without remove privilege on the v-storage must not be able to remove a version."); } catch (AccessDeniedException e) { // success log.debug(e.getMessage()); } }
public void testRemoveVersionLabel() throws RepositoryException { Node n = testRootNode.addNode(nodeName1); n.addMixin(mixVersionable); testRootNode.save(); Version v10 = n.checkin(); n.checkout(); n.checkin(); VersionHistory vh = n.getVersionHistory(); vh.addVersionLabel(v10.getName(), "test", true); // the next call must not fail vh.removeVersion(v10.getName()); // now the label must be gone String[] labels = vh.getVersionLabels(); assertEquals("Label of a removed version must be removed as well", 0, labels.length); } }
@Test @FixFor( "MODE-2152" ) public void shouldRemoveVersionInVersionGraphWithBranches2() throws Exception { registerNodeTypes("cnd/jj.cnd"); Node node = session.getRootNode().addNode("node", "jj:page"); session.save(); String nodePath = node.getPath(); //create two versions versionManager.checkpoint(nodePath); // version 1.0 versionManager.checkpoint(nodePath); // version 1.1 versionManager.restore(nodePath, "1.0", true); versionManager.checkout(nodePath); versionManager.checkpoint(nodePath); // version 1.1.0 versionManager.getVersionHistory(nodePath).removeVersion("1.1"); }