samvera / rubydora

Fedora Commons version 3 REST API ruby library
Other
27 stars 17 forks source link

Object state not being stored for new objects #79

Closed val99erie closed 10 years ago

val99erie commented 10 years ago

I'm trying to create a new object in fedora that has an object state of "I", but whenever I create a new object, the state always gets stored as "A". (The state is correctly "I" in memory, but if I examine the object in the fedora console or reload the object, the state will be "A".)

If you save the object a second time, it will have the correct state after that. The state just doesn't seem to stick the very first time you save it.

I wrote a failing spec to demonstrate the problem. (You should be able to paste this test into spec/lib/integration_test_spec.rb to get it to work.)

  it "should store object state" do
    pid = 'pid:1'
    @repository.find(pid).delete rescue nil 

    obj = Rubydora::DigitalObject.new(pid, @repository, { state: 'I' })
    obj.save
    expect(obj.state).to eq 'I' 

    profile = @repository.object_profile(pid)
    expect(profile['objState']).to eq 'I' 

    stored_obj = @repository.find(pid)
    expect(stored_obj.state).to eq 'I' 
  end
dchandekstark commented 10 years ago

Good catch, @val99erie!

val99erie commented 10 years ago

After digging around a little, I don't think this is an issue with rubydora. I think this behavior is coming from fedora itself. (I'm not sure if it is a bug in fedora, or if it's how fedora is intended to work.)

I sent the same POST request to fedora using the RESTClient extension for Firefox, and I get the same result.

This is the URL that I posted (the same URL that rubydora posted): http://localhost:8983/fedora/objects/pid%3A1?state=I&label=blerg

It did successfully create a new object in fedora with pid:1 and label "blerg", but the state was "A" instead of "I".

So, unless there is something wrong with that URL, there is no problem with rubydora that I can see. I'll close out this issue.

dchandekstark commented 10 years ago

Yeah, Fedora "ingest" REST API method doesn't support the "state" param. You have to ingest and then modify.

So, I guess technically it's not a bug, but a feature. :)

On Jun 6, 2014, at 4:59 PM, Valerie Maher notifications@github.com<mailto:notifications@github.com> wrote:

After digging around a little, I don't think this is an issue with rubydora. I think this behavior is coming from fedora itself. (I'm not sure if it is a bug in fedora, or if it's how fedora is intended to work.)

I sent the same POST request to fedora using the RESTClient extension for Firefox, and I get the same result.

This is the URL that I posted (the same URL that rubydora posted): http://localhost:8983/fedora/objects/pid%3A1?state=I&label=blerg

It did successfully create a new object in fedora with pid:1 and label "blerg", but the state was "A" instead of "I".

So, unless there is something wrong with that URL, there is no problem with rubydora that I can see. I'll close out this issue.

— Reply to this email directly or view it on GitHubhttps://github.com/projecthydra/rubydora/issues/79#issuecomment-45383732.