/** * export a compiled delivery into an archive * * @param core_kernel_classes_Resource $compiledDelivery * @throws Exception * @return string */ public static function exportCompiledDelivery(core_kernel_classes_Resource $compiledDelivery) { $fileName = tao_helpers_Display::textCleaner($compiledDelivery->getLabel()) . '.zip'; $path = tao_helpers_File::concat(array(tao_helpers_Export::getExportPath(), $fileName)); if (!tao_helpers_File::securityCheck($path, true)) { throw new Exception('Unauthorized file name'); } $zipArchive = new ZipArchive(); if ($zipArchive->open($path, ZipArchive::CREATE) !== true) { throw new Exception('Unable to create archive at ' . $path); } $taoDeliveryVersion = common_ext_ExtensionsManager::singleton()->getInstalledVersion('taoDelivery'); $data = array('dir' => array(), 'label' => $compiledDelivery->getLabel(), 'version' => $taoDeliveryVersion); $directories = $compiledDelivery->getPropertyValues(new core_kernel_classes_Property(PROPERTY_COMPILEDDELIVERY_DIRECTORY)); foreach ($directories as $id) { $directory = tao_models_classes_service_FileStorage::singleton()->getDirectoryById($id); tao_helpers_File::addFilesToZip($zipArchive, $directory->getPath(), $directory->getRelativePath()); $data['dir'][$id] = $directory->getRelativePath(); } $runtime = $compiledDelivery->getUniquePropertyValue(new core_kernel_classes_Property(PROPERTY_COMPILEDDELIVERY_RUNTIME)); $serviceCall = tao_models_classes_service_ServiceCall::fromResource($runtime); $data['runtime'] = base64_encode($serviceCall->serializeToString()); $rdfExporter = new tao_models_classes_export_RdfExporter(); $rdfdata = $rdfExporter->getRdfString(array($compiledDelivery)); if (!$zipArchive->addFromString('delivery.rdf', $rdfdata)) { throw common_Exception('Unable to add metadata to exported delivery assembly'); } $data['meta'] = 'delivery.rdf'; $content = json_encode($data); //'<?php return '.common_Utils::toPHPVariableString($data).";"; if (!$zipArchive->addFromString(self::MANIFEST_FILE, $content)) { $zipArchive->close(); unlink($path); throw common_Exception('Unable to add manifest to exported delivery assembly'); } $zipArchive->close(); return $path; }
private function migrateFsAccess() { $tao = \common_ext_ExtensionsManager::singleton()->getExtensionById('tao'); $config = $tao->getConfig('filesystemAccess'); if (is_array($config)) { foreach ($config as $id => $string) { list($class, $id, $fsUri, $jsconfig) = explode(' ', $string, 4); $config = json_decode($jsconfig, true); $options = array(TokenWebSource::OPTION_ID => $id, TokenWebSource::OPTION_FILESYSTEM_ID => $fsUri); switch ($class) { case 'tao_models_classes_fsAccess_TokenAccessProvider': $fs = new \core_kernel_fileSystem_FileSystem($fsUri); $options[TokenWebSource::OPTION_PATH] = $fs->getPath(); $options[TokenWebSource::OPTION_SECRET] = $config['secret']; $options[TokenWebSource::OPTION_TTL] = (int) ini_get('session.gc_maxlifetime'); $websource = new TokenWebSource($options); break; case 'tao_models_classes_fsAccess_ActionAccessProvider': $websource = new ActionWebSource($options); break; case 'tao_models_classes_fsAccess_DirectAccessProvider': $options[DirectWebSource::OPTION_URL] = $config['accessUrl']; $websource = new DirectWebSource($options); break; default: throw \common_Exception('unknown implementation ' . $class); } WebsourceManager::singleton()->addWebsource($websource); } } else { throw \common_Exception('Error reading former filesystem access configuration'); } return true; }