org.alfresco.repo.content.filestore
Class FileContentStore

java.lang.Object
  extended by org.alfresco.repo.content.AbstractContentStore
      extended by org.alfresco.repo.content.filestore.FileContentStore
All Implemented Interfaces:
ContentStore

public class FileContentStore
extends AbstractContentStore

Provides a store of node content directly to the file system. The writers are generated using information from the simple content context.

The file names obey, as they must, the URL naming convention as specified in the ContentStore interface.


Nested Class Summary
 
Nested classes/interfaces inherited from interface org.alfresco.repo.content.ContentStore
ContentStore.ContentUrlHandler
 
Field Summary
static java.lang.String STORE_PROTOCOL
          store is the new prefix for file content URLs
 
Fields inherited from interface org.alfresco.repo.content.ContentStore
NEW_CONTENT_CONTEXT, PROTOCOL_DELIMITER
 
Constructor Summary
FileContentStore(java.io.File rootDirectory)
           
FileContentStore(java.lang.String rootDirectoryStr)
           
 
Method Summary
static java.lang.String createNewFileStoreUrl()
          Creates a new content URL.
 boolean delete(java.lang.String contentUrl)
          Attempts to delete the content.
 boolean exists(java.lang.String contentUrl)
          Performs a direct check against the file for its existence.
 ContentReader getReader(java.lang.String contentUrl)
          This implementation requires that the URL start with FileContentStore.STORE_PROTOCOL.
 void getUrls(java.util.Date createdAfter, java.util.Date createdBefore, ContentStore.ContentUrlHandler handler)
          Override to provide an implementation.
 ContentWriter getWriterInternal(ContentReader existingContentReader, java.lang.String newContentUrl)
          Implement to supply a store-specific writer for the given existing content and optional target content URL.
 boolean isWriteSupported()
          Check if the store supports write requests.
 void setAllowRandomAccess(boolean allowRandomAccess)
          Stores may optionally produce readers and writers that support random access.
 void setReadOnly(boolean readOnly)
          File stores may optionally be declared read-only.
 java.lang.String toString()
           
 
Methods inherited from class org.alfresco.repo.content.AbstractContentStore
getContentUrlParts, getUrls, getWriter, getWriter, isContentUrlSupported, isValidContentUrl
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

STORE_PROTOCOL

public static final java.lang.String STORE_PROTOCOL
store is the new prefix for file content URLs

See Also:
ContentStore.PROTOCOL_DELIMITER, Constant Field Values
Constructor Detail

FileContentStore

public FileContentStore(java.lang.String rootDirectoryStr)
Parameters:
rootDirectoryStr - the root under which files will be stored. The directory will be created if it does not exist.
See Also:
FileContentStore.FileContentStore(File)

FileContentStore

public FileContentStore(java.io.File rootDirectory)
Parameters:
rootDirectory - the root under which files will be stored. The directory will be created if it does not exist.
Method Detail

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

setAllowRandomAccess

public void setAllowRandomAccess(boolean allowRandomAccess)
Stores may optionally produce readers and writers that support random access. Switch this off for this store by setting this to false.

This switch is primarily used during testing to ensure that the system has the ability to spoof random access in cases where the store is unable to produce readers and writers that allow random access. Typically, stream-based access would be an example.

Parameters:
allowRandomAccess - true to allow random access, false to have it faked

setReadOnly

public void setReadOnly(boolean readOnly)
File stores may optionally be declared read-only. This is useful when configuring a store, possibly temporarily, to act as a source of data but to preserve it against any writes.

Parameters:
readOnly - true to force the store to only allow reads.

isWriteSupported

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

Returns:
Returns true always

exists

public boolean exists(java.lang.String contentUrl)
Performs a direct check against the file for its existence.

Specified by:
exists in interface ContentStore
Overrides:
exists in class AbstractContentStore
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.
See Also:
ContentReader.exists()

getReader

public ContentReader getReader(java.lang.String contentUrl)
This implementation requires that the URL start with FileContentStore.STORE_PROTOCOL.

Parameters:
contentUrl - the path to where the content is located
Returns:
Returns a read-only content accessor for the given URL. There may be no content at the given URL, but the reader must still be returned.
See Also:
ContentStore.exists(String), ContentReader.exists(), EmptyContentReader

getWriterInternal

public ContentWriter getWriterInternal(ContentReader existingContentReader,
                                       java.lang.String newContentUrl)
Description copied from class: AbstractContentStore
Implement to supply a store-specific writer for the given existing content and optional target content URL.

Overrides:
getWriterInternal in class AbstractContentStore
Parameters:
existingContentReader - a reader onto any content to initialize the new writer with
newContentUrl - an optional target for the new content
Returns:
Returns a writer onto a location based on the date

getUrls

public void getUrls(java.util.Date createdAfter,
                    java.util.Date createdBefore,
                    ContentStore.ContentUrlHandler handler)
Description copied from class: AbstractContentStore
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
Overrides:
getUrls in class AbstractContentStore
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

delete

public boolean delete(java.lang.String contentUrl)
Attempts to delete the content. The actual deletion is optional on the interface so it just returns the success or failure of the underlying delete.

Specified by:
delete in interface ContentStore
Overrides:
delete in class AbstractContentStore
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:
java.lang.UnsupportedOperationException - if the store is read-only
See Also:
FileContentStore.setReadOnly(boolean)

createNewFileStoreUrl

public static java.lang.String createNewFileStoreUrl()
Creates a new content URL. This must be supported by all stores that are compatible with Alfresco.

Returns:
Returns a new and unique content URL


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