Beispiel #1
0
 public static function autocompletePath($path)
 {
     if (is_array($path)) {
         $urlParts &= $path;
     } else {
         $urlParts = EyeosAbstractVirtualFile::parse_url($path);
     }
     if ($urlParts['scheme'] != self::URL_SCHEME_USERFILES) {
         throw new EyeInvalidArgumentException($urlParts['scheme'] . ' is not a valid scheme for user file, expecting ' . self::URL_SCHEME_USERFILES . '.');
     }
     if (!isset($urlParts['principalname'])) {
         try {
             $currentProc = ProcManager::getInstance()->getCurrentProcess();
             if ($currentProc !== null) {
                 $logionContext = $currentProc->getLoginContext();
                 if ($logionContext !== null) {
                     $user = $logionContext->getEyeosUser();
                     if ($user !== null) {
                         $urlParts['host'] = self::URL_LOCATOR_CHAR . $user->getName();
                         $urlParts['principalname'] = $user->getName();
                     } else {
                         throw new EyeNullPointerException('No EyeosUser found in current login context.');
                     }
                 } else {
                     throw new EyeNullPointerException('No login context available.');
                 }
             } else {
                 throw new EyeNullPointerException('No current process found.');
             }
         } catch (Exception $e) {
             throw new EyeInvalidArgumentException('Unable to find which username to use for given path "' . $path . '".');
         }
     }
     return EyeosAbstractVirtualFile::buildUrl($urlParts);
 }
 protected static function getNewProviderInstance($mountpointPath)
 {
     $urlParts = EyeosAbstractVirtualFile::parse_url($mountpointPath);
     $userMountpointConfigPath = self::getUserMountpointsPath($urlParts['principalname']);
     $conf = FSI::getConfiguration(EyeosAbstractVirtualFile::URL_SCHEME_USERFILES . '.scheme' . SERVICE_FILESYSTEM_CONFIGURATION_FILE_EXTENSION);
     $providerClassName = (string) $conf->mountpointsManager[0]->provider['class'];
     $params = array('filePath' => $userMountpointConfigPath);
     return MountpointsManager::getNewMountpointDescriptorsProviderInstance($providerClassName, $params);
 }
 /**
  * @param string $path
  * @param SimpleXMLElement $xmlConf
  * @return AbstractFile
  */
 public static function getRealFile($path, $xmlParams = null, $params = null)
 {
     $urlParts = EyeosAbstractVirtualFile::parse_url($path, AdvancedPathLib::OS_UNIX);
     if (!isset($urlParts['principalname'])) {
         return null;
     }
     //$currentUser = ProcManager::getInstance()->getCurrentProcess()->getLoginContext()->getEyeosUser();
     //$shareInfo = SharingManager::getInstance()->getAllShareInfoFromCollaborator($currentUser, null, 'EyeosAbstractVirtualFile');
 }
 /**
  * @param string $path
  * @param SimpleXMLElement $xmlConf
  * @return AbstractFile
  */
 public static function getRealFile($path, $xmlParams = null, $params = null)
 {
     $urlParts = EyeosAbstractVirtualFile::parse_url($path, AdvancedPathLib::OS_UNIX);
     if (!isset($urlParts['principalname'])) {
         throw new EyeInvalidArgumentException('Missing username in given path "' . $path . '".');
     }
     $workgroupConfPath = WORKGROUPS_PATH . '/' . $urlParts['principalname'] . '/' . WORKGROUPS_CONF_DIR;
     if (!is_dir($workgroupConfPath)) {
         try {
             if (!mkdir($workgroupConfPath, 0777, true)) {
                 throw new EyeIOException('Unable to create workgroup files directory ' . $workgroupConfPath);
             }
         } catch (EyeErrorException $e) {
             throw new EyeIOException('Unable to create workgroup files directory ' . $workgroupConfPath . '.', 0, $e);
         }
     }
     return new LocalFile($workgroupConfPath . $urlParts['path'], $params);
 }
 /**
  * @param string $path
  * @param SimpleXMLElement $xmlConf
  * @return AbstractFile
  */
 public static function getRealFile($path, $xmlParams = null, $params = null)
 {
     $urlParts = EyeosAbstractVirtualFile::parse_url($path, AdvancedPathLib::OS_UNIX);
     if (!isset($urlParts['principalname'])) {
         throw new EyeInvalidArgumentException('Missing username in given path "' . $path . '".');
     }
     $userFilesPath = UMManager::getEyeosUserDirectory($urlParts['principalname']) . '/' . USERS_FILES_DIR;
     if (!is_dir($userFilesPath)) {
         try {
             if (!mkdir($userFilesPath, 0777, true)) {
                 throw new EyeIOException('Unable to create user files directory ' . $userFilesPath);
             }
         } catch (EyeErrorException $e) {
             throw new EyeIOException('Unable to create user files directory ' . $userFilesPath . '.', 0, $e);
         }
     }
     return new LocalFile($userFilesPath . $urlParts['path'], $params);
 }
Beispiel #6
0
 /**
  * @param string $path The path to the file (MUST BE A VALID URL)
  * @param mixed $params Additional arguments (could be useful for derivated classes)
  * @throws EyeInvalidArgumentException
  * @throws EyeMissingArgumentException
  * @throws EyeNullPointerException
  */
 public function __construct($path, $params = null)
 {
     try {
         $urlParts = EyeosAbstractVirtualFile::parse_url($path);
         if ($urlParts['scheme'] != self::URL_SCHEME_SHARE) {
             throw new EyeInvalidArgumentException($urlParts['scheme'] . ' is not a valid scheme for user file, expecting ' . self::URL_SCHEME_SHARE . '.');
         }
     } catch (EyeException $e) {
         throw new EyeInvalidArgumentException($path . ' is not a valid path value.', 0, $e);
     }
     if (isset($urlParts['principalname']) && $urlParts['path'] != '/') {
         throw new EyeInvalidArgumentException($path . ' is not a valid URL value: the path part should be empty.');
     }
     try {
         parent::__construct($path, $params);
     } catch (EyeException $e) {
         throw new EyeException('Unable to create ' . __CLASS__ . '.', 0, $e);
     }
 }