Пример #1
0
 private static function getFSInfo(core_kernel_versioning_Repository $fileSystem)
 {
     if (is_null(self::$cache)) {
         try {
             self::$cache = common_cache_FileCache::singleton()->get(self::SERIAL);
         } catch (common_cache_NotFoundException $e) {
             self::$cache = array();
         }
     }
     if (!isset(self::$cache[$fileSystem->getUri()])) {
         $props = $fileSystem->getPropertiesValues(array(PROPERTY_GENERIS_VERSIONEDREPOSITORY_PATH, PROPERTY_GENERIS_VERSIONEDREPOSITORY_TYPE));
         if (count($props[PROPERTY_GENERIS_VERSIONEDREPOSITORY_PATH]) == 1 && count($props[PROPERTY_GENERIS_VERSIONEDREPOSITORY_TYPE]) == 1) {
             self::$cache[$fileSystem->getUri()] = array(PROPERTY_GENERIS_VERSIONEDREPOSITORY_PATH => current($props[PROPERTY_GENERIS_VERSIONEDREPOSITORY_PATH]), PROPERTY_GENERIS_VERSIONEDREPOSITORY_TYPE => current($props[PROPERTY_GENERIS_VERSIONEDREPOSITORY_TYPE]));
             common_cache_FileCache::singleton()->put(self::$cache, self::SERIAL);
         } else {
             throw new common_exception_InconsistentData('Filesystem ' . $fileSystem->getUri() . ' has ' . count($props[PROPERTY_GENERIS_VERSIONEDREPOSITORY_PATH]) . ' path entries and ' . count($props[PROPERTY_GENERIS_VERSIONEDREPOSITORY_PATH]) . ' type entries');
         }
     }
     return self::$cache[$fileSystem->getUri()];
 }
Пример #2
0
 /**
  * Set the default file source for TAO File Upload.
  *
  * @access public
  * @author Jerome Bogaerts, <*****@*****.**>
  * @param  Repository source The repository to be used as the default TAO File Upload Source.
  * @return void
  */
 public function setUploadFileSource(core_kernel_versioning_Repository $source)
 {
     $ext = common_ext_ExtensionsManager::singleton()->getExtensionById('tao');
     $ext->setConfig(self::CONFIG_UPLOAD_FILESOURCE, $source->getUri());
 }
 private function getOneRepository()
 {
     $repository = null;
     if (!is_null($this->defaultRepository) && $this->defaultRepository instanceof core_kernel_versioning_Repository) {
         $repository = $this->defaultRepository;
     } else {
         $versioningRepositoryClass = new core_kernel_classes_Class(CLASS_GENERIS_VERSIONEDREPOSITORY);
         $repositories = $versioningRepositoryClass->getInstances();
         $repository = null;
         if (!count($repositories)) {
             throw new Exception('no default repository exists in TAO');
         } else {
             $repository = array_pop($repositories);
             $repository = new core_kernel_versioning_Repository($repository->getUri());
             $this->defaultRepository = $repository;
         }
     }
     return $repository;
 }
 /**
  * sets the filesource to use for new items
  *
  * @access public
  * @author Joel Bout, <*****@*****.**>
  * @param  Repository filesource
  * @return mixed
  */
 public function setDefaultFilesource(core_kernel_versioning_Repository $filesource)
 {
     $ext = common_ext_ExtensionsManager::singleton()->getExtensionById('taoItems');
     $ext->setConfig(self::CONFIG_DEFAULT_FILESOURCE, $filesource->getUri());
 }
Пример #5
0
 /**
  * Import specific source from the repository to the given target at the given revision
  *
  * @access public
  * @author Cédric Alfonsi, <*****@*****.**>
  * @param  Repository vcs
  * @param  string src
  * @param  string target
  * @param  string message
  * @param  array options
  * @return core_kernel_file_File
  */
 public function import(core_kernel_versioning_Repository $vcs, $src, $target, $message = "", $options = array())
 {
     $returnValue = null;
     //Does not work in the current version of php (try later) https://bugs.php.net/bug.php?id=60293
     //$returnValue = svn_import($src, $target, true);
     $startTime = helpers_Time::getMicroTime();
     $saveResource = isset($options['saveResource']) && $options['saveResource'] ? true : false;
     if (!$vcs->authenticate()) {
         throw new core_kernel_versioning_exception_Exception('Authentication failed on fileSource ' . $vcs->getUri());
     }
     $repositoryUrl = $vcs->getUrl();
     $relativePath = substr($target, strlen($repositoryUrl));
     $absolutePath = $vcs->getPath() . $relativePath;
     /*
     // The resource could already exist, this is not a problem
     //check if the resource already exist
     if(helpers_File::resourceExists($absolutePath)){
     	throw new core_kernel_versioning_exception_ResourceAlreadyExistsException('The folder ('.$absolutePath.') already exists in the repository ('.$vcs->getPath().')');
     }
     // Same thing here
     //check if the file already exist
     else if(file_exists($absolutePath)){
     	throw new common_exception_FileAlreadyExists($absolutePath);
     }
     */
     //Copy the src folder to the target destination
     helpers_File::copy($src, $absolutePath);
     // Create the importFolder
     $importFolder = $vcs->createFile('', $relativePath);
     //			//Get status of the imported folder
     //			$importFolderStatus = $importFolder->getStatus(array('SHOW_UPDATES'=>false));
     //			$importFolderYetCommited = true;
     //			if($importFolderStatus == VERSIONING_FILE_STATUS_ADDED || $importFolderStatus == VERSIONING_FILE_STATUS_UNVERSIONED){
     //				$importFolderYetCommited = false;
     //			}
     //
     //			//If the import folder has been yet commited, commit its content
     //			if($importFolderYetCommited){
     //				$filesToCommit = tao_helpers_File::scandir($importFolder->getAbsolutePath());
     //				$pathsFilesToCommit = array();
     //				foreach($filesToCommit as $fileToCommit){
     //					$pathFileToCommit = $fileToCommit->getAbsolutePath();
     //					$pathsFilesToCommit[] = $pathFileToCommit;
     //					//Add content of the folder if it is not versioned or partially not versioned
     //					if(!core_kernel_versioning_FileProxy::add($importFolder, $pathFileToCommit, true, true)){
     //						throw new core_kernel_versioning_exception_Exception('unable to import the folder ('.$src.') to the destination ('.$target.'). The add step encountered a problem');
     //					}
     //				}
     //				//Commit all the files in one commit operation
     //				if(!core_kernel_versioning_FileProxy::commit($VersionedUnitFolderInstance, $pathsFilesToCommit)){
     //					throw new core_kernel_versioning_exception_Exception('unable to import the folder ('.$src.') to the destination ('.$target.'). The commit step encountered a problem');
     //				}
     //			}
     //			//Else commit itself
     //			else{
     //				//Add the folder
     //				if(!$importFolder->add(true, true)){
     //					throw new core_kernel_versioning_exception_Exception('unable to import the folder ('.$src.') to the destination ('.$target.'). The add step encountered a problem');
     //				}
     //				//And commit it
     //				if(!$importFolder->commit($message, true)){
     //					throw new core_kernel_versioning_exception_Exception('unable to import the folder ('.$src.') to the destination ('.$target.'). The commit step encountered a problem');
     //				}
     //			}
     //Add the folder
     if (!$importFolder->add(true, true)) {
         throw new core_kernel_versioning_exception_Exception('unable to import the folder (' . $src . ') to the destination (' . $target . '). The add step encountered a problem');
     }
     //And commit it
     if (!$importFolder->commit($message, true)) {
         throw new core_kernel_versioning_exception_Exception('unable to import the folder (' . $src . ') to the destination (' . $target . '). The commit step encountered a problem');
     }
     //Delete the resource if the developer does not want to keep a reference in the onthology
     if ($saveResource) {
         $returnValue = $importFolder;
     } else {
         $resourceToDelete = new core_kernel_classes_Resource($importFolder->getUri());
         $resourceToDelete->delete();
     }
     $endTime = helpers_Time::getMicroTime();
     common_Logger::i("svn_import (" . $src . ' -> ' . $target . ') -> ' . ($endTime - $startTime) . 's');
     return $returnValue;
 }