|
CInbox (Common-Inbox)
0.1
Common functionality for ingesting files for archiving.
|
Public Member Functions | |
| __construct ($itemId, &$logger, $folderName, $baseFolder=null) | |
| isInitialized () | |
| isConfigured () | |
| setStatus ($status) | |
| getStatus () | |
| setItemId ($itemId) | |
| getItemId () | |
| isItemIdValid ($itemId, $itemIdValidRegEx) | |
| initItemSettings () | |
| initItem () | |
| callBucketScript ($script, &$bucket) | |
| getDefaultValues () | |
| runTask ($folder, $taskName, $itemSubDirs) | |
| process () | |
| finalize () | |
| canStart () | |
| setTempFolder ($tempFolder) | |
| removeTempFolder () | |
| getAge () | |
| lastChanged ($filter=null) | |
| updateTimestamp () | |
Public Member Functions inherited from CIFolder | |
| __construct (&$logger, $folderName, $baseFolder=null) | |
| setFolder ($folderName) | |
| moveFolder ($targetFolder) | |
| getLogger () | |
| setMoveLogs ($status) | |
| getMoveLogs () | |
| setParentItem (&$item) | |
| getParentItem () | |
| setParentFolder (&$folder) | |
| getParentFolder () | |
| hasParent () | |
| setBaseFolder ($baseFolder) | |
| getBaseFolder () | |
| getConfig () | |
| hasOwnConfig () | |
| getConfigForFolder ($arguments=null) | |
| getSubDir () | |
| getPathname () | |
| getFilename () | |
| setTempFolder ($tempFolder) | |
| getTempFolder () | |
| getTargetFolderRaw () | |
| isTargetAbsolute () | |
| getTargetFolder ($tempMask=null) | |
| getTargetFolderTemp ($targetFolder, $tempMask) | |
| logTargetFolder ($hasOwn=false, $isAbsolute=true) | |
| getChangelogFile () | |
Public Attributes | |
| $tryAgain = false | |
Config options | |
| const | CONF_SECTION_ITEM = '__INBOX__' |
| const | CONF_MAX_FOLDER_DEPTH = 'MAX_FOLDER_DEPTH' |
| const | CONF_ITEM_ID_VALID = 'ITEM_ID_VALID' |
| const | CONF_BUCKET_SCRIPT = 'BUCKET_SCRIPT' |
| const | CONF_COOLOFF_TIME = 'COOLOFF_TIME' |
| const | CONF_COOLOFF_FILTERS = 'COOLOFF_FILTERS' |
| const | CONF_TASKLIST = 'TASKLIST' |
Miscellaneous | |
| const | CHANGELOG_FILE = 'item_changelog.txt' |
Public Attributes inherited from CIFolder | |
| const | CONF_TARGET_FOLDER = 'TARGET_FOLDER' |
| const | CHANGELOG_FILE = 'folder_changelog.txt' |
Protected Member Functions | |
| initItemSubFolders ($folderName, $depth=null, $parent=null) | |
| initItemSubFolder ($folderName, $baseFolder, $parent) | |
Protected Attributes | |
| $itemId | |
| $initialized = false | |
| $configured = false | |
Protected Attributes inherited from CIFolder | |
| $logger | |
| $moveLogs = false | |
| $folderObj | |
| $config | |
| $tempFolder | |
| $changelog = null | |
| $parentItem | |
| $parentFolder | |
| $hasTargetFolder = null | |
Item states | |
| const | STATUS_TODO = 'TODO' |
| const | STATUS_IN_PROGRESS = 'IN_PROGRESS' |
| const | STATUS_DONE = 'DONE' |
| const | STATUS_ERROR = 'ERROR' |
| static | $itemStates |
This class is a logical representation of an CInbox Item. Each Item represents an archival package to regard as one.
Therefore, each Item requires a unique identifier (Item ID), which is also known in archival terms as "object identifier", "archive signature" or similar.
The list of tasks to be processed for each Item is handled in here.
| CIItem::callBucketScript | ( | $script, | |
| & | $bucket | ||
| ) |
This calls an external script with the ItemID as argument.
The output of that script will be used as-is and resolves the placeholder "[@BUCKET@]". This can be used to have a custom subfolder structure for each Item at the target destination.
For example: ItemID = VX-00815 Bucket = VX/00/VX-00815
As you can see in the example, the resulting subfolder structure creates something like "buckets" which divides the amount of ItemIDs over several subfolders, following a custom syntax (which would be in the external script).
| CIItem::canStart | ( | ) |
Returns 'true' if start condition for this item is fulfilled. False if item is not ready for processing yet.
| CIItem::finalize | ( | ) |
Do whatever things are to-be-done to finalize an item in order to proceed to the next one.
| CIItem::getAge | ( | ) |
Returns the "age" of an item.
Every change to a file/folder in the item resets the age. Can be used to determine if the item is still being written/changed or if it is safe to process it.
If the item's folder is empty, the modification time of the folder itself will be used.
| numeric | Age of the youngest file/folder in $folder. In minutes. |
| CIItem::getDefaultValues | ( | ) |
Set default values for Item settings. This must be loaded before 'loadSettings()' in order to have default values instead of empty values where no setting was configured in config file.
| CIItem::getStatus | ( | ) |
Returns the current status of this Item.
| CIItem::initItem | ( | ) |
Initialize an Item, so that everything's ready to begin processing the tasklist.
NOTE: initItemSettings() must have been run before!
The ItemID is checked against CONF_ITEM_ID_VALID. The bucket script is executed.
| CIItem::initItemSettings | ( | ) |
Load item configuration from INI file. It makes sure that placeholders are resolved and default values are loaded.
It sets the property $configured to true, to indicate that the item has been configured properly.
| boolean | 'true' if successful, 'false' if not. |
|
protected |
Recursion through subfolder structure of current item. Returns a flat array with: keys: foldernames (absolute) values: CIFolder (initialized with config and parent set)
| CIItem::isItemIdValid | ( | $itemId, | |
| $itemIdValidRegEx | |||
| ) |
Checks if itemId is valid, according to Regular Expressions in config file: #ITEM_ID_VALID
| string | itemId The itemId (=object identifier = archive signature) |
| string | itemIdValidRegEx Array of RegEx (string) from config file: #ITEM_ID_VALID |
| CIItem::lastChanged | ( | $filter = null | ) |
Used to determine the "cooloff" status of an item. It uses a temporary directory listing of the item's files/folders that it compares the current file/folder state.
The listing is created using Helper::dirlistToText().
| $filter | [Array] Optional list of associative keys of stat() values to exclude from comparison. $filter is forwarded as-is to Helper::dirlistToText() (as parameter $filter_keys). |
| $age | The duration since the last change (in minutes). |
| CIItem::removeTempFolder | ( | ) |
Deletes the item's temporary folder (including subfolders and files)
| CIItem::runTask | ( | $folder, | |
| $taskName, | |||
| $itemSubDirs | |||
| ) |
Instantiates and runs the task defined by $taskName on the given $folder. $folder must be an object of class type "CIFolder" and must already be initialized properly before.
$subDirs must be supplied with the output of "initItemSubFolders()".
The return value is the task instance itself, which allows the calling function to access all information to decide how to proceed. See "CITask" for details about Task statuses.
| CIItem::setStatus | ( | $status | ) |
Sets the current status of this Item to $status.
| CIItem::updateTimestamp | ( | ) |
Updates the item's source timestamp to now.
|
static |
1.8.11