org.alfresco.repo.content
Class AbstractRoutingContentStore

java.lang.Object
  extended by org.alfresco.repo.content.AbstractRoutingContentStore
All Implemented Interfaces:
ContentStore
Direct Known Subclasses:
TenantRoutingFileContentStore

public abstract class AbstractRoutingContentStore
extends java.lang.Object
implements ContentStore

A store providing support for content store implementations that provide routing of content read and write requests based on context.

Since:
2.1
See Also:
ContentContext

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.alfresco.repo.content.ContentStore
ContentStore.ContentUrlHandler
 
Field Summary
 
Fields inherited from interface org.alfresco.repo.content.ContentStore
NEW_CONTENT_CONTEXT, PROTOCOL_DELIMITER
 
Constructor Summary
protected AbstractRoutingContentStore()
           
 
Method Summary
 boolean delete(java.lang.String contentUrl)
          This operation has to be performed on all the stores in order to maintain the ContentStore.exists(String) contract.
 boolean exists(java.lang.String contentUrl)
          Check for the existence of content in the store.
protected abstract  java.util.List getAllStores()
           
 org.alfresco.service.cmr.repository.ContentReader getReader(java.lang.String contentUrl)
          Get the accessor with which to read from the content at the given URL.
 java.lang.String getRootLocation()
          Get the location where the store is rooted.
 long getSpaceFree()
          Calcualates the remaing free space in the underlying store.
 long getSpaceTotal()
          Calculates the total storage space of the underlying store.
 long getSpaceUsed()
          Calculates the total size of stored content, excluding any other data in the underlying storage.
 long getTotalSize()
          Uses AbstractRoutingContentStore.getSpaceUsed(), which is the equivalent method.
 void getUrls(ContentStore.ContentUrlHandler handler)
          Get all URLs for the store, regardless of creation time.
 void getUrls(java.util.Date createdAfter, java.util.Date createdBefore, ContentStore.ContentUrlHandler handler)
          Passes the call to each of the stores wrapped by this store
 org.alfresco.service.cmr.repository.ContentWriter getWriter(ContentContext context)
          Selects a store for the given context and caches store that was used.
 org.alfresco.service.cmr.repository.ContentWriter getWriter(org.alfresco.service.cmr.repository.ContentReader existingContentReader, java.lang.String newContentUrl)
          Shortcut method to ContentStore.getWriter(ContentContext).
 boolean isContentUrlSupported(java.lang.String contentUrl)
          Check if the content URL format is supported by the store.
 boolean isWriteSupported()
          Check if the store supports write requests.
protected abstract  ContentStore selectWriteStore(ContentContext ctx)
          Get a content store based on the context provided.
 void setStoresCache(org.alfresco.repo.cache.SimpleCache storesCache)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractRoutingContentStore

protected AbstractRoutingContentStore()
Method Detail

setStoresCache

public void setStoresCache(org.alfresco.repo.cache.SimpleCache storesCache)
Parameters:
storesCache - cache of stores used to access URLs

getAllStores

protected abstract java.util.List getAllStores()
Returns:
Returns a list of all possible stores available for reading or writing

selectWriteStore

protected abstract ContentStore selectWriteStore(ContentContext ctx)
Get a content store based on the context provided. The applicability of the context and even the types of context allowed are up to the implementation, but normally there should be a fallback case for when the parameters are not adequate to make a decision.

Parameters:
ctx - the context to use to make the choice
Returns:
Returns the store most appropriate for the given context and never null

isContentUrlSupported

public boolean isContentUrlSupported(java.lang.String contentUrl)
Description copied from interface: ContentStore
Check if the content URL format is supported by the store.

Specified by:
isContentUrlSupported in interface ContentStore
Parameters:
contentUrl - the content URL to check
Returns:
Returns true if the URL is supported by any of the stores.

isWriteSupported

public boolean isWriteSupported()
Description copied from interface: ContentStore
Check if the store supports write requests.

Specified by:
isWriteSupported in interface ContentStore
Returns:
Returns true if write is supported by any of the stores.

getRootLocation

public java.lang.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 . always

getTotalSize

public final long getTotalSize()
Uses AbstractRoutingContentStore.getSpaceUsed(), which is the equivalent method. This method is now final in order to catch any implementations that should switch over to AbstractRoutingContentStore.getSpaceUsed().

Specified by:
getTotalSize in interface ContentStore
See Also:
ContentStore.getSpaceFree(), ContentStore.getSpaceTotal()

getSpaceUsed

public long getSpaceUsed()
Description copied from interface: ContentStore
Calculates the total size of stored content, excluding any other data in the underlying storage.

NOTE: Calculating this value can be time-consuming - use sparingly.

NOTE: For efficiency, some implementations may provide a guess. If not, this call could take a long time.

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

getSpaceFree

public long getSpaceFree()
Description copied from interface: ContentStore
Calcualates the remaing 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 Long.MAX_VALUE 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 Long.MAX_VALUE always

exists

public boolean exists(java.lang.String contentUrl)
               throws org.alfresco.service.cmr.repository.ContentIOException
Description copied from interface: ContentStore
Check for the existence of content in the store.

The implementation of this may be more efficient than first getting a reader to check for existence, although that check should also be performed.

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.
Throws:
org.alfresco.service.cmr.repository.ContentIOException - if an IO error occurs
See Also:
AbstractRoutingContentStore.selectReadStore(String)

getReader

public org.alfresco.service.cmr.repository.ContentReader getReader(java.lang.String contentUrl)
                                                            throws org.alfresco.service.cmr.repository.ContentIOException
Description copied from interface: ContentStore
Get the accessor with which to read from the content at the given URL. The reader is stateful and can only be used once.

Specified by:
getReader in interface ContentStore
Parameters:
contentUrl - the path to where the content is located
Returns:
Returns a valid reader from one of the stores otherwise a EmptyContentReader is returned.
Throws:
org.alfresco.service.cmr.repository.ContentIOException - if an IO error occurs
See Also:
ContentStore.exists(String), ContentReader.exists(), EmptyContentReader

getWriter

public org.alfresco.service.cmr.repository.ContentWriter getWriter(ContentContext context)
                                                            throws org.alfresco.service.cmr.repository.ContentIOException
Selects a store for the given context and caches store that was used.

Specified by:
getWriter in interface ContentStore
Parameters:
context - the context of content.
Returns:
Returns a write-only content accessor
Throws:
org.alfresco.service.cmr.repository.ContentIOException - if an IO error occurs
See Also:
AbstractRoutingContentStore.selectWriteStore(ContentContext)

getWriter

public org.alfresco.service.cmr.repository.ContentWriter getWriter(org.alfresco.service.cmr.repository.ContentReader existingContentReader,
                                                                   java.lang.String newContentUrl)
                                                            throws org.alfresco.service.cmr.repository.ContentIOException
Description copied from interface: ContentStore
Shortcut method to ContentStore.getWriter(ContentContext).

Specified by:
getWriter in interface ContentStore
Throws:
org.alfresco.service.cmr.repository.ContentIOException
See Also:
ContentStore.getWriter(ContentContext)

getUrls

public void getUrls(ContentStore.ContentUrlHandler handler)
             throws org.alfresco.service.cmr.repository.ContentIOException
Description copied from interface: ContentStore
Get all URLs for the store, regardless of creation time.

Specified by:
getUrls in interface ContentStore
Throws:
org.alfresco.service.cmr.repository.ContentIOException - if an IO error occurs
See Also:
ContentStore.getUrls(Date, Date, ContentUrlHandler)

getUrls

public void getUrls(java.util.Date createdAfter,
                    java.util.Date createdBefore,
                    ContentStore.ContentUrlHandler handler)
             throws org.alfresco.service.cmr.repository.ContentIOException
Passes the call to each of the stores wrapped by this store

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:
org.alfresco.service.cmr.repository.ContentIOException - if an error occurs
See Also:
ContentStore.getUrls(Date, Date, ContentUrlHandler)

delete

public boolean delete(java.lang.String contentUrl)
               throws org.alfresco.service.cmr.repository.ContentIOException
This operation has to be performed on all the stores in order to maintain the ContentStore.exists(String) contract.

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:
org.alfresco.service.cmr.repository.ContentIOException - if an error occurs if an IO error occurs


Copyright © 2005 - 2010 Alfresco Software, Inc. All Rights Reserved.