public class Repository
extends java.lang.Object
A repository is a directory in which a scan will be done.
A repository configuration is composed of :
RepositoryIndexer
; validate()
method exists to see if all requirements are respected.
All registration of processors are done using the Class object of these processors.
Instanciation of processorss is done lasily at a first call to getFileProcessorSet(String)
,
after a modification in registration.
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
CURRENT_REPOSITORY
When a FileActionComponent (FileProcessor or FileParser) is invoked,
the repository for which it is invoked is availble through the
processing context using this attribute :
Repository repository = (Repository) ctxt.get(Repository.CURRENT_REPOSITORY);
|
static java.lang.String |
REVISION |
Constructor and Description |
---|
Repository(java.lang.String id,
JProperties properties)
The constructor set some default value and then read the specified properties.
|
Modifier and Type | Method and Description |
---|---|
void |
addActionComponent(java.lang.Class<? extends FileActionComponent> componentClazz,
java.lang.String[] extensions)
Add the specified FileActionComponent (parser or processor) to this repository for the specified extensions.
|
FileProcessingLog |
addFileProcessingLog(java.io.File file,
FileActionComponent component,
ProcessingType type,
ProcessingStatus status,
long duration,
java.lang.Exception exception)
Create a new instance of FileProcessingLog with the specified parameters and store it.
|
FileProcessingLog |
addFileProcessingLog(java.lang.String filename,
java.lang.Class<? extends FileActionComponent> componentClass,
ProcessingType type,
ProcessingStatus status,
long duration,
java.lang.String message) |
static java.lang.String |
applySubstitutions(java.lang.String abstractFileName,
Repository repository)
Returns a String constructed from the abstractFileName in parameter where :
<realpath> is replaced by the absolute real path of the webapp
<uploadpath> is replaced by the absolute real path of the upload/ directory in the webapp
<webinfpath> is replaced by the absolute real path of the WEB-INF/ directory in the webapp
<datapath> is replaced by the absolute real path of the WEB-INF/data/ directory in the webapp
<jcmsuploadindexpath> is replaced by the absolute real path of the WEB-INF/data/lucene/FilesIndex/ directory in the webapp
<repositoryid> is replaced by the id of the repository
<junit> is replaced by the -junit string
|
void |
blacklistFile(java.lang.String filename,
java.lang.Class<? extends FileActionComponent> actionComponentClass) |
void |
deleteAllNonBlacklistedLogs()
Remove all successful logs from the database and update the remaining information.
|
void |
deleteFileProcessingInfo(java.lang.String filename)
Delete the FileProcessingInfo for the specified filename
|
void |
deleteFileProcessingLog(java.lang.String filename,
java.lang.Class<? extends FileActionComponent> actionComponentClass)
Remove all log and info for the specified filename and component.
|
void |
deleteFileProcessingLog(java.lang.String filename,
java.lang.String component) |
boolean |
directoryIgnored(java.io.File file)
Tells if a directory under upload should be ignored given an exclusion pattern given
by the property :
fileprocessor.repository.
|
FileActionComponent |
getActionComponent(java.lang.Class<? extends FileActionComponent> componentClass)
Retrieve any instance already created for the specified FileActionComponent class.
|
java.util.Set<java.lang.Class<? extends FileActionComponent>> |
getActionComponentClassSet()
Retrieve a Set of all class FileActionComponent class registered for this repository
|
java.lang.String |
getAlarmManagerName() |
java.lang.Object |
getAttribute(java.lang.Object name)
Returns the value of the named attribute as an
Object ,
or null if no attribute of the given name exists. |
java.io.File |
getBaseDirectory() |
java.lang.String |
getBaseDirectoryPath()
Retrieve the base directory absolute path of this Repository
|
java.util.Map<java.lang.Class<? extends FileActionComponent>,java.util.SortedSet<java.lang.String>> |
getComponentClassToExtensionSetMap()
Retrieve a map of all component class to the extensions registered for them.
|
DirectoryScanner |
getDirectoryScanner()
Retrieve the DirectoryScanner instance used for repository scan
|
java.util.List<ProcessingEvent> |
getEventList() |
java.lang.String |
getExcludedDirRegExp() |
java.io.File |
getFile(java.lang.String path)
Retrieve a File instance from the specified relative path
|
java.lang.String |
getFilenameRelativeToBaseDirectory(java.io.File file)
Retrieve the filename of the specified file relative to
the base directory of this Repository.
|
java.util.Set<java.lang.Class<? extends FileParser>> |
getFileParserClassSet()
Retrieve a Set of all FileParser class.
|
java.util.SortedSet<java.lang.String> |
getFileParserExtensionSet()
Retrieve a Set of all extensions with at least one FileParser configured.
|
java.util.SortedSet<? extends FileParser> |
getFileParserSet(java.lang.String extension)
Retrieve a Set of all FileParser configured for the specified extension.
|
FileProcessingInfo |
getFileProcessingInfo(java.io.File file)
Retrieve the FileProcessingInfo for the specified file in this repository and webapp instance (urid).
|
FileProcessingInfo |
getFileProcessingInfo(java.lang.String filename)
Retrieve the FileProcessingInfo for the specified file in this repository and webapp instance (urid).
|
java.util.List<FileProcessingLog> |
getFileProcessingLogs(java.io.File file)
Retrieve all the FileProcessingLog for the specified file in this repository and webapp instance (urid).
|
java.util.List<FileProcessingLog> |
getFileProcessingLogs(java.lang.String filename)
Retrieve all the FileProcessingLog for the specified file in this repository and webapp instance (urid).
|
java.util.Set<java.lang.Class<? extends FileProcessor>> |
getFileProcessorClassSet()
Retrieve a Set of all FileProcessor class.
|
java.util.SortedSet<java.lang.String> |
getFileProcessorExtensionSet()
Retrieve a Set of all extensions with at least one FileProcessor configured.
|
java.util.SortedSet<? extends FileProcessor> |
getFileProcessorSet(java.lang.String extension)
Retrieve a Set of all FileProcessor configured for the specified extension.
|
java.lang.String |
getId() |
RepositoryIndexer |
getIndexer()
For one repository, the way LuceneDocument are constructed from the content of a file
and the file itself, is specific to the structure of the index.
|
java.io.File |
getLuceneIndex() |
long |
getMaxFilesPerScan() |
java.lang.String |
getName() |
int |
getProcessingLimitDuration() |
JProperties |
getRepositoryProperties() |
java.lang.String |
getScheduleCron()
Retrieve the cron defining rythm of scan of the directory.
|
int |
getSchedulePeriod()
Retrieve the period in minutes between scan of the directory.
|
boolean |
hasSchedule()
Check if this repository at a scanning scheduled defined.
|
boolean |
isCreateAssociatedTextFile() |
boolean |
isIndexable() |
boolean |
isProcessedByActionComponentClass(java.io.File file,
java.lang.Class<? extends FileActionComponent> clazz)
Test whether a file may be processed by a FileActionComponent.
|
void |
logProcessingEvent(ProcessingEvent newAction) |
boolean |
removeActionComponent(java.lang.Class<? extends FileActionComponent> componentClass)
Remove the specified component class from this repository configuration.
|
boolean |
removeActionComponent(java.lang.Class<? extends FileActionComponent> componentClass,
java.lang.String[] extensions)
Remove the specified component class from this repository configuration for the specified extension (if any).
|
java.lang.Object |
removeAttribute(java.lang.String name)
Removes an attribute from this repository.
|
boolean |
scanNow()
Trigger the repository scan now, in its specific thread (not in the current thread).
|
void |
setAlarmManagerName(java.lang.String alarmManagerName) |
java.lang.Object |
setAttribute(java.lang.String name,
java.lang.Object obj)
Stores an attribute in this repository.
|
void |
setBaseDirectory(java.io.File baseDirectory) |
void |
setCreateAssociatedTextFile(boolean createAssociatedTextFile) |
void |
setExcludedDirRegExp(java.lang.String excludedDirRegExp) |
void |
setId(java.lang.String id) |
void |
setIndexerClass(java.lang.Class<? extends RepositoryIndexer> indexerClass) |
void |
setLuceneIndex(java.io.File luceneIndex) |
void |
setMaxFilesPerScan(long maxFilesPerScan) |
void |
setName(java.lang.String name) |
void |
setProcessingLimitDuration(int processingLimitDuration) |
void |
setRepositoryProperties(JProperties properties) |
void |
setScheduleCron(java.lang.String scheduleCron) |
void |
setSchedulePeriod(int schedulePeriod)
Set the period in minutes between scan of the directory.
|
java.lang.String |
toStringConfiguration()
Convenient method to display configuration informations in logs.
|
void |
unBlacklistFile(java.lang.String filename,
java.lang.Class<? extends FileActionComponent> actionComponentClass) |
void |
updateAllFileProcessingInfo()
Create or Update all the FileProcessingInfo instance for
this repository and webapp instance (urid).
|
FileProcessingInfo |
updateFileProcessingInfo(java.io.File file,
java.util.List<FileProcessingLog> logList)
Create, Update or Delete the FileProcessingInfo instance for the specified
file (in this repository and webapp instance, ie urid),
from the specified list of FileProcessingLog
|
FileProcessingInfo |
updateFileProcessingInfo(java.lang.String filename,
java.util.List<FileProcessingLog> logList) |
boolean |
validate()
Validate the configuration is good for this repository.
|
public static final java.lang.String REVISION
public static final java.lang.String CURRENT_REPOSITORY
Repository repository = (Repository) ctxt.get(Repository.CURRENT_REPOSITORY);
public Repository(java.lang.String id, JProperties properties)
id
- the id of the repository to createproperties
- the properties to be used by this Repositorypublic boolean directoryIgnored(java.io.File file)
fileprocessor.repository.{repository-name}.excludedDirRegExp
file
- the directoy to checkpublic boolean validate()
public RepositoryIndexer getIndexer()
public boolean isIndexable()
public void setIndexerClass(java.lang.Class<? extends RepositoryIndexer> indexerClass)
public java.lang.String getId()
public void setId(java.lang.String id)
public java.lang.String getName()
public void setName(java.lang.String name)
public FileActionComponent getActionComponent(java.lang.Class<? extends FileActionComponent> componentClass)
componentClass
- the FileActionComponent classpublic void addActionComponent(java.lang.Class<? extends FileActionComponent> componentClazz, java.lang.String[] extensions)
componentClazz
- the class of the component to add, must not be nullextensions
- the extension for which the FileActionComponent will be configured, must not be null or empty (otherwise method will have no effect)public boolean removeActionComponent(java.lang.Class<? extends FileActionComponent> componentClass)
componentClass
- the FileActionComponent class to removepublic boolean removeActionComponent(java.lang.Class<? extends FileActionComponent> componentClass, java.lang.String[] extensions)
componentClass
- the FileActionComponent class to removeextensions
- the extension for which the FileActionComponent will be removed, if null or empty, the component will be completely removed from repositorypublic boolean isProcessedByActionComponentClass(java.io.File file, java.lang.Class<? extends FileActionComponent> clazz)
Tested with the file's extension in this current implementation.
file
- the File to testclazz
- the class of the FileActionComponentpublic java.util.Set<java.lang.Class<? extends FileActionComponent>> getActionComponentClassSet()
public java.util.SortedSet<? extends FileProcessor> getFileProcessorSet(java.lang.String extension)
extension
- a File extension, eg. "txt"public java.util.SortedSet<java.lang.String> getFileProcessorExtensionSet()
public java.util.Set<java.lang.Class<? extends FileProcessor>> getFileProcessorClassSet()
public java.util.SortedSet<? extends FileParser> getFileParserSet(java.lang.String extension)
extension
- a File extension, eg. "txt"public java.util.SortedSet<java.lang.String> getFileParserExtensionSet()
public java.util.Set<java.lang.Class<? extends FileParser>> getFileParserClassSet()
public java.util.Map<java.lang.Class<? extends FileActionComponent>,java.util.SortedSet<java.lang.String>> getComponentClassToExtensionSetMap()
public java.io.File getBaseDirectory()
public void setBaseDirectory(java.io.File baseDirectory)
public java.io.File getLuceneIndex()
public void setLuceneIndex(java.io.File luceneIndex)
public int getSchedulePeriod()
public void setSchedulePeriod(int schedulePeriod)
schedulePeriod
- a period in minutespublic java.lang.String getScheduleCron()
public void setScheduleCron(java.lang.String scheduleCron)
public boolean hasSchedule()
public java.lang.String getExcludedDirRegExp()
public void setExcludedDirRegExp(java.lang.String excludedDirRegExp)
public long getMaxFilesPerScan()
public void setMaxFilesPerScan(long maxFilesPerScan)
public java.lang.String toStringConfiguration()
public JProperties getRepositoryProperties()
public void setRepositoryProperties(JProperties properties)
public java.lang.String getAlarmManagerName()
public void setAlarmManagerName(java.lang.String alarmManagerName)
public java.lang.String getFilenameRelativeToBaseDirectory(java.io.File file)
file
- any file underdocs/text/plain/foobar.txt
or
null if specified file was null or not inside repository base directorypublic java.io.File getFile(java.lang.String path)
path
- a platform independant path relative to the repository base directory, eg : docs/text/plain/foobar.txt
public java.lang.String getBaseDirectoryPath()
public int getProcessingLimitDuration()
public void setProcessingLimitDuration(int processingLimitDuration)
public boolean isCreateAssociatedTextFile()
public void setCreateAssociatedTextFile(boolean createAssociatedTextFile)
public java.util.List<FileProcessingLog> getFileProcessingLogs(java.io.File file)
file
- the file for which logs are retrievedpublic java.util.List<FileProcessingLog> getFileProcessingLogs(java.lang.String filename)
filename
- the file path relative to the base directory of the repositorypublic void updateAllFileProcessingInfo()
WARNING: VERY EXPENSIVE METHODS WHICH ITERATES ALL THE DATABASE ENTRY.
public FileProcessingInfo updateFileProcessingInfo(java.io.File file, java.util.List<FileProcessingLog> logList)
file
- the file for which FileProcessingInfo should be updatedlogList
- the logList from which info will be updatedpublic FileProcessingInfo updateFileProcessingInfo(java.lang.String filename, java.util.List<FileProcessingLog> logList)
public FileProcessingInfo getFileProcessingInfo(java.io.File file)
file
- the File for which FileProcessingInfo is being retrievedpublic FileProcessingInfo getFileProcessingInfo(java.lang.String filename)
filename
- the file path relative to the base directory of the repositorypublic void deleteFileProcessingInfo(java.lang.String filename)
filename
- the filename relative to the repository base directorypublic FileProcessingLog addFileProcessingLog(java.io.File file, FileActionComponent component, ProcessingType type, ProcessingStatus status, long duration, java.lang.Exception exception)
The new instance will uses this repository and current webapp URID.
file
- the file for which log must be addedcomponent
- the component for which log is addedtype
- the type of processing performedstatus
- the new processing statusduration
- the duration it took to processexception
- any exception that might have occured during processingpublic FileProcessingLog addFileProcessingLog(java.lang.String filename, java.lang.Class<? extends FileActionComponent> componentClass, ProcessingType type, ProcessingStatus status, long duration, java.lang.String message)
public void deleteFileProcessingLog(java.lang.String filename, java.lang.Class<? extends FileActionComponent> actionComponentClass)
Update the info if logs were partially deleted.
filename
- the filename relative to the repository base directoryactionComponentClass
- the FileActionComponent class concerned (optionnal)public void deleteFileProcessingLog(java.lang.String filename, java.lang.String component)
public void blacklistFile(java.lang.String filename, java.lang.Class<? extends FileActionComponent> actionComponentClass)
public void unBlacklistFile(java.lang.String filename, java.lang.Class<? extends FileActionComponent> actionComponentClass)
public void deleteAllNonBlacklistedLogs()
public java.lang.Object setAttribute(java.lang.String name, java.lang.Object obj)
removeAttribute(java.lang.String)
.name
- a String
specifying the name of the attributeobj
- the Object
to be storedpublic java.lang.Object getAttribute(java.lang.Object name)
Object
,
or null
if no attribute of the given name exists.name
- a String
specifying the name of the attributeObject
containing the value of the attribute,
or null
if the attribute does not existpublic java.lang.Object removeAttribute(java.lang.String name)
name
- a String
specifyingpublic java.util.List<ProcessingEvent> getEventList()
public void logProcessingEvent(ProcessingEvent newAction)
public DirectoryScanner getDirectoryScanner()
public boolean scanNow()
The scan will NOT be triggered if it already running.
public static java.lang.String applySubstitutions(java.lang.String abstractFileName, Repository repository)
<realpath>
is replaced by the absolute real path of the webapp <uploadpath>
is replaced by the absolute real path of the upload/
directory in the webapp <webinfpath>
is replaced by the absolute real path of the WEB-INF/
directory in the webapp <datapath>
is replaced by the absolute real path of the WEB-INF/data/
directory in the webapp <jcmsuploadindexpath>
is replaced by the absolute real path of the WEB-INF/data/lucene/FilesIndex/
directory in the webapp <repositoryid>
is replaced by the id of the repository <junit>
is replaced by the -junit
string abstractFileName
- the filename in which any matching pattern is replaced as explained aboverepository
- the repository used for this subsitutionCopyright © 2001-2010 Jalios SA. All Rights Reserved.