コード例 #1
0
 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);
 }
コード例 #2
0
 /**
  * @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');
 }
コード例 #3
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 {
         $path = self::autocompletePath($path);
     } catch (EyeException $e) {
         throw new EyeInvalidArgumentException($path . ' is not a valid path value.', 0, $e);
     }
     try {
         parent::__construct($path, $params);
     } catch (EyeException $e) {
         throw new EyeException('Unable to create ' . __CLASS__ . '.', 0, $e);
     }
 }
コード例 #4
0
ファイル: SysFile.php プロジェクト: DavidGarciaCat/eyeos
 /**
  * @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 = AdvancedPathLib::parse_url($path);
         if ($urlParts['scheme'] != self::URL_SCHEME_SYSTEM) {
             throw new EyeInvalidArgumentException($urlParts['scheme'] . ' is not a valid scheme for system file, expecting ' . self::URL_SCHEME_SYSTEM . '.');
         }
     } catch (EyeException $e) {
         throw new EyeInvalidArgumentException($path . ' is not a valid path value.', 0, $e);
     }
     try {
         parent::__construct($path, $params);
     } catch (EyeException $e) {
         throw new EyeException('Unable to create ' . __CLASS__, 0, $e);
     }
 }
コード例 #5
0
 /**
  * @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);
 }
コード例 #6
0
 /**
  * @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);
 }
コード例 #7
0
ファイル: VirtualFile.php プロジェクト: DavidGarciaCat/eyeos
 public function __construct($path, $params = null)
 {
     if (isset($params['realFile']) && $params['realFile'] !== null && !$params['realFile'] instanceof IFile) {
         $type = get_class($params['realFile']) ? get_class($params['realFile']) : gettype($params['realFile']);
         throw new EyeInvalidArgumentException('Invalid argument $params[\'realFile\']: was ' . $type . ', expecting IFile.');
     }
     $this->path = $path;
     $this->realFile = $params['realFile'];
     if (self::$Logger === null) {
         self::$Logger = Logger::getLogger('fileSystem.VirtualFile');
     }
 }
コード例 #8
0
 /**
  * 
  * @param EyeosAbstractVirtualFile $file
  * @param array $params
  */
 public function __construct(EyeosAbstractVirtualFile $file, $params = null)
 {
     $this->fileObject = $file;
     $this->realFileInputStream = $file->getRealFile()->getInputStream($params);
 }
コード例 #9
0
 public function listFiles($pattern = '*', $flags = AdvancedPathLib::GLOB_NORMAL)
 {
     $files = array();
     $urlParts = $this->getURLComponents();
     $isRoot = false;
     if (!isset($urlParts['principalname'])) {
         $isRoot = true;
     }
     // ROOT (workgroup://): list the workgroups the current user is member of
     if ($isRoot) {
         $UM = UMManager::getInstance();
         $currentUser = ProcManager::getInstance()->getCurrentProcess()->getLoginContext()->getEyeosUser();
         // Retrieve all user/workgroup assignations with current user
         $refAssignation = $UM->getNewUserWorkgroupAssignationInstance();
         $refAssignation->setUserId($currentUser->getId());
         $assignations = $UM->getAllUserWorkgroupAssignations($refAssignation);
         // Build an array(workgroupId => workgroupName) only with workgroups the user is MEMBER of
         $workgroups = array();
         foreach ($assignations as &$assignation) {
             $status = $assignation->getStatus();
             if ($status === WorkgroupConstants::STATUS_MEMBER) {
                 $workgroups[] = $UM->getWorkgroupById($assignation->getWorkgroupId())->getName();
             }
         }
         sort($workgroups);
         foreach ($workgroups as $workgroupName) {
             $files[] = FSI::getFile(self::URL_SCHEME_WORKGROUPFILES . '://' . self::URL_LOCATOR_CHAR . $workgroupName . '/');
         }
     } else {
         $files = parent::listFiles($pattern, $flags);
     }
     return $files;
 }
コード例 #10
0
ファイル: UserFile.php プロジェクト: DavidGarciaCat/eyeos
 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);
 }
コード例 #11
0
ファイル: SharedFile.php プロジェクト: DavidGarciaCat/eyeos
 public function isWritable()
 {
     if ($this->realFile === null) {
         //FIXME: Not sure! It depends on the role of the user in the workgroup!
         return true;
     }
     return parent::isWritable();
 }