Open cjcolvar opened 6 years ago
This appears to be something that doesn't happen within Hyrax when it is functioning as an application and creating objects but it can occur when supplying id's for spec tests. Backwards compatibility seems to be a concern for any fix. Providing warnings in the spec test route and/or stopping object creation in the spec test route seems reasonable to resolve this issue. Developer testing is needed to review this issue and verify any fixes.
Descriptive summary
Objects that have ids less than 8 characters long (or the length of the noid configuration if it is smaller) cause bad data to be stored in fedora when added to a collection. This same problem could potentially manifest in other ways. This came up when objects were created with specific ids in the spec tests.
Expected behavior
Objects added to collections will get a ldp:contains
member_of_collections
IndirectContainer that contains a ActiveFedora::Aggregation::Proxy for the collection object.Actual behavior
Objects added to collections will cause a
member_of_collections
IndirectContainer to be created at the root (/rest/test/me/mb/er/_o/member_of_collections
) instead of hanging off of the object. The object does not get a ldp:contains for that node. The IndirectContainer correctly assigns the ldp:membershipResource. If another object with a less than 8 character id is added to a collection then the membershipResource is overwritten but the ldp:contains is appended to making the new object be a member of two collections instead of one as expected.Root Problem
The cause of the incorrect id for the indirect container is the
translate_uri_to_id
method that Hyrax uses: https://github.com/samvera/hyrax/blob/master/lib/hyrax/configuration.rb#L442-L447The ActiveFedora code that calls this is https://github.com/samvera/active_fedora/blob/master/lib/active_fedora/associations/indirectly_contains_association.rb#L51
Example tests
The first test passes but the second fails.
Related work
Link to related tickets or prior related work here. https://github.com/samvera/hyrax/issues/2521