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

Problem: Get file information for package (API) endpoint only works for transfers (those sent to backlog) #342

Open
ross-spencer opened this issue Nov 20, 2018 · 3 comments
Labels
API Issues relating to the Archivematica APIs, bugs/new endpoints, etc.

Comments

@ross-spencer
Copy link
Contributor

ross-spencer commented Nov 20, 2018

Expected behaviour

The endpoint description may be incorrect as this feature (from what I can establish) has never worked for any other package type but a SIP sent to Backlog see: artefactual/archivematica-storage-service@b1a62e8. That being said, if we could provide the same information for users about their AIPs then this does seem to be useful.

Original report of this issue: https://groups.google.com/d/msg/archivematica/SZyinU3Kq9U/B_Tz_FP_AQAJ

Current behaviour

A call to the endpoint will return a blank file array for a transfer that was processed immediately into an AIP:

{
    "files": [],
    "package": "951427e3-4a9e-4c2e-91fb-b63de793d09d",
    "success": true
}

For a transfer sent to backlog:

{
    "files": [
        {
            "accessionid": "2",
            "checksum": "",
            "name": "2-8367eda9-423c-45a0-86cb-67daa4b25250/objects/one_file/one_file.txt",
            "origin": "79492e4f-3952-415d-9173-4e1f459f5016",
            "source_id": "eec9576e-b0f2-4e07-ab8b-19a8d94c68e4",
            "source_package": "951427e3-4a9e-4c2e-91fb-b63de793d09d"
        },
        {
            "accessionid": "2",
            "checksum": "",
            "name": "2-8367eda9-423c-45a0-86cb-67daa4b25250/objects/one_zip/one_file.zip",
            "origin": "79492e4f-3952-415d-9173-4e1f459f5016",
            "source_id": "1cfd143d-aad4-4305-a857-6f972aa970a5",
            "source_package": "951427e3-4a9e-4c2e-91fb-b63de793d09d"
        }
    ],
    "package": "8367eda9-423c-45a0-86cb-67daa4b25250",
    "success": true
}

Steps to reproduce

For users running HTTPie, they can try an API call (for a package in AIP storage or SIP in transfer backlog):

http -v --pretty=format \
    GET http://127.0.0.1:62081/api/v2/file/{package-uuid}/contents/ \
    Authorization:"ApiKey test:test"

And they should see the contrasting output.

Your environment (version of Archivematica, OS version, etc)

Docker-compose, Archivematica Storage Service qa/0.x


For Artefactual use:
Please make sure these steps are taken before moving this issue from Review to Verified in Waffle:

  • All PRs related to this issue are properly linked 👍
  • All PRs related to this issue have been merged 👍
  • Test plan for this issue has been implemented and passed 👍
  • Documentation regarding this issue has been written and it has been added to the release notes, if needed 👍
@ross-spencer
Copy link
Contributor Author

Logged here recently as well: artefactual/archivematica-storage-service#427

@ross-spencer
Copy link
Contributor Author

ross-spencer commented Feb 23, 2019

The files are indexed through a different route in code, the location_file table which drives this is only updated when a package is sent to backlog, starting here, and then this eventually updates the table here.

Example table after storing a handful of AIPs and then sending one SIP to backlog:

mysql> select * from locations_file;
+----+--------------------------------------+-----------------------------------------------------------------------+--------------------------------------+----------+--------+-------------+--------------------------------------+------------+--------------------------------------+
| id | uuid                                 | name                                                                  | source_id                            | checksum | stored | accessionid | origin                               | package_id | source_package                       |
+----+--------------------------------------+-----------------------------------------------------------------------+--------------------------------------+----------+--------+-------------+--------------------------------------+------------+--------------------------------------+
|  1 | f9be9af4-8540-4729-ac32-9e3845b304b6 | 6-27bc7000-b181-4e9b-83e9-667e2358b579/objects/one_file/one_file.txt  | fbf2f1a8-8419-4074-b620-79a414c8b996 |          |      0 |             | efc5e342-7570-44d5-bd2f-285e00fe9608 |          6 | 27bc7000-b181-4e9b-83e9-667e2358b579 |
|  2 | e3415ff4-9154-4741-9a26-80a1a4f1ad0a | 6-27bc7000-b181-4e9b-83e9-667e2358b579/objects/one_zip/one_file.zip   | 86a3b9a7-456a-4366-9283-006746c222da |          |      0 |             | efc5e342-7570-44d5-bd2f-285e00fe9608 |          6 | 27bc7000-b181-4e9b-83e9-667e2358b579 |
+----+--------------------------------------+-----------------------------------------------------------------------+--------------------------------------+----------+--------+-------------+--------------------------------------+------------+--------------------------------------+
2 rows in set (0.00 sec)

Example API output:

HTTP/1.1 200 OK
Cache-Control: no-cache
Connection: keep-alive
Content-Language: en
Content-Type: application/json
Date: Fri, 22 Feb 2019 23:50:42 GMT
Server: nginx/1.14.2
Transfer-Encoding: chunked
Vary: Accept, Accept-Language, Cookie
X-Frame-Options: SAMEORIGIN

{
    "files": [
        {
            "accessionid": "",
            "checksum": "",
            "name": "6-27bc7000-b181-4e9b-83e9-667e2358b579/objects/one_file/one_file.txt",
            "origin": "efc5e342-7570-44d5-bd2f-285e00fe9608",
            "source_id": "fbf2f1a8-8419-4074-b620-79a414c8b996",
            "source_package": "27bc7000-b181-4e9b-83e9-667e2358b579"
        },
        {
            "accessionid": "",
            "checksum": "",
            "name": "6-27bc7000-b181-4e9b-83e9-667e2358b579/objects/one_zip/one_file.zip",
            "origin": "efc5e342-7570-44d5-bd2f-285e00fe9608",
            "source_id": "86a3b9a7-456a-4366-9283-006746c222da",
            "source_package": "27bc7000-b181-4e9b-83e9-667e2358b579"
        }
    ],
    "package": "27bc7000-b181-4e9b-83e9-667e2358b579",
    "success": true
}

@ross-spencer
Copy link
Contributor Author

This should also work for SWORD2 Fedora/Archidora/Islandora based transfers, per #947.

Related to #947

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API Issues relating to the Archivematica APIs, bugs/new endpoints, etc.
Projects
None yet
Development

No branches or pull requests

1 participant