samvera / active_fedora

A Rails interface to the Fedora repository, akin to ActiveModel
Other
54 stars 63 forks source link

Support deleting of versions #935

Open awead opened 8 years ago

awead commented 8 years ago

It would be nice to be able to delete versions. Currently, the only way to do this seems to be to:

curl -X DELETE http://localhost:8983/fedora/rest/foo/fcr:versions/label

Maybe use ActiveFedora::VersionsGraph to do something like object.versions.first.delete or object.versions.with_label("xyz").delete.

carolyncole commented 8 years ago

We need to be carful of deleting versions since our current version strategy goes by the count of the versions. When I deleted the first version, and then tried to upload a new version I got the following error:

2015-11-02 14:48:50 -0500 (4417) Rendering 500 page due to exception: #<Ldp::HttpError: STATUS: 409 The specified label "version2" is already assigned to another version of this resource!...> - ["/opt/heracles/deploy/scholarsphere/shared/bundle/ruby/2.2.0/gems/ldp-0.3.1/lib/ldp/client/methods.rb:108:in `block in check_for_errors'", "/opt/heracles/deploy/scholarsphere/shared/bundle/ruby/2.2.0/gems/ldp-0.3.1/lib/ldp/client/methods.rb:106:in `tap'", "/opt/heracles/deploy/scholarsphere/shared/bundle/ruby/2.2.0/gems/ldp-0.3.1/lib/ldp/client/methods.rb:106:in `check_for_errors'", "/opt/heracles/deploy/scholarsphere/shared/bundle/ruby/2.2.0/gems/ldp-0.3.1/lib/ldp/client/methods.rb:77:in `post'", "/opt/heracles/deploy/scholarsphere/shared/bundle/ruby/2.2.0/gems/active-fedora-9.4.0/lib/active_fedora/caching_connection.rb:19:in `post'", "/opt/heracles/deploy/scholarsphere/shared/bundle/ruby/2.2.0/gems/active-fedora-9.4.0/lib/active_fedora/versionable.rb:36:in `create_version'", "/opt/heracles/deploy/scholarsphere/shared/bundle/ruby/2.2.0/bundler/gems/sufia-fa0190067b76/sufia-models/lib/sufia/models/file_content/versions.rb:10:in `block in save'", "/opt/heracles/deploy/scholarsphere/shared/bundle/ruby/2.2.0/bundler/gems/sufia-fa0190067b76/sufia-models/lib/sufia/models/file_content/versions.rb:9:in `tap'", "/opt/heracles/deploy/scholarsphere/shared/bundle/ruby/2.2.0/bundler/gems/sufia-fa0190067b76/sufia-models/lib/sufia/models/file_content/versions.rb:9:in `save'", "/opt/heracles/deploy/scholarsphere/shared/bundle/ruby/2.2.0/gems/active-fedora-9.4.0/lib/active_fedora/persistence.rb:206:in `block in save_attached_files'", "/opt/heracles/deploy/scholarsphere/shared/bundle/ruby/2.2.0/gems/active-fedora-9.4.0/lib/active_fedora/persistence.rb:205:in `each'", "/opt/heracles/deplo...
awead commented 8 years ago

Yes, this is bad, and borrowed a bit from Fedora3's version process of adding .0, .1, etc. to the end of datastream names. A better solution might be to use the UUID as the label, but this would force some changes in Sufia or other apps that were using the label as a presented display such as "version1".