Ejemplo n.º 1
0
 /**
  * @param $target_vol
  * @return bool
  */
 public function ingest($target_vol)
 {
     static::$logger->addInfo("Ingest processing beginning");
     $this->report[] = 'Ingest begins: volume set: ' . $target_vol;
     // TODO make a config parameter
     if (!static::$manager->has('staging://default/' . $target_vol)) {
         $msg = 'No such volume found in staging directory: nothing to do.';
         static::$logger->alert(__CLASS__ . '::' . __FUNCTION__ . ': ' . $msg);
         $this->report[] = $msg;
         return false;
     }
     $this->target_vol = $target_vol;
     $ss = new SchemaService();
     $this->schemas = $ss->schemas();
     static::$logger->addInfo("Loaded " . count($this->schemas) . " schemas.");
     if (count($this->schemas) < 1) {
         static::$logger->addCritical("No schemas: run failed.");
         $this->report[] = 'No schemas found: run failed';
         $this->errors[] = 'No schema documents found. The system requires at least a default schema.';
         return false;
     }
     if (!($cnt = $this->loadSpools())) {
         static::$logger->addWarning("Nothing on spools: run failed.");
         $this->report[] = 'Nothing on the spools: run failed';
         return false;
     }
     $this->report[] = 'Spooled: ' . $cnt . ' assets';
     if (!static::$manager->has('default://' . $target_vol)) {
         if (!static::$manager->createDir('default://' . $target_vol)) {
             $msg = "Failed to make target directory: {$target_vol}";
             $this->report[] = $msg . ': run failed';
             $this->errors[] = $msg . ' Check file permissions for data directory.';
             static::$logger->addCritical($msg . ': run failed.');
             return false;
         }
         $msg = "Created target directory.";
         static::$logger->addInfo($msg);
     }
     $msg = "Begin despooling...";
     $this->report[] = $msg;
     static::$logger->addInfo($msg);
     $mimeTypes = array_keys($this->spool);
     foreach ($mimeTypes as $mimeType) {
         foreach ($this->spool[$mimeType] as $file) {
             if (strpos($file, '.') !== 0) {
                 $this->ingestAsset($mimeType, $file);
             }
         }
     }
     $msg = "Finished despooling. Processing complete.";
     $this->report[] = $msg;
     static::$logger->addInfo($msg);
     return true;
 }
Ejemplo n.º 2
0
 public function schemaListPOST(Request $request, Response $response, $args)
 {
     $this->logger->info(__CLASS__ . '::' . __FUNCTION__);
     $parsed = $request->getParsedBody();
     $fetch_me = $parsed['fetch_me'];
     $this->logger->info(__CLASS__ . '::' . __FUNCTION__ . ': fetch_me: ' . $fetch_me);
     $service = new SchemaService();
     $this->logger->info(__CLASS__ . '::' . __FUNCTION__ . ': have SchemaService instance.');
     $schemas = [];
     if ($fetch_me == 'all') {
         $this->logger->info(__CLASS__ . '::' . __FUNCTION__ . ': fetch all');
         $schemas = $service->schemas();
     } else {
         $this->logger->debug(__CLASS__ . '::' . __FUNCTION__ . ': $fetch_me: (mimeType): ' . $fetch_me);
         $schemas[$fetch_me] = $service->schema($fetch_me);
     }
     $this->logger->debug(__CLASS__ . '::' . __FUNCTION__ . ': count($schemas): ' . count($schemas));
     $text = serialize($schemas);
     return $response->getBody()->write($text);
 }