Interface ContentService

  • All Known Implementing Classes:
    ContentServiceImpl, RoutingContentService

    @AlfrescoPublicApi
    public interface ContentService
    Provides methods for accessing and transforming content.

    Implementations of this service are primarily responsible for ensuring that the correct store is used to access content, and that reads and writes for the same node reference are routed to the same store instance.

    The mechanism for selecting an appropriate store is not prescribed by the interface, but typically the decision will be made on the grounds of content type.

    Whereas the content stores have no knowledge of nodes other than their references, the ContentService is responsible for ensuring that all the relevant node-content relationships are maintained.

    Author:
    Derek Hulley
    See Also:
    ContentStore, ContentReader, ContentWriter
    • Method Summary

      All Methods Instance Methods Abstract Methods Deprecated Methods 
      Modifier and Type Method Description
      java.util.List<ContentTransformer> getActiveTransformers​(java.lang.String sourceMimetype, long sourceSize, java.lang.String targetMimetype, TransformationOptions options)
      java.util.List<ContentTransformer> getActiveTransformers​(java.lang.String sourceMimetype, java.lang.String targetMimetype, TransformationOptions options)
      ContentTransformer getImageTransformer()
      Deprecated.
      The transformations code is being moved out of the codebase and replaced by the new async RenditionService2 or other external libraries.
      long getMaxSourceSizeBytes​(java.lang.String sourceMimetype, java.lang.String targetMimetype, TransformationOptions options)
      Deprecated.
      The transformations code is being moved out of the codebase and replaced by the new async RenditionService2 or other external libraries.
      org.alfresco.service.cmr.repository.ContentReader getRawReader​(java.lang.String contentUrl)
      Fetch content from the low-level stores using a content URL.
      org.alfresco.service.cmr.repository.ContentReader getReader​(org.alfresco.service.cmr.repository.NodeRef nodeRef, org.alfresco.service.namespace.QName propertyQName)
      Gets a reader for the content associated with the given node property.
      long getStoreFreeSpace()
      Gets the remaing available space in the underlying content store.
      long getStoreTotalSpace()
      Gets the total space of the underlying content store (not exclusively Alfresco-controlled binaries).
      org.alfresco.service.cmr.repository.ContentWriter getTempWriter()
      Gets a writer to a temporary location.
      ContentTransformer getTransformer​(java.lang.String sourceMimetype, java.lang.String targetMimetype)
      Deprecated.
      The transformations code is being moved out of the codebase and replaced by the new async RenditionService2 or other external libraries.
      ContentTransformer getTransformer​(java.lang.String sourceUrl, java.lang.String sourceMimetype, long sourceSize, java.lang.String targetMimetype, TransformationOptions options)
      Deprecated.
      The transformations code is being moved out of the codebase and replaced by the new async RenditionService2 or other external libraries.
      ContentTransformer getTransformer​(java.lang.String sourceMimetype, java.lang.String targetMimetype, TransformationOptions options)
      Deprecated.
      use overloaded method with sourceSize parameter.
      java.util.List<ContentTransformer> getTransformers​(java.lang.String sourceUrl, java.lang.String sourceMimetype, long sourceSize, java.lang.String targetMimetype, TransformationOptions options)
      Deprecated.
      The transformations code is being moved out of the codebase and replaced by the new async RenditionService2 or other external libraries.
      org.alfresco.service.cmr.repository.ContentWriter getWriter​(org.alfresco.service.cmr.repository.NodeRef nodeRef, org.alfresco.service.namespace.QName propertyQName, boolean update)
      Get a content writer for the given node property, choosing to optionally have the node property updated automatically when the content stream closes.
      boolean isTransformable​(org.alfresco.service.cmr.repository.ContentReader reader, org.alfresco.service.cmr.repository.ContentWriter writer)
      boolean isTransformable​(org.alfresco.service.cmr.repository.ContentReader reader, org.alfresco.service.cmr.repository.ContentWriter writer, TransformationOptions options)
      Deprecated.
      The transformations code is being moved out of the codebase and replaced by the new async RenditionService2 or other external libraries.
      void transform​(org.alfresco.service.cmr.repository.ContentReader reader, org.alfresco.service.cmr.repository.ContentWriter writer)
      Deprecated.
      The transformations code is being moved out of the codebase and replaced by the new async RenditionService2 or other external libraries.
      void transform​(org.alfresco.service.cmr.repository.ContentReader reader, org.alfresco.service.cmr.repository.ContentWriter writer, java.util.Map<java.lang.String,​java.lang.Object> options)
      Deprecated.
      As of release 3.0 the TransformOptions class should be used to pass transformation options to a transformation execution.
      void transform​(org.alfresco.service.cmr.repository.ContentReader reader, org.alfresco.service.cmr.repository.ContentWriter writer, TransformationOptions options)
      Deprecated.
      The transformations code is being moved out of the codebase and replaced by the new async RenditionService2 or other external libraries.
    • Method Detail

      • getStoreTotalSpace

        long getStoreTotalSpace()
        Gets the total space of the underlying content store (not exclusively Alfresco-controlled binaries).
        Returns:
        Returns the total, possibly approximate, size (in bytes) of of the store or -1 if no size data is available.
        Since:
        3.3.3
      • getStoreFreeSpace

        long getStoreFreeSpace()
        Gets the remaing available space in the underlying content store.
        Returns:
        Returns the total, possibly approximate, remaining space (in bytes) available to store content or -1 if no size data is available.
        Since:
        3.3.3
      • getRawReader

        @Auditable(parameters="contentUrl")
        org.alfresco.service.cmr.repository.ContentReader getRawReader​(java.lang.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.

        Parameters:
        contentUrl - a content store URL
        Returns:
        Returns a reader for the URL that needs to be checked.
      • getReader

        @Auditable(parameters={"nodeRef","propertyQName"})
        org.alfresco.service.cmr.repository.ContentReader getReader​(org.alfresco.service.cmr.repository.NodeRef nodeRef,
                                                                    org.alfresco.service.namespace.QName propertyQName)
                                                             throws org.alfresco.service.cmr.repository.InvalidNodeRefException,
                                                                    org.alfresco.service.cmr.dictionary.InvalidTypeException
        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.

        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
        Throws:
        org.alfresco.service.cmr.repository.InvalidNodeRefException - if the node doesn't exist
        org.alfresco.service.cmr.dictionary.InvalidTypeException - if the node is not of type content
        See Also:
        FileContentReader.getSafeContentReader(ContentReader, String, Object[])
      • getWriter

        @Auditable(parameters={"nodeRef","propertyQName","update"})
        org.alfresco.service.cmr.repository.ContentWriter getWriter​(org.alfresco.service.cmr.repository.NodeRef nodeRef,
                                                                    org.alfresco.service.namespace.QName propertyQName,
                                                                    boolean update)
                                                             throws org.alfresco.service.cmr.repository.InvalidNodeRefException,
                                                                    org.alfresco.service.cmr.dictionary.InvalidTypeException
        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.

        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
        Throws:
        org.alfresco.service.cmr.repository.InvalidNodeRefException - if the node doesn't exist
        org.alfresco.service.cmr.dictionary.InvalidTypeException - if the node property is not of type content
      • getTempWriter

        @Auditable
        org.alfresco.service.cmr.repository.ContentWriter getTempWriter()
        Gets a writer to a temporary location. The longevity of the stored temporary content is determined by the system.
        Returns:
        Returns a writer onto a temporary location
      • transform

        @Deprecated
        @Auditable(parameters={"reader","writer"})
        void transform​(org.alfresco.service.cmr.repository.ContentReader reader,
                       org.alfresco.service.cmr.repository.ContentWriter writer)
                throws NoTransformerException,
                       org.alfresco.service.cmr.repository.ContentIOException
        Deprecated.
        The transformations code is being moved out of the codebase and replaced by the new async RenditionService2 or other external libraries.
        Transforms the content from the reader and writes the content back out to the writer.

        The mimetypes used for the transformation must be set both on the reader and on the writer.

        Parameters:
        reader - the source content location and mimetype
        writer - the target content location and mimetype
        Throws:
        NoTransformerException - if no transformer exists for the given source and target mimetypes of the reader and writer
        org.alfresco.service.cmr.repository.ContentIOException - if the transformation fails
      • transform

        @Deprecated
        @Auditable(parameters={"reader","writer","options"})
        void transform​(org.alfresco.service.cmr.repository.ContentReader reader,
                       org.alfresco.service.cmr.repository.ContentWriter writer,
                       java.util.Map<java.lang.String,​java.lang.Object> options)
                throws NoTransformerException,
                       org.alfresco.service.cmr.repository.ContentIOException
        Deprecated.
        As of release 3.0 the TransformOptions class should be used to pass transformation options to a transformation execution.
        Parameters:
        reader - the source content location and mimetype
        writer - the target content location and mimetype
        options - the options for the transformation
        Throws:
        NoTransformerException - if no transformer exists for the given source and target mimetypes of the reader and writer
        org.alfresco.service.cmr.repository.ContentIOException - if the transformation fails
        See Also:
        transform(ContentReader, ContentWriter), A map of transform options can be provided.
      • transform

        @Deprecated
        @Auditable(parameters={"reader","writer","options"})
        void transform​(org.alfresco.service.cmr.repository.ContentReader reader,
                       org.alfresco.service.cmr.repository.ContentWriter writer,
                       TransformationOptions options)
                throws NoTransformerException,
                       org.alfresco.service.cmr.repository.ContentIOException
        Deprecated.
        The transformations code is being moved out of the codebase and replaced by the new async RenditionService2 or other external libraries.
        Parameters:
        reader - the source content location and mimetype
        writer - the target content location and mimetype
        options - the options for the transformation
        Throws:
        NoTransformerException - if no transformer exists for the given source and target mimetypes of the reader and writer
        org.alfresco.service.cmr.repository.ContentIOException - if the transformation fails
        See Also:
        A transformation options can be provided.
      • getTransformer

        @Deprecated
        @Auditable(parameters={"sourceMimetype","targetMimetype"})
        ContentTransformer getTransformer​(java.lang.String sourceMimetype,
                                          java.lang.String targetMimetype)
        Deprecated.
        The transformations code is being moved out of the codebase and replaced by the new async RenditionService2 or other external libraries.
        Fetch the transformer that is capable of transforming the content in the given source mimetype to the given target mimetype.

        Since no transformation options are provided only the source and destination mimetypes are considered when getting the correct transformer.

        Parameters:
        sourceMimetype - the source mimetype
        targetMimetype - the target mimetype
        Returns:
        Returns a transformer that can be used, or null if one was not available
        See Also:
        getTransformer(String, String, long, String, TransformationOptions), ContentAccessor.getMimetype()
      • getTransformers

        @Deprecated
        @Auditable(parameters={"sourceMimetype","sourceSize","targetMimetype","options"})
        java.util.List<ContentTransformer> getTransformers​(java.lang.String sourceUrl,
                                                           java.lang.String sourceMimetype,
                                                           long sourceSize,
                                                           java.lang.String targetMimetype,
                                                           TransformationOptions options)
        Deprecated.
        The transformations code is being moved out of the codebase and replaced by the new async RenditionService2 or other external libraries.
        Fetch the transformers that are capable of transforming the content in the given source mimetype to the given target mimetype with the provided transformation options.

        The transformation options provide a finer grain way of discovering the correct transformer, since the values and type of the options provided are considered by the transformer when deciding whether it can satisfy the transformation request.

        Parameters:
        sourceUrl - TODO
        sourceMimetype - the source mimetype
        sourceSize - the source size (bytes). Ignored if negative.
        targetMimetype - the target mimetype
        options - the transformation options
        Returns:
        ContentTransformer the transformers that can be used, or null if none are available
      • getTransformer

        @Deprecated
        @Auditable(parameters={"sourceMimetype","sourceSize","targetMimetype","options"})
        ContentTransformer getTransformer​(java.lang.String sourceUrl,
                                          java.lang.String sourceMimetype,
                                          long sourceSize,
                                          java.lang.String targetMimetype,
                                          TransformationOptions options)
        Deprecated.
        The transformations code is being moved out of the codebase and replaced by the new async RenditionService2 or other external libraries.
        Fetch the transformer that is capable of transforming the content in the given source mimetype to the given target mimetype with the provided transformation options.

        The transformation options provide a finer grain way of discovering the correct transformer, since the values and type of the options provided are considered by the transformer when deciding whether it can satisfy the transformation request.

        Parameters:
        sourceUrl - TODO
        sourceMimetype - the source mimetype
        sourceSize - the source size (bytes). Ignored if negative.
        targetMimetype - the target mimetype
        options - the transformation options
        Returns:
        ContentTransformer a transformer that can be used, or null if one was not available
        See Also:
        ContentAccessor.getMimetype()
      • getTransformer

        @Deprecated
        ContentTransformer getTransformer​(java.lang.String sourceMimetype,
                                          java.lang.String targetMimetype,
                                          TransformationOptions options)
        Deprecated.
        use overloaded method with sourceSize parameter.
      • getMaxSourceSizeBytes

        @Deprecated
        @Auditable(parameters={"sourceMimetype","targetMimetype","options"})
        long getMaxSourceSizeBytes​(java.lang.String sourceMimetype,
                                   java.lang.String targetMimetype,
                                   TransformationOptions options)
        Deprecated.
        The transformations code is being moved out of the codebase and replaced by the new async RenditionService2 or other external libraries.
        Returns the maximum source size of any content that may transformed between the supplied mimetypes using the supplied options.
        Parameters:
        sourceMimetype - source mime type
        targetMimetype - target mime type
        options - transformation options
        Returns:
        0 if there are no transformers, -1 if there is no limit or if positive number the size in bytes.
      • getImageTransformer

        @Deprecated
        @Auditable
        ContentTransformer getImageTransformer()
        Deprecated.
        The transformations code is being moved out of the codebase and replaced by the new async RenditionService2 or other external libraries.
        Fetch the transformer that is capable of transforming image content.
        Returns:
        Returns a transformer that can be used, or null if one was not available
      • isTransformable

        @Deprecated
        @Auditable(parameters={"reader","writer","options"})
        boolean isTransformable​(org.alfresco.service.cmr.repository.ContentReader reader,
                                org.alfresco.service.cmr.repository.ContentWriter writer,
                                TransformationOptions options)
        Deprecated.
        The transformations code is being moved out of the codebase and replaced by the new async RenditionService2 or other external libraries.
        Returns whether a transformer exists that can read the content from the reader and write the content back out to the writer with the provided tranformation options.

        If you are about to call transform(ContentReader, ContentWriter, TransformationOptions) it is best NOT to call this method first as it must perform the same steps and will throw NoTransformerException if there are no transformers.

        The mimetypes used for the transformation must be set both on the reader and on the writer.

        Parameters:
        reader - the source content location and mimetype
        writer - the target content location and mimetype
        options - the transformation options
        Returns:
        boolean true if a transformer exists, false otherwise