Class NodesImpl

  • All Implemented Interfaces:
    Nodes

    public class NodesImpl
    extends Object
    implements Nodes
    Centralises access to file/folder/node services and maps between representations. Note: This class was originally used for returning some basic node info when listing Favourites. It has now been re-purposed and extended to implement the new Nodes (RESTful) API for managing files & folders, as well as custom node types.
    Since:
    publicapi1.0
    Author:
    steveglover, janv, Jamal Kaabi-Mofrad
    • Field Detail

      • PARAM_SYNONYMS_QNAME

        public static final Map<String,​org.alfresco.service.namespace.QName> PARAM_SYNONYMS_QNAME
    • Constructor Detail

      • NodesImpl

        public NodesImpl()
    • Method Detail

      • setNonAttachContentTypes

        public void setNonAttachContentTypes​(Set<String> nonAttachWhiteList)
      • init

        public void init()
      • setServiceRegistry

        public void setServiceRegistry​(ServiceRegistry sr)
      • setBehaviourFilter

        public void setBehaviourFilter​(BehaviourFilter behaviourFilter)
      • setRepositoryHelper

        public void setRepositoryHelper​(Repository repositoryHelper)
      • setQuickShareLinks

        public void setQuickShareLinks​(QuickShareLinks quickShareLinks)
      • setIgnoreTypes

        public void setIgnoreTypes​(Set<String> ignoreTypesAndAspects)
      • setPersonLookupProperties

        public void setPersonLookupProperties​(Set<String> personLookupProperties)
      • setSmartStore

        public void setSmartStore​(VirtualStore smartStore)
      • setClassDefinitionMapper

        public void setClassDefinitionMapper​(ClassDefinitionMapper classDefinitionMapper)
      • nodeMatches

        public boolean nodeMatches​(NodeRef nodeRef,
                                   Set<org.alfresco.service.namespace.QName> expectedTypes,
                                   Set<org.alfresco.service.namespace.QName> excludedTypes)
        Specified by:
        nodeMatches in interface Nodes
      • isSubClass

        public boolean isSubClass​(NodeRef nodeRef,
                                  org.alfresco.service.namespace.QName ofClassQName,
                                  boolean validateNodeRef)
        Description copied from interface: Nodes
        Determines whether the type of the given nodeRef is a sub-class of another class or not.
        Specified by:
        isSubClass in interface Nodes
        Parameters:
        nodeRef - source nodeRef
        ofClassQName - the class to test against
        validateNodeRef - whether to validate the given source node or not
        Returns:
        true if the type of the given nodeRef is a sub-class of another class, otherwise false
      • typeMatches

        protected boolean typeMatches​(org.alfresco.service.namespace.QName type,
                                      Set<org.alfresco.service.namespace.QName> expectedTypes,
                                      Set<org.alfresco.service.namespace.QName> excludedTypes)
      • getNode

        public Node getNode​(String nodeId)
        Deprecated.
        review usage (backward compat')
        Description copied from interface: Nodes
        Get the node representation for the given node.
        Specified by:
        getNode in interface Nodes
        Parameters:
        nodeId - String
        Returns:
        Node
      • getNode

        public Node getNode​(NodeRef nodeRef)
        Deprecated.
        review usage (backward compat')
      • getDocument

        public Document getDocument​(NodeRef nodeRef)
        Deprecated.
        note: currently required for backwards compat' (Favourites API)
        Description copied from interface: Nodes
        Get the document representation for the given node.
        Specified by:
        getDocument in interface Nodes
        Parameters:
        nodeRef - NodeRef
        Returns:
        Document
      • getFolder

        public Folder getFolder​(NodeRef nodeRef)
        Deprecated.
        note: currently required for backwards compat' (Favourites API)
        Description copied from interface: Nodes
        Get the folder representation for the given node.
        Specified by:
        getFolder in interface Nodes
        Parameters:
        nodeRef - NodeRef
        Returns:
        Folder
      • resolveNodeByPath

        protected NodeRef resolveNodeByPath​(NodeRef parentNodeRef,
                                            String path,
                                            boolean checkForCompanyHome)
      • getFolderOrDocument

        public Node getFolderOrDocument​(String nodeId,
                                        Parameters parameters)
        Description copied from interface: Nodes
        Get the folder or document representation (as appropriate) for the given node.
        Specified by:
        getFolderOrDocument in interface Nodes
        Parameters:
        nodeId - String nodeId or well-known alias, eg. "-root-" or "-my-"
        parameters - the Parameters object to get the parameters passed into the request including: - incPrimaryParent
        Returns:
      • getFolderOrDocument

        public Node getFolderOrDocument​(NodeRef nodeRef,
                                        NodeRef parentNodeRef,
                                        org.alfresco.service.namespace.QName nodeTypeQName,
                                        List<String> includeParam,
                                        Map<String,​UserInfo> mapUserInfo)
        Description copied from interface: Nodes
        Get the folder or document representation (as appropriate) for the given node.
        Specified by:
        getFolderOrDocument in interface Nodes
        Parameters:
        nodeRef - A real Node
        Returns:
      • lookupPathInfo

        public PathInfo lookupPathInfo​(NodeRef nodeRefIn,
                                       ChildAssociationRef archivedParentAssoc)
        Description copied from interface: Nodes
        Returns the path to the given nodeRef nodeRefIn or the archived nodeRef archivedParentAssoc.
        Specified by:
        lookupPathInfo in interface Nodes
        Parameters:
        nodeRefIn - the NodeRef
        archivedParentAssoc - the ChildAssociationRef of the archived NodeRef
        Returns:
        the path to the given node
      • mapToNodeAspects

        public Set<org.alfresco.service.namespace.QName> mapToNodeAspects​(List<String> aspectNames)
        Description copied from interface: Nodes
        Map from a String representation of aspect names to a set of QName objects, as used by the repository.
        Specified by:
        mapToNodeAspects in interface Nodes
        Returns:
      • mapToNodeProperties

        public Map<org.alfresco.service.namespace.QName,​Serializable> mapToNodeProperties​(Map<String,​Object> props)
        Description copied from interface: Nodes
        Map from the JSON API format of properties (String to Object) to the typical node properties map used by the repository (QName to Serializable).
        Specified by:
        mapToNodeProperties in interface Nodes
        Returns:
      • mapFromNodeProperties

        public Map<String,​Object> mapFromNodeProperties​(Map<org.alfresco.service.namespace.QName,​Serializable> nodeProps,
                                                              List<String> selectParam,
                                                              Map<String,​UserInfo> mapUserInfo,
                                                              List<String> excludedNS,
                                                              List<org.alfresco.service.namespace.QName> excludedProps)
        Description copied from interface: Nodes
        Convert from node properties (map of QName to Serializable) retrieved from the respository to a map of String to Object that can be formatted/expressed as required by the API JSON response for get nodes, get person etc.

        Returns null if there are no properties to return, rather than an empty map.

        Specified by:
        mapFromNodeProperties in interface Nodes
        Returns:
        The map of properties, or null if none to return.
      • mapFromNodeAspects

        public List<String> mapFromNodeAspects​(Set<org.alfresco.service.namespace.QName> nodeAspects,
                                               List<String> excludedNS,
                                               List<org.alfresco.service.namespace.QName> excludedAspects)
        Description copied from interface: Nodes
        Map from aspects (Set of QName) retrieved from the repository to a map List of String required that can be formatted/expressed as required by the API JSON response for get nodes, get person etc.

        Returns null if there are no aspect names to return, rather than an empty list.

        Specified by:
        mapFromNodeAspects in interface Nodes
        Returns:
        The list of aspect names, or null if none to return.
      • listChildren

        public CollectionWithPagingInfo<Node> listChildren​(String parentFolderNodeId,
                                                           Parameters parameters)
        Description copied from interface: Nodes
        Get list of children of a parent folder.
        Specified by:
        listChildren in interface Nodes
        Parameters:
        parentFolderNodeId - String id of parent folder node or well-known alias, eg. "-root-" or "-my-"
        parameters - the Parameters object to get the parameters passed into the request including: - filter, sort & paging params (where, orderBy, skipCount, maxItems) - incFiles, incFolders (both true by default)
        Returns:
        a paged list of org.alfresco.rest.api.model.Node objects
      • getListChildrenFilterProps

        protected List<FilterProp> getListChildrenFilterProps​(Parameters parameters)

        Returns a List of filter properties specified by request parameters.

        Parameters:
        parameters - The Parameters object to get the parameters passed into the request including: - filter, sort & paging params (where, orderBy, skipCount, maxItems) - incFiles, incFolders (both true by default)
        Returns:
        The list of FilterProp. Can be null.
      • getListChildrenSortProps

        protected List<Pair<org.alfresco.service.namespace.QName,​Boolean>> getListChildrenSortProps​(Parameters parameters)

        Returns a List of sort properties specified by the "sorting" request parameter.

        Parameters:
        parameters - The Parameters object to get the parameters passed into the request including: - filter, sort & paging params (where, orderBy, skipCount, maxItems) - incFiles, incFolders (both true by default)
        Returns:
        The list of Pair<QName, Boolean> sort properties. If no sort parameters are found defaults to getListChildrenSortPropsDefault.
      • getListChildrenSortPropsDefault

        protected List<Pair<org.alfresco.service.namespace.QName,​Boolean>> getListChildrenSortPropsDefault()

        Returns the default sort order.

        Returns:
        The list of Pair<QName, Boolean> sort properties.
      • buildAssocTypes

        protected Set<org.alfresco.service.namespace.QName> buildAssocTypes​(org.alfresco.service.namespace.QName assocTypeQName)
      • buildSearchTypesAndIgnoreAspects

        protected Pair<Set<org.alfresco.service.namespace.QName>,​Set<org.alfresco.service.namespace.QName>> buildSearchTypesAndIgnoreAspects​(org.alfresco.service.namespace.QName nodeTypeQName,
                                                                                                                                                   boolean includeSubTypes,
                                                                                                                                                   Set<org.alfresco.service.namespace.QName> ignoreQNameTypes,
                                                                                                                                                   Boolean includeFiles,
                                                                                                                                                   Boolean includeFolders)
      • buildSearchTypesAndIgnoreAspects

        protected Pair<Set<org.alfresco.service.namespace.QName>,​Set<org.alfresco.service.namespace.QName>> buildSearchTypesAndIgnoreAspects​(Parameters parameters)
      • deleteNode

        public void deleteNode​(String nodeId,
                               Parameters parameters)
        Description copied from interface: Nodes
        Delete the given node. Note: will cascade delete for a folder.
        Specified by:
        deleteNode in interface Nodes
        Parameters:
        nodeId - String id of node (folder or document)
        parameters - the Parameters object to get the parameters passed into the request - permanent (default false)
      • createNode

        public Node createNode​(String parentFolderNodeId,
                               Node nodeInfo,
                               Parameters parameters)
        Description copied from interface: Nodes
        Create node - folder or (empty) file.
        Specified by:
        createNode in interface Nodes
        Returns:
      • addCustomAspects

        public void addCustomAspects​(NodeRef nodeRef,
                                     List<String> aspectNames,
                                     List<org.alfresco.service.namespace.QName> excludedAspects)
        Description copied from interface: Nodes
        Add aspects to the specified NodeRef. Aspects that appear in the exclusions list will be ignored.
        Specified by:
        addCustomAspects in interface Nodes
      • getAssocType

        public org.alfresco.service.namespace.QName getAssocType​(String assocTypeQNameStr)
        Specified by:
        getAssocType in interface Nodes
      • getAssocType

        public org.alfresco.service.namespace.QName getAssocType​(String assocTypeQNameStr,
                                                                 boolean mandatory)
        Specified by:
        getAssocType in interface Nodes
      • postActivity

        protected void postActivity​(org.alfresco.rest.api.impl.NodesImpl.Activity_Type activity_type,
                                    ActivityInfo activityInfo,
                                    boolean aSync)
        Posts activities based on the activity_type. If the method is called with aSync=true then a TransactionListener is used post the activity afterCommit. Otherwise the activity posting is done synchronously.
        Parameters:
        activity_type -
        activityInfo -
        aSync -
      • determineActivityType

        protected static String determineActivityType​(org.alfresco.rest.api.impl.NodesImpl.Activity_Type activity_type,
                                                      boolean isFolder)
      • isSpecialNode

        protected boolean isSpecialNode​(NodeRef nodeRef,
                                        org.alfresco.service.namespace.QName type)
        Check for special case: additional node validation (pending common lower-level service support) for blacklist of system nodes that should not be deleted or locked, eg. Company Home, Sites, Data Dictionary
        Parameters:
        nodeRef -
        type -
        Returns:
      • processNodePermissions

        protected void processNodePermissions​(NodeRef nodeRef,
                                              Node nodeInfo)
      • updateCustomAspects

        public void updateCustomAspects​(NodeRef nodeRef,
                                        List<String> aspectNames,
                                        List<org.alfresco.service.namespace.QName> excludedAspects)
        Description copied from interface: Nodes
        Update aspects for the specified NodeRef. An empty list will result in aspects being removed.
        Specified by:
        updateCustomAspects in interface Nodes
      • getContent

        public BinaryResource getContent​(String fileNodeId,
                                         Parameters parameters,
                                         boolean recordActivity)
        Description copied from interface: Nodes
        Download file content.
        Specified by:
        getContent in interface Nodes
        recordActivity - true, if an activity post is required.
        Returns:
      • getContent

        public BinaryResource getContent​(NodeRef nodeRef,
                                         Parameters parameters,
                                         boolean recordActivity)
        Description copied from interface: Nodes
        Download file content.
        Specified by:
        getContent in interface Nodes
        Parameters:
        nodeRef - the content nodeRef
        recordActivity - true, if an activity post is required.
        Returns:
      • updateContent

        public Node updateContent​(String fileNodeId,
                                  BasicContentInfo contentInfo,
                                  InputStream stream,
                                  Parameters parameters)
        Description copied from interface: Nodes
        Uploads file content (updates existing node with new content). Note: may create a new version, depending on versioning behaviour.
        Specified by:
        updateContent in interface Nodes
        Returns:
      • createVersion

        protected void createVersion​(NodeRef nodeRef,
                                     boolean isVersioned,
                                     VersionType versionType,
                                     String reason)
      • upload

        public Node upload​(String parentFolderNodeId,
                           org.springframework.extensions.webscripts.servlet.FormData formData,
                           Parameters parameters)
        Description copied from interface: Nodes
        Uploads file content and meta-data into the repository.
        Specified by:
        upload in interface Nodes
        Parameters:
        parentFolderNodeId - String id of parent folder node or well-known alias, eg. "-root-" or "-my-"
        formData - the FormData
        parameters - the Parameters object to get the parameters passed into the request
        Returns:
        Node if successful
      • createQName

        public org.alfresco.service.namespace.QName createQName​(String qnameStr)
        Helper to create a QName from either a fully qualified or short-name QName string
        Specified by:
        createQName in interface Nodes
        Parameters:
        qnameStr - Fully qualified or short-name QName string
        Returns:
        QName
      • createQNames

        protected List<org.alfresco.service.namespace.QName> createQNames​(List<String> qnameStrList,
                                                                          List<org.alfresco.service.namespace.QName> excludedProps)
        Helper to create a QName from either a fully qualified or short-name QName string
        Parameters:
        qnameStrList - list of fully qualified or short-name QName string
        excludedProps -
        Returns:
        a list of QName objects
      • getNodeService

        protected NodeService getNodeService()
      • getDictionaryService

        protected org.alfresco.service.cmr.dictionary.DictionaryService getDictionaryService()
      • getNamespaceService

        protected org.alfresco.service.namespace.NamespaceService getNamespaceService()
      • getSiteService

        protected SiteService getSiteService()
      • getLockService

        protected LockService getLockService()
      • getRepositoryHelper

        protected Repository getRepositoryHelper()