diff --git a/databox/api/src/Api/InputTransformer/AbstractFileInputTransformer.php b/databox/api/src/Api/InputTransformer/AbstractFileInputTransformer.php index 5fc1fb783..cb1cbadfb 100644 --- a/databox/api/src/Api/InputTransformer/AbstractFileInputTransformer.php +++ b/databox/api/src/Api/InputTransformer/AbstractFileInputTransformer.php @@ -80,7 +80,9 @@ protected function handleSource(?AssetSourceInput $source, Workspace $workspace) $file = new File(); $file->setPath($source->url); $file->setOriginalName($source->originalName); - $file->setExtension(FileUtil::getExtensionFromPath($source->originalName ?: $source->url)); + $extension = FileUtil::getExtensionFromPath($source->originalName ?: $source->url); + $file->setExtension($extension); + $file->setType($source->type ?? FileUtil::getTypeFromExtension($extension)); $file->setPathPublic(!$source->isPrivate); $file->setStorage(File::STORAGE_URL); $file->setWorkspace($workspace); diff --git a/databox/api/src/Api/InputTransformer/AssetInputTransformer.php b/databox/api/src/Api/InputTransformer/AssetInputTransformer.php index 57e2c6b48..9425cd7fd 100644 --- a/databox/api/src/Api/InputTransformer/AssetInputTransformer.php +++ b/databox/api/src/Api/InputTransformer/AssetInputTransformer.php @@ -132,7 +132,7 @@ public function transform(object $data, string $resourceClass, array $context = throw new BadRequestHttpException('Rendition input error: You must provide either "name" or "definitionId"'); } $rendition = $this->renditionManager->getOrCreateRendition($object, $definition); - $file = $this->handleSource($renditionInput->source, $workspace); + $file = $this->handleSource($renditionInput->sourceFile, $workspace); $rendition->setFile($file); $this->em->persist($rendition); diff --git a/databox/api/src/Api/InputTransformer/RenditionInputTransformer.php b/databox/api/src/Api/InputTransformer/RenditionInputTransformer.php index e5ff77c7c..cff227bc1 100644 --- a/databox/api/src/Api/InputTransformer/RenditionInputTransformer.php +++ b/databox/api/src/Api/InputTransformer/RenditionInputTransformer.php @@ -43,7 +43,7 @@ public function transform(object $data, string $resourceClass, array $context = $workspace = $object->getAsset()->getWorkspace(); - if (null !== $file = $this->handleSource($data->source, $workspace)) { + if (null !== $file = $this->handleSource($data->sourceFile, $workspace)) { $object->setFile($file); } elseif (null !== $file = $this->handleFromFile($data->sourceFileId)) { $this->postFlushStackListener->addEvent(CopyFileToRenditionHandler::createEvent($object->getId(), $file->getId())); diff --git a/databox/api/src/Api/Model/Input/AssetSourceInput.php b/databox/api/src/Api/Model/Input/AssetSourceInput.php index e526f40de..71536ae3e 100644 --- a/databox/api/src/Api/Model/Input/AssetSourceInput.php +++ b/databox/api/src/Api/Model/Input/AssetSourceInput.php @@ -12,6 +12,7 @@ class AssetSourceInput public ?string $url = null; public ?string $originalName = null; + public ?string $type = null; public bool $isPrivate = false; diff --git a/databox/api/src/Api/Model/Input/RenditionInput.php b/databox/api/src/Api/Model/Input/RenditionInput.php index afe77a5f9..755a30b1e 100644 --- a/databox/api/src/Api/Model/Input/RenditionInput.php +++ b/databox/api/src/Api/Model/Input/RenditionInput.php @@ -25,7 +25,7 @@ class RenditionInput /** * @var AssetSourceInput|null */ - public $source; + public $sourceFile; /** * @var string|null diff --git a/databox/client/src/components/Dialog/Asset/InfoAsset.tsx b/databox/client/src/components/Dialog/Asset/InfoAsset.tsx index 56e6ad92e..fe4e2f9d1 100644 --- a/databox/client/src/components/Dialog/Asset/InfoAsset.tsx +++ b/databox/client/src/components/Dialog/Asset/InfoAsset.tsx @@ -31,7 +31,7 @@ export default function InfoAsset({ } /> diff --git a/databox/client/src/components/Dialog/Collection/InfoCollection.tsx b/databox/client/src/components/Dialog/Collection/InfoCollection.tsx index 17f097822..1f232a45a 100644 --- a/databox/client/src/components/Dialog/Collection/InfoCollection.tsx +++ b/databox/client/src/components/Dialog/Collection/InfoCollection.tsx @@ -32,7 +32,7 @@ export default function InfoCollection({ } /> diff --git a/databox/client/src/components/Media/Asset/FilePlayer.tsx b/databox/client/src/components/Media/Asset/FilePlayer.tsx index 0026cca4d..5d9874903 100644 --- a/databox/client/src/components/Media/Asset/FilePlayer.tsx +++ b/databox/client/src/components/Media/Asset/FilePlayer.tsx @@ -72,6 +72,6 @@ export default function FilePlayer({ width: '100%', height: '100%', }} - > + >Unsupported format } } diff --git a/databox/indexer/src/databox/types.d.ts b/databox/indexer/src/databox/types.d.ts index 1a416041a..73e49053c 100644 --- a/databox/indexer/src/databox/types.d.ts +++ b/databox/indexer/src/databox/types.d.ts @@ -9,6 +9,7 @@ type Source = { isPrivate?: boolean; alternateUrls?: AlternateUrl[]; importFile?: boolean; + type?: string; }; export type AssetInput = { diff --git a/databox/indexer/src/handlers/phraseanet/shared.ts b/databox/indexer/src/handlers/phraseanet/shared.ts index 1dea2b6bf..734594ec7 100644 --- a/databox/indexer/src/handlers/phraseanet/shared.ts +++ b/databox/indexer/src/handlers/phraseanet/shared.ts @@ -64,6 +64,7 @@ export function createAsset( url: s.permalink.url, isPrivate: false, importFile: importFiles, + type: s.mime_type, } }; }).filter(s => Boolean(s)), diff --git a/databox/indexer/src/handlers/phraseanet/types.d.ts b/databox/indexer/src/handlers/phraseanet/types.d.ts index b14a7c2bb..17bed16f8 100644 --- a/databox/indexer/src/handlers/phraseanet/types.d.ts +++ b/databox/indexer/src/handlers/phraseanet/types.d.ts @@ -15,6 +15,7 @@ export type PhraseanetConfig = { export type SubDef = { name: string; + mime_type?: string; permalink: { url: string; } diff --git a/lib/php/auth-bundle/Client/KeycloakClient.php b/lib/php/auth-bundle/Client/KeycloakClient.php index 75551e4fb..56cd91e28 100644 --- a/lib/php/auth-bundle/Client/KeycloakClient.php +++ b/lib/php/auth-bundle/Client/KeycloakClient.php @@ -4,6 +4,7 @@ namespace Alchemy\AuthBundle\Client; +use Psr\Log\LoggerInterface; use Symfony\Component\HttpClient\Exception\ClientException; use Symfony\Component\HttpKernel\Exception\UnauthorizedHttpException; use Symfony\Contracts\Cache\CacheInterface; @@ -18,6 +19,7 @@ public function __construct( private CacheInterface $keycloakRealmCache, private string $clientId, private string $clientSecret, + private LoggerInterface $logger, ) { } @@ -110,13 +112,19 @@ public function createUser(array $data, string $accessToken): array public function getUser(string $accessToken, string $userId, array $options = []): ?array { - return $this->wrapRequest(function () use ($userId, $accessToken, $options) { - return $this->keycloakClient->request('GET', sprintf('%s/%s', $this->urlGenerator->getUsersApiUrl(), $userId), array_merge([ - 'headers' => [ - 'Authorization' => 'Bearer '.$accessToken, - ], - ], $options)); - }); + try { + return $this->wrapRequest(function () use ($userId, $accessToken, $options) { + return $this->keycloakClient->request('GET', sprintf('%s/%s', $this->urlGenerator->getUsersApiUrl(), $userId), array_merge([ + 'headers' => [ + 'Authorization' => 'Bearer '.$accessToken, + ], + ], $options)); + }); + } catch (ClientException $e) { + $this->logger->error($e->getMessage()); + + return null; + } } public function getUsers(string $accessToken, int $limit = null, int $offset = null, array $options = []): array diff --git a/lib/php/auth-bundle/Repository/UserRepository.php b/lib/php/auth-bundle/Repository/UserRepository.php index a7e61a634..5026eab4f 100644 --- a/lib/php/auth-bundle/Repository/UserRepository.php +++ b/lib/php/auth-bundle/Repository/UserRepository.php @@ -18,8 +18,8 @@ public function getUsers(int $limit = null, int $offset = null): array public function getUser(string $userId): ?array { - return $this->keycloakRealmCache->get('users_'.$userId, function () use ($userId): array { - return $this->executeWithAccessToken(fn (string $accessToken): array => $this->oauthClient->getUser($accessToken, $userId)); + return $this->keycloakRealmCache->get('users_'.$userId, function () use ($userId): ?array { + return $this->executeWithAccessToken(fn (string $accessToken): ?array => $this->oauthClient->getUser($accessToken, $userId)); }); }