Skip to content

Commit

Permalink
Fixes from local tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rjzondervan committed Aug 13, 2024
1 parent c332b6d commit 9fd9447
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
7 changes: 6 additions & 1 deletion lib/Controller/PublicationsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use OCP\AppFramework\Db\DoesNotExistException;
use OCP\AppFramework\Http\TemplateResponse;
use OCP\AppFramework\Http\JSONResponse;
use OCP\AppFramework\OCS\OCSBadRequestException;
use OCP\IAppConfig;
use OCP\IRequest;
use Symfony\Component\Uid\Uuid;
Expand Down Expand Up @@ -215,7 +216,11 @@ public function create(ObjectService $objectService, ElasticSearchService $elast
}
}

$data = $validationService->validatePublication($data);
try {
$data = $validationService->validatePublication($data);
} catch (OCSBadRequestException $exception) {
return new JSONResponse(data: ['message' => $exception->getMessage()], statusCode: 400);
}

if($this->config->hasKey($this->appName, 'mongoStorage') === false
|| $this->config->getValueString($this->appName, 'mongoStorage') !== '1'
Expand Down
6 changes: 3 additions & 3 deletions lib/Service/ValidationService.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ public function getMongodbConfig(): array
*/
public function getCatalog (string $id): array
{
if ($this->config->hasKey(app: $this->appName, key: 'mongoStorage') === false
|| $this->config->getValueString(app: $this->appName, key: 'mongoStorage') !== '1'
if ($this->config->hasKey(app: $this->appName, key: 'mongoStorage') !== false
|| $this->config->getValueString(app: $this->appName, key: 'mongoStorage') === '1'
) {
$filter = ['id' => $id, '_schema' => 'catalog'];

Expand All @@ -77,7 +77,7 @@ public function getCatalog (string $id): array
*/
public function validatePublication(array $publication): array
{
$catalogId = $publication['catalog'];
$catalogId = $publication['catalogi'];
$metadata = $publication['metadata'];

$catalog = $this->getCatalog($catalogId);
Expand Down

0 comments on commit 9fd9447

Please sign in to comment.