Interface ContentService

  • All Superinterfaces:
    ContentTransformService
    All Known Implementing Classes:
    ContentServiceImpl, RoutingContentService

    @AlfrescoPublicApi
    public interface ContentService
    extends ContentTransformService
    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 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")
        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.

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

        @Auditable(parameters={"nodeRef","propertyQName","update"})
        ContentWriter getWriter​(NodeRef nodeRef,
                                QName propertyQName,
                                boolean update)
                         throws InvalidNodeRefException,
                                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:
        InvalidNodeRefException - if the node doesn't exist
        InvalidTypeException - if the node property is not of type content
      • getTempWriter

        @Auditable
        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