|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.jalios.jcms.fileprocessor.repository.Repository
public class Repository
Represent a configuration of a repository.
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.
Field Summary | |
---|---|
static 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 : |
static String |
REVISION
|
Constructor Summary | |
---|---|
Repository(String id,
JProperties properties)
The constructor set some default value and then read the specified properties. |
Method Summary | |
---|---|
void |
addActionComponent(Class<? extends FileActionComponent> componentClazz,
String[] extensions)
Add the specified FileActionComponent (parser or processor) to this repository for the specified extensions. |
FileProcessingLog |
addFileProcessingLog(File file,
FileActionComponent component,
ProcessingType type,
ProcessingStatus status,
long duration,
Exception exception)
Create a new instance of FileProcessingLog with the specified parameters and store it. |
FileProcessingLog |
addFileProcessingLog(String filename,
Class<? extends FileActionComponent> componentClass,
ProcessingType type,
ProcessingStatus status,
long duration,
String message)
|
static String |
applySubstitutions(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(String filename,
Class<? extends FileActionComponent> actionComponentClass)
|
void |
deleteAllNonBlacklistedLogs()
Remove all successful logs from the database and update the remaining information. |
void |
deleteFileProcessingInfo(String filename)
Delete the FileProcessingInfo for the specified filename |
void |
deleteFileProcessingLog(String filename,
Class<? extends FileActionComponent> actionComponentClass)
Remove all log and info for the specified filename and component. |
void |
deleteFileProcessingLog(String filename,
String component)
|
boolean |
directoryIgnored(File file)
Tells if a directory under upload should be ignored given an exclusion pattern given by the property : |
FileActionComponent |
getActionComponent(Class<? extends FileActionComponent> componentClass)
Retrieve any instance already created for the specified FileActionComponent class. |
Set<Class<? extends FileActionComponent>> |
getActionComponentClassSet()
Retrieve a Set of all class FileActionComponent class registered for this repository |
String |
getAlarmManagerName()
|
Object |
getAttribute(Object name)
Returns the value of the named attribute as an Object ,
or null if no attribute of the given name exists. |
File |
getBaseDirectory()
|
String |
getBaseDirectoryPath()
Retrieve the base directory absolute path of this Repository |
Map<Class<? extends FileActionComponent>,SortedSet<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 |
List<ProcessingEvent> |
getEventList()
|
String |
getExcludedDirRegExp()
|
File |
getFile(String path)
Retrieve a File instance from the specified relative path |
String |
getFilenameRelativeToBaseDirectory(File file)
Retrieve the filename of the specified file relative to the base directory of this Repository. |
Set<Class<? extends FileParser>> |
getFileParserClassSet()
Retrieve a Set of all FileParser class. |
SortedSet<String> |
getFileParserExtensionSet()
Retrieve a Set of all extensions with at least one FileParser configured. |
SortedSet<? extends FileParser> |
getFileParserSet(String extension)
Retrieve a Set of all FileParser configured for the specified extension. |
FileProcessingInfo |
getFileProcessingInfo(File file)
Retrieve the FileProcessingInfo for the specified file in this repository and webapp instance (urid). |
FileProcessingInfo |
getFileProcessingInfo(String filename)
Retrieve the FileProcessingInfo for the specified file in this repository and webapp instance (urid). |
List<FileProcessingLog> |
getFileProcessingLogs(File file)
Retrieve all the FileProcessingLog for the specified file in this repository and webapp instance (urid). |
List<FileProcessingLog> |
getFileProcessingLogs(String filename)
Retrieve all the FileProcessingLog for the specified file in this repository and webapp instance (urid). |
Set<Class<? extends FileProcessor>> |
getFileProcessorClassSet()
Retrieve a Set of all FileProcessor class. |
SortedSet<String> |
getFileProcessorExtensionSet()
Retrieve a Set of all extensions with at least one FileProcessor configured. |
SortedSet<? extends FileProcessor> |
getFileProcessorSet(String extension)
Retrieve a Set of all FileProcessor configured for the specified extension. |
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. |
File |
getLuceneIndex()
|
long |
getMaxFilesPerScan()
|
String |
getName()
|
int |
getProcessingLimitDuration()
|
JProperties |
getRepositoryProperties()
|
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(File file,
Class<? extends FileActionComponent> clazz)
Test whether a file may be processed by a FileActionComponent. |
void |
logProcessingEvent(ProcessingEvent newAction)
|
boolean |
removeActionComponent(Class<? extends FileActionComponent> componentClass)
Remove the specified component class from this repository configuration. |
boolean |
removeActionComponent(Class<? extends FileActionComponent> componentClass,
String[] extensions)
Remove the specified component class from this repository configuration for the specified extension (if any). |
Object |
removeAttribute(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(String alarmManagerName)
|
Object |
setAttribute(String name,
Object obj)
Stores an attribute in this repository. |
void |
setBaseDirectory(File baseDirectory)
|
void |
setCreateAssociatedTextFile(boolean createAssociatedTextFile)
|
void |
setExcludedDirRegExp(String excludedDirRegExp)
|
void |
setId(String id)
|
void |
setIndexerClass(Class<? extends RepositoryIndexer> indexerClass)
|
void |
setLuceneIndex(File luceneIndex)
|
void |
setMaxFilesPerScan(long maxFilesPerScan)
|
void |
setName(String name)
|
void |
setProcessingLimitDuration(int processingLimitDuration)
|
void |
setRepositoryProperties(JProperties properties)
|
void |
setScheduleCron(String scheduleCron)
|
void |
setSchedulePeriod(int schedulePeriod)
Set the period in minutes between scan of the directory. |
String |
toStringConfiguration()
Convenient method to display configuration informations in logs. |
void |
unBlacklistFile(String filename,
Class<? extends FileActionComponent> actionComponentClass)
|
void |
updateAllFileProcessingInfo()
Create or Update all the FileProcessingInfo instance for this repository and webapp instance (urid). |
FileProcessingInfo |
updateFileProcessingInfo(File file,
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(String filename,
List<FileProcessingLog> logList)
|
boolean |
validate()
Validate the configuration is good for this repository. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String REVISION
public static final String CURRENT_REPOSITORY
Repository repository = (Repository) ctxt.get(Repository.CURRENT_REPOSITORY);
Constructor Detail |
---|
public Repository(String id, JProperties properties)
id
- the id of the repository to createproperties
- the properties to be used by this RepositoryMethod Detail |
---|
public boolean directoryIgnored(File file)
fileprocessor.repository.{repository-name}.excludedDirRegExp
file
- the directoy to check
public boolean validate()
public RepositoryIndexer getIndexer()
public boolean isIndexable()
public void setIndexerClass(Class<? extends RepositoryIndexer> indexerClass)
public String getId()
public void setId(String id)
public String getName()
public void setName(String name)
public FileActionComponent getActionComponent(Class<? extends FileActionComponent> componentClass)
componentClass
- the FileActionComponent class
public void addActionComponent(Class<? extends FileActionComponent> componentClazz, 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(Class<? extends FileActionComponent> componentClass)
componentClass
- the FileActionComponent class to remove
public boolean removeActionComponent(Class<? extends FileActionComponent> componentClass, 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 repository
public boolean isProcessedByActionComponentClass(File file, Class<? extends FileActionComponent> clazz)
Tested with the file's extension in this current implementation.
file
- the File to testclazz
- the class of the FileActionComponent
public Set<Class<? extends FileActionComponent>> getActionComponentClassSet()
public SortedSet<? extends FileProcessor> getFileProcessorSet(String extension)
extension
- a File extension, eg. "txt"
public SortedSet<String> getFileProcessorExtensionSet()
public Set<Class<? extends FileProcessor>> getFileProcessorClassSet()
public SortedSet<? extends FileParser> getFileParserSet(String extension)
extension
- a File extension, eg. "txt"
public SortedSet<String> getFileParserExtensionSet()
public Set<Class<? extends FileParser>> getFileParserClassSet()
public Map<Class<? extends FileActionComponent>,SortedSet<String>> getComponentClassToExtensionSetMap()
public File getBaseDirectory()
public void setBaseDirectory(File baseDirectory)
public File getLuceneIndex()
public void setLuceneIndex(File luceneIndex)
public int getSchedulePeriod()
public void setSchedulePeriod(int schedulePeriod)
schedulePeriod
- a period in minutespublic String getScheduleCron()
public void setScheduleCron(String scheduleCron)
public boolean hasSchedule()
public String getExcludedDirRegExp()
public void setExcludedDirRegExp(String excludedDirRegExp)
public long getMaxFilesPerScan()
public void setMaxFilesPerScan(long maxFilesPerScan)
public String toStringConfiguration()
public JProperties getRepositoryProperties()
public void setRepositoryProperties(JProperties properties)
public String getAlarmManagerName()
public void setAlarmManagerName(String alarmManagerName)
public String getFilenameRelativeToBaseDirectory(File file)
file
- any file under
docs/text/plain/foobar.txt
or
null if specified file was null or not inside repository base directorypublic File getFile(String path)
path
- a platform independant path relative to the repository base directory, eg : docs/text/plain/foobar.txt
public String getBaseDirectoryPath()
public int getProcessingLimitDuration()
public void setProcessingLimitDuration(int processingLimitDuration)
public boolean isCreateAssociatedTextFile()
public void setCreateAssociatedTextFile(boolean createAssociatedTextFile)
public List<FileProcessingLog> getFileProcessingLogs(File file)
file
- the file for which logs are retrieved
public List<FileProcessingLog> getFileProcessingLogs(String filename)
filename
- the file path relative to the base directory of the repository
public void updateAllFileProcessingInfo()
WARNING: VERY EXPENSIVE METHODS WHICH ITERATES ALL THE DATABASE ENTRY.
public FileProcessingInfo updateFileProcessingInfo(File file, List<FileProcessingLog> logList)
file
- the file for which FileProcessingInfo should be updatedlogList
- the logList from which info will be updated
public FileProcessingInfo updateFileProcessingInfo(String filename, List<FileProcessingLog> logList)
public FileProcessingInfo getFileProcessingInfo(File file)
file
- the File for which FileProcessingInfo is being retrieved
public FileProcessingInfo getFileProcessingInfo(String filename)
filename
- the file path relative to the base directory of the repository
public void deleteFileProcessingInfo(String filename)
filename
- the filename relative to the repository base directorypublic FileProcessingLog addFileProcessingLog(File file, FileActionComponent component, ProcessingType type, ProcessingStatus status, long duration, 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 processing
public FileProcessingLog addFileProcessingLog(String filename, Class<? extends FileActionComponent> componentClass, ProcessingType type, ProcessingStatus status, long duration, String message)
public void deleteFileProcessingLog(String filename, 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(String filename, String component)
public void blacklistFile(String filename, Class<? extends FileActionComponent> actionComponentClass)
public void unBlacklistFile(String filename, Class<? extends FileActionComponent> actionComponentClass)
public void deleteAllNonBlacklistedLogs()
public Object setAttribute(String name, Object obj)
removeAttribute(java.lang.String)
.
name
- a String
specifying the name of the attributeobj
- the Object
to be stored
public Object getAttribute(Object name)
Object
,
or null
if no attribute of the given name exists.
name
- a String
specifying the name of the attribute
Object
containing the value of the attribute,
or null
if the attribute does not existpublic Object removeAttribute(String name)
name
- a String
specifying
public 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 String applySubstitutions(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 subsitution
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |