Example #1
0
 public function performPreInstallTasks()
 {
     $o_config = Configuration::load();
     CompositeCache::flush();
     // avoid stale cache
     // create tmp dir
     if (!file_exists($o_config->get('taskqueue_tmp_directory'))) {
         if (!self::createDirectoryPath($o_config->get('taskqueue_tmp_directory'))) {
             $this->addError("Couldn't create tmp directory at " . $o_config->get('taskqueue_tmp_directory'));
             return false;
         }
     } else {
         // if already exists then remove all contents to avoid stale cache
         caRemoveDirectory($o_config->get('taskqueue_tmp_directory'), false);
     }
     // Create media directories
     $o_media_volumes = new MediaVolumes();
     $va_media_volumes = $o_media_volumes->getAllVolumeInformation();
     $vs_base_dir = $o_config->get('ca_base_dir');
     $va_dir_creation_errors = array();
     foreach ($va_media_volumes as $vs_label => $va_volume_info) {
         if (preg_match('!^' . $vs_base_dir . '!', $va_volume_info['absolutePath'])) {
             if (!self::createDirectoryPath($va_volume_info['absolutePath'])) {
                 $this->addError("Couldn't create directory for media volume {$vs_label}");
                 return false;
             }
         }
     }
     // nuke search index if we using ElasticSearch (the SqlSearch index is nuked when we drop the database)
     if ($o_config->get('search_engine_plugin') == 'ElasticSearch') {
         require_once __CA_LIB_DIR__ . '/core/Plugins/SearchEngine/ElasticSearch.php';
         $o_es = new WLPlugSearchEngineElasticSearch();
         $o_es->truncateIndex(null, true);
     }
     return true;
 }
Example #2
0
 public function performPreInstallTasks()
 {
     $o_config = Configuration::load();
     CompositeCache::flush();
     // avoid stale cache
     // create tmp dir
     if (!file_exists($o_config->get('taskqueue_tmp_directory'))) {
         if (!self::createDirectoryPath($o_config->get('taskqueue_tmp_directory'))) {
             $this->addError("Couldn't create tmp directory at " . $o_config->get('taskqueue_tmp_directory'));
             return false;
         }
     } else {
         // if already exists then remove all contents to avoid stale cache
         caRemoveDirectory($o_config->get('taskqueue_tmp_directory'), false);
     }
     // Create media directories
     $o_media_volumes = new MediaVolumes();
     $va_media_volumes = $o_media_volumes->getAllVolumeInformation();
     $vs_base_dir = $o_config->get('ca_base_dir');
     $va_dir_creation_errors = array();
     foreach ($va_media_volumes as $vs_label => $va_volume_info) {
         if (preg_match('!^' . $vs_base_dir . '!', $va_volume_info['absolutePath'])) {
             if (!self::createDirectoryPath($va_volume_info['absolutePath'])) {
                 $this->addError("Couldn't create directory for media volume {$vs_label}");
                 return false;
             }
         }
     }
     return true;
 }
 /**
  * Get list of mimetypes for which replication options are configured
  *
  * @return array
  */
 public static function getMediaReplicationMimeTypes()
 {
     $o_media_volumes = new MediaVolumes();
     $o_media_processing = new MediaProcessingSettings('ca_object_representations', 'media');
     $va_volumes = $o_media_volumes->getAllVolumeInformation();
     $va_mimetypes = array();
     foreach ($va_volumes as $vs_volume => $va_volume_info) {
         if (isset($va_volume_info['replication']) && is_array($va_volume_info['replication'])) {
             foreach ($va_volume_info['replication'] as $vs_target => $va_target_info) {
                 if (isset($va_target_info['mimetypes']) && is_array($va_target_info['mimetypes'])) {
                     $va_mimetype_list = $va_target_info['mimetypes'];
                 } else {
                     // get mimetypes for volume from media_processing
                     $va_mimetype_list = $o_media_processing->getMimetypesForVolume($vs_volume);
                 }
                 foreach ($va_mimetype_list as $vs_mimetype) {
                     $va_mimetypes[$vs_mimetype] = true;
                 }
             }
         }
     }
     return array_keys($va_mimetypes);
 }