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.filestore
Class FileContentStore
java.lang.Object
  org.alfresco.repo.content.AbstractContentStore
      org.alfresco.repo.content.filestore.FileContentStore
All Implemented Interfaces:
org.springframework.context.ApplicationContextAware, org.springframework.beans.factory.Aware, org.springframework.context.ApplicationListener<org.springframework.context.ApplicationEvent>, EventListener, ContentStore

@org.alfresco.api.AlfrescoPublicApi
public class FileContentStore
extends AbstractContentStore
implements org.springframework.context.ApplicationContextAware, org.springframework.context.ApplicationListener<org.springframework.context.ApplicationEvent>
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.
The protocols handled are:

Author:
Derek Hulley

Field Summary
static String
SPOOF_PROTOCOL
static String
STORE_PROTOCOL
           store is the default prefix for file content URLs
Fields inherited from class org.alfresco.repo.content.AbstractContentStore
contentLimitProvider
Fields inherited from interface org.alfresco.repo.content.ContentStore
NEW_CONTENT_CONTEXT, PROTOCOL_DELIMITER
Constructor Summary
FileContentStore(org.springframework.context.ApplicationContext context, File rootDirectory)
          Public constructor for programmatic use.
FileContentStore(org.springframework.context.ApplicationContext context, File rootDirectory, Map<String,Serializable> extendedEventParams)
FileContentStore(org.springframework.context.ApplicationContext context, String rootDirectoryStr)
          Public constructor for programmatic use.
Method Summary
static String
createNewFileStoreUrl()
          Creates a new content URL.
boolean
delete(String contentUrl)
          Attempts to delete the content.
boolean
exists(String contentUrl)
          Performs a direct check against the file for its existence.
getReader(String contentUrl)
          This implementation requires that the URL start with STORE_PROTOCOL or SPOOF_PROTOCOL
getRootLocation()
          Get the location where the store is rooted.
long
getSpaceFree()
          Get the filesystem's free space.
long
getSpaceTotal()
          Get the filesystem's total space.
getWriterInternal(ContentReader existingContentReader, String newContentUrl)
          Returns a writer onto a location based on the date.
boolean
isWriteSupported()
          Check if the store supports write requests.
void
onApplicationEvent(org.springframework.context.ApplicationEvent event)
void
setAllowRandomAccess(boolean allowRandomAccess)
          Stores may optionally produce readers and writers that support random access.
void
setApplicationContext(org.springframework.context.ApplicationContext applicationContext)
void
setDeleteEmptyDirs(boolean deleteEmptyDirs)
          Configure the FileContentStore to delete empty parent directories upon deleting a content URL.
void
setFileContentUrlProvider(FileContentUrlProvider fileContentUrlProvider)
void
setReadOnly(boolean readOnly)
          File stores may optionally be declared read-only.
toString()
Methods inherited from class org.alfresco.repo.content.AbstractContentStore
getContentUrlParts, getWriter, isContentUrlSupported, isValidContentUrl, setContentLimitProvider
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Field Detail
SPOOF_PROTOCOL
public static final String SPOOF_PROTOCOL
See Also:
Constant Field Values

STORE_PROTOCOL
public static final String STORE_PROTOCOL
store is the default prefix for file content URLs
See Also:
ContentStore.PROTOCOL_DELIMITER, Constant Field Values
Constructor Detail
FileContentStore
public FileContentStore(org.springframework.context.ApplicationContext context,
                        String rootDirectoryStr)
Public constructor for programmatic use.
Parameters:
context - application context through which events can be published
rootDirectoryStr - the root under which files will be stored. The directory will be created if it does not exist.
See Also:
FileContentStore(File)

FileContentStore
public FileContentStore(org.springframework.context.ApplicationContext context,
                        File rootDirectory)
Public constructor for programmatic use.
Parameters:
context - application context through which events can be published
rootDirectory - the root under which files will be stored. The directory will be created if it does not exist.

FileContentStore
public FileContentStore(org.springframework.context.ApplicationContext context,
                        File rootDirectory,
                        Map<String,Serializable> extendedEventParams)
Method Detail
toString
public String toString()
Overrides:
toString in class Object

setApplicationContext
public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext)
                           throws org.springframework.beans.BeansException
Specified by:
setApplicationContext in interface org.springframework.context.ApplicationContextAware
Throws:
org.springframework.beans.BeansException

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.

setFileContentUrlProvider
public void setFileContentUrlProvider(FileContentUrlProvider fileContentUrlProvider)

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 always

exists
public boolean exists(String contentUrl)
Performs a direct check against the file for its existence. For spoofed URLs, the URL always exists.
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.

getSpaceFree
public long getSpaceFree()
Get the filesystem's free space.
Specified by:
getSpaceFree in interface ContentStore
Overrides:
getSpaceFree in class AbstractContentStore
Returns:
Returns the root directory partition's free space

getSpaceTotal
public long getSpaceTotal()
Get the filesystem's total space.
Specified by:
getSpaceTotal in interface ContentStore
Overrides:
getSpaceTotal in class AbstractContentStore
Returns:
Returns the root directory partition's total space

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
Overrides:
getRootLocation in class AbstractContentStore
Returns:
Returns the canonical path to the root directory

getReader
public ContentReader getReader(String contentUrl)
This implementation requires that the URL start with STORE_PROTOCOL or SPOOF_PROTOCOL
Specified by:
getReader in interface ContentStore
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.

getWriterInternal
public ContentWriter getWriterInternal(ContentReader existingContentReader,
                                       String newContentUrl)
Returns a writer onto a location based on the date.
Overrides:
getWriterInternal in class AbstractContentStore
Parameters:
existingContentReader - the existing content reader
newContentUrl - the new content url
Returns:
Returns a writer onto a location based on the date

delete
public boolean delete(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:
UnsupportedOperationException - if the store is read-only
See Also:
setReadOnly(boolean)

createNewFileStoreUrl
public static 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

onApplicationEvent
public void onApplicationEvent(org.springframework.context.ApplicationEvent event)
Specified by:
onApplicationEvent in interface org.springframework.context.ApplicationListener<E extends org.springframework.context.ApplicationEvent>

setDeleteEmptyDirs
public void setDeleteEmptyDirs(boolean deleteEmptyDirs)
Configure the FileContentStore to delete empty parent directories upon deleting a content URL.
Parameters:
deleteEmptyDirs - the deleteEmptyDirs to set

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.