From 83c55a9fa5a30128821b8f84f756f15471f22296 Mon Sep 17 00:00:00 2001 From: Philip Durbin Date: Thu, 27 Jul 2023 16:36:27 -0400 Subject: [PATCH] Revert "fix(sword): as of Payara 6, "attachment; " required to upload files #8305" This reverts commit 89182c1de0335a7a72079ee773504ca9d006f4aa. --- doc/release-notes/8305-payara6.md | 3 --- doc/sphinx-guides/source/api/sword.rst | 6 +----- .../api/datadeposit/SWORDv2MediaResourceServlet.java | 4 ---- src/test/java/edu/harvard/iq/dataverse/api/UtilIT.java | 4 ++-- 4 files changed, 3 insertions(+), 14 deletions(-) delete mode 100644 doc/release-notes/8305-payara6.md diff --git a/doc/release-notes/8305-payara6.md b/doc/release-notes/8305-payara6.md deleted file mode 100644 index 9e197f07e98..00000000000 --- a/doc/release-notes/8305-payara6.md +++ /dev/null @@ -1,3 +0,0 @@ -## Backward Incompatible Changes - -- To upload files, the SWORD API now requires "Content-Disposition: attachment; filename=example.zip" rather than "Content-Disposition: filename=example.zip". diff --git a/doc/sphinx-guides/source/api/sword.rst b/doc/sphinx-guides/source/api/sword.rst index 7be1f3ffc16..11b43e98774 100755 --- a/doc/sphinx-guides/source/api/sword.rst +++ b/doc/sphinx-guides/source/api/sword.rst @@ -67,8 +67,6 @@ Differences in Dataverse Software 4 from DVN 3.x lead to a few minor backward in - As of Dataverse Software 5.10, ``NONE`` is no longer supported as a license. -- As of Dataverse Software 6.0, when uploading files, you must supply "Content-Disposition: attachment; filename=example.zip" rather than "Content-Disposition: filename=example.zip". See :ref:`sword-add-files`. - New features as of v1.1 ----------------------- @@ -163,8 +161,6 @@ You must have permission to add datasets in a Dataverse collection (the Datavers curl -u $API_TOKEN: https://$HOSTNAME/dvn/api/data-deposit/v1.1/swordv2/collection/dataverse/$DATAVERSE_ALIAS -.. _sword-add-files: - Add files to a dataset with a zip file ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -172,7 +168,7 @@ You must have ``EditDataset`` permission (Contributor role or above such as Cura .. code-block:: bash - curl -u $API_TOKEN: --data-binary @path/to/example.zip -H "Content-Disposition: attachment; filename=example.zip" -H "Content-Type: application/zip" -H "Packaging: http://purl.org/net/sword/package/SimpleZip" https://$HOSTNAME/dvn/api/data-deposit/v1.1/swordv2/edit-media/study/doi:TEST/12345 + curl -u $API_TOKEN: --data-binary @path/to/example.zip -H "Content-Disposition: filename=example.zip" -H "Content-Type: application/zip" -H "Packaging: http://purl.org/net/sword/package/SimpleZip" https://$HOSTNAME/dvn/api/data-deposit/v1.1/swordv2/edit-media/study/doi:TEST/12345 Display a dataset atom entry ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/src/main/java/edu/harvard/iq/dataverse/api/datadeposit/SWORDv2MediaResourceServlet.java b/src/main/java/edu/harvard/iq/dataverse/api/datadeposit/SWORDv2MediaResourceServlet.java index 0cea1b80571..245ab6ab23b 100644 --- a/src/main/java/edu/harvard/iq/dataverse/api/datadeposit/SWORDv2MediaResourceServlet.java +++ b/src/main/java/edu/harvard/iq/dataverse/api/datadeposit/SWORDv2MediaResourceServlet.java @@ -61,10 +61,6 @@ protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws S try { lock.lock(); mediaResourceManagerImpl.setHttpRequest(req); - // Under Payara 5 we could send "Content-Disposition: filename=example.zip" - // Under Payara 6 now must send "Content-Disposition: attachment; filename=example.zip" - // Otherwise we get "Filename could not be extracted from Content-Disposition: Expected separator ';' instead of '='" - // Use req.getHeader("Content-Disposition") to see what the client is sending. this.api.post(req, resp); mediaResourceManagerImpl.setHttpRequest(null); } finally { diff --git a/src/test/java/edu/harvard/iq/dataverse/api/UtilIT.java b/src/test/java/edu/harvard/iq/dataverse/api/UtilIT.java index a19f251b065..5f61ab3f2c7 100644 --- a/src/test/java/edu/harvard/iq/dataverse/api/UtilIT.java +++ b/src/test/java/edu/harvard/iq/dataverse/api/UtilIT.java @@ -648,7 +648,7 @@ public static Response uploadFile(String persistentId, String zipfilename, Strin Response swordStatementResponse = given() .body(bytes) .header("Packaging", "http://purl.org/net/sword/package/SimpleZip") - .header("Content-Disposition", "attachment; filename=" + zipfilename) + .header("Content-Disposition", "filename=" + zipfilename) /** * It's unclear why we need to add "preemptive" to auth but * without it we can't use send bytes using the body/content @@ -675,7 +675,7 @@ public static Response uploadZipFileViaSword(String persistentId, String pathToZ Response swordStatementResponse = given() .body(bytes) .header("Packaging", "http://purl.org/net/sword/package/SimpleZip") - .header("Content-Disposition", "attachment; filename=" + zipfilename) + .header("Content-Disposition", "filename=" + zipfilename) /** * It's unclear why we need to add "preemptive" to auth but * without it we can't use send bytes using the body/content