ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilWebDAVUriPathResolver Class Reference

Class ilWebDAVUriPathResolver. More...

+ Collaboration diagram for ilWebDAVUriPathResolver:

Public Member Functions

 __construct (ilWebDAVRepositoryHelper $repo_helper)
 ilWebDAVUriPathResolver constructor. More...
 
 getRefIdForWebDAVPath (string $a_uri)
 Returns the ref_id of the given webdav path. More...
 

Protected Member Functions

 getRefIdFromPathInRepositoryMount (string $path_inside_of_mountpoint)
 Gets the ref_id from a searched object in the repository. More...
 
 getRefIdFromPathInRefMount (string $repository_mountpoint, string $path_inside_of_mountpoint)
 Gets the ref_id from a searched object in the repository. More...
 
 getRefIdFromGivenParentRefAndTitlePath (int $a_parent_ref, array $a_current_path_array)
 Searches an object inside the given path, starting at the given reference id. More...
 
 getChildRefIdByGivenTitle (int $a_parent_ref_id, string $a_searched_title)
 Searches for a an object with a specific title inside an other object (identified by ref_id) More...
 

Protected Attributes

 $repo_helper
 

Detailed Description

Class ilWebDAVUriPathResolver.

This class resolves given WebDAV-Uris and returns the reference id of the searched object.

Author
Raphael Heer rapha.nosp@m.el.h.nosp@m.eer@h.nosp@m.slu..nosp@m.ch $Id$

Definition at line 11 of file class.ilWebDAVUriPathResolver.php.

Constructor & Destructor Documentation

◆ __construct()

ilWebDAVUriPathResolver::__construct ( ilWebDAVRepositoryHelper  $repo_helper)

ilWebDAVUriPathResolver constructor.

Parameters
ilWebDAVRepositoryHelper$repo_helper

Definition at line 21 of file class.ilWebDAVUriPathResolver.php.

References $repo_helper.

22  {
23  $this->repo_helper = $repo_helper;
24  }

Member Function Documentation

◆ getChildRefIdByGivenTitle()

ilWebDAVUriPathResolver::getChildRefIdByGivenTitle ( int  $a_parent_ref_id,
string  $a_searched_title 
)
protected

Searches for a an object with a specific title inside an other object (identified by ref_id)

Note: This check is case sensitive, since URIS SHOULD BE case sensitive

Parameters
int$a_parent_ref_id
string$a_searched_title
Returns
int
Exceptions

Definition at line 174 of file class.ilWebDAVUriPathResolver.php.

Referenced by getRefIdFromGivenParentRefAndTitlePath().

174  : int
175  {
176  // Search if any child of the given ref has the name of the given searched element
177  foreach ($this->repo_helper->getChildrenOfRefId($a_parent_ref_id) as $child_ref) {
178  $child_title = $this->repo_helper->getObjectTitleFromRefId($child_ref, true);
179  if ($a_searched_title == $child_title) {
180  return $child_ref;
181  }
182  }
183 
184  throw new \Sabre\DAV\Exception\NotFound('Node not found');
185  }
+ Here is the caller graph for this function:

◆ getRefIdForWebDAVPath()

ilWebDAVUriPathResolver::getRefIdForWebDAVPath ( string  $a_uri)

Returns the ref_id of the given webdav path.

Path starts without php-script

Examples

Path starts at a ref: <client_name>/ref_<ref_id>/folder1/folder2 Path starts at root: <client_name>/ILIAS/foo_container1/course1

Note: This URI is handled case sensitive, since URIS SHOULD BE case sensitive

Parameters
$a_uri
Returns
int|mixed
Exceptions

Definition at line 41 of file class.ilWebDAVUriPathResolver.php.

References getRefIdFromPathInRefMount(), and getRefIdFromPathInRepositoryMount().

41  : int
42  {
43  $a_uri = trim($a_uri, '/');
44 
45  /* After this funciton, the array SHOULD look like this:
46  * $splitted_path[0] = '<client_name>'
47  * $splitted_path[1] = 'ref_<ref_id>' or <ilias_root_name>
48  * $splitted_path[2] = '<rest>/<of>/<the>/<path>
49  */
50  $splitted_path = explode('/', $a_uri, 3);
51 
52  // Early exit for bad request
53  if (count($splitted_path) < 2) {
54  throw new \Sabre\DAV\Exception\BadRequest('Path too short');
55  }
56 
57  $repository_mountpoint = $splitted_path[1];
58  $path_inside_of_mountpoint = isset($splitted_path[2]) ? $splitted_path[2] : '';
59 
60  // Since we already know our client, we only have to check the requested root for our path
61  // if second string = 'ilias', the request was for the ilias root
62  if ($repository_mountpoint == 'ILIAS') {
63  return $this->getRefIdFromPathInRepositoryMount($path_inside_of_mountpoint);
64  } // if the first 4 letters are 'ref_', we are searching for a ref ID in the tree
65  elseif (substr($repository_mountpoint, 0, 4) == 'ref_') {
66  return $this->getRefIdFromPathInRefMount($repository_mountpoint, $path_inside_of_mountpoint);
67  }
68 
69  // if there was no 'ilias' and no 'ref_' in the second string, then its an invalid request
70  throw new \Sabre\DAV\Exception\BadRequest('Invalid mountpoint given');
71  }
getRefIdFromPathInRefMount(string $repository_mountpoint, string $path_inside_of_mountpoint)
Gets the ref_id from a searched object in the repository.
getRefIdFromPathInRepositoryMount(string $path_inside_of_mountpoint)
Gets the ref_id from a searched object in the repository.
+ Here is the call graph for this function:

◆ getRefIdFromGivenParentRefAndTitlePath()

ilWebDAVUriPathResolver::getRefIdFromGivenParentRefAndTitlePath ( int  $a_parent_ref,
array  $a_current_path_array 
)
protected

Searches an object inside the given path, starting at the given reference id.

The return value is the ref_id of the last object in the given path.

Parameters
int$a_parent_ref
array$a_current_path_array
Returns
int
Exceptions

Definition at line 138 of file class.ilWebDAVUriPathResolver.php.

References getChildRefIdByGivenTitle().

Referenced by getRefIdFromPathInRefMount(), and getRefIdFromPathInRepositoryMount().

138  : int
139  {
140  $current_ref_id = $a_parent_ref;
141  while (count($a_current_path_array) >= 1) {
142  // Pops out first element (respectively object title)
143  $next_searched_title = array_shift($a_current_path_array);
144  if ($next_searched_title != '') {
145  try {
146  $current_ref_id = $this->getChildRefIdByGivenTitle($current_ref_id, $next_searched_title);
147  } catch (\Sabre\DAV\Exception\NotFound $e) {
148  if (count($a_current_path_array) == 0) {
149  /* This is a really special case. It occurs, if the lock is meant for an object that does not
150  exist yet (so called NullRessources) since we can't ant won't lock non existing objects, we
151  set the Exception code to -1. The receiving class SHOULD handle what to do with this value */
152  throw new \Sabre\DAV\Exception\NotFound('Last node not found', -1);
153  } else {
154  // Set Exception code to 0, so their won't be any conflicts with default values
155  throw new \Sabre\DAV\Exception\NotFound('Node not found', 0);
156  }
157  }
158  }
159  }
160  return $current_ref_id;
161  }
getChildRefIdByGivenTitle(int $a_parent_ref_id, string $a_searched_title)
Searches for a an object with a specific title inside an other object (identified by ref_id) ...
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getRefIdFromPathInRefMount()

ilWebDAVUriPathResolver::getRefIdFromPathInRefMount ( string  $repository_mountpoint,
string  $path_inside_of_mountpoint 
)
protected

Gets the ref_id from a searched object in the repository.

The string $repository_mountpoint indicates, on which object the search should start. It has a format of "ref_<id>", where <id> is the actual reference id of an object.

The string $path_inside_of_mountpoint is the title path (a path made out of object titles), with which the object will be searched. It could look like following: "groupXYZ/folder123/file.txt"

Parameters
string$repository_mountpoint
string$path_inside_of_mountpoint
Returns
int
Exceptions

Definition at line 108 of file class.ilWebDAVUriPathResolver.php.

References getRefIdFromGivenParentRefAndTitlePath().

Referenced by getRefIdForWebDAVPath().

108  : int
109  {
110  // Make a 'ref_1234' to a '1234'
111  // Since we already tested for 'ref_', we can be sure there is at least one '_' character
112  $relative_mountpoint_ref_id = (int) explode('_', $repository_mountpoint)[1];
113 
114  // Case 1: Path to an object given and a ref_id is given
115  if ($path_inside_of_mountpoint != '' && $relative_mountpoint_ref_id > 0) {
116  return $this->getRefIdFromGivenParentRefAndTitlePath($relative_mountpoint_ref_id, explode('/', $path_inside_of_mountpoint));
117  }
118  // Case 2: No path is given, but a ref_id. This means, the searched object is actually the given ref_id
119  // This happens for an URI like "<client_id>/ref_1234/" (the part after the '/' is actually an empty string)
120  elseif ($path_inside_of_mountpoint == '' && $relative_mountpoint_ref_id > 0) {
121  return $relative_mountpoint_ref_id;
122  }
123  // Case 3: Given ref_id is invalid (no number or 0 given). Throw an exception since there is no object like this
124  else {
125  throw new \Sabre\DAV\Exception\NotFound('Mount point not found');
126  }
127  }
getRefIdFromGivenParentRefAndTitlePath(int $a_parent_ref, array $a_current_path_array)
Searches an object inside the given path, starting at the given reference id.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getRefIdFromPathInRepositoryMount()

ilWebDAVUriPathResolver::getRefIdFromPathInRepositoryMount ( string  $path_inside_of_mountpoint)
protected

Gets the ref_id from a searched object in the repository.

The search starts at the root node of the ILIAS-Repository, which is defined with the constant ROOT_FOLDER_ID

The string $path_inside_of_mountpoint is the title path (a path made out of object titles), with which the object will be searched. It could look like following: "groupXYZ/folder123/file.txt"

Parameters
$path_inside_of_mountpoint
Returns
int
Exceptions

Definition at line 85 of file class.ilWebDAVUriPathResolver.php.

References getRefIdFromGivenParentRefAndTitlePath().

Referenced by getRefIdForWebDAVPath().

85  : int
86  {
87  if ($path_inside_of_mountpoint != '') {
88  return $this->getRefIdFromGivenParentRefAndTitlePath(ROOT_FOLDER_ID, explode('/', $path_inside_of_mountpoint));
89  } else {
90  return ROOT_FOLDER_ID;
91  }
92  }
getRefIdFromGivenParentRefAndTitlePath(int $a_parent_ref, array $a_current_path_array)
Searches an object inside the given path, starting at the given reference id.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $repo_helper

ilWebDAVUriPathResolver::$repo_helper
protected

Definition at line 14 of file class.ilWebDAVUriPathResolver.php.

Referenced by __construct().


The documentation for this class was generated from the following file: