示例#1
0
 /**
  * @param $mimeType
  * @param $file
  */
 private function ingestAsset($mimeType, $file)
 {
     $msg = "Ingesting asset: {$file}";
     $this->report[] = $msg;
     static::$logger->addInfo($msg);
     //        $file = str_replace(' ','\ ',$file);
     //        $msg = "Fixed spaces in file path: $file";
     //        $this->report[] = $msg;
     //        static::$logger->addInfo( $msg );
     $service = new MetadataBuilderService();
     $data = $service->analyze('staging://' . $file);
     $filepath = $this->config->get('staging.local') . DS . $file;
     if (!$data) {
         $this->reject($filepath);
         // despool doesn't care if we return anything in particular
         // it will just dish up the next item for processing
         return;
     }
     $filer = new AssetFiler($filepath, $this->target_vol);
     $msg = "Filing derived properties";
     $this->report[] = $msg;
     static::$logger->info($msg);
     $filer->derivedProperties($data);
     $msg = "Finalizing ingest: calling filer to move files";
     $this->report[] = $msg;
     static::$logger->info($msg);
     $filer->ingest($mimeType);
     $msg = "Ingested: {$mimeType}";
     $this->report[] = $msg;
     static::$logger->info($msg);
 }
示例#2
0
 public function rebuildAsset($uuid)
 {
     $asset = static::$disk->asset($uuid);
     $asset_path = $asset->parent()->parent()->parent()->protocol() . $asset->parent()->parent()->name() . DS . $asset->parent()->name() . DS . $uuid;
     static::$logger->info(__CLASS__ . '::' . __FUNCTION__ . ':  rebuilding metadata: ' . $asset_path);
     $asset_json = $asset_path . '.json';
     $asset_binary = $asset_path . '.' . $asset->extension();
     if (static::$manager->has($asset_binary)) {
         static::$logger->info(__CLASS__ . '::' . __FUNCTION__ . ':  exists: ' . $asset_binary);
         // this class will take over from ingest this functionality
         $service = new MetadataBuilderService();
         // pass in the asset file's path
         $new_md_json = $service->analyze($asset_binary);
         $new_md_json->{'created'} = time();
         static::$logger->info(__CLASS__ . '::' . __FUNCTION__ . ': MD:  ' . json_encode($new_md_json, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES));
         // new md is not complete - need basics from the asset instance to wrap it up
         $asset->derivedProperties($new_md_json);
         $json = $asset->toJson();
         static::$logger->debug($json);
         // write it
         static::$manager->put($asset_json, $json);
     } else {
         static::$logger->info(__CLASS__ . '::' . __FUNCTION__ . ':  does not exist: ' . $asset_binary);
     }
     return true;
 }