Overview  Package   Class  Use  Tree  Deprecated  Index  Help 
PREV CLASS   NEXT CLASS FRAMES    NO FRAMES    All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD DETAIL: FIELD | CONSTR | METHOD

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

@org.alfresco.api.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:
getWriter(org.alfresco.repo.content.ContentContext), getWriterInternal(ContentReader, String)

Field Summary
protected org.alfresco.repo.content.ContentLimitProvider
contentLimitProvider
Fields inherited from interface org.alfresco.repo.content.ContentStore
NEW_CONTENT_CONTEXT, PROTOCOL_DELIMITER
Constructor Summary
AbstractContentStore()
Method Summary
boolean
delete(String contentUrl)
          Override if the derived class supports the operation.
boolean
exists(String contentUrl)
          Simple implementation that uses the reader's exists method as its implementation.
protected Pair<String>
getContentUrlParts(String contentUrl)
          Splits the content URL into its component parts as separated by protocol delimiter.
getRootLocation()
          Get the location where the store is rooted.
long
getSpaceFree()
          Calculates the remaning free space in the underlying store.
long
getSpaceTotal()
          Calculates the total storage space of the underlying store.
void
getUrls(org.alfresco.repo.content.ContentStore.ContentUrlHandler handler)
          Get all URLs for the store, regardless of creation time.
void
getUrls(Date createdAfter, Date createdBefore, org.alfresco.repo.content.ContentStore.ContentUrlHandler handler)
          Override to provide an implementation.
getWriter(org.alfresco.repo.content.ContentContext context)
          An implementation that does some sanity checking before requesting a writer from the store.
protected ContentWriter
getWriterInternal(ContentReader existingContentReader, String newContentUrl)
          Implement to supply a store-specific writer for the given existing content and optional target content URL.
boolean
isContentUrlSupported(String contentUrl)
          Override this method to supply a efficient and direct check of the URL supplied.
static boolean
isValidContentUrl(String contentUrl)
          Checks that the content conforms to the format protocol://identifier as specified in the contract of the ContentStore interface.
void
setContentLimitProvider(org.alfresco.repo.content.ContentLimitProvider contentLimitProvider)
          An object that prevents abuse of the underlying store(s)
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.alfresco.repo.content.ContentStore
getReader, isWriteSupported
Field Detail
contentLimitProvider
protected org.alfresco.repo.content.ContentLimitProvider contentLimitProvider
Constructor Detail
AbstractContentStore
public AbstractContentStore()
Method Detail
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(org.alfresco.repo.content.ContentLimitProvider contentLimitProvider)
An object that prevents abuse of the underlying store(s)

getContentUrlParts
protected Pair<StringgetContentUrlParts(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
Parameters:
contentUrl - the content URL to check
Returns:
Returns true if none of the other methods on the store will throw an UnsupportedContentUrlException when given this URL.
Since:
2.1

delete
public boolean delete(String contentUrl)
Override if the derived class supports the operation.
Specified by:
delete in interface ContentStore
Parameters:
contentUrl - the URL of the content to delete
Returns:
Returns true if the content was deleted (either by this or another operation), otherwise false. If the content no longer exists, then true is returned.
Throws:
UnsupportedOperationException - always
Since:
2.1

getUrls
public final void getUrls(org.alfresco.repo.content.ContentStore.ContentUrlHandler handler)
                   throws ContentIOException
Description copied from interface: ContentStore
Get all URLs for the store, regardless of creation time.
Specified by:
getUrls in interface ContentStore
Throws:
ContentIOException - if an IO error occurs
See Also:
ContentStore.getUrls(Date, Date, ContentUrlHandler)

getUrls
public void getUrls(Date createdAfter,
                    Date createdBefore,
                    org.alfresco.repo.content.ContentStore.ContentUrlHandler handler)
             throws ContentIOException
Override to provide an implementation. If no implementation is supplied, then the store will not support cleaning of orphaned content binaries.
Specified by:
getUrls in interface ContentStore
Parameters:
createdAfter - all URLs returned must have been created after this date. May be null.
createdBefore - all URLs returned must have been created before this date. May be null.
handler - the callback that will passed each URL
Throws:
ContentIOException - if an error occurs
UnsupportedOperationException - always

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(org.alfresco.repo.content.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
Parameters:
context - the context of content.
Returns:
Returns a write-only content accessor
Since:
2.1
See Also:
getWriterInternal(ContentReader, String)

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
Parameters:
contentUrl - the path to the content
Returns:
Returns true if the content exists, otherwise false if the content doesn't exist or if the URL is not applicable to this store.

getSpaceFree
public long getSpaceFree()
Description copied from interface: ContentStore
Calculates the remaning free space in the underlying store.

NOTE: For efficiency, some implementations may provide a guess.

Implementations should focus on calculating a size value quickly, rather than accurately.

Specified by:
getSpaceFree in interface ContentStore
Returns:
Returns -1 always

getSpaceTotal
public long getSpaceTotal()
Description copied from interface: ContentStore
Calculates the total storage space of the underlying store.

NOTE: For efficiency, some implementations may provide a guess.

Implementations should focus on calculating a size value quickly, rather than accurately.

Specified by:
getSpaceTotal in interface ContentStore
Returns:
Returns -1 always

getRootLocation
public String getRootLocation()
Description copied from interface: ContentStore
Get the location where the store is rooted. The format of the returned value will depend on the specific implementation of the store.
Specified by:
getRootLocation in interface ContentStore
Returns:
Returns a '.' (period) always

Overview  Package   Class  Use  Tree  Deprecated  Index  Help 
PREV CLASS   NEXT CLASS FRAMES    NO FRAMES    All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD DETAIL: FIELD | CONSTR | METHOD

Copyright © 2005–2018 Alfresco Software. All rights reserved.

Java API documentation generated with DocFlex/Javadoc 1.6.1 using JavadocPro template set.