Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Cannot retrieve any type of identifier from the files created with uploadFile method since it does not return any information of the created file #16

Closed
AleixMT opened this issue Nov 16, 2022 · 6 comments

Comments

@AleixMT
Copy link
Contributor

AleixMT commented Nov 16, 2022

When using the uploadFile method, it uses internally the method deposit from class UploadFile. Method deposit returns a DepositReceipt that contains the result of the operation, for example the identifier of the file that you uploaded, but the method uploadFile does not return anything. This makes impossible to keep manipulating the file for example for metadata addition because you are not returning the identification.

¿Could you please explain if this is the intentional design? ¿Is there a possible workaround to obtain the id of the file that you updated with the uploadFile method?

If not I will raise another pull request to fix this or add another method that has this behaviour.

@pdurbin
Copy link
Member

pdurbin commented Nov 21, 2022

The workaround we use in tests is to retrieve the SWORD statement using a method called getFileIdFromSwordStatementBody: https://github.com/IQSS/dataverse/blob/v5.12.1/src/test/java/edu/harvard/iq/dataverse/api/UtilIT.java#L1003

That is to say, from what I can tell, no, with SWORD we don't give you the database ID of the file in the deposit receipt. You have to make a separate call to the get the statement. Yes, this is pretty sub-optimal. The native (JSON) API works in a more sane manner, returning the database ID of the file when you upload the file.

For reference, this is what I'm seeing as output when you upload a file via SWORD (no "database ID 7" or whatever):

<entry xmlns="http://www.w3.org/2005/Atom">
  <bibliographicCitation xmlns="http://purl.org/dc/terms/">Lastname, Firstname, 2022, "My Working Title", https://doi.org/10.5072/FK2/E8ZFGV, Root, DRAFT VERSION</bibliographicCitation>
  <generator uri="http://www.swordapp.org/" version="2.0"/>
  <id>http://localhost:8080/dvn/api/data-deposit/v1.1/swordv2/edit/study/doi:10.5072/FK2/E8ZFGV</id>
  <link href="http://localhost:8080/dvn/api/data-deposit/v1.1/swordv2/edit/study/doi:10.5072/FK2/E8ZFGV" rel="edit"/>
  <link href="http://localhost:8080/dvn/api/data-deposit/v1.1/swordv2/edit/study/doi:10.5072/FK2/E8ZFGV" rel="http://purl.org/net/sword/terms/add"/>
  <link href="http://localhost:8080/dvn/api/data-deposit/v1.1/swordv2/edit-media/study/doi:10.5072/FK2/E8ZFGV" rel="edit-media"/>
  <link href="http://localhost:8080/dvn/api/data-deposit/v1.1/swordv2/statement/study/doi:10.5072/FK2/E8ZFGV" rel="http://purl.org/net/sword/terms/statement" type="application/atom+xml; type=feed"/>
  <treatment xmlns="http://purl.org/net/sword/terms/">no treatment information available</treatment>
  <link href="https://doi.org/10.5072/FK2/E8ZFGV" rel="alternate"/>
</entry>

@otter606
Copy link
Contributor

Hi, I'm working on supporting native API file upload, will do a PR soon. I don't think this was available last time I looked which was a while ago.

@pdurbin
Copy link
Member

pdurbin commented Nov 22, 2022

@otter606 fantastic! It's been great watching you and @AleixMT breathe new life into this library! Go go go!

@otter606
Copy link
Contributor

PR #23 contains a fix for this if anyone wants to take a look.

@AleixMT
Copy link
Contributor Author

AleixMT commented Nov 26, 2022

@pdurbin Thanks for the workaround. Since a PR is incoming I hope that I can use the method the way I needed it :D

Thank you for your time and work @otter606 , I will take a look to PR #23

@richarda23
Copy link
Collaborator

closing, assumed done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants