Class VersionServiceImpl

All Implemented Interfaces:
VersionBaseModel, VersionModel, VersionService
Direct Known Subclasses:
Version2ServiceImpl

public abstract class VersionServiceImpl extends AbstractVersionServiceImpl implements VersionService, VersionModel
Version1 Service - implements lightWeightVersionStore
Author:
Roy Wetheral NOTE: deprecated since 3.1 (migrate and use Version2 Service)
  • Field Details

  • Constructor Details

    • VersionServiceImpl

      public VersionServiceImpl()
  • Method Details

    • setDbNodeService

      public void setDbNodeService(NodeService nodeService)
      Sets the db node service, used as the version store implementation
      Parameters:
      nodeService - the node service
    • setSearcher

      public void setSearcher(SearchService searcher)
      Parameters:
      searcher - the searcher
    • setPolicyBehaviourFilter

      public void setPolicyBehaviourFilter(BehaviourFilter policyBehaviourFilter)
      Set the policy behaviour filter
      Parameters:
      policyBehaviourFilter - the policy behaviour filter
    • setVersionComparatorClass

      public void setVersionComparatorClass(String versionComparatorClass)
      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:
      registerVersionLabelPolicy in interface VersionService
      Parameters:
      typeQName - QName
      policy - CalculateVersionLabelPolicy
    • initialise

      public void initialise()
      Initialise method
      Overrides:
      initialise in class AbstractVersionServiceImpl
    • getVersionStoreReference

      public StoreRef getVersionStoreReference()
      Gets the reference to the version store
      Specified by:
      getVersionStoreReference in interface VersionService
      Specified by:
      getVersionStoreReference in class AbstractVersionServiceImpl
      Returns:
      reference to the version store
    • createVersion

      public Version createVersion(NodeRef nodeRef, Map<String,Serializable> versionProperties) throws ReservedVersionNameException, AspectMissingException
      Description copied from interface: VersionService
      Creates 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:
      createVersion in interface VersionService
      Parameters:
      nodeRef - a node reference
      versionProperties - 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 provided
      AspectMissingException - thrown if the version aspect is missing
      See Also:
    • createVersion

      public Collection<Version> createVersion(NodeRef nodeRef, Map<String,Serializable> versionProperties, boolean versionChildren) throws ReservedVersionNameException, AspectMissingException
      The 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:
      createVersion in interface VersionService
      Parameters:
      nodeRef - a node reference
      versionProperties - the version properties that are stored with the newly created version
      versionChildren - 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 provided
      AspectMissingException - thrown if the version aspect is missing
    • createVersion

      public Collection<Version> createVersion(Collection<NodeRef> nodeRefs, Map<String,Serializable> versionProperties) throws ReservedVersionNameException, AspectMissingException
      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.
      Specified by:
      createVersion in interface VersionService
      Parameters:
      nodeRefs - a list of node references
      versionProperties - version property values
      Returns:
      a collection of newly created versions
      Throws:
      ReservedVersionNameException - thrown if a reserved property name is used in the version properties provided
      AspectMissingException - thrown if the version aspect is missing
    • createVersion

      protected Version createVersion(NodeRef nodeRef, Map<String,Serializable> origVersionProperties, int versionNumber) throws ReservedVersionNameException
      Creates a new version of the passed node assigning the version properties accordingly.
      Parameters:
      nodeRef - a node reference
      origVersionProperties - the version properties
      versionNumber - the version number
      Returns:
      the newly created version
      Throws:
      ReservedVersionNameException - thrown if there is a name clash in the version properties
    • getVersionHistory

      public VersionHistory getVersionHistory(NodeRef nodeRef)
      Description copied from interface: VersionService
      Gets 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:
      getVersionHistory in interface VersionService
      Parameters:
      nodeRef - a node reference
      Returns:
      the version history information
      See Also:
    • getCurrentVersion

      public Version getCurrentVersion(NodeRef nodeRef)
      Description copied from interface: VersionService
      Gets the version object for the current version of the node reference passed.

      Returns null if the node is not versionable or has not been versioned.

      Specified by:
      getCurrentVersion in interface VersionService
      Parameters:
      nodeRef - the node reference of the 'live' node
      Returns:
      the version object for the current version
      See Also:
    • getVersionMetaData

      protected Map<String,Serializable> getVersionMetaData(NodeRef versionNodeRef)
    • getRootNode

      protected NodeRef getRootNode()
      Gets the version stores root node
      Returns:
      the node ref to the root node of the version store
    • buildVersionHistory

      protected VersionHistory buildVersionHistory(NodeRef versionHistoryRef, NodeRef nodeRef)
      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 history
      nodeRef - the node reference
      Returns:
      a constructed version history object
    • getVersion

      protected Version getVersion(NodeRef versionRef)
      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

      protected NodeRef getVersionHistoryNodeRef(NodeRef nodeRef)
      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

      public void ensureVersioningEnabled(NodeRef nodeRef, Map<QName,Serializable> versionProperties)
      Description copied from interface: VersionService
      Ensures 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:
      ensureVersioningEnabled in interface VersionService
      Parameters:
      nodeRef - the node reference
      versionProperties - the version properties to apply if versioning isn't currently enabled for the node
      See Also:
    • revert

      public void revert(NodeRef nodeRef)
      Description copied from interface: VersionService
      Revert 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:
      revert in interface VersionService
      Parameters:
      nodeRef - the node reference
      See Also:
    • revert

      public void revert(NodeRef nodeRef, boolean deep)
      Description copied from interface: VersionService
      Revert the state of the node to the current version.

      The node will be reverted to the current version.

      Specified by:
      revert in interface VersionService
      Parameters:
      nodeRef - the node reference
      deep - true if a deep revert is to be performed, false otherwise
      See Also:
    • revert

      public void revert(NodeRef nodeRef, Version version)
      Description copied from interface: VersionService
      Revert the state of the node to the specified version.

      A deep revert will take place by default.

      Specified by:
      revert in interface VersionService
      Parameters:
      nodeRef - the node reference
      version - the version to revert to
      See Also:
    • revert

      public void revert(NodeRef nodeRef, Version version, boolean deep)
      Description copied from interface: VersionService
      Revert 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:
      revert in interface VersionService
      Parameters:
      nodeRef - the node reference
      version - the version to revert to
      deep - 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: VersionService
      By default a deep restore is performed.
      Specified by:
      restore in interface VersionService
      Parameters:
      nodeRef - the node reference to a node that no longer exists in the store
      parentNodeRef - the new parent of the restored node
      assocTypeQName - the assoc type qname
      assocQName - 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: VersionService
      Restores 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:
      restore in interface VersionService
      Parameters:
      nodeRef - the node reference to a node that no longer exists in the store
      parentNodeRef - the new parent of the restored node
      assocTypeQName - the assoc type qname
      assocQName - the assoc qname
      deep - 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

      public void deleteVersionHistory(NodeRef nodeRef) throws AspectMissingException
      Description copied from interface: VersionService
      Delete 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:
      deleteVersionHistory in interface VersionService
      Parameters:
      nodeRef - the node reference
      Throws:
      AspectMissingException - thrown if the version aspect is missing
      See Also:
    • deleteVersion

      public void deleteVersion(NodeRef nodeRef, Version version)
      Description copied from interface: VersionService
      Delete 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:
      deleteVersion in interface VersionService
      Parameters:
      nodeRef - the node reference
      version - the version to delete
    • defaultOnCreateVersion

      protected void defaultOnCreateVersion(QName classRef, NodeRef nodeRef, Map<String,Serializable> versionProperties, PolicyScope nodeDetails)
      Description copied from class: AbstractVersionServiceImpl
      Default implementation of the on create version policy. Override if you wish to supply your own policy.
      Specified by:
      defaultOnCreateVersion in class AbstractVersionServiceImpl
      Parameters:
      classRef - QName
      nodeRef - NodeRef
      nodeDetails - PolicyScope
    • isAVersion

      public boolean isAVersion(NodeRef nodeRef)
      Description copied from interface: VersionService
      Is the nodeRef a version node?
      Specified by:
      isAVersion in interface VersionService
      Returns:
      true, if the nodeRef is a version node, false otherwise
    • isVersioned

      public boolean isVersioned(NodeRef nodeRef)
      Description copied from interface: VersionService
      Is the nodeRef versioned?
      Specified by:
      isVersioned in interface VersionService
      Returns:
      true, if the nodeRef is versioned, false otherwise