|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.bibalex.daf.entities.phase.CheckStrategy org.bibalex.daf.entities.phase.StepThroughCheckStrategy
public class StepThroughCheckStrategy
Used to apply phase checks against a folder structure by evaluating one node at a time. The name 'StepThrough' refers to querying the file system at each step not one time in order to decrease memory consumption.
Field Summary | |
---|---|
private java.util.ArrayList<NameCountCompareTriple> |
filesCount
Stores each file as it is being visited and it physical count. |
private FileHandler |
handler
A handler to get information about the folder physically. |
private java.lang.String |
jobName
Holds the name of the job. |
Constructor Summary | |
---|---|
StepThroughCheckStrategy()
Creates a new instance of StepThroughCheckStrategy. |
Method Summary | |
---|---|
void |
applyChecks(PhysicalDef physicalDef,
java.lang.String jobPath,
FileHandler fileHandler,
PhysicalDef alternateDef,
java.lang.String alternatePath,
FileHandler alternateHandler)
Compares the folder structure against the given definition. |
private void |
checkFilesExist(FolderElement folder,
java.lang.String path)
Checks that each file type defined within the given FolderElement has a corresponding physical files. |
private void |
checkFoldersExist(FolderElement folder,
java.lang.String path)
Checks that each folder defined within the given FolderElement has a corresponding physical folder. |
private void |
checkFolderStructure(FolderElement folder,
java.lang.String folderPath)
Makes sure that folder structure conforms to the defintion. |
private void |
checkNoMoreFilesExist(FolderElement folder,
java.lang.String path,
NameCountCompareTriple[] files)
For a 'Restricted' mode folder, this method makes sure that no extra file types exists except for those specified in the definition. |
private void |
checkNoMoreFoldersExist(FolderElement folder,
java.lang.String path)
For a 'Restricted' mode folder, this method makes sure that no extra folders exists except for those specified in the definition. |
private void |
compareFiles(NameCountCompareTriple[] files)
Compare the files count. |
private void |
countAlternateFiles(PhysicalDef physicalDef,
java.lang.String path,
FileHandler handler)
Counts the files mentioned in the PhysicalDef. |
private void |
countFiles(FolderElement folder,
java.lang.String path,
FileHandler handler)
Count the files within the given folder. |
private int |
getCountByName(NameCountCompareTriple[] files,
java.lang.String name)
Gets the count associated with the given name. |
private FolderElement[] |
getTestFolders(FolderElement[] folders)
Gets the folders that will have their structure tested, that is folders with 'Create' attribute set to false. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private FileHandler handler
private java.util.ArrayList<NameCountCompareTriple> filesCount
private java.lang.String jobName
Constructor Detail |
---|
public StepThroughCheckStrategy()
Method Detail |
---|
public void applyChecks(PhysicalDef physicalDef, java.lang.String jobPath, FileHandler fileHandler, PhysicalDef alternateDef, java.lang.String alternatePath, FileHandler alternateHandler) throws PhaseCheckException
applyChecks
in class CheckStrategy
physicalDef
- The XML definition of the job folder.jobPath
- The complete path of the job folder. The path corresponds to the given PhysicalDef.
That is if the physicalDef is PrePhase then the path is FTP path and if the physicalDef is PostPhase then the path is local.fileHandler
- A concrete FileHandler to get information about the job folder. The handler corresponds to the given physicalDef.
That is if the given PhysicalDef is PrePhase then the handler is FTPImpl and if the PhysicalDef is PostPhase then the handler is LocalImpl.alternateDef
- The alternate XML definition of the job.
By alternate we mean if the given physicalDef is PrePhase then this should be PostPhase and vice versa.alternatePath
- The alternate path of the job folder.
By alternate we mean if the given job path is a local one then this will be a remote path and vice versa.alternateHandler
- A concrete FileHandler to get information about the folder physically.
By alternate we mean if the given handler is a FTPImpl then this one is LocalImpl and vice versa.
PhaseCheckException
- If the checks fails.private void checkFolderStructure(FolderElement folder, java.lang.String folderPath) throws PhaseCheckException
folder
- The folder definition in the XML file.folderPath
- The complete physical path corresponding to the folder being checked.
PhaseCheckException
- If the checking of the folder fails.private void checkFoldersExist(FolderElement folder, java.lang.String path) throws PhaseCheckException
folder
- The FolderElement that defines other elements within it.path
- The path of the physical folder that corresponds to the folder being tested.
PhaseCheckException
- If the folders defined in the FolderElement don't exist physically.private FolderElement[] getTestFolders(FolderElement[] folders)
folders
- The entire set of folders.
private void checkFilesExist(FolderElement folder, java.lang.String path) throws PhaseCheckException
folder
- The FolderElement that defines other elements within it.path
- The path of the physical folder that corresponds to the folder being tested.
PhaseCheckException
- If the file types defined in the FolderElement don't exist physically or comparing fails.private void checkNoMoreFoldersExist(FolderElement folder, java.lang.String path) throws PhaseCheckException
folder
- The FolderElement that defines other elements within it.path
- The path of the physical folder that corresponds to the folder being tested.
PhaseCheckException
- If extra folders are found.private void checkNoMoreFilesExist(FolderElement folder, java.lang.String path, NameCountCompareTriple[] files) throws PhaseCheckException
folder
- The FolderElement that defines other elements within it.path
- The path of the physical folder that corresponds to the folder being tested.files
- An array holding the name and the count of each file type.
PhaseCheckException
- If extra file types are found.private void countAlternateFiles(PhysicalDef physicalDef, java.lang.String path, FileHandler handler)
physicalDef
- The physical defintion describing the job.path
- The physical path of the job.handler
- The handler used to get information about the job.private void countFiles(FolderElement folder, java.lang.String path, FileHandler handler)
folder
- The FolderElement to count the files defined within it.path
- The path of the folder.handler
- The FileHandler used to count the files.private void compareFiles(NameCountCompareTriple[] files) throws PhaseCheckException
files
- A Hashtable that holds each FileElement and its physical count.
PhaseCheckException
- If the comparison fails.
A comparison can fail due to numerous reasons:
1) If the file doesn't have an associated entry doesn't have an entry in the given Hashtable.
2) If the file mentioned in the 'Compare' attribute doesn't have an entry in the given Hashtable.
3) The count of files doesn't match.private int getCountByName(NameCountCompareTriple[] files, java.lang.String name)
files
- An array holding the name and count of each file. The compare field is not used.name
- The name of the entry we are looking for.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |