Exemple #1
0
 public function archive($id, $guid)
 {
     global $mtlda, $mbus;
     if (empty($id) || !is_numeric($id)) {
         static::raiseError("id is invalid!");
         return false;
     }
     if (empty($guid) || !$mtlda->isValidGuidSyntax($guid)) {
         static::raiseError("guid is invalid!");
         return false;
     }
     if (!($obj = $mtlda->loadModel("queueitem", $id, $guid))) {
         static::raiseError("Unable to load model for {$id}, {$guid}");
         return false;
     }
     if ($obj->isProcessing()) {
         return true;
     }
     if (($file_hash = $obj->getFileHash()) === false) {
         static::raiseError(get_class($obj) . '::getFileHash() returned false!');
         return false;
     }
     if (empty($file_hash)) {
         static::raiseError("Found no file hash for QueueItemModel {$id}, {$guid}!");
         return false;
     }
     try {
         $archive = new \Mtlda\Controllers\ArchiveController();
     } catch (\Exception $e) {
         static::raiseError("Failed to load ArchiveController!");
         return false;
     }
     if (!$archive) {
         static::raiseError("Unable to load ArchiveController!");
         return false;
     }
     if (($dupl_item = $archive->checkForDuplicateFileByHash($file_hash)) === false) {
         static::raiseError("ArchiveController::checkForDuplicateFileByHash returned false!");
         return false;
     }
     if (!empty($dupl_item)) {
         static::raiseError("There is already an item with the same file hash in the archive!");
         return false;
     }
     if (!$mbus->sendMessageToClient('archive-reply', 'Invoking archive process.', '20%')) {
         static::raiseError(get_class($mbus) . '::sendMessageToClient() returned false!');
         return false;
     }
     if (!$archive->archive($obj)) {
         static::raiseError("ArchiveController::archive() exited with an error!");
         return false;
     }
     return true;
 }
Exemple #2
0
 protected function rpcDeleteExpiredDocuments()
 {
     try {
         $archive = new \Mtlda\Controllers\ArchiveController();
     } catch (\Exception $e) {
         static::raiseError(__METHOD__ . ', failed to load ArchiveController!');
         return false;
     }
     if (!$archive->deleteExpiredDocuments()) {
         static::raiseError(get_class($archive) . '::deleteExpiredDocuments() returned false!');
         return false;
     }
     return true;
 }
Exemple #3
0
 private function signDocument(&$document)
 {
     if (!is_a($document, "Mtlda\\Models\\DocumentModel")) {
         static::raiseError(__METHOD__ . ', can only work with DocumentModels!');
         return false;
     }
     if ($document->isSignedCopy()) {
         static::raiseError(__METHOD__ . ", will not resign an already signed document!");
         return false;
     }
     try {
         $archive = new \Mtlda\Controllers\ArchiveController();
     } catch (\Exception $e) {
         static::raiseError(__METHOD__ . '(), failed to load ArchiveController!');
         return false;
     }
     if (!$archive) {
         static::raiseError(__METHOD__ . '(), unable to load ArchiveController!');
         return false;
     }
     if (!$archive->sign($document)) {
         static::raiseError(get_class($archive) . '::sign() returned false!');
         return false;
     }
     return true;
 }