diff --git a/admin_scripts/migrate_to_9.5.php b/admin_scripts/migrate_to_9.5.php new file mode 100755 index 00000000..007d9472 --- /dev/null +++ b/admin_scripts/migrate_to_9.5.php @@ -0,0 +1,46 @@ +#!/command/with-contenv php + +query('BEGIN'); + + /* User name is now UNIQUE and called username */ + $dbDriver->query('UPDATE ' . $dbDriver->targetSchema . '.user SET name = lower(name)'); + $dbDriver->query('WITH tmp AS (SELECT name as n FROM ' . $dbDriver->targetSchema . '.user GROUP BY name HAVING count(name) > 1) UPDATE ' . $dbDriver->targetSchema . '.user SET name = tmp.n || (floor(random() * 1000 + 1)::int)::TEXT FROM tmp WHERE name = tmp.n'); + $dbDriver->query('UPDATE ' . $dbDriver->targetSchema . '.user SET name = \'anonymous\' || (floor(random() * 1000 + 1)::int)::TEXT WHERE name IS NULL'); + $dbDriver->query('ALTER TABLE ' . $dbDriver->commonSchema . '.user RENAME name TO username'); + $dbDriver->query('ALTER TABLE ' . $dbDriver->commonSchema . '.user ADD UNIQUE (username)'); + $dbDriver->query('ALTER TABLE ' . $dbDriver->commonSchema . '.user ALTER COLUMN settings SET DEFAULT \'{"notifyOnAddFeature":true,"notifyOnNewFollower":true,"notifyOnLikeFeature":true,"notifyOnAddComment":true,"showBio":true,"showIdentity":true,"showTopics":true,"showEmail":false,"profileNeedReview":true}\''); + + // Create private group per user + $dbDriver->query('DROP INDEX IF EXISTS ' . $dbDriver->commonSchema . '.idx_uname_group'); + $dbDriver->query('WITH tmp AS (SELECT id, username FROM ' . $dbDriver->commonSchema . '.user) INSERT INTO ' . $dbDriver->commonSchema . '.group (name, description, owner, private) SELECT username || \'_private\', \'Private group for user \' || username, id, 1 FROM tmp WHERE username <> \'admin\''); + + $dbDriver->query('WITH tmp AS (SELECT id, owner FROM ' . $dbDriver->commonSchema . '.group WHERE private = 1) INSERT INTO ' . $dbDriver->commonSchema . '.group_member (groupid, userid, created) SELECT tmp.id, tmp.owner, now() FROM tmp'); + + $dbDriver->query('COMMIT'); + + } catch(Exception $e){ + $dbDriver->query('ROLLBACK'); + RestoLogUtil::httpError(500, $e->getMessage()); + } + echo "Looks good\n"; + + \ No newline at end of file diff --git a/app/resto/core/RestoCollection.php b/app/resto/core/RestoCollection.php index 8629fee6..5e6e248f 100755 --- a/app/resto/core/RestoCollection.php +++ b/app/resto/core/RestoCollection.php @@ -816,6 +816,7 @@ public function toArray() ), array( 'rel' => 'items', + 'title' => 'All items', 'type' => RestoUtil::$contentTypes['geojson'], 'href' => $this->context->core['baseUrl'] . RestoUtil::replaceInTemplate(RestoRouter::ROUTE_TO_FEATURES, array('collectionId' => $this->id)) ), diff --git a/app/resto/core/RestoCollections.php b/app/resto/core/RestoCollections.php index 72aa7c2f..191141f6 100755 --- a/app/resto/core/RestoCollections.php +++ b/app/resto/core/RestoCollections.php @@ -253,7 +253,7 @@ public function toArray() ), array( 'rel' => 'items', - 'title' => 'All collections', + 'title' => 'All items', 'type' => RestoUtil::$contentTypes['geojson'], 'href' => $this->context->core['baseUrl'] . RestoRouter::ROUTE_TO_STAC_SEARCH ) diff --git a/app/resto/core/RestoConstants.php b/app/resto/core/RestoConstants.php index 45439c04..0ada97b2 100644 --- a/app/resto/core/RestoConstants.php +++ b/app/resto/core/RestoConstants.php @@ -20,7 +20,7 @@ class RestoConstants // [IMPORTANT] Starting resto 7.x, default routes are defined in RestoRouter class // resto version - const VERSION = '9.4.0'; + const VERSION = '9.5.0'; /* ============================================================ * NEVER EVER TOUCH THESE VALUES diff --git a/app/resto/core/api/STACAPI.php b/app/resto/core/api/STACAPI.php index 07078212..d64f9105 100644 --- a/app/resto/core/api/STACAPI.php +++ b/app/resto/core/api/STACAPI.php @@ -1620,6 +1620,7 @@ private function getParentAndChilds($catalogId, $params) if ( $catalogs[0]['rtype'] === 'collection' ) { $items = array( 'rel' => 'items', + 'title' => 'All items', 'type' => RestoUtil::$contentTypes['geojson'], 'href' => $this->context->core['baseUrl'] . '/collections/' . substr($parentAndChilds['parent']['id'], strrpos($parentAndChilds['parent']['id'], '/') + 1) . '/items' ); diff --git a/examples/catalogs/dummyCatalogChild2.json b/examples/catalogs/dummyCatalogChild2.json index e2412d72..3204d9bd 100644 --- a/examples/catalogs/dummyCatalogChild2.json +++ b/examples/catalogs/dummyCatalogChild2.json @@ -4,5 +4,11 @@ "title": "Dummy Catalog child 2", "description":"I'm a child of dummyCatalog", "stac_version":"1.0.0", - "links":[] + "links":[ + { + "rel":"item", + "href":"http://127.0.0.1:5252/collections/JohnDoeCollection/items/e3b2cf46-6f4f-58cc-95e9-8686efc89f58", + "title":"Catalog can also have item" + } + ] } \ No newline at end of file diff --git a/examples/catalogs/dummyCatalogWithChilds_update.json b/examples/catalogs/dummyCatalogWithChilds_update.json new file mode 100644 index 00000000..3ae0051d --- /dev/null +++ b/examples/catalogs/dummyCatalogWithChilds_update.json @@ -0,0 +1,16 @@ +{ + "id": "dummyCatalogWithChilds", + "title": "Dummy Catalog with childs", + "type": "Catalog", + "description":"This catalog has no childs - they will be added later on", + "stac_version":"1.0.0", + "links":[ + { + "rel": "child", + "type": "application/json", + "href": "http://127.0.0.1:5252/catalogs/dummyCatalogWithChilds/dummyCatalogChild1", + "title": "Dummy Catalog child 1", + "description": "I'm a child of dummyCatalog" + } + ] +} \ No newline at end of file