-
Notifications
You must be signed in to change notification settings - Fork 495
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11124 from IQSS/10943-featured-items
Dataverse Featured Items support
- Loading branch information
Showing
35 changed files
with
2,002 additions
and
101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
CRUD endpoints for Collection Featured Items have been implemented. In particular, the following endpoints have been implemented: | ||
|
||
- Create a feature item (POST /api/dataverses/<dataverse_id>/featuredItems) | ||
- Update a feature item (PUT /api/dataverseFeaturedItems/<item_id>) | ||
- Delete a feature item (DELETE /api/dataverseFeaturedItems/<item_id>) | ||
- List all featured items in a collection (GET /api/dataverses/<dataverse_id>/featuredItems) | ||
- Delete all featured items in a collection (DELETE /api/dataverses/<dataverse_id>/featuredItems) | ||
- Update all featured items in a collection (PUT /api/dataverses/<dataverse_id>/featuredItems) | ||
|
||
New settings: | ||
|
||
- dataverse.files.featured-items.image-maxsize - It sets the maximum allowed size of the image that can be added to a featured item. | ||
- dataverse.files.featured-items.image-uploads - It specifies the name of the subdirectory for saving featured item images within the docroot directory. | ||
|
||
See also #10943 and #11124. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1156,6 +1156,209 @@ Use the ``/settings`` API to enable or disable the enforcement of storage quotas | |
curl -X PUT -d 'true' http://localhost:8080/api/admin/settings/:UseStorageQuotas | ||
List All Collection Featured Items | ||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
||
List the featured items configured for a given Dataverse collection ``id``: | ||
|
||
.. code-block:: bash | ||
export API_TOKEN=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx | ||
export SERVER_URL=https://demo.dataverse.org | ||
export ID=root | ||
curl -H "X-Dataverse-key:$API_TOKEN" "$SERVER_URL/api/dataverses/$ID/featuredItems" | ||
The fully expanded example above (without environment variables) looks like this: | ||
|
||
.. code-block:: bash | ||
curl -H "X-Dataverse-key:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" "https://demo.dataverse.org/api/dataverses/root/featuredItems" | ||
Update All Collection Featured Items | ||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
||
Updates all featured items in the given Dataverse collection ``id``. | ||
|
||
The data sent to the endpoint represents the desired final state of the featured items in the Dataverse collection and overwrites any existing featured items configuration. | ||
|
||
The parameters ``id``, ``content``, ``displayOrder``, and ``fileName`` must be specified as many times as the number of items we want to add or update. The order in which these parameters are repeated must match to ensure they correspond to the same featured item. | ||
|
||
The ``file`` parameter must be specified for each image we want to attach to featured items. Note that images can be shared between featured items, so ``fileName`` can have the same value in different featured items. | ||
|
||
The ``id`` parameter must be ``0`` for new items or set to the item's identifier for updates. The ``fileName`` parameter should be empty to exclude an image or match the name of a file sent in a ``file`` parameter to set a new image. ``keepFile`` must always be set to ``false``, unless it's an update to a featured item where we want to preserve the existing image, if one exists. | ||
|
||
Note that any existing featured item not included in the call with its associated identifier and corresponding properties will be removed from the collection. | ||
|
||
The following example creates two featured items, with an image assigned to the second one: | ||
|
||
.. code-block:: bash | ||
export API_TOKEN=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx | ||
export SERVER_URL=https://demo.dataverse.org | ||
export ID=root | ||
export FIRST_ITEM_CONTENT='Content 1' | ||
export FIRST_ITEM_DISPLAY_ORDER=1 | ||
export SECOND_ITEM_IMAGE_FILENAME='image.png' | ||
export SECOND_ITEM_CONTENT='Content 2' | ||
export SECOND_ITEM_DISPLAY_ORDER=2 | ||
curl -H "X-Dataverse-key:$API_TOKEN" \ | ||
-X PUT \ | ||
-F "id=0" -F "id=0" \ | ||
-F "content=$FIRST_ITEM_CONTENT" -F "content=$SECOND_ITEM_CONTENT" \ | ||
-F "displayOrder=$FIRST_ITEM_DISPLAY_ORDER" -F "displayOrder=$SECOND_ITEM_DISPLAY_ORDER" \ | ||
-F "fileName=" -F "fileName=$SECOND_ITEM_IMAGE_FILENAME" \ | ||
-F "keepFile=false" -F "keepFile=false" \ | ||
-F "file=@$SECOND_ITEM_IMAGE_FILENAME" \ | ||
"$SERVER_URL/api/dataverses/$ID/featuredItems" | ||
The fully expanded example above (without environment variables) looks like this: | ||
|
||
.. code-block:: bash | ||
curl -H "X-Dataverse-key:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" \ | ||
-X PUT \ | ||
-F "id=0" -F "id=0" \ | ||
-F "content=Content 1" -F "content=Content 2" \ | ||
-F "displayOrder=1" -F "displayOrder=2" \ | ||
-F "fileName=" -F "fileName=image.png" \ | ||
-F "keepFile=false" -F "keepFile=false" \ | ||
-F "[email protected]" \ | ||
"https://demo.dataverse.org/api/dataverses/root/featuredItems" | ||
The following example creates one featured item and updates a second one, keeping the existing image it may have had: | ||
|
||
.. code-block:: bash | ||
curl -H "X-Dataverse-key:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" \ | ||
-X PUT \ | ||
-F "id=0" -F "id=1" \ | ||
-F "content=Content 1" -F "content=Updated content 2" \ | ||
-F "displayOrder=1" -F "displayOrder=2" \ | ||
-F "fileName=" -F "fileName=" \ | ||
-F "keepFile=false" -F "keepFile=true" \ | ||
"https://demo.dataverse.org/api/dataverses/root/featuredItems" | ||
Delete All Collection Featured Items | ||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
||
Deletes the featured items configured for a given Dataverse collection ``id``: | ||
|
||
.. code-block:: bash | ||
export API_TOKEN=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx | ||
export SERVER_URL=https://demo.dataverse.org | ||
export ID=root | ||
curl -H "X-Dataverse-key: $API_TOKEN" -X DELETE "$SERVER_URL/api/dataverses/$ID/featuredItems" | ||
The fully expanded example above (without environment variables) looks like this: | ||
|
||
.. code-block:: bash | ||
curl -H "X-Dataverse-key:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" -X DELETE "https://demo.dataverse.org/api/dataverses/root/featuredItems" | ||
Create a Collection Featured Item | ||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
||
Creates a featured item in the given Dataverse collection ``id``: | ||
|
||
.. code-block:: bash | ||
export API_TOKEN=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx | ||
export IMAGE_FILENAME='image.png' | ||
export CONTENT='Content for featured item.' | ||
export DISPLAY_ORDER=1 | ||
export SERVER_URL=https://demo.dataverse.org | ||
export ID=root | ||
curl -H "X-Dataverse-key:$API_TOKEN" -X POST -F "file=@$IMAGE_FILENAME" -F "content=$CONTENT" -F "displayOrder=$DISPLAY_ORDER" "$SERVER_URL/api/dataverses/$ID/featuredItems" | ||
The fully expanded example above (without environment variables) looks like this: | ||
|
||
.. code-block:: bash | ||
curl -H "X-Dataverse-key:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" -X POST -F "[email protected]" -F "content=Content for featured item." -F "displayOrder=1" "https://demo.dataverse.org/api/dataverses/root/featuredItems" | ||
A featured item may or may not contain an image. If you wish to create it without an image, omit the file parameter in the request. | ||
|
||
Update a Collection Featured Item | ||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
||
Updates a featured item given its ``id``: | ||
|
||
.. code-block:: bash | ||
export API_TOKEN=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx | ||
export IMAGE_FILENAME='image.png' | ||
export CONTENT='Content for featured item.' | ||
export DISPLAY_ORDER=1 | ||
export SERVER_URL=https://demo.dataverse.org | ||
export ID=1 | ||
curl -H "X-Dataverse-key:$API_TOKEN" -X PUT -F "file=@$IMAGE_FILENAME" -F "content=$CONTENT" -F "displayOrder=$DISPLAY_ORDER" "$SERVER_URL/api/dataverseFeaturedItems/$ID" | ||
The fully expanded example above (without environment variables) looks like this: | ||
|
||
.. code-block:: bash | ||
curl -H "X-Dataverse-key:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" -X PUT -F "[email protected]" -F "content=Content for featured item." -F "displayOrder=1" "https://demo.dataverse.org/api/dataverseFeaturedItems/1" | ||
``content`` and ``displayOrder`` must always be provided; otherwise, an error will occur. Use the ``file`` parameter to set a new image for the featured item. To keep the existing image, omit ``file`` and send ``keepFile=true``. To remove the image, omit the file parameter. | ||
|
||
Updating the featured item keeping the existing image: | ||
|
||
.. code-block:: bash | ||
curl -H "X-Dataverse-key:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" -X PUT -F "keepFile=true" -F "content=Content for featured item." -F "displayOrder=1" "https://demo.dataverse.org/api/dataverseFeaturedItems/1" | ||
Updating the featured item removing the existing image: | ||
|
||
.. code-block:: bash | ||
curl -H "X-Dataverse-key:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" -X PUT -F "content=Content for featured item." -F "displayOrder=1" "https://demo.dataverse.org/api/dataverseFeaturedItems/1" | ||
Delete a Collection Featured Item | ||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
||
Deletes a featured item given its ``id``: | ||
|
||
.. code-block:: bash | ||
export API_TOKEN=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx | ||
export SERVER_URL=https://demo.dataverse.org | ||
export ID=1 | ||
curl -H "X-Dataverse-key:$API_TOKEN" -X DELETE "$SERVER_URL/api/dataverseFeaturedItems/$ID" | ||
The fully expanded example above (without environment variables) looks like this: | ||
|
||
.. code-block:: bash | ||
curl -H "X-Dataverse-key:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" -X DELETE "https://demo.dataverse.org/api/dataverseFeaturedItems/1" | ||
Get a Collection Featured Item Image | ||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
||
Returns the image of a featured item if one is assigned, given the featured item ``id``: | ||
|
||
.. code-block:: bash | ||
export API_TOKEN=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx | ||
export SERVER_URL=https://demo.dataverse.org | ||
export ID=1 | ||
curl -H "X-Dataverse-key:$API_TOKEN" -X GET "$SERVER_URL/api/access/dataverseFeaturedItemImage/{ID}" | ||
The fully expanded example above (without environment variables) looks like this: | ||
|
||
.. code-block:: bash | ||
curl -H "X-Dataverse-key:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" -X GET "https://demo.dataverse.org/api/access/dataverseFeaturedItemImage/1" | ||
Datasets | ||
-------- | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.