Class FileContentStore
- java.lang.Object
-
- org.alfresco.repo.content.AbstractContentStore
-
- org.alfresco.repo.content.filestore.FileContentStore
-
- All Implemented Interfaces:
java.util.EventListener,org.alfresco.repo.content.ContentStore,org.springframework.beans.factory.Aware,org.springframework.context.ApplicationContextAware,org.springframework.context.ApplicationListener<org.springframework.context.ApplicationEvent>
@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 thesimple 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
Fields Modifier and Type Field Description static java.lang.StringSPOOF_PROTOCOLstatic java.lang.StringSTORE_PROTOCOLstore is the default prefix for file content URLs-
Fields inherited from class org.alfresco.repo.content.AbstractContentStore
contentLimitProvider
-
-
Constructor Summary
Constructors Constructor Description FileContentStore(org.springframework.context.ApplicationContext context, java.io.File rootDirectory)Public constructor for programmatic use.FileContentStore(org.springframework.context.ApplicationContext context, java.io.File rootDirectory, java.util.Map<java.lang.String,java.io.Serializable> extendedEventParams)FileContentStore(org.springframework.context.ApplicationContext context, java.lang.String rootDirectoryStr)Public constructor for programmatic use.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static java.lang.StringcreateNewFileStoreUrl()Creates a new content URL.booleandelete(java.lang.String contentUrl)Attempts to delete the content.booleanexists(java.lang.String contentUrl)Performs a direct check against the file for its existence.org.alfresco.service.cmr.repository.ContentReadergetReader(java.lang.String contentUrl)This implementation requires that the URL start withSTORE_PROTOCOLorSPOOF_PROTOCOLjava.lang.StringgetRootLocation()longgetSpaceFree()Get the filesystem's free space.longgetSpaceTotal()Get the filesystem's total space.org.alfresco.service.cmr.repository.ContentWritergetWriterInternal(org.alfresco.service.cmr.repository.ContentReader existingContentReader, java.lang.String newContentUrl)Returns a writer onto a location based on the date.booleanisWriteSupported()voidonApplicationEvent(org.springframework.context.ApplicationEvent event)voidsetAllowRandomAccess(boolean allowRandomAccess)Stores may optionally produce readers and writers that support random access.voidsetApplicationContext(org.springframework.context.ApplicationContext applicationContext)voidsetDeleteEmptyDirs(boolean deleteEmptyDirs)Configure the FileContentStore to delete empty parent directories upon deleting a content URL.voidsetFileContentUrlProvider(FileContentUrlProvider fileContentUrlProvider)voidsetReadOnly(boolean readOnly)File stores may optionally be declared read-only.java.lang.StringtoString()-
Methods inherited from class org.alfresco.repo.content.AbstractContentStore
getContentUrlParts, getWriter, isContentUrlSupported, isValidContentUrl, setContentLimitProvider
-
-
-
-
Field Detail
-
STORE_PROTOCOL
public static final java.lang.String STORE_PROTOCOL
store is the default prefix for file content URLs- See Also:
ContentStore.PROTOCOL_DELIMITER, Constant Field Values
-
SPOOF_PROTOCOL
public static final java.lang.String SPOOF_PROTOCOL
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
FileContentStore
public FileContentStore(org.springframework.context.ApplicationContext context, java.lang.String rootDirectoryStr)Public constructor for programmatic use.- Parameters:
context- application context through which events can be publishedrootDirectoryStr- 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, java.io.File rootDirectory)Public constructor for programmatic use.- Parameters:
context- application context through which events can be publishedrootDirectory- 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, java.io.File rootDirectory, java.util.Map<java.lang.String,java.io.Serializable> extendedEventParams)
-
-
Method Detail
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
setApplicationContext
public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext) throws org.springframework.beans.BeansException- Specified by:
setApplicationContextin interfaceorg.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()
- Specified by:
isWriteSupportedin interfaceorg.alfresco.repo.content.ContentStore- Returns:
- Returns true always
-
exists
public boolean exists(java.lang.String contentUrl)
Performs a direct check against the file for its existence. ForspoofedURLs, the URL always exists.- Specified by:
existsin interfaceorg.alfresco.repo.content.ContentStore- Overrides:
existsin classAbstractContentStore
-
getSpaceFree
public long getSpaceFree()
Get the filesystem's free space.- Specified by:
getSpaceFreein interfaceorg.alfresco.repo.content.ContentStore- Overrides:
getSpaceFreein classAbstractContentStore- Returns:
- Returns the root directory partition's
free space
-
getSpaceTotal
public long getSpaceTotal()
Get the filesystem's total space.- Specified by:
getSpaceTotalin interfaceorg.alfresco.repo.content.ContentStore- Overrides:
getSpaceTotalin classAbstractContentStore- Returns:
- Returns the root directory partition's
total space
-
getRootLocation
public java.lang.String getRootLocation()
- Specified by:
getRootLocationin interfaceorg.alfresco.repo.content.ContentStore- Overrides:
getRootLocationin classAbstractContentStore- Returns:
- Returns the canonical path to the root directory
-
getReader
public org.alfresco.service.cmr.repository.ContentReader getReader(java.lang.String contentUrl)
This implementation requires that the URL start withSTORE_PROTOCOLorSPOOF_PROTOCOL- Specified by:
getReaderin interfaceorg.alfresco.repo.content.ContentStore
-
getWriterInternal
public org.alfresco.service.cmr.repository.ContentWriter getWriterInternal(org.alfresco.service.cmr.repository.ContentReader existingContentReader, java.lang.String newContentUrl)Returns a writer onto a location based on the date.- Overrides:
getWriterInternalin classAbstractContentStore- Parameters:
existingContentReader- the existing content readernewContentUrl- the new content url- Returns:
- Returns a writer onto a location based on the date
-
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:
deletein interfaceorg.alfresco.repo.content.ContentStore- Overrides:
deletein classAbstractContentStore- Throws:
java.lang.UnsupportedOperationException- if the store is read-only- See Also:
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
-
onApplicationEvent
public void onApplicationEvent(org.springframework.context.ApplicationEvent event)
- Specified by:
onApplicationEventin interfaceorg.springframework.context.ApplicationListener<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
-
-