Class VersionServiceImpl
- All Implemented Interfaces:
VersionBaseModel,VersionModel,VersionService
- Direct Known Subclasses:
Version2ServiceImpl
- Author:
- Roy Wetheral NOTE: deprecated since 3.1 (migrate and use Version2 Service)
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected NodeServiceThe db node service, used as the version store implementationprotected static final Stringprotected static final StringError message I18N id'sprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected BehaviourFilterPolicy behaviour filterprotected SearchServiceThe repository searcherprotected Comparator<Version>Fields inherited from class org.alfresco.repo.version.common.AbstractVersionServiceImpl
dictionaryService, nodeService, policyComponentFields inherited from interface org.alfresco.repo.version.VersionBaseModel
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_ASSOCFields inherited from interface org.alfresco.repo.version.VersionModel
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_PROPERTYFields inherited from interface org.alfresco.service.cmr.version.VersionService
VERSION_STORE_PROTOCOL -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected VersionHistorybuildVersionHistory(NodeRef versionHistoryRef, NodeRef nodeRef) Builds a version history object from the version history reference.createVersion(Collection<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.createVersion(NodeRef nodeRef, Map<String, Serializable> versionProperties) Creates a new version based on the referenced node.createVersion(NodeRef nodeRef, Map<String, Serializable> versionProperties, boolean versionChildren) The version's are created from the children upwards with the parent being created first.protected VersioncreateVersion(NodeRef nodeRef, Map<String, Serializable> origVersionProperties, int versionNumber) Creates a new version of the passed node assigning the version properties accordingly.protected voiddefaultOnCreateVersion(QName classRef, NodeRef nodeRef, Map<String, Serializable> versionProperties, PolicyScope nodeDetails) Default implementation of the on create version policy.voiddeleteVersion(NodeRef nodeRef, Version version) Delete a specific version associated with a node reference.voiddeleteVersionHistory(NodeRef nodeRef) Delete the version history associated with a node reference.voidensureVersioningEnabled(NodeRef nodeRef, Map<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.getCurrentVersion(NodeRef nodeRef) Gets the version object for the current version of the node reference passed.protected NodeRefGets the version stores root nodeprotected VersiongetVersion(NodeRef versionRef) Constructs the a version object to contain the version information from the version node ref.getVersionHistory(NodeRef nodeRef) Gets the version history information for a node.protected NodeRefgetVersionHistoryNodeRef(NodeRef nodeRef) Gets a reference to the version history node for a given 'real' node.protected Map<String,Serializable> getVersionMetaData(NodeRef versionNodeRef) Gets the reference to the version storevoidInitialise methodbooleanisAVersion(NodeRef nodeRef) Is the nodeRef a version node?booleanisVersioned(NodeRef nodeRef) Is the nodeRef versioned?voidregisterVersionLabelPolicy(QName typeQName, VersionServicePolicies.CalculateVersionLabelPolicy policy) Register version label policy for the specified typeBy default a deep restore is performed.restore(NodeRef nodeRef, NodeRef parentNodeRef, QName assocTypeQName, QName assocQName, boolean deep) Restores a node not currently present in the store, but that has a version history.voidRevert the state of the node to the current version.voidRevert the state of the node to the current version.voidRevert the state of the node to the specified version.voidRevert the state of the node to the specified version.voidsetDbNodeService(NodeService nodeService) Sets the db node service, used as the version store implementationvoidsetPolicyBehaviourFilter(BehaviourFilter policyBehaviourFilter) Set the policy behaviour filtervoidsetSearcher(SearchService searcher) voidsetVersionComparatorClass(String versionComparatorClass) Sets an optional comparator to sort a versions in descending order (eg.Methods inherited from class org.alfresco.repo.version.common.AbstractVersionServiceImpl
getRevertAspectAction, getRevertAssocAction, invokeAfterCreateVersion, invokeAfterVersionRevert, invokeBeforeCreateVersion, invokeCalculateVersionLabel, invokeOnCreateVersion, setDictionaryService, setNodeService, setPolicyComponent
-
Field Details
-
MSGID_ERR_NOT_FOUND
Error message I18N id's- See Also:
-
MSGID_ERR_NO_BRANCHES
- See Also:
-
MSGID_ERR_RESTORE_EXISTS
- See Also:
-
MSGID_ERR_ONE_PRECEEDING
- See Also:
-
MSGID_ERR_RESTORE_NO_VERSION
- See Also:
-
MSGID_ERR_REVERT_MISMATCH
- See Also:
-
dbNodeService
The db node service, used as the version store implementation -
policyBehaviourFilter
Policy behaviour filter -
searcher
The repository searcher -
versionComparatorDesc
-
-
Constructor Details
-
VersionServiceImpl
public VersionServiceImpl()
-
-
Method Details
-
setDbNodeService
Sets the db node service, used as the version store implementation- Parameters:
nodeService- the node service
-
setSearcher
- Parameters:
searcher- the searcher
-
setPolicyBehaviourFilter
Set the policy behaviour filter- Parameters:
policyBehaviourFilter- the policy behaviour filter
-
setVersionComparatorClass
Sets an optional comparator to sort a versions in descending order (eg. 2.1, 2.0, 1.1, 1.0). Really only needed in a 4.1.3 system (or above) that has been upgraded from an earlier system that used NON ordered sequence numbers in a cluster. Not something we really support but was the subject of MNT-226.- Parameters:
versionComparatorClass- the name of a comparator. For example "org.alfresco.repo.version.common.VersionLabelComparator".
-
registerVersionLabelPolicy
public void registerVersionLabelPolicy(QName typeQName, VersionServicePolicies.CalculateVersionLabelPolicy policy) Register version label policy for the specified type- Specified by:
registerVersionLabelPolicyin interfaceVersionService- Parameters:
typeQName- QNamepolicy- CalculateVersionLabelPolicy
-
initialise
public void initialise()Initialise method- Overrides:
initialisein classAbstractVersionServiceImpl
-
getVersionStoreReference
Gets the reference to the version store- Specified by:
getVersionStoreReferencein interfaceVersionService- Specified by:
getVersionStoreReferencein classAbstractVersionServiceImpl- Returns:
- reference to the version store
-
createVersion
public Version createVersion(NodeRef nodeRef, Map<String, Serializable> versionProperties) throws ReservedVersionNameException, AspectMissingExceptionDescription copied from interface:VersionServiceCreates a new version based on the referenced node.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.
- Specified by:
createVersionin interfaceVersionService- Parameters:
nodeRef- a node referenceversionProperties- the version properties that are stored with the newly created version, or null if there are no relevant properties- Returns:
- the created version object
- Throws:
ReservedVersionNameException- thrown if a reserved property name is used int he version properties providedAspectMissingException- thrown if the version aspect is missing- See Also:
-
createVersion
public Collection<Version> createVersion(NodeRef nodeRef, Map<String, Serializable> versionProperties, boolean versionChildren) throws ReservedVersionNameException, AspectMissingExceptionThe version's are created from the children upwards with the parent being created first. This will ensure that the child version references in the version node will point to the version history nodes for the (possibly) newly created version histories.- Specified by:
createVersionin interfaceVersionService- Parameters:
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 otherwise- Returns:
- the created version object(s)
- Throws:
ReservedVersionNameException- thrown if a reserved property name is used int he version properties providedAspectMissingException- thrown if the version aspect is missing
-
createVersion
public Collection<Version> createVersion(Collection<NodeRef> nodeRefs, Map<String, Serializable> versionProperties) throws ReservedVersionNameException, AspectMissingExceptionNote: 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.- Specified by:
createVersionin interfaceVersionService- Parameters:
nodeRefs- a list of node referencesversionProperties- version property values- Returns:
- a collection of newly created versions
- Throws:
ReservedVersionNameException- thrown if a reserved property name is used in the version properties providedAspectMissingException- thrown if the version aspect is missing
-
createVersion
protected Version createVersion(NodeRef nodeRef, Map<String, Serializable> origVersionProperties, int versionNumber) throws ReservedVersionNameExceptionCreates a new version of the passed node assigning the version properties accordingly.- Parameters:
nodeRef- a node referenceorigVersionProperties- the version propertiesversionNumber- the version number- Returns:
- the newly created version
- Throws:
ReservedVersionNameException- thrown if there is a name clash in the version properties
-
getVersionHistory
Description copied from interface:VersionServiceGets the version history information for a node.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.
- Specified by:
getVersionHistoryin interfaceVersionService- Parameters:
nodeRef- a node reference- Returns:
- the version history information
- See Also:
-
getCurrentVersion
Description copied from interface:VersionServiceGets the version object for the current version of the node reference passed.Returns
nullif the node is not versionable or has not been versioned.- Specified by:
getCurrentVersionin interfaceVersionService- Parameters:
nodeRef- the node reference of the 'live' node- Returns:
- the version object for the current version
- See Also:
-
getVersionMetaData
-
getRootNode
Gets the version stores root node- Returns:
- the node ref to the root node of the version store
-
buildVersionHistory
Builds a version history object from the version history reference.The node ref is passed to enable the version history to be scoped to the appropriate branch in the version history.
- Parameters:
versionHistoryRef- the node ref for the version historynodeRef- the node reference- Returns:
- a constructed version history object
-
getVersion
Constructs the a version object to contain the version information from the version node ref.- Parameters:
versionRef- the version reference- Returns:
- object containing verison data
-
getVersionHistoryNodeRef
Gets a reference to the version history node for a given 'real' node.- Parameters:
nodeRef- a node reference- Returns:
- a reference to the version history node, null of none
-
ensureVersioningEnabled
Description copied from interface:VersionServiceEnsures that a node has the versionable aspect applied to it, and has at least an initial entry in the version store. If any of these requirements are missing, then they will be fixed.- Specified by:
ensureVersioningEnabledin interfaceVersionService- Parameters:
nodeRef- the node referenceversionProperties- the version properties to apply if versioning isn't currently enabled for the node- See Also:
-
revert
Description copied from interface:VersionServiceRevert the state of the node to the current version.The node reference will be reverted to the current version.
A deep revert will be performed.
- Specified by:
revertin interfaceVersionService- Parameters:
nodeRef- the node reference- See Also:
-
revert
Description copied from interface:VersionServiceRevert the state of the node to the current version.The node will be reverted to the current version.
- Specified by:
revertin interfaceVersionService- Parameters:
nodeRef- the node referencedeep- true if a deep revert is to be performed, false otherwise- See Also:
-
revert
Description copied from interface:VersionServiceRevert the state of the node to the specified version.A deep revert will take place by default.
- Specified by:
revertin interfaceVersionService- Parameters:
nodeRef- the node referenceversion- the version to revert to- See Also:
-
revert
Description copied from interface:VersionServiceRevert the state of the node to the specified version.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.
- Specified by:
revertin interfaceVersionService- Parameters:
nodeRef- the node referenceversion- the version to revert todeep- true is a deep revert is to be performed, false otherwise.- See Also:
-
restore
public NodeRef restore(NodeRef nodeRef, NodeRef parentNodeRef, QName assocTypeQName, QName assocQName) Description copied from interface:VersionServiceBy default a deep restore is performed.- Specified by:
restorein interfaceVersionService- Parameters:
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 qname- Returns:
- the newly restored node reference
- See Also:
-
restore
public NodeRef restore(NodeRef nodeRef, NodeRef parentNodeRef, QName assocTypeQName, QName assocQName, boolean deep) Description copied from interface:VersionServiceRestores a node not currently present in the store, but that has a version history.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.
- Specified by:
restorein interfaceVersionService- Parameters:
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 otherwise- Returns:
- the newly restored node reference
- See Also:
-
deleteVersionHistory
Description copied from interface:VersionServiceDelete the version history associated with a node reference.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.
- Specified by:
deleteVersionHistoryin interfaceVersionService- Parameters:
nodeRef- the node reference- Throws:
AspectMissingException- thrown if the version aspect is missing- See Also:
-
deleteVersion
Description copied from interface:VersionServiceDelete a specific version associated with a node reference.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.
- Specified by:
deleteVersionin interfaceVersionService- Parameters:
nodeRef- the node referenceversion- the version to delete
-
defaultOnCreateVersion
protected void defaultOnCreateVersion(QName classRef, NodeRef nodeRef, Map<String, Serializable> versionProperties, PolicyScope nodeDetails) Description copied from class:AbstractVersionServiceImplDefault implementation of the on create version policy. Override if you wish to supply your own policy.- Specified by:
defaultOnCreateVersionin classAbstractVersionServiceImpl- Parameters:
classRef- QNamenodeRef- NodeRefnodeDetails- PolicyScope
-
isAVersion
Description copied from interface:VersionServiceIs the nodeRef a version node?- Specified by:
isAVersionin interfaceVersionService- Returns:
- true, if the nodeRef is a version node, false otherwise
-
isVersioned
Description copied from interface:VersionServiceIs the nodeRef versioned?- Specified by:
isVersionedin interfaceVersionService- Returns:
- true, if the nodeRef is versioned, false otherwise
-