public abstract class VersionServiceImpl extends AbstractVersionServiceImpl implements VersionService, VersionModel
Modifier and Type | Field and Description |
---|---|
protected org.alfresco.service.cmr.repository.NodeService |
dbNodeService
The db node service, used as the version store implementation
|
protected static String |
MSGID_ERR_NO_BRANCHES |
protected static String |
MSGID_ERR_NOT_FOUND
Error message I18N id's
|
protected static String |
MSGID_ERR_ONE_PRECEEDING |
protected static String |
MSGID_ERR_RESTORE_EXISTS |
protected static String |
MSGID_ERR_RESTORE_NO_VERSION |
protected static String |
MSGID_ERR_REVERT_MISMATCH |
protected BehaviourFilter |
policyBehaviourFilter
Policy behaviour filter
|
protected org.alfresco.service.cmr.search.SearchService |
searcher
The repository searcher
|
protected Comparator<Version> |
versionComparatorDesc |
dictionaryService, nodeService, policyComponent
VERSION_STORE_PROTOCOL
ASPECT_VERSION_STORE_ROOT, ASSOC_ROOT_VERSION, ASSOC_SUCCESSOR, CHILD_QNAME_VERSION_HISTORIES, CHILD_QNAME_VERSION_META_DATA, CHILD_QNAME_VERSIONED_ASSOCS, CHILD_QNAME_VERSIONED_ATTRIBUTES, CHILD_QNAME_VERSIONED_CHILD_ASSOCS, CHILD_QNAME_VERSIONS, CHILD_VERSION_META_DATA, CHILD_VERSIONED_ATTRIBUTES, CHILD_VERSIONED_CHILD_ASSOCS, NAMESPACE_URI, PROP_ASSOC_QNAME, PROP_ASSOC_TYPE_QNAME, PROP_FROZEN_ASPECTS, PROP_FROZEN_NODE_ID, PROP_FROZEN_NODE_STORE_ID, PROP_FROZEN_NODE_STORE_PROTOCOL, PROP_FROZEN_NODE_TYPE, PROP_IS_MULTI_VALUE, PROP_IS_PRIMARY, PROP_META_DATA_NAME, PROP_META_DATA_VALUE, PROP_MULTI_VALUE, PROP_NTH_SIBLING, PROP_QNAME, PROP_QNAME_ASSOC_QNAME, PROP_QNAME_ASSOC_TYPE_QNAME, PROP_QNAME_FROZEN_ASPECTS, PROP_QNAME_FROZEN_NODE_ID, PROP_QNAME_FROZEN_NODE_STORE_ID, PROP_QNAME_FROZEN_NODE_STORE_PROTOCOL, PROP_QNAME_FROZEN_NODE_TYPE, PROP_QNAME_IS_MULTI_VALUE, PROP_QNAME_IS_PRIMARY, PROP_QNAME_META_DATA_NAME, PROP_QNAME_META_DATA_VALUE, PROP_QNAME_MULTI_VALUE, PROP_QNAME_NTH_SIBLING, PROP_QNAME_QNAME, PROP_QNAME_TRANSLATION_VERSIONS, PROP_QNAME_VALUE, PROP_QNAME_VERSION_LABEL, PROP_QNAME_VERSION_NUMBER, PROP_QNAME_VERSIONED_NODE_ID, PROP_VALUE, STORE_ID, TYPE_QNAME_VERSION, TYPE_QNAME_VERSION_HISTORY, TYPE_QNAME_VERSION_META_DATA_VALUE, TYPE_QNAME_VERSIONED_ASSOC, TYPE_QNAME_VERSIONED_CHILD_ASSOC, TYPE_QNAME_VERSIONED_PROPERTY, TYPE_VERSION, TYPE_VERSION_META_DATA_VALUE, TYPE_VERSIONED_CHILD_ASSOC, TYPE_VERSIONED_PROPERTY
ASPECT_LOCALNAME_VERSION_STORE_ROOT, ASSOC_LOCALNAME_ROOT_VERSION, CHILD_VERSION_HISTORIES, CHILD_VERSIONED_ASSOCS, CHILD_VERSIONS, PROP_CREATED_DATE, PROP_CREATOR, PROP_DESCRIPTION, PROP_TRANSLATION_VERSIONS, PROP_VERSION_DESCRIPTION, PROP_VERSION_LABEL, PROP_VERSION_NUMBER, PROP_VERSION_TYPE, PROP_VERSIONED_NODE_ID, STORE_PROTOCOL, TYPE_VERSION_HISTORY, TYPE_VERSIONED_ASSOC
Constructor and Description |
---|
VersionServiceImpl() |
Modifier and Type | Method and Description |
---|---|
protected VersionHistory |
buildVersionHistory(org.alfresco.service.cmr.repository.NodeRef versionHistoryRef,
org.alfresco.service.cmr.repository.NodeRef nodeRef)
Builds a version history object from the version history reference.
|
Collection<Version> |
createVersion(Collection<org.alfresco.service.cmr.repository.NodeRef> nodeRefs,
Map<String,Serializable> versionProperties)
Note: we can't control the order of the list, so if we have children and parents in the list and the
parents get versioned before the children and the children are not already versioned then the parents
child references will be pointing to the node ref, rather than the verison history.
|
Version |
createVersion(org.alfresco.service.cmr.repository.NodeRef nodeRef,
Map<String,Serializable> versionProperties)
Creates a new version based on the referenced node.
|
Collection<Version> |
createVersion(org.alfresco.service.cmr.repository.NodeRef nodeRef,
Map<String,Serializable> versionProperties,
boolean versionChildren)
The version's are created from the children upwards with the parent being created first.
|
protected Version |
createVersion(org.alfresco.service.cmr.repository.NodeRef nodeRef,
Map<String,Serializable> origVersionProperties,
int versionNumber)
Creates a new version of the passed node assigning the version properties
accordingly.
|
protected void |
defaultOnCreateVersion(org.alfresco.service.namespace.QName classRef,
org.alfresco.service.cmr.repository.NodeRef nodeRef,
Map<String,Serializable> versionProperties,
PolicyScope nodeDetails)
Default implementation of the on create version policy.
|
void |
deleteVersion(org.alfresco.service.cmr.repository.NodeRef nodeRef,
Version version)
Delete a specific version associated with a node reference.
|
void |
deleteVersionHistory(org.alfresco.service.cmr.repository.NodeRef nodeRef)
Delete the version history associated with a node reference.
|
void |
ensureVersioningEnabled(org.alfresco.service.cmr.repository.NodeRef nodeRef,
Map<org.alfresco.service.namespace.QName,Serializable> versionProperties)
Ensures that a node has the versionable aspect applied to it, and has
at least an initial entry in the version store.
|
Version |
getCurrentVersion(org.alfresco.service.cmr.repository.NodeRef nodeRef)
Gets the version object for the current version of the node reference passed.
|
protected org.alfresco.service.cmr.repository.NodeRef |
getRootNode()
Gets the version stores root node
|
protected Version |
getVersion(org.alfresco.service.cmr.repository.NodeRef versionRef)
Constructs the a version object to contain the version information from the version node ref.
|
VersionHistory |
getVersionHistory(org.alfresco.service.cmr.repository.NodeRef nodeRef)
Gets the version history information for a node.
|
protected org.alfresco.service.cmr.repository.NodeRef |
getVersionHistoryNodeRef(org.alfresco.service.cmr.repository.NodeRef nodeRef)
Gets a reference to the version history node for a given 'real' node.
|
protected Map<String,Serializable> |
getVersionMetaData(org.alfresco.service.cmr.repository.NodeRef versionNodeRef) |
org.alfresco.service.cmr.repository.StoreRef |
getVersionStoreReference()
Gets the reference to the version store
|
void |
initialise()
Initialise method
|
boolean |
isAVersion(org.alfresco.service.cmr.repository.NodeRef nodeRef)
Is the nodeRef a version node?
|
boolean |
isVersioned(org.alfresco.service.cmr.repository.NodeRef nodeRef)
Is the nodeRef versioned?
|
void |
registerVersionLabelPolicy(org.alfresco.service.namespace.QName typeQName,
VersionServicePolicies.CalculateVersionLabelPolicy policy)
Register version label policy for the specified type
|
org.alfresco.service.cmr.repository.NodeRef |
restore(org.alfresco.service.cmr.repository.NodeRef nodeRef,
org.alfresco.service.cmr.repository.NodeRef parentNodeRef,
org.alfresco.service.namespace.QName assocTypeQName,
org.alfresco.service.namespace.QName assocQName)
By default a deep restore is performed.
|
org.alfresco.service.cmr.repository.NodeRef |
restore(org.alfresco.service.cmr.repository.NodeRef nodeRef,
org.alfresco.service.cmr.repository.NodeRef parentNodeRef,
org.alfresco.service.namespace.QName assocTypeQName,
org.alfresco.service.namespace.QName assocQName,
boolean deep)
Restores a node not currently present in the store, but that has a version
history.
|
void |
revert(org.alfresco.service.cmr.repository.NodeRef nodeRef)
Revert the state of the node to the current version.
|
void |
revert(org.alfresco.service.cmr.repository.NodeRef nodeRef,
boolean deep)
Revert the state of the node to the current version.
|
void |
revert(org.alfresco.service.cmr.repository.NodeRef nodeRef,
Version version)
Revert the state of the node to the specified version.
|
void |
revert(org.alfresco.service.cmr.repository.NodeRef nodeRef,
Version version,
boolean deep)
Revert the state of the node to the specified version.
|
void |
setDbNodeService(org.alfresco.service.cmr.repository.NodeService nodeService)
Sets the db node service, used as the version store implementation
|
void |
setPolicyBehaviourFilter(BehaviourFilter policyBehaviourFilter)
Set the policy behaviour filter
|
void |
setSearcher(org.alfresco.service.cmr.search.SearchService searcher) |
void |
setVersionComparatorClass(String versionComparatorClass)
Sets an optional comparator to sort a versions in descending order (eg.
|
getRevertAspectAction, getRevertAssocAction, invokeAfterCreateVersion, invokeAfterVersionRevert, invokeBeforeCreateVersion, invokeCalculateVersionLabel, invokeOnCreateVersion, setDictionaryService, setNodeService, setPolicyComponent
protected static final String MSGID_ERR_NOT_FOUND
protected static final String MSGID_ERR_NO_BRANCHES
protected static final String MSGID_ERR_RESTORE_EXISTS
protected static final String MSGID_ERR_ONE_PRECEEDING
protected static final String MSGID_ERR_RESTORE_NO_VERSION
protected static final String MSGID_ERR_REVERT_MISMATCH
protected org.alfresco.service.cmr.repository.NodeService dbNodeService
protected BehaviourFilter policyBehaviourFilter
protected org.alfresco.service.cmr.search.SearchService searcher
protected Comparator<Version> versionComparatorDesc
public void setDbNodeService(org.alfresco.service.cmr.repository.NodeService nodeService)
nodeService
- the node servicepublic void setSearcher(org.alfresco.service.cmr.search.SearchService searcher)
searcher
- the searcherpublic void setPolicyBehaviourFilter(BehaviourFilter policyBehaviourFilter)
policyBehaviourFilter
- the policy behaviour filterpublic void setVersionComparatorClass(String versionComparatorClass)
versionComparatorClass
- the name of a comparator. For example
"org.alfresco.repo.version.common.VersionLabelComparator".public void registerVersionLabelPolicy(org.alfresco.service.namespace.QName typeQName, VersionServicePolicies.CalculateVersionLabelPolicy policy)
registerVersionLabelPolicy
in interface VersionService
typeQName
- QNamepolicy
- CalculateVersionLabelPolicypublic void initialise()
initialise
in class AbstractVersionServiceImpl
public org.alfresco.service.cmr.repository.StoreRef getVersionStoreReference()
getVersionStoreReference
in interface VersionService
getVersionStoreReference
in class AbstractVersionServiceImpl
public Version createVersion(org.alfresco.service.cmr.repository.NodeRef nodeRef, Map<String,Serializable> versionProperties) throws ReservedVersionNameException, AspectMissingException
VersionService
If the node has not previously been versioned then a version history and initial version will be created.
If the node referenced does not or can not have the version aspect applied to it then an exception will be raised.
The version properties are stored as version meta-data against the newly created version.
createVersion
in interface VersionService
nodeRef
- a node referenceversionProperties
- the version properties that are stored with the newly created
version, or null if there are no relevant propertiesReservedVersionNameException
- thrown if a reserved property name is used int he version properties
providedAspectMissingException
- thrown if the version aspect is missingVersionService.createVersion(NodeRef, Map)
public Collection<Version> createVersion(org.alfresco.service.cmr.repository.NodeRef nodeRef, Map<String,Serializable> versionProperties, boolean versionChildren) throws ReservedVersionNameException, AspectMissingException
createVersion
in interface VersionService
nodeRef
- a node referenceversionProperties
- the version properties that are stored with the newly created
versionversionChildren
- if true then the children of the referenced node are also
versioned, false otherwiseReservedVersionNameException
- thrown if a reserved property name is used int he version properties
providedAspectMissingException
- thrown if the version aspect is missingpublic Collection<Version> createVersion(Collection<org.alfresco.service.cmr.repository.NodeRef> nodeRefs, Map<String,Serializable> versionProperties) throws ReservedVersionNameException, AspectMissingException
createVersion
in interface VersionService
nodeRefs
- a list of node referencesversionProperties
- version property valuesReservedVersionNameException
- thrown if a reserved property name is used in the version properties
providedAspectMissingException
- thrown if the version aspect is missingprotected Version createVersion(org.alfresco.service.cmr.repository.NodeRef nodeRef, Map<String,Serializable> origVersionProperties, int versionNumber) throws ReservedVersionNameException
nodeRef
- a node referenceorigVersionProperties
- the version propertiesversionNumber
- the version numberReservedVersionNameException
- thrown if there is a name clash in the version propertiespublic VersionHistory getVersionHistory(org.alfresco.service.cmr.repository.NodeRef nodeRef)
VersionService
If the node has not been versioned then null is returned.
If the node referenced does not or can not have the version aspect applied to it then an exception will be raised.
getVersionHistory
in interface VersionService
nodeRef
- a node referenceVersionService.getVersionHistory(NodeRef)
public Version getCurrentVersion(org.alfresco.service.cmr.repository.NodeRef nodeRef)
VersionService
Returns null
if the node is not versionable or has not been versioned.
getCurrentVersion
in interface VersionService
nodeRef
- the node reference of the 'live' nodeVersionService.getCurrentVersion(NodeRef)
protected Map<String,Serializable> getVersionMetaData(org.alfresco.service.cmr.repository.NodeRef versionNodeRef)
protected org.alfresco.service.cmr.repository.NodeRef getRootNode()
protected VersionHistory buildVersionHistory(org.alfresco.service.cmr.repository.NodeRef versionHistoryRef, org.alfresco.service.cmr.repository.NodeRef nodeRef)
The node ref is passed to enable the version history to be scoped to the appropriate branch in the version history.
versionHistoryRef
- the node ref for the version historynodeRef
- the node referenceprotected Version getVersion(org.alfresco.service.cmr.repository.NodeRef versionRef)
versionRef
- the version referenceprotected org.alfresco.service.cmr.repository.NodeRef getVersionHistoryNodeRef(org.alfresco.service.cmr.repository.NodeRef nodeRef)
nodeRef
- a node referencepublic void ensureVersioningEnabled(org.alfresco.service.cmr.repository.NodeRef nodeRef, Map<org.alfresco.service.namespace.QName,Serializable> versionProperties)
VersionService
ensureVersioningEnabled
in interface VersionService
nodeRef
- the node referenceversionProperties
- the version properties to apply if versioning
isn't currently enabled for the nodeVersionService.ensureVersioningEnabled(NodeRef,Map)
public void revert(org.alfresco.service.cmr.repository.NodeRef nodeRef)
VersionService
The node reference will be reverted to the current version.
A deep revert will be performed.
revert
in interface VersionService
nodeRef
- the node referenceVersionService.revert(NodeRef)
public void revert(org.alfresco.service.cmr.repository.NodeRef nodeRef, boolean deep)
VersionService
The node will be reverted to the current version.
revert
in interface VersionService
nodeRef
- the node referencedeep
- true if a deep revert is to be performed, false otherwiseVersionService.revert(org.alfresco.service.cmr.repository.NodeRef, boolean)
public void revert(org.alfresco.service.cmr.repository.NodeRef nodeRef, Version version)
VersionService
A deep revert will take place by default.
revert
in interface VersionService
nodeRef
- the node referenceversion
- the version to revert toVersionService.revert(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.cmr.version.Version)
public void revert(org.alfresco.service.cmr.repository.NodeRef nodeRef, Version version, boolean deep)
VersionService
Any changes made to the node will be lost and the state of the node will reflect that of the version specified.
The version label property on the node reference will remain unchanged.
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.
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 will not be restored.
revert
in interface VersionService
nodeRef
- the node referenceversion
- the version to revert todeep
- true is a deep revert is to be performed, false otherwise.VersionService.revert(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.cmr.version.Version, boolean)
public org.alfresco.service.cmr.repository.NodeRef restore(org.alfresco.service.cmr.repository.NodeRef nodeRef, org.alfresco.service.cmr.repository.NodeRef parentNodeRef, org.alfresco.service.namespace.QName assocTypeQName, org.alfresco.service.namespace.QName assocQName)
VersionService
restore
in interface VersionService
nodeRef
- the node reference to a node that no longer exists in the storeparentNodeRef
- the new parent of the restored nodeassocTypeQName
- the assoc type qnameassocQName
- the assoc qnameVersionService.restore(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.namespace.QName, org.alfresco.service.namespace.QName)
public org.alfresco.service.cmr.repository.NodeRef restore(org.alfresco.service.cmr.repository.NodeRef nodeRef, org.alfresco.service.cmr.repository.NodeRef parentNodeRef, org.alfresco.service.namespace.QName assocTypeQName, org.alfresco.service.namespace.QName assocQName, boolean deep)
VersionService
The restored node will be at the head (most resent version).
Restoration will fail if there is no version history for the specified node id in the specified store.
If the node already exists in the store then an exception will be raised.
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 otherwise.
restore
in interface VersionService
nodeRef
- the node reference to a node that no longer exists in
the storeparentNodeRef
- the new parent of the restored nodeassocTypeQName
- the assoc type qnameassocQName
- the assoc qnamedeep
- true is a deep revert should be performed once the node has been
restored, false otherwiseVersionService.restore(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.namespace.QName, org.alfresco.service.namespace.QName, boolean)
public void deleteVersionHistory(org.alfresco.service.cmr.repository.NodeRef nodeRef) throws AspectMissingException
VersionService
This operation is permanent, all versions in the version history are deleted and cannot be retrieved.
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.
deleteVersionHistory
in interface VersionService
nodeRef
- the node referenceAspectMissingException
- thrown if the version aspect is missingVersionService.deleteVersionHistory(NodeRef)
public void deleteVersion(org.alfresco.service.cmr.repository.NodeRef nodeRef, Version version)
VersionService
This operation is permanent, the specific version in the version history is deleted and cannot be retrieved.
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.
deleteVersion
in interface VersionService
nodeRef
- the node referenceversion
- the version to deleteprotected void defaultOnCreateVersion(org.alfresco.service.namespace.QName classRef, org.alfresco.service.cmr.repository.NodeRef nodeRef, Map<String,Serializable> versionProperties, PolicyScope nodeDetails)
AbstractVersionServiceImpl
defaultOnCreateVersion
in class AbstractVersionServiceImpl
classRef
- QNamenodeRef
- NodeRefnodeDetails
- PolicyScopepublic boolean isAVersion(org.alfresco.service.cmr.repository.NodeRef nodeRef)
VersionService
isAVersion
in interface VersionService
public boolean isVersioned(org.alfresco.service.cmr.repository.NodeRef nodeRef)
VersionService
isVersioned
in interface VersionService
Copyright © 2005–2017 Alfresco Software. All rights reserved.