mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
JAWS-172 - add VersionService.deleteVersion(...)
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@12385 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -41,7 +41,6 @@ import org.alfresco.repo.version.common.VersionHistoryImpl;
|
|||||||
import org.alfresco.repo.version.common.VersionImpl;
|
import org.alfresco.repo.version.common.VersionImpl;
|
||||||
import org.alfresco.repo.version.common.VersionUtil;
|
import org.alfresco.repo.version.common.VersionUtil;
|
||||||
import org.alfresco.service.cmr.repository.AspectMissingException;
|
import org.alfresco.service.cmr.repository.AspectMissingException;
|
||||||
import org.alfresco.service.cmr.repository.AssociationRef;
|
|
||||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
import org.alfresco.service.cmr.repository.StoreRef;
|
import org.alfresco.service.cmr.repository.StoreRef;
|
||||||
@@ -1036,22 +1035,35 @@ public class Version2ServiceImpl extends VersionServiceImpl implements VersionSe
|
|||||||
if (versionHistoryNodeRef != null)
|
if (versionHistoryNodeRef != null)
|
||||||
{
|
{
|
||||||
List<ChildAssociationRef> versionsAssoc = this.dbNodeService.getChildAssocs(versionHistoryNodeRef, Version2Model.CHILD_QNAME_VERSIONS, RegexQNamePattern.MATCH_ALL);
|
List<ChildAssociationRef> versionsAssoc = this.dbNodeService.getChildAssocs(versionHistoryNodeRef, Version2Model.CHILD_QNAME_VERSIONS, RegexQNamePattern.MATCH_ALL);
|
||||||
|
|
||||||
|
ChildAssociationRef headVersionAssoc = null;
|
||||||
|
int headVersionNumber = -1;
|
||||||
for (ChildAssociationRef versionAssoc : versionsAssoc)
|
for (ChildAssociationRef versionAssoc : versionsAssoc)
|
||||||
{
|
{
|
||||||
NodeRef versionNodeRef = versionAssoc.getChildRef();
|
String localName = versionAssoc.getQName().getLocalName();
|
||||||
List<AssociationRef> successors = this.dbNodeService.getTargetAssocs(versionNodeRef, Version2Model.ASSOC_SUCCESSOR);
|
if (localName.indexOf(Version2Model.CHILD_VERSIONS+"-") != -1) // TODO - could remove this belts-and-braces, should match correctly above !
|
||||||
if (successors.size() == 0)
|
|
||||||
{
|
{
|
||||||
NodeRef versionedNodeRef = (NodeRef)this.dbNodeService.getProperty(
|
int versionNumber = Integer.parseInt(localName.substring((Version2Model.CHILD_VERSIONS+"-").length()));
|
||||||
versionNodeRef,
|
if (versionNumber > headVersionNumber)
|
||||||
QName.createQName(Version2Model.NAMESPACE_URI, Version2Model.PROP_FROZEN_NODE_REF));
|
|
||||||
StoreRef versionStoreRef = versionedNodeRef.getStoreRef();
|
|
||||||
if (storeRef.equals(versionStoreRef) == true)
|
|
||||||
{
|
{
|
||||||
version = getVersion(versionNodeRef);
|
headVersionNumber = versionNumber;
|
||||||
|
headVersionAssoc = versionAssoc;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (headVersionAssoc != null)
|
||||||
|
{
|
||||||
|
NodeRef versionNodeRef = headVersionAssoc.getChildRef();
|
||||||
|
NodeRef versionedNodeRef = (NodeRef)this.dbNodeService.getProperty(
|
||||||
|
versionNodeRef,
|
||||||
|
QName.createQName(Version2Model.NAMESPACE_URI, Version2Model.PROP_FROZEN_NODE_REF));
|
||||||
|
StoreRef versionStoreRef = versionedNodeRef.getStoreRef();
|
||||||
|
if (storeRef.equals(versionStoreRef) == true)
|
||||||
|
{
|
||||||
|
version = getVersion(versionNodeRef);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return version;
|
return version;
|
||||||
@@ -1085,4 +1097,40 @@ public class Version2ServiceImpl extends VersionServiceImpl implements VersionSe
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.alfresco.service.cmr.version.VersionService#deleteVersion(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.cmr.version.Version)
|
||||||
|
*/
|
||||||
|
public void deleteVersion(NodeRef nodeRef, Version version)
|
||||||
|
{
|
||||||
|
if (useDeprecatedV1)
|
||||||
|
{
|
||||||
|
super.deleteVersion(nodeRef, version); // throws UnsupportedOperationException
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Check the mandatory parameters
|
||||||
|
ParameterCheck.mandatory("nodeRef", nodeRef);
|
||||||
|
ParameterCheck.mandatory("version", version);
|
||||||
|
|
||||||
|
Version currentVersion = getCurrentVersion(nodeRef);
|
||||||
|
|
||||||
|
// Delete the version node
|
||||||
|
this.dbNodeService.deleteNode(VersionUtil.convertNodeRef(version.getFrozenStateNodeRef()));
|
||||||
|
|
||||||
|
if (currentVersion.getVersionLabel().equals(version.getVersionLabel()))
|
||||||
|
{
|
||||||
|
Version headVersion = getHeadVersion(nodeRef);
|
||||||
|
if (headVersion != null)
|
||||||
|
{
|
||||||
|
// Reset the version label property on the versionable node to new head version
|
||||||
|
this.nodeService.setProperty(nodeRef, ContentModel.PROP_VERSION_LABEL, headVersion.getVersionLabel());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
deleteVersionHistory(nodeRef);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
File diff suppressed because it is too large
Load Diff
@@ -25,8 +25,10 @@
|
|||||||
package org.alfresco.repo.version;
|
package org.alfresco.repo.version;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@@ -216,6 +218,28 @@ public class VersionServiceImplTest extends BaseVersionStoreTest
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void CheckVersionHistory(VersionHistory vh, List<Version> expectedVersions)
|
||||||
|
{
|
||||||
|
if (vh == null)
|
||||||
|
{
|
||||||
|
assertNull(expectedVersions);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Iterator<Version> itr = expectedVersions.iterator();
|
||||||
|
|
||||||
|
for (Version version : vh.getAllVersions())
|
||||||
|
{
|
||||||
|
Version expectedVersion = itr.next();
|
||||||
|
|
||||||
|
assertEquals(version.getVersionLabel(), expectedVersion.getVersionLabel());
|
||||||
|
assertEquals(version.getFrozenStateNodeRef(), expectedVersion.getFrozenStateNodeRef());
|
||||||
|
}
|
||||||
|
|
||||||
|
assertFalse(itr.hasNext());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests the version history
|
* Tests the version history
|
||||||
*/
|
*/
|
||||||
@@ -512,6 +536,141 @@ public class VersionServiceImplTest extends BaseVersionStoreTest
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test deleteVersion
|
||||||
|
*/
|
||||||
|
public void testDeleteVersion()
|
||||||
|
{
|
||||||
|
// Create a versionable node
|
||||||
|
NodeRef versionableNode = createNewVersionableNode();
|
||||||
|
|
||||||
|
// Check that there is no version history
|
||||||
|
VersionHistory versionHistory = this.versionService.getVersionHistory(versionableNode);
|
||||||
|
CheckVersionHistory(versionHistory, null);
|
||||||
|
|
||||||
|
// Check that the current version property on the versionable node is not set
|
||||||
|
String versionLabel = (String)this.dbNodeService.getProperty(versionableNode, ContentModel.PROP_VERSION_LABEL);
|
||||||
|
assertNull(versionLabel);
|
||||||
|
|
||||||
|
// Check that there is no current version
|
||||||
|
Version version = this.versionService.getCurrentVersion(versionableNode);
|
||||||
|
assertNull(version);
|
||||||
|
|
||||||
|
// Create a couple of versions
|
||||||
|
Version version0 = createVersion(versionableNode);
|
||||||
|
Version version1 = createVersion(versionableNode);
|
||||||
|
|
||||||
|
// Check that the version label is correct on the versionable node
|
||||||
|
String versionLabel1 = (String)this.dbNodeService.getProperty(versionableNode, ContentModel.PROP_VERSION_LABEL);
|
||||||
|
assertEquals("1.1", versionLabel1);
|
||||||
|
assertEquals(version1.getVersionLabel(), versionLabel1);
|
||||||
|
|
||||||
|
// Check the version history
|
||||||
|
List<Version> expectedVersions = new ArrayList<Version>(2);
|
||||||
|
expectedVersions.add(version1);
|
||||||
|
expectedVersions.add(version0);
|
||||||
|
versionHistory = this.versionService.getVersionHistory(versionableNode);
|
||||||
|
assertEquals(2, versionHistory.getAllVersions().size());
|
||||||
|
CheckVersionHistory(versionHistory, expectedVersions);
|
||||||
|
|
||||||
|
// Check current version
|
||||||
|
Version currentVersion = this.versionService.getCurrentVersion(versionableNode);
|
||||||
|
assertEquals(currentVersion.getVersionLabel(), version1.getVersionLabel());
|
||||||
|
assertEquals(currentVersion.getFrozenStateNodeRef(), version1.getFrozenStateNodeRef());
|
||||||
|
|
||||||
|
// Create a couple more versions
|
||||||
|
Version version2 = createVersion(versionableNode);
|
||||||
|
Version version3 = createVersion(versionableNode);
|
||||||
|
|
||||||
|
// Check that the version label is correct on the versionable node
|
||||||
|
String versionLabel3 = (String)this.dbNodeService.getProperty(versionableNode, ContentModel.PROP_VERSION_LABEL);
|
||||||
|
assertEquals("1.3", versionLabel3);
|
||||||
|
assertEquals(version3.getVersionLabel(), versionLabel3);
|
||||||
|
|
||||||
|
// Check the version history
|
||||||
|
expectedVersions = new ArrayList<Version>(4);
|
||||||
|
expectedVersions.add(version3);
|
||||||
|
expectedVersions.add(version2);
|
||||||
|
expectedVersions.add(version1);
|
||||||
|
expectedVersions.add(version0);
|
||||||
|
versionHistory = this.versionService.getVersionHistory(versionableNode);
|
||||||
|
assertEquals(4, versionHistory.getAllVersions().size());
|
||||||
|
CheckVersionHistory(versionHistory, expectedVersions);
|
||||||
|
|
||||||
|
// Check current version
|
||||||
|
currentVersion = this.versionService.getCurrentVersion(versionableNode);
|
||||||
|
assertEquals(currentVersion.getVersionLabel(), version3.getVersionLabel());
|
||||||
|
assertEquals(currentVersion.getFrozenStateNodeRef(), version3.getFrozenStateNodeRef());
|
||||||
|
|
||||||
|
// Delete version 2
|
||||||
|
this.versionService.deleteVersion(versionableNode, version2);
|
||||||
|
|
||||||
|
// Delete version 0
|
||||||
|
this.versionService.deleteVersion(versionableNode, version0);
|
||||||
|
|
||||||
|
// Check the version history
|
||||||
|
expectedVersions = new ArrayList<Version>(2);
|
||||||
|
expectedVersions.add(version3);
|
||||||
|
expectedVersions.add(version1);
|
||||||
|
versionHistory = this.versionService.getVersionHistory(versionableNode);
|
||||||
|
assertEquals(2, versionHistory.getAllVersions().size());
|
||||||
|
CheckVersionHistory(versionHistory, expectedVersions);
|
||||||
|
|
||||||
|
// Check current version is unchanged
|
||||||
|
currentVersion = this.versionService.getCurrentVersion(versionableNode);
|
||||||
|
assertEquals(currentVersion.getVersionLabel(), version3.getVersionLabel());
|
||||||
|
assertEquals(currentVersion.getFrozenStateNodeRef(), version3.getFrozenStateNodeRef());
|
||||||
|
|
||||||
|
// Delete version 3
|
||||||
|
this.versionService.deleteVersion(versionableNode, version3);
|
||||||
|
|
||||||
|
// Check the version history size
|
||||||
|
expectedVersions = new ArrayList<Version>(1);
|
||||||
|
expectedVersions.add(version1);
|
||||||
|
versionHistory = this.versionService.getVersionHistory(versionableNode);
|
||||||
|
assertEquals(1, versionHistory.getAllVersions().size());
|
||||||
|
CheckVersionHistory(versionHistory, expectedVersions);
|
||||||
|
|
||||||
|
// Check current version has changed to version 1
|
||||||
|
currentVersion = this.versionService.getCurrentVersion(versionableNode);
|
||||||
|
assertEquals(currentVersion.getVersionLabel(), version1.getVersionLabel());
|
||||||
|
assertEquals(currentVersion.getFrozenStateNodeRef(), version1.getFrozenStateNodeRef());
|
||||||
|
|
||||||
|
// Create version 4
|
||||||
|
Version version4 = createVersion(versionableNode);
|
||||||
|
|
||||||
|
// Check the version history size
|
||||||
|
expectedVersions = new ArrayList<Version>(2);
|
||||||
|
expectedVersions.add(version4);
|
||||||
|
expectedVersions.add(version1);
|
||||||
|
versionHistory = this.versionService.getVersionHistory(versionableNode);
|
||||||
|
assertEquals(2, versionHistory.getAllVersions().size());
|
||||||
|
CheckVersionHistory(versionHistory, expectedVersions);
|
||||||
|
|
||||||
|
// Check current version has changed to version 4
|
||||||
|
currentVersion = this.versionService.getCurrentVersion(versionableNode);
|
||||||
|
assertEquals(currentVersion.getVersionLabel(), version4.getVersionLabel());
|
||||||
|
assertEquals(currentVersion.getFrozenStateNodeRef(), version4.getFrozenStateNodeRef());
|
||||||
|
|
||||||
|
// Delete version 1
|
||||||
|
this.versionService.deleteVersion(versionableNode, version1);
|
||||||
|
|
||||||
|
// Delete version 4
|
||||||
|
this.versionService.deleteVersion(versionableNode, version4);
|
||||||
|
|
||||||
|
// Check the version history is empty
|
||||||
|
versionHistory = this.versionService.getVersionHistory(versionableNode);
|
||||||
|
CheckVersionHistory(versionHistory, null);
|
||||||
|
|
||||||
|
// Check that the current version property on the versionable node is no longer set
|
||||||
|
versionLabel = (String)this.dbNodeService.getProperty(versionableNode, ContentModel.PROP_VERSION_LABEL);
|
||||||
|
assertNull(versionLabel);
|
||||||
|
|
||||||
|
// Check that there is no current version
|
||||||
|
version = this.versionService.getCurrentVersion(versionableNode);
|
||||||
|
assertNull(version);
|
||||||
|
}
|
||||||
|
|
||||||
public void testAutoVersionOnInitialVersionOn()
|
public void testAutoVersionOnInitialVersionOn()
|
||||||
{
|
{
|
||||||
// Create a versionable node
|
// Create a versionable node
|
||||||
|
@@ -1,285 +1,300 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2005-2007 Alfresco Software Limited.
|
* Copyright (C) 2005-2008 Alfresco Software Limited.
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or
|
* This program is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU General Public License
|
* modify it under the terms of the GNU General Public License
|
||||||
* as published by the Free Software Foundation; either version 2
|
* as published by the Free Software Foundation; either version 2
|
||||||
* of the License, or (at your option) any later version.
|
* of the License, or (at your option) any later version.
|
||||||
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
|
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program; if not, write to the Free Software
|
* along with this program; if not, write to the Free Software
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
* As a special exception to the terms and conditions of version 2.0 of
|
* As a special exception to the terms and conditions of version 2.0 of
|
||||||
* the GPL, you may redistribute this Program in connection with Free/Libre
|
* the GPL, you may redistribute this Program in connection with Free/Libre
|
||||||
* and Open Source Software ("FLOSS") applications as described in Alfresco's
|
* and Open Source Software ("FLOSS") applications as described in Alfresco's
|
||||||
* FLOSS exception. You should have recieved a copy of the text describing
|
* FLOSS exception. You should have recieved a copy of the text describing
|
||||||
* the FLOSS exception, and it is also available here:
|
* the FLOSS exception, and it is also available here:
|
||||||
* http://www.alfresco.com/legal/licensing"
|
* http://www.alfresco.com/legal/licensing"
|
||||||
*/
|
*/
|
||||||
package org.alfresco.service.cmr.version;
|
package org.alfresco.service.cmr.version;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.alfresco.service.Auditable;
|
import org.alfresco.service.Auditable;
|
||||||
import org.alfresco.service.PublicService;
|
import org.alfresco.service.PublicService;
|
||||||
import org.alfresco.service.cmr.repository.AspectMissingException;
|
import org.alfresco.service.cmr.repository.AspectMissingException;
|
||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
import org.alfresco.service.cmr.repository.StoreRef;
|
import org.alfresco.service.cmr.repository.StoreRef;
|
||||||
import org.alfresco.service.namespace.QName;
|
import org.alfresco.service.namespace.QName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Interface for public and internal version operations.
|
* Interface for public and internal version operations.
|
||||||
*
|
*
|
||||||
* @author Roy Wetherall
|
* @author Roy Wetherall, janv
|
||||||
*/
|
*/
|
||||||
@PublicService
|
@PublicService
|
||||||
public interface VersionService
|
public interface VersionService
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* The version store protocol label, used in store references
|
* The version store protocol label, used in store references
|
||||||
*/
|
*/
|
||||||
public static final String VERSION_STORE_PROTOCOL = "versionStore";
|
public static final String VERSION_STORE_PROTOCOL = "versionStore";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the reference to the version store
|
* Gets the reference to the version store
|
||||||
*
|
*
|
||||||
* @return reference to the version store
|
* @return reference to the version store
|
||||||
*/
|
*/
|
||||||
@Auditable
|
@Auditable
|
||||||
public StoreRef getVersionStoreReference();
|
public StoreRef getVersionStoreReference();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new version based on the referenced node.
|
* Creates a new version based on the referenced node.
|
||||||
* <p>
|
* <p>
|
||||||
* If the node has not previously been versioned then a version history and
|
* If the node has not previously been versioned then a version history and
|
||||||
* initial version will be created.
|
* initial version will be created.
|
||||||
* <p>
|
* <p>
|
||||||
* If the node referenced does not or can not have the version aspect
|
* If the node referenced does not or can not have the version aspect
|
||||||
* applied to it then an exception will be raised.
|
* applied to it then an exception will be raised.
|
||||||
* <p>
|
* <p>
|
||||||
* The version properties are stored as version meta-data against the newly
|
* The version properties are stored as version meta-data against the newly
|
||||||
* created version.
|
* created version.
|
||||||
*
|
*
|
||||||
* @param nodeRef a node reference
|
* @param nodeRef a node reference
|
||||||
* @param versionProperties the version properties that are stored with the newly created
|
* @param versionProperties the version properties that are stored with the newly created
|
||||||
* version
|
* version
|
||||||
* @return the created version object
|
* @return the created version object
|
||||||
* @throws ReservedVersionNameException
|
* @throws ReservedVersionNameException
|
||||||
* thrown if a reserved property name is used int he version properties
|
* thrown if a reserved property name is used int he version properties
|
||||||
* provided
|
* provided
|
||||||
* @throws AspectMissingException
|
* @throws AspectMissingException
|
||||||
* thrown if the version aspect is missing
|
* thrown if the version aspect is missing
|
||||||
*/
|
*/
|
||||||
@Auditable(key = Auditable.Key.ARG_0, parameters = {"nodeRef", "versionProperties"})
|
@Auditable(key = Auditable.Key.ARG_0, parameters = {"nodeRef", "versionProperties"})
|
||||||
public Version createVersion(
|
public Version createVersion(
|
||||||
NodeRef nodeRef,
|
NodeRef nodeRef,
|
||||||
Map<String, Serializable> versionProperties)
|
Map<String, Serializable> versionProperties)
|
||||||
throws ReservedVersionNameException, AspectMissingException;
|
throws ReservedVersionNameException, AspectMissingException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new version based on the referenced node.
|
* Creates a new version based on the referenced node.
|
||||||
* <p>
|
* <p>
|
||||||
* If the node has not previously been versioned then a version history and
|
* If the node has not previously been versioned then a version history and
|
||||||
* initial version will be created.
|
* initial version will be created.
|
||||||
* <p>
|
* <p>
|
||||||
* If the node referenced does not or can not have the version aspect
|
* If the node referenced does not or can not have the version aspect
|
||||||
* applied to it then an exception will be raised.
|
* applied to it then an exception will be raised.
|
||||||
* <p>
|
* <p>
|
||||||
* The version properties are stored as version meta-data against the newly
|
* The version properties are stored as version meta-data against the newly
|
||||||
* created version.
|
* created version.
|
||||||
*
|
*
|
||||||
* @param nodeRef a node reference
|
* @param nodeRef a node reference
|
||||||
* @param versionProperties the version properties that are stored with the newly created
|
* @param versionProperties the version properties that are stored with the newly created
|
||||||
* version
|
* version
|
||||||
* @param versionChildren if true then the children of the referenced node are also
|
* @param versionChildren if true then the children of the referenced node are also
|
||||||
* versioned, false otherwise
|
* versioned, false otherwise
|
||||||
* @return the created version object(s)
|
* @return the created version object(s)
|
||||||
* @throws ReservedVersionNameException
|
* @throws ReservedVersionNameException
|
||||||
* thrown if a reserved property name is used int he version properties
|
* thrown if a reserved property name is used int he version properties
|
||||||
* provided
|
* provided
|
||||||
* @throws AspectMissingException
|
* @throws AspectMissingException
|
||||||
* thrown if the version aspect is missing
|
* thrown if the version aspect is missing
|
||||||
*/
|
*/
|
||||||
@Auditable(key = Auditable.Key.ARG_0, parameters = {"nodeRef", "versionProperties", "versionChildren"})
|
@Auditable(key = Auditable.Key.ARG_0, parameters = {"nodeRef", "versionProperties", "versionChildren"})
|
||||||
public Collection<Version> createVersion(
|
public Collection<Version> createVersion(
|
||||||
NodeRef nodeRef,
|
NodeRef nodeRef,
|
||||||
Map<String, Serializable> versionProperties,
|
Map<String, Serializable> versionProperties,
|
||||||
boolean versionChildren)
|
boolean versionChildren)
|
||||||
throws ReservedVersionNameException, AspectMissingException;
|
throws ReservedVersionNameException, AspectMissingException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates new versions based on the list of node references provided.
|
* Creates new versions based on the list of node references provided.
|
||||||
*
|
*
|
||||||
* @param nodeRefs a list of node references
|
* @param nodeRefs a list of node references
|
||||||
* @param versionProperties version property values
|
* @param versionProperties version property values
|
||||||
* @return a collection of newly created versions
|
* @return a collection of newly created versions
|
||||||
* @throws ReservedVersionNameException
|
* @throws ReservedVersionNameException
|
||||||
* thrown if a reserved property name is used int he version properties
|
* thrown if a reserved property name is used int he version properties
|
||||||
* provided
|
* provided
|
||||||
* @throws AspectMissingException
|
* @throws AspectMissingException
|
||||||
* thrown if the version aspect is missing
|
* thrown if the version aspect is missing
|
||||||
*/
|
*/
|
||||||
@Auditable(key = Auditable.Key.ARG_0, parameters = {"nodeRef", "versionProperties"})
|
@Auditable(key = Auditable.Key.ARG_0, parameters = {"nodeRef", "versionProperties"})
|
||||||
public Collection<Version> createVersion(
|
public Collection<Version> createVersion(
|
||||||
Collection<NodeRef> nodeRefs,
|
Collection<NodeRef> nodeRefs,
|
||||||
Map<String, Serializable> versionProperties)
|
Map<String, Serializable> versionProperties)
|
||||||
throws ReservedVersionNameException, AspectMissingException;
|
throws ReservedVersionNameException, AspectMissingException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the version history information for a node.
|
* Gets the version history information for a node.
|
||||||
* <p>
|
* <p>
|
||||||
* If the node has not been versioned then null is returned.
|
* If the node has not been versioned then null is returned.
|
||||||
* <p>
|
* <p>
|
||||||
* If the node referenced does not or can not have the version aspect
|
* If the node referenced does not or can not have the version aspect
|
||||||
* applied to it then an exception will be raised.
|
* applied to it then an exception will be raised.
|
||||||
*
|
*
|
||||||
* @param nodeRef a node reference
|
* @param nodeRef a node reference
|
||||||
* @return the version history information
|
* @return the version history information
|
||||||
* @throws AspectMissingException
|
* @throws AspectMissingException
|
||||||
* thrown if the version aspect is missing
|
* thrown if the version aspect is missing
|
||||||
*/
|
*/
|
||||||
@Auditable(key = Auditable.Key.ARG_0, parameters = {"nodeRef"})
|
@Auditable(key = Auditable.Key.ARG_0, parameters = {"nodeRef"})
|
||||||
public VersionHistory getVersionHistory(NodeRef nodeRef)
|
public VersionHistory getVersionHistory(NodeRef nodeRef)
|
||||||
throws AspectMissingException;
|
throws AspectMissingException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the version object for the current version of the node reference
|
* Gets the version object for the current version of the node reference
|
||||||
* passed.
|
* passed.
|
||||||
* <p>
|
* <p>
|
||||||
* Returns null if the node is not versionable or has not been versioned.
|
* Returns null if the node is not versionable or has not been versioned.
|
||||||
* @param nodeRef the node reference
|
* @param nodeRef the node reference
|
||||||
* @return the version object for the current version
|
* @return the version object for the current version
|
||||||
*/
|
*/
|
||||||
@Auditable(key = Auditable.Key.ARG_0, parameters = {"nodeRef"})
|
@Auditable(key = Auditable.Key.ARG_0, parameters = {"nodeRef"})
|
||||||
public Version getCurrentVersion(NodeRef nodeRef);
|
public Version getCurrentVersion(NodeRef nodeRef);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The node reference will be reverted to the current version.
|
* The node reference will be reverted to the current version.
|
||||||
* <p>
|
* <p>
|
||||||
* A deep revert will be performed.
|
* A deep revert will be performed.
|
||||||
*
|
*
|
||||||
* @see VersionService#revert(NodeRef, Version, boolean)
|
* @see VersionService#revert(NodeRef, Version, boolean)
|
||||||
*
|
*
|
||||||
* @param nodeRef the node reference
|
* @param nodeRef the node reference
|
||||||
*/
|
*/
|
||||||
@Auditable(key = Auditable.Key.ARG_0, parameters = {"nodeRef"})
|
@Auditable(key = Auditable.Key.ARG_0, parameters = {"nodeRef"})
|
||||||
public void revert(NodeRef nodeRef);
|
public void revert(NodeRef nodeRef);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The node reference will be reverted to the current version.
|
* The node reference will be reverted to the current version.
|
||||||
*
|
*
|
||||||
* @see VersionService#revert(NodeRef, Version, boolean)
|
* @see VersionService#revert(NodeRef, Version, boolean)
|
||||||
*
|
*
|
||||||
* @param nodeRef the node reference
|
* @param nodeRef the node reference
|
||||||
* @param deep true if a deep revert is to be performed, flase otherwise
|
* @param deep true if a deep revert is to be performed, flase otherwise
|
||||||
*/
|
*/
|
||||||
@Auditable(key = Auditable.Key.ARG_0, parameters = {"nodeRef", "deep"})
|
@Auditable(key = Auditable.Key.ARG_0, parameters = {"nodeRef", "deep"})
|
||||||
public void revert(NodeRef nodeRef, boolean deep);
|
public void revert(NodeRef nodeRef, boolean deep);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A deep revert will take place by default.
|
* A deep revert will take place by default.
|
||||||
*
|
*
|
||||||
* @see VersionService#revert(NodeRef, Version, boolean)
|
* @see VersionService#revert(NodeRef, Version, boolean)
|
||||||
*
|
*
|
||||||
* @param nodeRef the node reference
|
* @param nodeRef the node reference
|
||||||
* @param version the version to revert to
|
* @param version the version to revert to
|
||||||
*/
|
*/
|
||||||
@Auditable(key = Auditable.Key.ARG_0, parameters = {"nodeRef", "version"})
|
@Auditable(key = Auditable.Key.ARG_0, parameters = {"nodeRef", "version"})
|
||||||
public void revert(NodeRef nodeRef, Version version);
|
public void revert(NodeRef nodeRef, Version version);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Revert the state of the node to the specified version.
|
* Revert the state of the node to the specified version.
|
||||||
* <p>
|
* <p>
|
||||||
* Any changes made to the node will be lost and the state of the node will reflect
|
* Any changes made to the node will be lost and the state of the node will reflect
|
||||||
* that of the version specified.
|
* that of the version specified.
|
||||||
* <p>
|
* <p>
|
||||||
* The version label property on the node reference will remain unchanged.
|
* The version label property on the node reference will remain unchanged.
|
||||||
* <p>
|
* <p>
|
||||||
* If the node is further versioned then the new version will be created at the head of
|
* If the node is further versioned then the new version will be created at the head of
|
||||||
* the version history graph. A branch will not be created.
|
* the version history graph. A branch will not be created.
|
||||||
* <p>
|
* <p>
|
||||||
* If a deep revert is to be performed then any child nodes that are no longer present will
|
* If a deep revert is to be performed then any child nodes that are no longer present will
|
||||||
* be deep restored (if appropriate) otherwise child associations to deleted, versioned nodes
|
* be deep restored (if appropriate) otherwise child associations to deleted, versioned nodes
|
||||||
* will not be restored.
|
* will not be restored.
|
||||||
*
|
*
|
||||||
* @param nodeRef the node reference
|
* @param nodeRef the node reference
|
||||||
* @param version the version to revert to
|
* @param version the version to revert to
|
||||||
* @param deep true is a deep revert is to be performed, false otherwise.
|
* @param deep true is a deep revert is to be performed, false otherwise.
|
||||||
*/
|
*/
|
||||||
@Auditable(key = Auditable.Key.ARG_0, parameters = {"nodeRef", "version", "deep"})
|
@Auditable(key = Auditable.Key.ARG_0, parameters = {"nodeRef", "version", "deep"})
|
||||||
public void revert(NodeRef nodeRef, Version version, boolean deep);
|
public void revert(NodeRef nodeRef, Version version, boolean deep);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* By default a deep restore is performed.
|
* By default a deep restore is performed.
|
||||||
*
|
*
|
||||||
* @see org.alfresco.service.cmr.version.VersionService#restore(NodeRef, NodeRef, QName, QName, boolean)
|
* @see org.alfresco.service.cmr.version.VersionService#restore(NodeRef, NodeRef, QName, QName, boolean)
|
||||||
*
|
*
|
||||||
* @param nodeRef the node reference to a node that no longer exists in the store
|
* @param nodeRef the node reference to a node that no longer exists in the store
|
||||||
* @param parentNodeRef the new parent of the restored node
|
* @param parentNodeRef the new parent of the restored node
|
||||||
* @param assocTypeQName the assoc type qname
|
* @param assocTypeQName the assoc type qname
|
||||||
* @param assocQName the assoc qname
|
* @param assocQName the assoc qname
|
||||||
* @return the newly restored node reference
|
* @return the newly restored node reference
|
||||||
*/
|
*/
|
||||||
@Auditable(key = Auditable.Key.ARG_0, parameters = {"nodeRef", "parentNodeRef", "assocTypeQName", "assocQName"})
|
@Auditable(key = Auditable.Key.ARG_0, parameters = {"nodeRef", "parentNodeRef", "assocTypeQName", "assocQName"})
|
||||||
public NodeRef restore(
|
public NodeRef restore(
|
||||||
NodeRef nodeRef,
|
NodeRef nodeRef,
|
||||||
NodeRef parentNodeRef,
|
NodeRef parentNodeRef,
|
||||||
QName assocTypeQName,
|
QName assocTypeQName,
|
||||||
QName assocQName);
|
QName assocQName);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Restores a node not currently present in the store, but that has a version
|
* Restores a node not currently present in the store, but that has a version
|
||||||
* history.
|
* history.
|
||||||
* <p>
|
* <p>
|
||||||
* The restored node will be at the head (most resent version).
|
* The restored node will be at the head (most resent version).
|
||||||
* <p>
|
* <p>
|
||||||
* Restoration will fail if there is no version history for the specified node id in
|
* Restoration will fail if there is no version history for the specified node id in
|
||||||
* the specified store.
|
* the specified store.
|
||||||
* <p>
|
* <p>
|
||||||
* If the node already exists in the store then an exception will be raised.
|
* If the node already exists in the store then an exception will be raised.
|
||||||
* <p>
|
* <p>
|
||||||
* Once the node is restored it is reverted to the head version in the appropriate
|
* Once the node is restored it is reverted to the head version in the appropriate
|
||||||
* version history tree. If deep is set to true then this will be a deep revert, false
|
* version history tree. If deep is set to true then this will be a deep revert, false
|
||||||
* otherwise.
|
* otherwise.
|
||||||
*
|
*
|
||||||
* @param nodeRef the node reference to a node that no longer exists in
|
* @param nodeRef the node reference to a node that no longer exists in
|
||||||
* the store
|
* the store
|
||||||
* @param parentNodeRef the new parent of the restored node
|
* @param parentNodeRef the new parent of the restored node
|
||||||
* @param assocTypeQName the assoc type qname
|
* @param assocTypeQName the assoc type qname
|
||||||
* @param assocQName the assoc qname
|
* @param assocQName the assoc qname
|
||||||
* @param deep true is a deep revert should be performed once the node has been
|
* @param deep true is a deep revert should be performed once the node has been
|
||||||
* restored, false otherwise
|
* restored, false otherwise
|
||||||
* @return the newly restored node reference
|
* @return the newly restored node reference
|
||||||
*/
|
*/
|
||||||
@Auditable(key = Auditable.Key.ARG_0, parameters = {"nodeRef", "parentNodeRef", "assocTypeQName", "assocQName", "deep"})
|
@Auditable(key = Auditable.Key.ARG_0, parameters = {"nodeRef", "parentNodeRef", "assocTypeQName", "assocQName", "deep"})
|
||||||
public NodeRef restore(
|
public NodeRef restore(
|
||||||
NodeRef nodeRef,
|
NodeRef nodeRef,
|
||||||
NodeRef parentNodeRef,
|
NodeRef parentNodeRef,
|
||||||
QName assocTypeQName,
|
QName assocTypeQName,
|
||||||
QName assocQName,
|
QName assocQName,
|
||||||
boolean deep);
|
boolean deep);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete the version history associated with a node reference.
|
* Delete the version history associated with a node reference.
|
||||||
* <p>
|
* <p>
|
||||||
* This operation is permanent, all versions in the version history are
|
* This operation is permanent, all versions in the version history are
|
||||||
* deleted and cannot be retrieved.
|
* deleted and cannot be retrieved.
|
||||||
* <p>
|
* <p>
|
||||||
* The current version label for the node reference is reset and any subsequent versions
|
* The current version label for the node reference is reset and any subsequent versions
|
||||||
* of the node will result in a new version history being created.
|
* of the node will result in a new version history being created.
|
||||||
*
|
*
|
||||||
* @param nodeRef the node reference
|
* @param nodeRef the node reference
|
||||||
* @throws AspectMissingException thrown if the version aspect is missing
|
* @throws AspectMissingException thrown if the version aspect is missing
|
||||||
*/
|
*/
|
||||||
@Auditable(key = Auditable.Key.ARG_0, parameters = {"nodeRef"})
|
@Auditable(key = Auditable.Key.ARG_0, parameters = {"nodeRef"})
|
||||||
public void deleteVersionHistory(NodeRef nodeRef)
|
public void deleteVersionHistory(NodeRef nodeRef)
|
||||||
throws AspectMissingException;
|
throws AspectMissingException;
|
||||||
}
|
|
||||||
|
/**
|
||||||
|
* Delete a specific version associated with a node reference.
|
||||||
|
* <p>
|
||||||
|
* This operation is permanent, the specific version in the version history is
|
||||||
|
* deleted and cannot be retrieved.
|
||||||
|
* <p>
|
||||||
|
* If this is the last version, then the current version label for the node reference is
|
||||||
|
* reset and any subsequent versions of the node will result in a new version history being created.
|
||||||
|
*
|
||||||
|
* @param nodeRef the node reference
|
||||||
|
* @param version the version to delete
|
||||||
|
*/
|
||||||
|
@Auditable(key = Auditable.Key.ARG_0, parameters = {"nodeRef", "version"})
|
||||||
|
public void deleteVersion(NodeRef nodeRef, Version version);
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user