예제 #1
0
 /**
  * Perfom work.
  *
  * @param Opus_Job $job Job description and attached data.
  * @return array Array of Jobs to be newly created.
  */
 public function work(Opus_Job $job)
 {
     if ($job->getLabel() != $this->getActivationLabel()) {
         throw new Opus_Job_Worker_InvalidJobException($job->getLabel() . " is not a suitable job for this worker.");
     }
     $data = $job->getData();
     if (!(is_object($data) && isset($data->xml) && !is_null($data->xml))) {
         throw new Opus_Job_Worker_InvalidJobException("Incomplete or missing data.");
     }
     if (null !== $this->_logger) {
         $this->_logger->debug("Importing Metadata:\n" . $data->xml);
     }
     $importer = new Opus_Util_MetadataImport($data->xml);
     $importer->run();
 }
예제 #2
0
 public function run($options)
 {
     $consoleConf = array('lineFormat' => '[%1$s] %4$s');
     $logfileConf = array('append' => false, 'lineFormat' => '%4$s');
     $this->_console = Log::factory('console', '', '', $consoleConf, PEAR_LOG_INFO);
     if (count($options) < 2) {
         $this->_console->log('Missing parameter: no file to import.');
         return;
     }
     $logfilePath = 'reject.log';
     if (count($options) > 2) {
         // logfile path is given
         $logfilePath = $options[2];
     }
     $this->_logfile = Log::factory('file', $logfilePath, '', $logfileConf, PEAR_LOG_INFO);
     $xmlFile = $options[1];
     $importer = new Opus_Util_MetadataImport($xmlFile, true, $this->_console, $this->_logfile);
     $importer->run();
 }