19declare(strict_types=1);
31use ILIAS\ResourceStorage\Preloader\SecureString;
111 $resource = $this->resource_repository->blank(
112 $this->primary_storage_handler->getIdentificationGenerator()->getUniqueResourceIdentification()
115 return $this->
append($resource, $result, $info_resolver);
121 bool $keep_original =
false
123 $resource = $this->resource_repository->blank(
124 $this->primary_storage_handler->getIdentificationGenerator()->getUniqueResourceIdentification()
127 return $this->
appendFromStream($resource, $stream, $info_resolver, $keep_original);
133 $resource = $this->resource_repository->blank(
134 $this->primary_storage_handler->getIdentificationGenerator()->getUniqueResourceIdentification()
136 $resource->
setStorageID($this->primary_storage_handler->getID());
150 $revision = $this->revision_repository->blankFromUpload($info_resolver, $resource, $result);
151 $revision = $this->populateRevisionInfo($revision, $info_resolver);
169 $revision = $this->revision_repository->blankFromUpload($info_resolver, $resource, $result);
170 $revision = $this->populateRevisionInfo($revision, $info_resolver);
173 $this->deleteRevision($resource, $existing_revision);
188 bool $keep_original =
false
190 $revision = $this->revision_repository->blankFromStream($info_resolver, $resource, $stream, $keep_original);
191 $revision = $this->populateRevisionInfo($revision, $info_resolver);
205 bool $keep_original =
false
207 $revision = $this->revision_repository->blankFromStream($info_resolver, $resource, $stream, $keep_original);
208 $revision = $this->populateRevisionInfo($revision, $info_resolver);
211 $this->deleteRevision($resource, $existing_revision);
226 $existing_revision = $resource->getSpecificRevision($revision_number);
233 $cloned_revision = $this->revision_repository->blankFromClone(
239 $this->populateRevisionInfo($cloned_revision, $info_resolver);
255 return $this->resource_repository->has($identification);
266 $this->file_name_policy->check($revision->getInformation()->getSuffix());
269 $r = $this->lock_handler->lockTables(
271 $this->resource_repository->getNamesForLocking(),
272 $this->revision_repository->getNamesForLocking(),
273 $this->information_repository->getNamesForLocking(),
274 $this->stakeholder_repository->getNamesForLocking()
277 $this->resource_repository->store($resource);
280 $this->storeRevision($revision);
284 $this->stakeholder_repository->register($resource->getIdentification(), $stakeholder);
298 $new_resource = $this->newBlank();
300 $stakeholder = clone $stakeholder;
301 $new_resource->addStakeholder($stakeholder);
309 $existing_revision->getVersionNumber(),
314 $existing_revision = $this->stream_access->populateRevision($existing_revision);
317 $new_resource->getIdentification(),
318 $existing_revision->maybeGetToken()->resolveStream(),
322 $this->populateRevisionInfo($cloned_revision, $info_resolver);
323 $cloned_revision->setVersionNumber($existing_revision->getVersionNumber());
325 $new_resource->addRevision($cloned_revision);
327 $this->store($new_resource);
328 return $new_resource;
339 $this->file_name_policy->check($revision->
getInformation()->getSuffix());
340 $this->primary_storage_handler->storeUpload($revision);
343 $this->primary_storage_handler->storeStream($revision);
346 $this->primary_storage_handler->cloneRevision($revision);
348 $this->revision_repository->store($revision);
349 $this->information_repository->store($revision->
getInformation(), $revision);
358 if (isset($this->resource_cache[$identification->serialize()])) {
359 return $this->resource_cache[$identification->serialize()];
361 $resource = $this->resource_repository->get($identification);
363 $this->resource_cache[$identification->serialize()] = $this->populateNakedResourceWithRevisionsAndStakeholders(
367 return $this->resource_cache[$identification->serialize()];
374 return Streams::ofResource(fopen($revision->getUpload()->getPath(),
'rb'));
376 return $revision->getRevisionToClone()->getStream();
379 return $this->storage_handler_factory->getHandlerForRevision(
381 )->getStream($revision);
383 return $this->storage_handler_factory->getHandlerForResource(
385 )->getStream($revision);
389 throw new \LogicException(
'This revision type is not supported');
402 $this->stakeholder_repository->deregister($resource->
getIdentification(), $stakeholder);
403 $sucessful = $stakeholder->resourceHasBeenDeleted($resource->
getIdentification());
410 $sucessful = $s->resourceHasBeenDeleted($resource->
getIdentification()) && $sucessful;
414 $this->deleteRevision($resource, $revision);
417 $this->storage_handler_factory->getHandlerForResource($resource)->deleteResource($resource);
418 $this->resource_repository->delete($resource);
426 if ($reveision_to_delete !==
null) {
427 $this->deleteRevision($resource, $reveision_to_delete);
429 $this->store($resource);
435 $this->storage_handler_factory->getHandlerForResource($resource)->deleteRevision($revision);
436 }
catch (\Throwable $exception) {
439 $this->information_repository->delete($revision->
getInformation(), $revision);
440 $this->revision_repository->delete($revision);
447 public function getAll(): \Iterator
452 foreach ($this->resource_repository->getAll() as $resource) {
453 yield $this->populateNakedResourceWithRevisionsAndStakeholders($resource);
459 $revisions = $this->revision_repository->get($resource);
462 foreach ($revisions->getAll() as
$i => $revision) {
463 $information = $this->information_repository->get($revision);
464 $revision->setInformation($information);
469 foreach ($this->stakeholder_repository->getStakeholders($resource->
getIdentification()) as $s) {
480 $info->setTitle($this->secure($info_resolver->
getFileName()));
482 $info->setSuffix($this->secure($info_resolver->
getSuffix()));
483 $info->setSize($info_resolver->
getSize());
488 $revision->setOwnerId($info_resolver->
getOwnerId());
static return function(ContainerConfigurator $containerConfigurator)
Class ResourceIdentification.
Class NoneFileNamePolicy.
getStakeholderRepository()
getInformationRepository()
LockHandler $lock_handler
append(StorableResource $resource, UploadResult $result, InfoResolver $info_resolver)
populateRevisionInfo(Revision $revision, InfoResolver $info_resolver)
ILIAS ResourceStorage Revision Repository RevisionRepository $revision_repository
@readonly
StorageHandlerFactory $storage_handler_factory
appendFromStream(StorableResource $resource, FileStream $stream, InfoResolver $info_resolver, bool $keep_original=false)
ILIAS ResourceStorage Resource Repository ResourceRepository $resource_repository
@readonly
appendFromRevision(StorableResource $resource, int $revision_number)
ILIAS ResourceStorage Information Repository InformationRepository $information_repository
@readonly
extractStream(Revision $revision)
newFromStream(FileStream $stream, InfoResolver $info_resolver, bool $keep_original=false)
populateNakedResourceWithRevisionsAndStakeholders(StorableResource $resource)
__construct(StorageHandlerFactory $storage_handler_factory, Repositories $repositories, LockHandler $lock_handler, StreamAccess $stream_access, FileNamePolicy $file_name_policy=null)
ResourceBuilder constructor.
ILIAS ResourceStorage Stakeholder Repository StakeholderRepository $stakeholder_repository
@readonly
replaceWithStream(StorableResource $resource, FileStream $stream, InfoResolver $info_resolver, bool $keep_original=false)
store(StorableResource $resource)
@description after you have modified a resource, you can store it here
has(ResourceIdentification $identification)
@description check if a resource exists
deleteRevision(StorableResource $resource, Revision $revision)
replaceWithUpload(StorableResource $resource, UploadResult $result, InfoResolver $info_resolver)
@inheritDoc
removeRevision(StorableResource $resource, int $revision_number)
storeRevision(Revision $revision)
@description Store one Revision
ILIAS ResourceStorage Policy FileNamePolicy $file_name_policy
StreamAccess $stream_access
clone(StorableResource $resource)
@description Clone anexisting resource with all it's revisions, stakeholders and information
ILIAS ResourceStorage StorageHandler StorageHandler $primary_storage_handler
Class UploadedFileRevision.
Class UploadedFileRevision.
Class StorageHandlerFactory.
Interface FileNamePolicy.
Interface StorageResource.
setRevisions(RevisionCollection $collection)
addStakeholder(ResourceStakeholder $s)
addRevision(Revision $revision)
removeRevision(Revision $revision)
removeStakeholder(ResourceStakeholder $s)
setStorageID(string $storage_id)
getSpecificRevision(int $number)
setInformation(Information $information)
Interface ResourceStakeholder.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...