CInbox (Common-Inbox)  0.1
Common functionality for ingesting files for archiving.
Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | List of all members
TaskHashSearch Class Reference
Inheritance diagram for TaskHashSearch:
TaskHash CITask

Public Member Functions

 __construct (&$CIFolder)
 
 init ()
 
 run ()
 
- Public Member Functions inherited from TaskHash
 __construct (&$CIFolder)
 
 loadHashFromFile ($fileName)
 
 getTempHashForFilename ($fileName)
 
 getHashTypesAllowed ()
 
- Public Member Functions inherited from CITask
 __construct (&$CIFolder, $label)
 
 getName ()
 
 setLabel ($label)
 
 getLabel ()
 
 setDescription ($description)
 
 getDescription ()
 
 skip ()
 
 skipIt ()
 
 setItemSubDirs ($itemSubDirs)
 
 getStatus ()
 
 statusUndefined ()
 
 statusRunning ()
 
 statusWait ()
 
 statusDone ()
 
 statusPBCT ()
 
 statusPBC ()
 
 statusSkipped ()
 
 statusError ()
 
 statusConfigError ()
 
 init ()
 
 run ()
 
 finalize ()
 

Public Attributes

const TASK_LABEL = 'Hashcode search'
 
const CONF_HASH_SEARCH = 'HASH_SEARCH'
 
const CONF_HASH_MUST_EXIST = 'HASH_MUST_EXIST'
 
- Public Attributes inherited from TaskHash
const TASK_LABEL = 'Hash Base (abstract)'
 
const CONF_HASH_TYPE = 'HASH_TYPE'
 
- Public Attributes inherited from CITask
const STATUS_UNDEFINED = 0
 Undefined. Default unless task changes it.
 
const STATUS_RUNNING = 1
 Undefined, but indicates that the task is in progress.
 
const STATUS_WAIT = 2
 Task decided that Item is not ready yet and shall be moved back to 'to-do'.
 
const STATUS_DONE = 5
 Success! This means the task completed successfully.
 
const STATUS_PBCT = 6
 There were problems, but the task may continue.
 
const STATUS_PBC = 7
 There were problems, but subsequent task may continue.
 
const STATUS_ERROR = 10
 An error occurred. Abort execution as soon as possible.
 
const STATUS_CONFIG_ERROR = 11
 If a config option was not valid.
 
const STATUS_SKIPPED = 15
 If task was skipped.
 
const ONCE_PER_ITEM = false
 True: Run this task only once per item.
 
const IS_RECURSIVE = false
 Default (false): one task = one folder. True: The task performs actions on subfolders too.
 
const CONF_COPY_EXCLUDE = 'COPY_EXCLUDE'
 Patterns which files to exclude from copying.
 
const MASK_TARGET_TEMP = 'temp_%s'
 

Protected Member Functions

 loadSettings ()
 
 searchHashCodes ($sourceFolder)
 
 searchHashCode ($sourceFolder, $hashCode)
 
 findHashInFile ($fileName, $hashCode)
 
 checkMustExist ($filesMatched)
 
- Protected Member Functions inherited from TaskHash
 loadSettings ()
 
 saveHashToFile ($fileName, $hashCode)
 
 getTempHashForFolder ($folderName)
 
 hashTypeIsAllowed ($hashType)
 
 generateHashcode ($hashType, $fileName)
 
 compareHashcode ($hash1, $hash2)
 
- Protected Member Functions inherited from CITask
 setName ($name)
 
 exclude ($file, $excludePatterns)
 
 optionIsArray ($option, $optionName)
 
 resolveTargetFolderTemp ($CIFolder=null)
 
 setStatus ($status)
 
 setStatusUndefined ()
 
 setStatusRunning ()
 
 setStatusWait ()
 
 setStatusDone ()
 
 setStatusPBCT ()
 
 setStatusPBC ()
 
 setStatusSkipped ()
 
 setStatusError ()
 
 setStatusConfigError ()
 
 checkTempFolder ()
 
 getTempFolder ()
 
 setTempFolder ($tempFolder=null)
 
 loadSettings ()
 

Protected Attributes

 $hashSearch
 
 $hashMustExist
 
- Protected Attributes inherited from TaskHash
 $hashType
 
- Protected Attributes inherited from CITask
 $logger
 Logging handler.
 
 $name
 Class name of this task.
 
 $label
 Human readable Task label.
 
 $description
 Human readable description of Task's purpose/actions.
 
 $CIFolder
 CIFolder object that provides all information needed for this task.
 
 $sourceFolder
 Source folder of this task.
 
 $targetFolder
 Target folder of this task (read from config).
 
 $targetFolderTemp
 Temporary name of Target folder of this task. Used until inbox processing completed successfully.
 
 $itemSubDirs
 Array of Item subfolders: key=foldername, value=CIFolder (initialized with its config).
 
 $tempFolder
 Path of the temp folder for this task.
 
 $copyExclude
 Contains the value of CONF_COPY_EXCLUDE.
 
 $skip = false
 True: Skip execution. Default=false (=normal execution).
 
 $status
 Status of this task (=for current item subfolder).
 

Additional Inherited Members

- Static Public Member Functions inherited from TaskHash
static getHashTempFilename ($fileName, $CIFolder, $hashType)
 
static removeHashTempFile ($fileName, $CIFolder, $hashType)
 
- Static Public Member Functions inherited from CITask
static isRecursive ()
 
static oncePerItem ()
 
static getTaskByName ($taskName, $CIFolder)
 
static getTaskClassName ($taskName)
 
- Static Protected Attributes inherited from CITask
static $statusGlobal
 Status of the sum of tasks of this type. // TODO! Implement and use this.
 

Detailed Description

For files matching 'HASH_MUST_EXIST', this task searches for existing hashes in files matching 'HASH_SEARCH' in the source folder in order to compare the current hashcode against it.

This allows to validate already existing hashes to document the chain of file transfer. It must be run after TaskHashGenerate, because the hashcodes are read from the temp-files created in that task.

Author
Peter Bubestinger-Steindl (pb@av.nosp@m.-rd..nosp@m.com)
See also

Member Function Documentation

TaskHashSearch::checkMustExist (   $filesMatched)
protected

Checks if all files in "$filesMatched" have a matching hashcode.

TaskHashSearch::findHashInFile (   $fileName,
  $hashCode 
)
protected

Searches the given hashcode in a file.

Returns
Array of String
Return values
linesMatchArray of the matching lines (if any were found).
NULLIf contents of hash-containing file ($fileName) were empty.
FALSEIf no lines matching the hashcode were found.
TaskHashSearch::init ( )

Prepare everything so it's ready for processing.

Returns
bool success True if init went fine, False if an error occurred.
TaskHashSearch::loadSettings ( )
protected

Load settings from config that are relevant for this task.

TaskHashSearch::run ( )

Perform the actual steps of this task.

TaskHashSearch::searchHashCode (   $sourceFolder,
  $hashCode 
)
protected

Tries to find the given hashcode in the source folder matching the glob patterns in "$this->hashSearch glob". Returns an array with key is filename where match was found - and value is an array of lines containing the hashcode. Returns false if no match is found.

TaskHashSearch::searchHashCodes (   $sourceFolder)
protected

Iterates through all files in source folder and searches for existing checksums.


The documentation for this class was generated from the following file: