1 <?php declare(strict_types=1);
94 $this->primary_storage_handler = $storage_handler_factory->
getPrimary();
113 $resource = $this->resource_repository->blank($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($this->primary_storage_handler->getIdentificationGenerator()->getUniqueResourceIdentification());
125 return $this->
appendFromStream($resource, $stream, $info_resolver, $keep_original);
130 $resource = $this->resource_repository->blank($this->primary_storage_handler->getIdentificationGenerator()->getUniqueResourceIdentification());
131 $resource->
setStorageID($this->primary_storage_handler->getID());
145 $revision = $this->revision_repository->blankFromUpload($info_resolver, $resource, $result);
162 $revision = $this->revision_repository->blankFromUpload($info_resolver, $resource, $result);
179 bool $keep_original =
false 181 $revision = $this->revision_repository->blankFromStream($info_resolver, $resource, $stream, $keep_original);
194 bool $keep_original =
false 196 $revision = $this->revision_repository->blankFromStream($info_resolver, $resource, $stream, $keep_original);
220 $cloned_revision = $this->revision_repository->blankFromClone(
243 return $this->resource_repository->has($identification);
254 $this->file_name_policy->check($revision->getInformation()->getSuffix());
257 $r = $this->lock_handler->lockTables(array_merge(
258 $this->resource_repository->getNamesForLocking(),
259 $this->revision_repository->getNamesForLocking(),
260 $this->information_repository->getNamesForLocking(),
261 $this->stakeholder_repository->getNamesForLocking(),
263 ),
function () use ($resource) {
264 $this->resource_repository->store($resource);
271 $this->stakeholder_repository->register($resource->
getIdentification(), $stakeholder);
287 $stakeholder =
clone $stakeholder;
288 $new_resource->addStakeholder($stakeholder);
296 $existing_revision->getVersionNumber(),
300 $stream =
new FileStreamConsumer($resource, $this->storage_handler_factory->getHandlerForResource($resource));
301 $stream->setRevisionNumber($existing_revision->getVersionNumber());
303 $cloned_revision =
new FileStreamRevision($new_resource->getIdentification(), $stream->getStream(),
true);
305 $cloned_revision->setVersionNumber($existing_revision->getVersionNumber());
307 $new_resource->addRevision($cloned_revision);
309 $this->
store($new_resource);
310 return $new_resource;
323 $this->file_name_policy->check($revision->
getInformation()->getSuffix());
324 $this->primary_storage_handler->storeUpload($revision);
327 $this->primary_storage_handler->storeStream($revision);
330 $this->primary_storage_handler->cloneRevision($revision);
332 $this->revision_repository->store($revision);
333 $this->information_repository->store($revision->
getInformation(), $revision);
344 if (isset($this->resource_cache[$identification->serialize()])) {
345 return $this->resource_cache[$identification->serialize()];
347 $resource = $this->resource_repository->get($identification);
351 return $this->resource_cache[$identification->serialize()];
364 $this->stakeholder_repository->deregister($resource->
getIdentification(), $stakeholder);
365 $sucessful = $sucessful && $stakeholder->resourceHasBeenDeleted($resource->
getIdentification());
372 $sucessful = $sucessful && $s->resourceHasBeenDeleted($resource->
getIdentification());
379 $this->storage_handler_factory->getHandlerForResource($resource)->deleteResource($resource);
380 $this->resource_repository->delete($resource);
388 if ($reveision_to_delete) {
391 $this->
store($resource);
397 $this->storage_handler_factory->getHandlerForResource($resource)->deleteRevision($revision);
401 $this->information_repository->delete($revision->
getInformation(), $revision);
402 $this->revision_repository->delete($revision);
414 foreach ($this->resource_repository->getAll() as $resource) {
425 $revisions = $this->revision_repository->get($resource);
429 $information = $this->information_repository->get($revision);
430 $revision->setInformation($information);
433 foreach ($this->stakeholder_repository->getStakeholders($resource->
getIdentification()) as $s) {
444 $info->setTitle($this->secure($info_resolver->
getFileName()));
446 $info->setSuffix($this->secure($info_resolver->
getSuffix()));
447 $info->setSize($info_resolver->
getSize());
452 $revision->setOwnerId($info_resolver->
getOwnerId());
populateRevisionInfo(Revision $revision, InfoResolver $info_resolver)
appendFromStream(StorableResource $resource, FileStream $stream, InfoResolver $info_resolver, bool $keep_original=false)
Class RevisionARRepository.
newFromStream(FileStream $stream, InfoResolver $info_resolver, bool $keep_original=false)
removeRevision(StorableResource $resource, int $revision_number)
removeRevision(Revision $revision)
replaceWithUpload(StorableResource $resource, UploadResult $result, InfoResolver $info_resolver)
Interface StorageResource.
append(StorableResource $resource, UploadResult $result, InfoResolver $info_resolver)
addRevision(Revision $revision)
clone(StorableResource $resource)
Class UploadedFileRevision.
Class UploadedFileRevision.
setRevisions(RevisionCollection $collection)
__construct(StorageHandlerFactory $storage_handler_factory, RevisionRepository $revision_repository, ResourceRepository $resource_repository, InformationRepository $information_repository, StakeholderRepository $stakeholder_repository, LockHandler $lock_handler, FileNamePolicy $file_name_policy=null)
ResourceBuilder constructor.
Interface FileNamePolicy.
Class NoneFileNamePolicy.
setStorageID(string $storage_id)
setInformation(Information $information)
Interface StakeholderRepository.
deleteRevision(StorableResource $resource, Revision $revision)
populateNakedResourceWithRevisionsAndStakeholders(StorableResource $resource)
Interface Identification.
replaceWithStream(StorableResource $resource, FileStream $stream, InfoResolver $info_resolver, bool $keep_original=false)
storeRevision(Revision $revision)
Store one Revision
store(StorableResource $resource)
getSpecificRevision(int $number)
Class StorageHandlerFactory.
has(ResourceIdentification $identification)
removeStakeholder(ResourceStakeholder $s)
Interface ResourceRepository.
Interface ResourceStakeholder.
addStakeholder(ResourceStakeholder $s)
appendFromRevision(StorableResource $resource, int $revision_number)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Interface FileStream The base interface for all filesystem streams.