Class AbstractContentStore

java.lang.Object
org.alfresco.repo.content.AbstractContentStore
All Implemented Interfaces:
ContentStore
Direct Known Subclasses:
AggregatingContentStore, FileContentStore, HttpAlfrescoStore

@AlfrescoPublicApi public abstract class AbstractContentStore extends Object implements ContentStore
Base class providing support for different types of content stores.

Since content URLs have to be consistent across all stores for reasons of replication and backup, the most important functionality provided is the generation of new content URLs and the checking of existing URLs.

Implementations must override either of the getWriter methods; getWriter(ContentContext) or getWriterInternal(ContentReader, String).

Author:
Derek Hulley
See Also:
  • Field Details

  • Constructor Details

    • AbstractContentStore

      public AbstractContentStore()
  • Method Details

    • isValidContentUrl

      public static final boolean isValidContentUrl(String contentUrl)
      Checks that the content conforms to the format protocol://identifier as specified in the contract of the ContentStore interface.
      Parameters:
      contentUrl - the content URL to check
      Returns:
      Returns true if the content URL is valid
      Since:
      2.1
    • setContentLimitProvider

      public void setContentLimitProvider(ContentLimitProvider contentLimitProvider)
      An object that prevents abuse of the underlying store(s)
    • getContentUrlParts

      protected Pair<String,String> getContentUrlParts(String contentUrl)
      Splits the content URL into its component parts as separated by protocol delimiter.
      Parameters:
      contentUrl - the content URL to split
      Returns:
      Returns the protocol and identifier portions of the content URL, both of which will not be null
      Throws:
      UnsupportedContentUrlException - if the content URL is invalid
      Since:
      2.1
    • isContentUrlSupported

      public boolean isContentUrlSupported(String contentUrl)
      Override this method to supply a efficient and direct check of the URL supplied. The default implementation checks whether ContentStore.getReader(String) throws the UnsupportedContentUrlException exception.
      Specified by:
      isContentUrlSupported in interface ContentStore
      Since:
      2.1
    • delete

      public boolean delete(String contentUrl)
      Override if the derived class supports the operation.
      Specified by:
      delete in interface ContentStore
      Throws:
      UnsupportedOperationException - always
      Since:
      2.1
    • getWriterInternal

      protected ContentWriter getWriterInternal(ContentReader existingContentReader, String newContentUrl)
      Implement to supply a store-specific writer for the given existing content and optional target content URL.
      Parameters:
      existingContentReader - a reader onto any content to initialize the new writer with
      newContentUrl - an optional target for the new content
      Throws:
      UnsupportedContentUrlException - if the content URL supplied is not supported by the store
      ContentExistsException - if the content URL is already in use
      ContentIOException - if an IO error occurs
      Since:
      2.1
    • getWriter

      public ContentWriter getWriter(ContentContext context)
      An implementation that does some sanity checking before requesting a writer from the store. If this method is not overridden, then an implementation of getWriterInternal(ContentReader, String) must be supplied.
      Specified by:
      getWriter in interface ContentStore
      Since:
      2.1
      See Also:
    • exists

      public boolean exists(String contentUrl)
      Simple implementation that uses the reader's exists method as its implementation. Override this method if a more efficient implementation is possible.
      Specified by:
      exists in interface ContentStore
    • getSpaceFree

      public long getSpaceFree()
      Specified by:
      getSpaceFree in interface ContentStore
      Returns:
      Returns -1 always
    • getSpaceTotal

      public long getSpaceTotal()
      Specified by:
      getSpaceTotal in interface ContentStore
      Returns:
      Returns -1 always
    • getRootLocation

      public String getRootLocation()
      Specified by:
      getRootLocation in interface ContentStore
      Returns:
      Returns a '.' (period) always