ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
ilDAVFile Class Reference
+ Inheritance diagram for ilDAVFile:
+ Collaboration diagram for ilDAVFile:

Public Member Functions

 __construct (ilObjFile $obj, ilWebDAVRepositoryHelper $repo_helper, Services $resource_storage, RequestInterface $request, ilWebDAVObjFactory $dav_factory, bool $versioning_enabled)
 
 put ($data)
 
 get ()
 
 getName ()
 
 getContentType ()
 
 getETag ()
 
 getSize ()
 
 noSizeCheckNeeded ()
 
 setName ($name)
 
 delete ()
 
 getLastModified ()
 

Protected Attributes

ilObjFile $obj
 
ilWebDAVRepositoryHelper $repo_helper
 
Manager $resource_manager
 
Consumers $resource_consumer
 
RequestInterface $request
 
ilWebDAVObjFactory $dav_factory
 
bool $needs_size_check = true
 
bool $versioning_enabled
 

Detailed Description

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

Definition at line 33 of file class.ilDAVFile.php.

Constructor & Destructor Documentation

◆ __construct()

ilDAVFile::__construct ( ilObjFile  $obj,
ilWebDAVRepositoryHelper  $repo_helper,
Services  $resource_storage,
RequestInterface  $request,
ilWebDAVObjFactory  $dav_factory,
bool  $versioning_enabled 
)

Definition at line 49 of file class.ilDAVFile.php.

References $dav_factory, $obj, $repo_helper, $request, $versioning_enabled, ILIAS\ResourceStorage\Services\consume(), and ILIAS\ResourceStorage\Services\manage().

56  {
57  $this->obj = $obj;
58  $this->repo_helper = $repo_helper;
59  $this->resource_manager = $resource_storage->manage();
60  $this->resource_consumer = $resource_storage->consume();
61  $this->request = $request;
62  $this->dav_factory = $dav_factory;
63  $this->versioning_enabled = $versioning_enabled;
64  }
RequestInterface $request
ilWebDAVRepositoryHelper $repo_helper
ilObjFile $obj
bool $versioning_enabled
ilWebDAVObjFactory $dav_factory
+ Here is the call graph for this function:

Member Function Documentation

◆ delete()

ilDAVFile::delete ( )

Definition at line 185 of file class.ilDAVFile.php.

185  : void
186  {
187  $this->repo_helper->deleteObject($this->obj->getRefId());
188  }

◆ get()

ilDAVFile::get ( )
Returns
string|resource

Definition at line 119 of file class.ilDAVFile.php.

120  {
121  if (!$this->repo_helper->checkAccess("read", $this->obj->getRefId())) {
122  throw new Forbidden("Permission denied. No read access for this file");
123  }
124 
125  if (($r_id = $this->obj->getResourceId()) &&
126  ($identification = $this->resource_manager->find($r_id))) {
127  return $this->resource_consumer->stream($identification)->getStream()->getContents();
128  }
129 
130  throw new NotFound("File not found");
131  }

◆ getContentType()

ilDAVFile::getContentType ( )

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

138  : ?string
139  {
140  return $this->obj->getFileType();
141  }

◆ getETag()

ilDAVFile::getETag ( )

Definition at line 143 of file class.ilDAVFile.php.

References getName(), and getSize().

Referenced by put().

143  : ?string
144  {
145  if ($this->getSize() > 0) {
146  return '"' . sha1(
147  $this->getSize() .
148  $this->getName() .
149  $this->obj->getCreateDate()
150  ) . '"';
151  }
152 
153  return null;
154  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getLastModified()

ilDAVFile::getLastModified ( )

Definition at line 190 of file class.ilDAVFile.php.

190  : ?int
191  {
192  return $this->retrieveLastModifiedAsIntFromObjectLastUpdateString($this->obj->getLastUpdateDate());
193  }

◆ getName()

ilDAVFile::getName ( )

Definition at line 133 of file class.ilDAVFile.php.

References ilFileUtils\getValidFilename().

Referenced by getETag(), and put().

133  : string
134  {
135  return ilFileUtils::getValidFilename($this->obj->getTitle());
136  }
static getValidFilename(string $a_filename)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getSize()

ilDAVFile::getSize ( )

Definition at line 156 of file class.ilDAVFile.php.

References Vendor\Package\$e.

Referenced by getETag(), and put().

156  : int
157  {
158  try {
159  return $this->obj->getFileSize();
160  } catch (Error $e) {
161  return -1;
162  }
163  }
+ Here is the caller graph for this function:

◆ noSizeCheckNeeded()

ilDAVFile::noSizeCheckNeeded ( )

Definition at line 165 of file class.ilDAVFile.php.

165  : void
166  {
167  $this->needs_size_check = false;
168  }

◆ put()

ilDAVFile::put (   $data)
Parameters
string | resource$data

Definition at line 69 of file class.ilDAVFile.php.

References $data, getETag(), getName(), getSize(), ilFileUtils\getUploadSizeLimitBytes(), and ILIAS\Repository\int().

69  : ?string
70  {
71  if (!$this->repo_helper->checkAccess('write', $this->obj->getRefId())) {
72  throw new Forbidden("Permission denied. No write access for this file");
73  }
74 
75  $size = 0;
76 
77  if ($this->request->hasHeader("Content-Length")) {
78  $size = (int) $this->request->getHeader("Content-Length")[0];
79  }
80  if ($size === 0 && $this->request->hasHeader('X-Expected-Entity-Length')) {
81  $size = (int) $this->request->getHeader('X-Expected-Entity-Length')[0];
82  }
83 
85  throw new Forbidden('File is too big');
86  }
87 
88  if ($this->needs_size_check && $this->getSize() === 0) {
89  $parent_ref_id = $this->repo_helper->getParentOfRefId($this->obj->getRefId());
90  $obj_id = $this->obj->getId();
91  $this->repo_helper->deleteObject($this->obj->getRefId());
92  $file_obj = new ilObjFile();
93  $file_obj->setTitle($this->getName());
94  $file_obj->setFileName($this->getName());
95 
96  $file_dav = $this->dav_factory->createDAVObject($file_obj, $parent_ref_id);
97  $file_dav->noSizeCheckNeeded();
98  $this->repo_helper->updateLocksAfterResettingObject($obj_id, $file_obj->getId());
99  return $file_dav->put($data);
100  }
101 
102  $stream = Streams::ofResource($data);
103 
104  if ($this->versioning_enabled === true ||
105  $this->obj->getVersion() === 0 && $this->obj->getMaxVersion() === 0) {
106  $this->obj->appendStream($stream, $this->obj->getTitle());
107  } else {
108  $this->obj->replaceWithStream($stream, $this->obj->getTitle());
109  }
110 
111  $stream->close();
112 
113  return $this->getETag();
114  }
static getUploadSizeLimitBytes()
Class ilObjFile.
+ Here is the call graph for this function:

◆ setName()

ilDAVFile::setName (   $name)

Definition at line 170 of file class.ilDAVFile.php.

References $name, and ilWebDAVNotDavableException\OBJECT_TITLE_NOT_DAVABLE.

170  : void
171  {
172  if (!$this->repo_helper->checkAccess("write", $this->obj->getRefId())) {
173  throw new Forbidden('Permission denied');
174  }
175 
176  if ($this->isDAVableObjTitle($name) &&
177  $name === $this->obj->checkFileExtension($this->getName(), $name)) {
178  $this->obj->setTitle($name);
179  $this->obj->update();
180  } else {
182  }
183  }
if($format !==null) $name
Definition: metadata.php:247
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

Field Documentation

◆ $dav_factory

ilWebDAVObjFactory ilDAVFile::$dav_factory
protected

Definition at line 44 of file class.ilDAVFile.php.

Referenced by __construct().

◆ $needs_size_check

bool ilDAVFile::$needs_size_check = true
protected

Definition at line 46 of file class.ilDAVFile.php.

◆ $obj

ilObjFile ilDAVFile::$obj
protected

Definition at line 39 of file class.ilDAVFile.php.

Referenced by __construct().

◆ $repo_helper

ilWebDAVRepositoryHelper ilDAVFile::$repo_helper
protected

Definition at line 40 of file class.ilDAVFile.php.

Referenced by __construct().

◆ $request

RequestInterface ilDAVFile::$request
protected

Definition at line 43 of file class.ilDAVFile.php.

Referenced by __construct().

◆ $resource_consumer

Consumers ilDAVFile::$resource_consumer
protected

Definition at line 42 of file class.ilDAVFile.php.

◆ $resource_manager

Manager ilDAVFile::$resource_manager
protected

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

◆ $versioning_enabled

bool ilDAVFile::$versioning_enabled
protected

Definition at line 47 of file class.ilDAVFile.php.

Referenced by __construct().


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