Class Version2ServiceImpl

    • Constructor Detail

      • Version2ServiceImpl

        public Version2ServiceImpl()
    • Method Detail

      • setPermissionService

        public void setPermissionService​(org.alfresco.service.cmr.security.PermissionService permissionService)
      • createVersion

        public Version createVersion​(org.alfresco.service.cmr.repository.NodeRef nodeRef,
                                     java.util.Map<java.lang.String,​java.io.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
        Overrides:
        createVersion in class VersionServiceImpl
        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:
        VersionService.createVersion(NodeRef, Map)
      • createVersion

        public java.util.Collection<Version> createVersion​(java.util.Collection<org.alfresco.service.cmr.repository.NodeRef> nodeRefs,
                                                           java.util.Map<java.lang.String,​java.io.Serializable> versionProperties)
                                                    throws ReservedVersionNameException,
                                                           AspectMissingException
        Description copied from class: VersionServiceImpl
        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
        Overrides:
        createVersion in class VersionServiceImpl
        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​(org.alfresco.service.cmr.repository.NodeRef nodeRef,
                                        java.util.Map<java.lang.String,​java.io.Serializable> origVersionProperties,
                                        int versionNumber)
                                 throws ReservedVersionNameException
        Description copied from class: VersionServiceImpl
        Creates a new version of the passed node assigning the version properties accordingly.
        Overrides:
        createVersion in class VersionServiceImpl
        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
      • createVersionHistory

        protected org.alfresco.service.cmr.repository.NodeRef createVersionHistory​(org.alfresco.service.cmr.repository.NodeRef nodeRef)
        Creates a new version history node, applying the root version aspect is required
        Parameters:
        nodeRef - the node ref
        Returns:
        the version history node reference
      • getStandardVersionProperties

        protected java.util.Map<org.alfresco.service.namespace.QName,​java.io.Serializable> getStandardVersionProperties​(org.alfresco.service.cmr.repository.NodeRef nodeRef,
                                                                                                                              long nodeDbId,
                                                                                                                              java.util.Set<org.alfresco.service.namespace.QName> nodeAspects,
                                                                                                                              int versionNumber,
                                                                                                                              java.lang.String versionLabel,
                                                                                                                              java.lang.String versionDescription)
        Get a map containing the standard list of version properties populated.
        Parameters:
        nodeRef - the node reference
        Returns:
        the standard version properties
      • createNewVersion

        protected org.alfresco.service.cmr.repository.NodeRef createNewVersion​(org.alfresco.service.namespace.QName sourceTypeRef,
                                                                               org.alfresco.service.cmr.repository.NodeRef versionHistoryRef,
                                                                               java.util.Map<org.alfresco.service.namespace.QName,​java.io.Serializable> standardVersionProperties,
                                                                               java.util.Map<java.lang.String,​java.io.Serializable> versionProperties,
                                                                               int versionNumber,
                                                                               PolicyScope nodeDetails)
        Creates a new version node, setting the properties both calculated and specified.
        Parameters:
        sourceTypeRef - the reference to the node being versioned
        versionHistoryRef - version history node reference
        standardVersionProperties - version properties
        versionProperties - version properties
        versionNumber - the version number
        nodeDetails - PolicyScope
        Returns:
        the version node reference
      • getAllVersions

        protected java.util.List<Version> getAllVersions​(org.alfresco.service.cmr.repository.NodeRef versionHistoryRef)
        Gets all versions in version history
        Parameters:
        versionHistoryRef - the version history nodeRef
        Returns:
        list of all versions
      • buildVersionHistory

        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.

        The node ref is passed to enable the version history to be scoped to the appropriate branch in the version history.

        Overrides:
        buildVersionHistory in class VersionServiceImpl
        Parameters:
        versionHistoryRef - the node ref for the version history
        nodeRef - the node reference
        Returns:
        a constructed version history object
      • getVersion

        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.
        Overrides:
        getVersion in class VersionServiceImpl
        Parameters:
        versionRef - the version reference
        Returns:
        object containing verison data
      • getVersionHistoryNodeRef

        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.
        Overrides:
        getVersionHistoryNodeRef in class VersionServiceImpl
        Parameters:
        nodeRef - a node reference
        Returns:
        a reference to the version history node, null of none
      • revert

        public void revert​(org.alfresco.service.cmr.repository.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
        Overrides:
        revert in class VersionServiceImpl
        Parameters:
        nodeRef - the node reference
        See Also:
        VersionService.revert(NodeRef)
      • revert

        public void revert​(org.alfresco.service.cmr.repository.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
        Overrides:
        revert in class VersionServiceImpl
        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:
        VersionService.revert(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.cmr.version.Version, boolean)
      • restore

        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)
        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
        Overrides:
        restore in class VersionServiceImpl
        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:
        VersionService.restore(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.namespace.QName, org.alfresco.service.namespace.QName, boolean)
      • deleteVersion

        public void deleteVersion​(org.alfresco.service.cmr.repository.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
        Overrides:
        deleteVersion in class VersionServiceImpl
        Parameters:
        nodeRef - the node reference
        version - the version to delete
      • isAVersion

        public boolean isAVersion​(org.alfresco.service.cmr.repository.NodeRef nodeRef)
        Description copied from interface: VersionService
        Is the nodeRef a version node?
        Specified by:
        isAVersion in interface VersionService
        Overrides:
        isAVersion in class VersionServiceImpl
        Returns:
        true, if the nodeRef is a version node, false otherwise
      • isVersioned

        public boolean isVersioned​(org.alfresco.service.cmr.repository.NodeRef nodeRef)
        Description copied from interface: VersionService
        Is the nodeRef versioned?
        Specified by:
        isVersioned in interface VersionService
        Overrides:
        isVersioned in class VersionServiceImpl
        Returns:
        true, if the nodeRef is versioned, false otherwise