From 0c6e734d9c58b0fa98acd481297cd54240daa4de Mon Sep 17 00:00:00 2001 From: jjrom Date: Mon, 13 May 2024 12:26:45 +0200 Subject: [PATCH 1/2] Refactor pid 'root' position --- app/resto/core/addons/STACCatalog.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/resto/core/addons/STACCatalog.php b/app/resto/core/addons/STACCatalog.php index 7834a80e..6177b596 100644 --- a/app/resto/core/addons/STACCatalog.php +++ b/app/resto/core/addons/STACCatalog.php @@ -368,12 +368,12 @@ private function storeCatalogAsFacet($catalog, $parentId) $catalog['id'] = substr($catalog['id'], strlen($this->prefix)); } - $parentId = isset($parentId) ? (str_starts_with($parentId, $this->prefix) ? $parentId : $this->prefix . $parentId) : null; + $parentId = isset($parentId) ? (str_starts_with($parentId, $this->prefix) ? $parentId : $this->prefix . $parentId) : 'root'; /* * Catalog already exist */ - if ( $this->catalogExists($this->prefix . $catalog['id'], $parentId ?? 'root', '*') ) { + if ( $this->catalogExists($this->prefix . $catalog['id'], $parentId, '*') ) { return RestoLogUtil::httpError(409, 'Catalog ' . $catalog['id'] . ' already exist'); } From 3999c08edbd89f783452810ed6c827d11cca9919 Mon Sep 17 00:00:00 2001 From: jjrom Date: Mon, 13 May 2024 16:03:38 +0200 Subject: [PATCH 2/2] Correct rights UPDATE_FEATURE --- app/resto/core/RestoUser.php | 4 +- app/resto/core/addons/STACCatalog.php | 4 +- docs/api/resto-api.html | 103 ++++++++++++++++++++++---- docs/api/resto-api.json | 52 +++++++++++-- 4 files changed, 136 insertions(+), 27 deletions(-) diff --git a/app/resto/core/RestoUser.php b/app/resto/core/RestoUser.php index 64dbae7c..0e8edb81 100755 --- a/app/resto/core/RestoUser.php +++ b/app/resto/core/RestoUser.php @@ -320,10 +320,10 @@ public function hasRightsTo($action, $params = array()) // Only owner of feature can do this case RestoUser::DELETE_FEATURE: case RestoUser::UPDATE_FEATURE: - if ( !isset($feature) ) { + if ( !isset($params['feature']) ) { return false; } - $featureArray = $feature->toArray(); + $featureArray = $params['feature']->toArray(); return $rights[$action] && isset($featureArray['properties']['owner']) && $featureArray['properties']['owner'] !== $this->profile['id']; default: diff --git a/app/resto/core/addons/STACCatalog.php b/app/resto/core/addons/STACCatalog.php index 6177b596..f4c93928 100644 --- a/app/resto/core/addons/STACCatalog.php +++ b/app/resto/core/addons/STACCatalog.php @@ -133,7 +133,7 @@ public function addCatalog($params, $body) * Update catalog as a facet entry * * @OA\Put( - * path="/catalogs/{catalogId}", + * path="/catalogs/catalogs/{catalogId}", * summary="Update catalog", * description="Update catalog as a facet entry", * tags={"STAC"}, @@ -231,7 +231,7 @@ public function updateCatalog($params, $body) * Delete catalog as a facet entry * * @OA\Delete( - * path="/catalogs/{catalogId}", + * path="/catalogs/catalogs/{catalogId}", * summary="Delete catalog", * description="Delete catalog as a facet entry - update feature keywords accordingly", * tags={"STAC"}, diff --git a/docs/api/resto-api.html b/docs/api/resto-api.html index 9e73a32d..aacc0526 100644 --- a/docs/api/resto-api.html +++ b/docs/api/resto-api.html @@ -1496,7 +1496,7 @@