Class NodesImpl

java.lang.Object
org.alfresco.rest.api.impl.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 Details

    • PARAM_SYNONYMS_QNAME

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

    • NodesImpl

      public NodesImpl()
  • Method Details

    • setNonAttachContentTypes

      public void setNonAttachContentTypes(String nonAttachAllowListStr)
    • 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)
    • setPoster

      public void setPoster(ActivityPoster poster)
    • setSmartStore

      public void setSmartStore(VirtualStore smartStore)
    • setClassDefinitionMapper

      public void setClassDefinitionMapper(ClassDefinitionMapper classDefinitionMapper)
    • validateNode

      public NodeRef validateNode(String nodeId)
      Specified by:
      validateNode in interface Nodes
    • validateNode

      public NodeRef validateNode(StoreRef storeRef, String nodeId)
      Specified by:
      validateNode in interface Nodes
    • validateNode

      public NodeRef validateNode(NodeRef nodeRef)
      Specified by:
      validateNode in interface Nodes
    • 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
    • validateOrLookupNode

      public NodeRef validateOrLookupNode(String nodeId, String path)
      Specified by:
      validateOrLookupNode in interface Nodes
    • 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:
    • getFolderOrDocumentFullInfo

      public Node getFolderOrDocumentFullInfo(NodeRef nodeRef, NodeRef parentNodeRef, org.alfresco.service.namespace.QName nodeTypeQName, Parameters parameters, Map<String,UserInfo> mapUserInfo)
      Specified by:
      getFolderOrDocumentFullInfo in interface Nodes
    • 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
    • addChildren

      public List<AssocChild> addChildren(String parentNodeId, List<AssocChild> entities)
      Specified by:
      addChildren in interface Nodes
      Returns:
    • addTargets

      public List<AssocTarget> addTargets(String sourceNodeId, List<AssocTarget> entities)
      Specified by:
      addTargets in interface Nodes
      Returns:
    • 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 -
    • getActivityInfo

      protected ActivityInfo getActivityInfo(NodeRef parentNodeRef, NodeRef nodeRef)
    • 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:
    • updateNode

      public Node updateNode(String nodeId, Node nodeInfo, Parameters parameters)
      Description copied from interface: Nodes
      Update node meta-data.
      Specified by:
      updateNode in interface Nodes
      Returns:
    • updateNodeImpl

      protected NodeRef updateNodeImpl(String nodeId, Node nodeInfo, Parameters parameters)
    • processNodePermissions

      protected void processNodePermissions(NodeRef nodeRef, Node nodeInfo)
    • moveOrCopyNode

      public Node moveOrCopyNode(String sourceNodeId, String targetParentId, String name, Parameters parameters, boolean isCopy)
      Description copied from interface: Nodes
      Move or Copy node
      Specified by:
      moveOrCopyNode in interface Nodes
      Returns:
    • 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
    • moveOrCopyImpl

      protected FileInfo moveOrCopyImpl(NodeRef nodeRef, NodeRef parentNodeRef, String name, boolean isCopy)
    • 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
    • lock

      public Node lock(String nodeId, LockInfo lockInfo, Parameters parameters)
      Description copied from interface: Nodes
      Lock a node
      Specified by:
      lock in interface Nodes
      Returns:
    • unlock

      public Node unlock(String nodeId, Parameters parameters)
      Description copied from interface: Nodes
      Unlock a node
      Specified by:
      unlock in interface Nodes
      Returns:
    • requestContentDirectUrl

      public DirectAccessUrl requestContentDirectUrl(NodeRef nodeRef, boolean attachment, Long validFor)
      Gets a presigned URL to directly access content.
      Specified by:
      requestContentDirectUrl in interface Nodes
      Parameters:
      nodeRef - The node reference for which to obtain the direct access URL
      attachment - true if an attachment URL is requested, false for an embedded URL.
      validFor - The time at which the direct access URL will expire.
      Returns:
      A direct access URL object for the content.
    • validateAspects

      public void validateAspects(List<String> aspectNames, List<String> excludedNS, List<org.alfresco.service.namespace.QName> excludedAspects)
      Specified by:
      validateAspects in interface Nodes
    • validateProperties

      public void validateProperties(Map<String,Object> properties, List<String> excludedNS, List<org.alfresco.service.namespace.QName> excludedProperties)
      Specified by:
      validateProperties in interface Nodes
    • getNodeService

      protected NodeService getNodeService()
    • getDictionaryService

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

      protected FileFolderService getFileFolderService()
    • getNamespaceService

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

      protected PermissionService getPermissionService()
    • getMimetypeService

      protected MimetypeService getMimetypeService()
    • getContentService

      protected ContentService getContentService()
    • getActionService

      protected ActionService getActionService()
    • getVersionService

      protected VersionService getVersionService()
    • getPersonService

      protected PersonService getPersonService()
    • getOwnableService

      protected OwnableService getOwnableService()
    • getAuthorityService

      protected AuthorityService getAuthorityService()
    • getThumbnailService

      @Deprecated protected ThumbnailService getThumbnailService()
      Deprecated.
    • getSiteService

      protected SiteService getSiteService()
    • getPoster

      protected ActivityPoster getPoster()
    • getRetryingTransactionHelper

      protected RetryingTransactionHelper getRetryingTransactionHelper()
    • getLockService

      protected LockService getLockService()
    • getSmartStore

      protected VirtualStore getSmartStore()
    • getQuickShareLinks

      protected QuickShareLinks getQuickShareLinks()
    • getRepositoryHelper

      protected Repository getRepositoryHelper()