Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Add support for deposit to the DSpace REST API #135

Merged
merged 12 commits into from
Feb 11, 2025

Conversation

markpatton
Copy link
Contributor

@markpatton markpatton commented Nov 15, 2024

A new deposit option is added which uses the DSpace REST API.

Also:

  • Cleaned up DSpace configuration properties
  • Small fix to the duplicate JSONObject warnings when running tests.

DSpace deposit takes three calls and tries to handle resumption after an error in the last two calls.

Operational changes:

  • Can now use repository key DSpace to use the new direct deposit
  • Will need to set additional DSPACE_ variables. See documentation pr below.
  • The metadata set is slightly different. Need to review on stage.

Required prs:

Related prs:

Test by building the pass-core, pass-ui, and pass-support prs. Then using the pass-docker pr, start up PASS with dspace support. Finally attempt to do some deposits and verify that they work. You should notice that publication date is now required.

Notes on interacting directly with the DSpace REST API:

Generate a CSRF token. Note that this endpoint returns 404.

CSRF_TOKEN=`curl -I http://localhost:9000/server/api/security/csrf -w '%header{DSPACE-XSRF-TOKEN}' -o /dev/null`

Login and get the auth token

AUTH_TOKEN=`curl -v -X POST http://localhost:9000/server/api/authn/# --data "user=xxx&password=yyy" -H "X-XSRF-TOKEN: $CSRF_TOKEN" -b "DSPACE-XSRF-COOKIE=$CSRF_TOKEN" -w '%header{Authorization}'`

Create a workspace item

export COLLECTION=8d80c978-5cf3-46bb-a5ea-dd8425f1af2f

curl -v -X POST "http://localhost:9000/server/api/submission/workspaceitems?owningCollection=$COLLECTION" --form 'file=@/home/msp/Downloads/test.pdf' --form 'file=@/home/msp/Downloads/test2.pdf' -H "Authorization: $AUTH_TOKEN" -H "X-XSRF-TOKEN: $CSRF_TOKEN" -b "DSPACE-XSRF-COOKIE=$CSRF_TOKEN"
export WSI_ID=49

See workspace items

curl -v "http://localhost:9000/server/api/submission/workspaceitems/" -H "Authorization: Bearer $AUTH_TOKEN"

Set required metadata

curl -v -X PATCH "http://localhost:9000/server/api/submission/workspaceitems/$WSI_ID" -H 'Content-Type: application/json' --data-binary "@/home/msp/work/pass/pass-support/md.patch" -H "Authorization: $AUTH_TOKEN" -H "X-XSRF-TOKEN: $CSRF_TOKEN" -b "DSPACE-XSRF-COOKIE=$CSRF_TOKEN"

Create a workflow item for workspace item

 curl -v -X POST http://localhost:9000/server/api/workflow/workflowitems -H "Content-Type:text/uri-list" --data "http://localhost:9000/server/api/submission/workspaceitems/$WSI_ID" -H "Authorization: $AUTH_TOKEN" -H "X-XSRF-TOKEN: $CSRF_TOKEN" -b "DSPACE-XSRF-COOKIE=$CSRF_TOKEN"

Example of patch

[
    {
        "op": "add",
        "path": "/sections/teste/dc.title",
        "value": [
            {
                "authority": null,
                "confidence": -1,
                "display": "AROLDO TEST WITH REST",
                "language": null,
                "otherInformation": null,
                "place": 0,
                "value": "AROLDO TEST WITH REST"
            }
        ]
    },
{
        "op": "add",
        "path": "/sections/license/granted",
        "value": "true"
    }
]





[
    {
        "op": "add",
        "path": "/sections/teste/dc.title",
        "value": [
            {
                "authority": null,
                "confidence": -1,
                "display": "AROLDO TEST WITH REST",
                "language": null,
                "otherInformation": null,
                "place": 0,
                "value": "AROLDO TEST WITH REST"
            }
        ]
    },
{
        "op": "add",
        "path": "/sections/license/granted",
        "value": "true"
    }
]

@markpatton markpatton marked this pull request as draft November 15, 2024 15:17
@markpatton markpatton linked an issue Nov 15, 2024 that may be closed by this pull request
@markpatton markpatton force-pushed the 1063-dspace-rest-deposit branch 2 times, most recently from fec504f to d4a366b Compare November 22, 2024 18:32
@markpatton markpatton force-pushed the 1063-dspace-rest-deposit branch from 6ce178a to d750107 Compare December 16, 2024 14:56
@markpatton markpatton force-pushed the 1063-dspace-rest-deposit branch from 5bf461e to c84a802 Compare January 2, 2025 18:16
@markpatton markpatton marked this pull request as ready for review January 3, 2025 15:35
@markpatton markpatton force-pushed the 1063-dspace-rest-deposit branch from 94a9f14 to d34fdf5 Compare February 4, 2025 14:47
@markpatton markpatton requested a review from rpoet-jh February 5, 2025 16:14
Copy link
Contributor

@rpoet-jh rpoet-jh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice job, Mark! Just a few comments, but in general it looks good. I still need to test and review the other PRs, but this is a first pass at the review for this main PR.

@markpatton markpatton requested a review from rpoet-jh February 10, 2025 20:52
@markpatton markpatton merged commit b4840ce into main Feb 11, 2025
3 checks passed
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for deposit using the DSpace REST API
2 participants