|
xmlBlaster 2.2.0 API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.xmlBlaster.contrib.filewatcher.DirectoryManager
public class DirectoryManager
DirectoryManager
Field Summary | |
---|---|
private boolean |
copyOnMove
|
private long |
delaySinceLastFileChange
|
private java.io.File |
directory
|
private java.util.Map |
directoryEntries
|
private java.lang.String |
directoryName
|
private java.io.File |
discardedDirectory
this is the name of the directory where files are moved if they could not be send (too big) |
private java.io.FileFilter |
fileFilter
all files matching the filter will be processed. |
private Global |
global
|
private java.lang.String |
lockExt
convenience for performance: if lockExtention is '*.gif', then this will be '.gif' |
private java.io.FileFilter |
lockExtention
if set, then files will only be published when the lock-file has been removed. |
private java.util.Set |
lockFiles
|
private static java.util.logging.Logger |
log
|
private java.lang.String |
ME
|
private java.io.File |
sentDirectory
this is the the directory where files are moved to after successful publishing. |
private java.lang.String |
subDirectoryName
|
Constructor Summary | |
---|---|
DirectoryManager(Global global,
java.lang.String name,
java.lang.String directoryName,
java.lang.String subDir,
long delaySinceLastFileChange,
java.lang.String filter,
java.lang.String sent,
java.lang.String discarded,
java.lang.String lockExtention,
boolean trueRegex,
boolean copyOnMove)
|
Method Summary | |
---|---|
private boolean |
deleteFile(java.io.File tempFile)
On Windows sometimes the file is not deleted (even if the stream.close() were called before) We try as long until the file is away See http://forum.java.sun.com/thread.jspa?forumID=4&threadID=158689 |
(package private) void |
deleteOrMoveEntry(java.lang.String entryName,
boolean success)
Removes the specified entry from the map. |
java.lang.String[] |
getAllSubDirs()
Returns null if no subdirectory found. |
byte[] |
getContent(FileInfo info)
Gets the content from the specified file as a byte[]. |
java.io.FileInputStream |
getContentStream(FileInfo info)
|
(package private) java.io.File |
getDir()
|
(package private) java.util.Set |
getEntries()
Gets all entries which are ready to be sent (i.e. |
private java.util.Map |
getNewFiles(java.io.File directory)
Retrieves all files from the specified directory |
java.lang.String |
getString()
|
java.lang.String |
getSubDir()
|
private java.io.File |
initDirectory(java.io.File parent,
java.lang.String propNameForLogging,
java.lang.String dirName)
Returns the specified directory or null or if needed it will create one |
static boolean |
isFileNameCasesensitive()
|
private boolean |
isReady(FileInfo info,
long currentTime)
Returns false if the info object is null, if the size is zero or if it has not passed sufficient time since the last change. |
static void |
main(java.lang.String[] args)
java org.xmlBlaster.contrib.filewatcher.DirectoryManager -path /tmp/filewatcher -filter "*.xml" -filterType simple |
private void |
moveTo(java.io.File file,
java.lang.String origName,
java.io.File destinationDirectory)
|
private java.util.TreeSet |
prepareEntries(java.util.Map existingFiles)
|
private static java.util.List |
scanSubdirs(java.io.File root,
java.lang.String prefix,
java.util.List subdirs,
java.util.List ignore)
|
private void |
updateExistingFiles(java.util.Map existingFiles,
java.util.Map newFiles)
It updates the existing list of files: - if a file which previously existed is not found in the new list anymore it is deleted - new files are added to the list - if something has changed (timestamp or size, then the corresponding info object is touched |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private java.lang.String ME
private Global global
private static java.util.logging.Logger log
private long delaySinceLastFileChange
private java.lang.String directoryName
private java.io.File directory
private java.io.File sentDirectory
private java.io.File discardedDirectory
private java.util.Map directoryEntries
private java.io.FileFilter fileFilter
private java.io.FileFilter lockExtention
private java.lang.String lockExt
private java.util.Set lockFiles
private boolean copyOnMove
private java.lang.String subDirectoryName
Constructor Detail |
---|
public DirectoryManager(Global global, java.lang.String name, java.lang.String directoryName, java.lang.String subDir, long delaySinceLastFileChange, java.lang.String filter, java.lang.String sent, java.lang.String discarded, java.lang.String lockExtention, boolean trueRegex, boolean copyOnMove) throws XmlBlasterException
XmlBlasterException
Method Detail |
---|
private static java.util.List scanSubdirs(java.io.File root, java.lang.String prefix, java.util.List subdirs, java.util.List ignore)
public java.lang.String[] getAllSubDirs()
private java.io.File initDirectory(java.io.File parent, java.lang.String propNameForLogging, java.lang.String dirName) throws XmlBlasterException
propName
- dirName
-
XmlBlasterException
private java.util.Map getNewFiles(java.io.File directory) throws XmlBlasterException
directory
-
XmlBlasterException
private boolean deleteFile(java.io.File tempFile)
tempFile
-
public static boolean isFileNameCasesensitive()
private boolean isReady(FileInfo info, long currentTime)
info
- currentTime
-
private java.util.TreeSet prepareEntries(java.util.Map existingFiles)
private void updateExistingFiles(java.util.Map existingFiles, java.util.Map newFiles)
existingFiles
- newFiles
- java.util.Set getEntries() throws XmlBlasterException
XmlBlasterException
- if the application has no read or write
rights on the directoryvoid deleteOrMoveEntry(java.lang.String entryName, boolean success) throws XmlBlasterException
entryName
- the name of the entry to remove.
XmlBlasterException
private void moveTo(java.io.File file, java.lang.String origName, java.io.File destinationDirectory) throws XmlBlasterException
XmlBlasterException
public java.io.FileInputStream getContentStream(FileInfo info) throws XmlBlasterException
XmlBlasterException
public byte[] getContent(FileInfo info) throws XmlBlasterException
info
-
XmlBlasterException
public java.lang.String getSubDir()
public static void main(java.lang.String[] args)
public java.lang.String getString()
java.io.File getDir()
|
xmlBlaster 2.2.0 API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |