Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add missing dependencies for ACL strategy copy #462

Merged
merged 9 commits into from
Apr 27, 2023
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@
"oat-sa/oatbox-extension-installer": "~1.1||dev-master",
"oat-sa/lib-generis-search": "2.1.2",
"oat-sa/generis": ">=15.22",
"oat-sa/tao-core": ">=50.27.0",
"oat-sa/extension-tao-item": ">=11.13.4",
"oat-sa/tao-core": "dev-feat/RFE-530/integration-branch as 52.0",
"oat-sa/extension-tao-item": "dev-feat/RFE-530/integration-branch as 12.0",
"oat-sa/extension-tao-itemqti": ">=29.14.5",
"oat-sa/extension-tao-test": ">=15.0.0",
"oat-sa/extension-tao-test": "dev-feat/RFE-530/integration-branch as 16.0",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Use proper versions before release

"oat-sa/extension-tao-testqti-previewer": "*"
},
"autoload": {
Expand Down
45 changes: 27 additions & 18 deletions model/classes/Copier/AssetClassCopier.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,44 +22,53 @@

namespace oat\taoMediaManager\model\classes\Copier;

use oat\generis\model\data\Ontology;
use oat\tao\model\resources\Command\ResourceTransferCommand;
use oat\tao\model\resources\Contract\ClassCopierInterface;
use oat\tao\model\resources\Contract\ClassPropertyCopierInterface;
use oat\tao\model\resources\Contract\RootClassesListServiceInterface;
use oat\tao\model\resources\Service\ClassPropertyCopier;
use oat\tao\model\resources\Contract\ResourceTransferInterface;
use oat\tao\model\resources\ResourceTransferResult;
use oat\tao\model\Specification\ClassSpecificationInterface;
use oat\taoMediaManager\model\TaoMediaOntology;
use core_kernel_classes_Class;
use InvalidArgumentException;

class AssetClassCopier implements ClassCopierInterface
class AssetClassCopier implements ClassCopierInterface, ResourceTransferInterface
{
/** @var RootClassesListServiceInterface */
private $rootClassesListService;

/** @var ClassSpecificationInterface */
private $mediaClassSpecification;

/** @var ClassCopierInterface */
private $taoClassCopier;
private ClassSpecificationInterface $mediaClassSpecification;
private ResourceTransferInterface $taoClassCopier;
private Ontology $ontology;

public function __construct(
RootClassesListServiceInterface $rootClassesListService,
ClassSpecificationInterface $mediaClassSpecification,
ClassCopierInterface $taoClassCopier
ResourceTransferInterface $taoClassCopier,
Ontology $ontology
) {
$this->rootClassesListService = $rootClassesListService;
$this->mediaClassSpecification = $mediaClassSpecification;
$this->taoClassCopier = $taoClassCopier;
$this->ontology = $ontology;
}

public function transfer(ResourceTransferCommand $command): ResourceTransferResult
gabrielfs7 marked this conversation as resolved.
Show resolved Hide resolved
{
$this->assertInAssetsRootClass($this->ontology->getClass($command->getFrom()));

return $this->taoClassCopier->transfer($command);
}

public function copy(
core_kernel_classes_Class $class,
core_kernel_classes_Class $destinationClass
): core_kernel_classes_Class {
$this->assertInAssetsRootClass($class);
$this->assertInAssetsRootClass($destinationClass);
$result = $this->transfer(
new ResourceTransferCommand(
$class->getUri(),
$destinationClass->getUri(),
ResourceTransferCommand::ACL_KEEP_ORIGINAL,
ResourceTransferCommand::TRANSFER_MODE_COPY
)
);

return $this->taoClassCopier->copy($class, $destinationClass);
return $this->ontology->getClass($result->getDestination());
}

private function assertInAssetsRootClass(core_kernel_classes_Class $class): void
Expand Down
21 changes: 16 additions & 5 deletions model/classes/ServiceProvider/MediaServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,10 @@
use oat\tao\model\resources\Service\ClassCopierProxy;
use oat\tao\model\resources\Service\ClassMetadataCopier;
use oat\tao\model\resources\Service\ClassMetadataMapper;
use oat\tao\model\resources\Service\ClassPropertyCopier;
use oat\tao\model\resources\Service\InstanceCopier;
use oat\tao\model\resources\Service\InstanceCopierProxy;
use oat\tao\model\resources\Service\InstanceMetadataCopier;
use oat\tao\model\resources\Service\RootClassesListService;
use oat\taoItems\model\Copier\ClassCopier;
use oat\tao\model\resources\Service\ClassCopier as TaoClassCopier;
use oat\taoMediaManager\model\accessControl\MediaPermissionService;
use oat\taoMediaManager\model\classes\Copier\AssetClassCopier;
Expand Down Expand Up @@ -127,6 +126,7 @@ public function __invoke(ContainerConfigurator $configurator): void
->args(
[
service(AssetMetadataCopier::class),
service(Ontology::SERVICE_ID)
]
)
->call(
Expand All @@ -138,7 +138,7 @@ public function __invoke(ContainerConfigurator $configurator): void
->call(
'withPermissionCopiers',
[
tagged_iterator('tao.copier.permissions.instance.assets'),
tagged_iterator('tao.copier.permissions'),
]
);

Expand All @@ -151,12 +151,13 @@ public function __invoke(ContainerConfigurator $configurator): void
service(ClassMetadataCopier::class),
service(InstanceCopier::class . '::ASSETS'),
service(ClassMetadataMapper::class),
service(Ontology::SERVICE_ID),
]
)
->call(
'withPermissionCopiers',
[
tagged_iterator('tao.copier.permissions.class.assets'),
tagged_iterator('tao.copier.permissions'),
]
);

Expand All @@ -165,9 +166,9 @@ public function __invoke(ContainerConfigurator $configurator): void
->share(false)
->args(
[
service(RootClassesListService::class),
service(MediaClassSpecification::class),
service(TaoClassCopier::class . '::ASSETS'),
service(Ontology::SERVICE_ID),
]
);

Expand All @@ -180,5 +181,15 @@ public function __invoke(ContainerConfigurator $configurator): void
service(AssetClassCopier::class),
]
);

$services
->get(InstanceCopierProxy::class)
->call(
'addInstanceCopier',
[
TaoMediaOntology::CLASS_URI_MEDIA_ROOT,
service(InstanceCopier::class . '::ASSETS'),
]
);
}
}