Class ContentServiceImpl

java.lang.Object
org.alfresco.repo.content.ContentServiceImpl
All Implemented Interfaces:
ContentService, org.springframework.beans.factory.Aware, org.springframework.context.ApplicationContextAware
Direct Known Subclasses:
RoutingContentService

public class ContentServiceImpl extends Object implements ContentService, org.springframework.context.ApplicationContextAware
Service implementation acting as a level of indirection between the client and the underlying content store.

Note: This class was formerly the RoutingContentService but the 'routing' functionality has been pushed into the store implementations.

Since:
3.2
Author:
Derek Hulley
  • Constructor Details

    • ContentServiceImpl

      public ContentServiceImpl()
  • Method Details

    • setRetryingTransactionHelper

      public void setRetryingTransactionHelper(RetryingTransactionHelper helper)
    • setDictionaryService

      public void setDictionaryService(DictionaryService dictionaryService)
    • setNodeService

      public void setNodeService(NodeService nodeService)
    • setMimetypeService

      public void setMimetypeService(MimetypeService mimetypeService)
    • setEagerContentStoreCleaner

      public void setEagerContentStoreCleaner(EagerContentStoreCleaner eagerContentStoreCleaner)
    • setStore

      public void setStore(ContentStore store)
    • setSystemWideDirectUrlConfig

      public void setSystemWideDirectUrlConfig(SystemWideDirectUrlConfig systemWideDirectUrlConfig)
    • setNonAttachContentTypes

      public void setNonAttachContentTypes(String nonAttachAllowListStr)
    • setPolicyComponent

      public void setPolicyComponent(PolicyComponent policyComponent)
    • setIgnoreEmptyContent

      public void setIgnoreEmptyContent(boolean ignoreEmptyContent)
      Deprecated.
      The transformations code is being moved out of the codebase and replaced by the new async RenditionService2 or other external libraries.
    • setApplicationContext

      public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext) throws org.springframework.beans.BeansException
      Specified by:
      setApplicationContext in interface org.springframework.context.ApplicationContextAware
      Throws:
      org.springframework.beans.BeansException
    • init

      public void init()
      Service initialise
    • onUpdateProperties

      public void onUpdateProperties(NodeRef nodeRef, Map<QName,Serializable> before, Map<QName,Serializable> after)
      Update properties policy behaviour
      Parameters:
      nodeRef - the node reference
      before - the before values of the properties
      after - the after values of the properties
    • getStoreFreeSpace

      public long getStoreFreeSpace()
      Description copied from interface: ContentService
      Gets the remaing available space in the underlying content store.
      Specified by:
      getStoreFreeSpace in interface ContentService
      Returns:
      Returns the total, possibly approximate, remaining space (in bytes) available to store content or -1 if no size data is available.
    • getStoreTotalSpace

      public long getStoreTotalSpace()
      Description copied from interface: ContentService
      Gets the total space of the underlying content store (not exclusively Alfresco-controlled binaries).
      Specified by:
      getStoreTotalSpace in interface ContentService
      Returns:
      Returns the total, possibly approximate, size (in bytes) of of the store or -1 if no size data is available.
    • getRawReader

      public ContentReader getRawReader(String contentUrl)
      Fetch content from the low-level stores using a content URL. None of the metadata associated with the content will be populated. This method should be used only to stream the binary data out when no other metadata is required.

      null is never returned, but the reader should always be checked for existence.

      Specified by:
      getRawReader in interface ContentService
      Parameters:
      contentUrl - a content store URL
      Returns:
      Returns a reader for the URL that needs to be checked.
    • getReader

      public ContentReader getReader(NodeRef nodeRef, QName propertyQName)
      Description copied from interface: ContentService
      Gets a reader for the content associated with the given node property.

      If a content URL is present for the given node then a reader must be returned. The exists method should then be used to detect 'missing' content.

      Specified by:
      getReader in interface ContentService
      Parameters:
      nodeRef - a reference to a node having a content property
      propertyQName - the name of the property, which must be of type content
      Returns:
      Returns a reader for the content associated with the node property, or null if no content has been written for the property
      See Also:
    • getWriter

      public ContentWriter getWriter(NodeRef nodeRef, QName propertyQName, boolean update)
      Description copied from interface: ContentService
      Get a content writer for the given node property, choosing to optionally have the node property updated automatically when the content stream closes.

      If the update flag is off, then the state of the node property will remain unchanged regardless of the state of the written binary data. If the flag is on, then the node property will be updated on the same thread as the code that closed the write channel.

      If no node is supplied, then the writer will provide a stream into the backing content store, but will not be associated with any new or previous content.

      NOTE: The content URL provided will be registered for automatic cleanup in the event that the transaction, in which this method was called, rolls back. If the transaction is successful, the writer may still be open and available for use but the underlying binary will not be cleaned up subsequently. The recommended pattern is to group calls to retrieve the writer in the same transaction as the calls to subsequently update and close the write stream - including setting of the related content properties.

      Specified by:
      getWriter in interface ContentService
      Parameters:
      nodeRef - a reference to a node having a content property, or null to just get a valid writer into a backing content store.
      propertyQName - the name of the property, which must be of type content
      update - true if the property must be updated atomically when the content write stream is closed (attaches a listener to the stream); false if the client code will perform the updates itself.
      Returns:
      Returns a writer for the content associated with the node property
    • getTempWriter

      public ContentWriter getTempWriter()
      Description copied from interface: ContentService
      Gets a writer to a temporary location. The longevity of the stored temporary content is determined by the system.
      Specified by:
      getTempWriter in interface ContentService
      Returns:
      Returns a writer to an anonymous location
    • isContentDirectUrlEnabled

      public boolean isContentDirectUrlEnabled()
      Checks if the system and at least one store supports the retrieving of direct access URLs.
      Specified by:
      isContentDirectUrlEnabled in interface ContentService
      Returns:
      true if direct access URLs retrieving is supported, false otherwise
    • isContentDirectUrlEnabled

      public boolean isContentDirectUrlEnabled(NodeRef nodeRef, QName propertyQName)
      Checks if the system and store supports the retrieving of a direct access URL for the given node.
      Specified by:
      isContentDirectUrlEnabled in interface ContentService
      Parameters:
      nodeRef - a reference to a node having a content property
      propertyQName - the name of the property, which must be of type content
      Returns:
      true if direct access URLs retrieving is supported for the node, false otherwise
    • requestContentDirectUrl

      public DirectAccessUrl requestContentDirectUrl(NodeRef nodeRef, QName propertyQName, boolean attachment, Long validFor, String fileNameOverride)
      Gets a presigned URL to directly access the content. It is up to the actual store implementation if it can fulfil this request with an expiry time or not.
      Specified by:
      requestContentDirectUrl in interface ContentService
      Parameters:
      nodeRef - Node ref for which to obtain the direct access URL.
      propertyQName - the name of the property, which must be of type content
      attachment - true if an attachment URL is requested, false for an embedded URL.
      validFor - The time at which the direct access URL will expire.
      fileNameOverride - Optional name for the file when downloaded
      Returns:
      A direct access URL object for the content.
    • getStorageProperties

      public Map<String,String> getStorageProperties(NodeRef nodeRef, QName propertyQName)
      Gets a key-value (String-String) collection of storage headers/properties with their respective values for a specific node reference. A particular Cloud Connector will fill in that data with Cloud Storage Provider generic data. Map may be also filled in with entries consisting of pre-defined Alfresco keys of ObjectStorageProps and their values. If empty Map is returned - no connector is present or connector is not supporting retrieval of the properties or cannot determine the properties.
      Specified by:
      getStorageProperties in interface ContentService
      Parameters:
      nodeRef - a reference to a node having a content property
      propertyQName - the name of the property, which must be of type content
      Returns:
      Returns a key-value (String-String) collection of storage headers/properties with their respective values for a given NodeRef.
    • requestSendContentToArchive

      public boolean requestSendContentToArchive(NodeRef nodeRef, QName propertyQName, Map<String,Serializable> archiveParams)
      Submit a request to send content to archive (offline) state. If no connector is present or connector is not supporting sending to archive, then UnsupportedOperationException will be returned. Specific connector will decide which storage class/tier will be set for content.
      Specified by:
      requestSendContentToArchive in interface ContentService
      Parameters:
      nodeRef - a reference to a node having a content property
      propertyQName - the name of the property, which must be of type content
      archiveParams - a map of String-Serializable parameters defining Storage Provider specific request parameters (can be empty).
      Returns:
      true when request successful, false when unsuccessful.
    • requestRestoreContentFromArchive

      public boolean requestRestoreContentFromArchive(NodeRef nodeRef, QName propertyQName, Map<String,Serializable> restoreParams)
      Submit a request to restore content from archive (offline) state. If no connector is present or connector is not supporting restoring fom archive, then UnsupportedOperationException will be returned. One of input parameters of this method is a map (String-Serializable) of Storage Provider specific input needed to perform proper restore. Keys of this map should be restricted to ContentRestoreParams enumeration. For AWS S3 map can indicating expiry days, Glacier restore tier. For Azure Blob map can indicate rehydrate priority.
      Specified by:
      requestRestoreContentFromArchive in interface ContentService
      Parameters:
      nodeRef - a reference to a node having a content property
      propertyQName - the name of the property, which must be of type content
      restoreParams - a map of String-Serializable parameters defining Storage Provider specific request parameters (can be empty).
      Returns:
      true when request successful, false when unsuccessful.
    • getFileName

      protected String getFileName(NodeRef nodeRef)