Package org.alfresco.repo.content
Class AbstractContentStore
- java.lang.Object
-
- org.alfresco.repo.content.AbstractContentStore
-
- All Implemented Interfaces:
org.alfresco.repo.content.ContentStore
- Direct Known Subclasses:
AggregatingContentStore,FileContentStore,HttpAlfrescoStore
@AlfrescoPublicApi public abstract class AbstractContentStore extends java.lang.Object implements org.alfresco.repo.content.ContentStoreBase 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)orgetWriterInternal(ContentReader, String).- Author:
- Derek Hulley
- See Also:
getWriter(org.alfresco.repo.content.ContentContext),getWriterInternal(ContentReader, String)
-
-
Field Summary
Fields Modifier and Type Field Description protected ContentLimitProvidercontentLimitProvider
-
Constructor Summary
Constructors Constructor Description AbstractContentStore()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleandelete(java.lang.String contentUrl)Override if the derived class supports the operation.booleanexists(java.lang.String contentUrl)Simple implementation that uses thereader's existsmethod as its implementation.protected org.alfresco.util.Pair<java.lang.String,java.lang.String>getContentUrlParts(java.lang.String contentUrl)Splits the content URL into its component parts as separated byprotocol delimiter.java.lang.StringgetRootLocation()longgetSpaceFree()longgetSpaceTotal()org.alfresco.service.cmr.repository.ContentWritergetWriter(org.alfresco.repo.content.ContentContext context)An implementation that does some sanity checking before requesting a writer from the store.protected org.alfresco.service.cmr.repository.ContentWritergetWriterInternal(org.alfresco.service.cmr.repository.ContentReader existingContentReader, java.lang.String newContentUrl)Implement to supply a store-specific writer for the given existing content and optional target content URL.booleanisContentUrlSupported(java.lang.String contentUrl)Override this method to supply a efficient and direct check of the URL supplied.static booleanisValidContentUrl(java.lang.String contentUrl)Checks that the content conforms to the format protocol://identifier as specified in the contract of theContentStoreinterface.voidsetContentLimitProvider(ContentLimitProvider contentLimitProvider)An object that prevents abuse of the underlying store(s)
-
-
-
Field Detail
-
contentLimitProvider
protected ContentLimitProvider contentLimitProvider
-
-
Method Detail
-
isValidContentUrl
public static final boolean isValidContentUrl(java.lang.String contentUrl)
Checks that the content conforms to the format protocol://identifier as specified in the contract of theContentStoreinterface.- 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 org.alfresco.util.Pair<java.lang.String,java.lang.String> getContentUrlParts(java.lang.String contentUrl)
Splits the content URL into its component parts as separated byprotocol 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(java.lang.String contentUrl)
Override this method to supply a efficient and direct check of the URL supplied. The default implementation checks whetherContentStore.getReader(String)throws theUnsupportedContentUrlExceptionexception.- Specified by:
isContentUrlSupportedin interfaceorg.alfresco.repo.content.ContentStore- Since:
- 2.1
-
delete
public boolean delete(java.lang.String contentUrl)
Override if the derived class supports the operation.- Specified by:
deletein interfaceorg.alfresco.repo.content.ContentStore- Throws:
java.lang.UnsupportedOperationException- always- Since:
- 2.1
-
getWriterInternal
protected org.alfresco.service.cmr.repository.ContentWriter getWriterInternal(org.alfresco.service.cmr.repository.ContentReader existingContentReader, java.lang.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 withnewContentUrl- an optional target for the new content- Throws:
UnsupportedContentUrlException- if the content URL supplied is not supported by the storeContentExistsException- if the content URL is already in useorg.alfresco.service.cmr.repository.ContentIOException- if an IO error occurs- Since:
- 2.1
-
getWriter
public org.alfresco.service.cmr.repository.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 ofgetWriterInternal(ContentReader, String)must be supplied.- Specified by:
getWriterin interfaceorg.alfresco.repo.content.ContentStore- Since:
- 2.1
- See Also:
getWriterInternal(ContentReader, String)
-
exists
public boolean exists(java.lang.String contentUrl)
Simple implementation that uses thereader's existsmethod as its implementation. Override this method if a more efficient implementation is possible.- Specified by:
existsin interfaceorg.alfresco.repo.content.ContentStore
-
getSpaceFree
public long getSpaceFree()
- Specified by:
getSpaceFreein interfaceorg.alfresco.repo.content.ContentStore- Returns:
- Returns -1 always
-
getSpaceTotal
public long getSpaceTotal()
- Specified by:
getSpaceTotalin interfaceorg.alfresco.repo.content.ContentStore- Returns:
- Returns -1 always
-
getRootLocation
public java.lang.String getRootLocation()
- Specified by:
getRootLocationin interfaceorg.alfresco.repo.content.ContentStore- Returns:
- Returns a '.' (period) always
-
-