OAI-PMH problem with more than one parameter.

Hello.

I'm trying to make my site work with OAI-PMH (http:// oai.rubyforge.org/). Whilst running the tests on http://re.cs.uct.ac.za/ it seems that it can't process more than two parameters. For example:

http://mysite.com/oai?verb=Identify works fine, but http://mysite.com/oai?verb=Identify&test=tes end ups with an error with any second parameter

Processing OaiController#index (for 0.0.0.0:3030 at 2010-01-09 00:47:21) [GET]   Parameters: {"verb"=>"Identify", "test"=>"tes"}

TypeError (can't convert nil into Array):   oai (0.0.12) lib/oai/provider/response.rb:67:in `-'   oai (0.0.12) lib/oai/provider/response.rb:67:in `valid?'   oai (0.0.12) lib/oai/provider/response.rb:31:in `initialize'   ...

Line 67 is: return false unless (@options.keys - self.class.valid_options).empty? where, ofcourse, self.class.valid_options is nil. But why? Any thoughts?

Hi,

As you know the OAI-PMH standard is pretty specific about what are acceptable parameters to requests and "test" is definitely not one. I have a pretty customized version of the OAI lib running on the Kete project and though it answers properly formed requests correctly it gives a 500 error when passed "&test=test", too.

You seem to indicate that you have tried other second parameters, but are they definitely valid. Here's a valid URL query string, for example:

http://yoursite.com/oai?verb=ListRecords&from=2010-01-01

and here is one with a valid third parameter:

http://yoursite.com/oai?verb=ListRecords&from=2009-12-01&until=2010-01-01

You may get "no records match" type message, but it should be a well formed XML response.

Hopefully it is just a matter of testing with valid parameters and things will come right. At the least it is good to narrow down your issue.

Cheers, Walter

Sheesh, wish I had used "valid" grammar. Oops.

Hi,

You seem to indicate that you have tried other second parameters, but are they definitely valid.

Pretty sure. I used the tests from http://re.cs.uct.ac.za/

Here's a valid URL query string, for example:

http://yoursite.com/oai?verb=ListRecords&from=2010-01-01

and here is one with a valid third parameter:

http://yoursite.com/oai?verb=ListRecords&from=2009-12-01&until=2010-01-01

Unfortunatly your examples don't work either. I get this error:

Processing OaiController#index (for 0.0.0.0 at 2010-01-19 14:15:44) [GET]   Parameters: {"verb"=>"ListRecords", "from"=>"2010-01-01"}

NoMethodError (private method `gsub!' called for Fri Jan 01 00:00:00 UTC 2010:Time):   /usr/lib/ruby/1.8/date/format.rb:1061:in `_parse'   /usr/lib/ruby/1.8/time.rb:240:in `parse'   oai (0.0.12) lib/oai/provider/model/activerecord_wrapper.rb:123:in `sql_conditions'   oai (0.0.12) lib/oai/provider/model/activerecord_wrapper.rb:46:in `find'   oai (0.0.12) lib/oai/provider/response/list_records.rb:6:in `to_xml'   oai (0.0.12) lib/oai/provider.rb:260:in `list_records'   oai (0.0.12) lib/oai/provider.rb:286:in `send'   oai (0.0.12) lib/oai/provider.rb:286:in `process_request'   app/controllers/oai_controller.rb:6:in `index'   /usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'   ...

Rendering /srv/mysite/rails/public/500.html (500 Internal Server Error)

Even funnier is that the same link in the dev mode gives:

Processing OaiController#index (for 127.0.0.1 at 2010-01-19 15:20:18) [GET]   Parameters: {"verb"=>"ListRecords", "from"=>"2010-01-01"}

TypeError (can't dup NilClass):   oai (0.0.12) lib/oai/provider/model/activerecord_wrapper.rb:34:in `latest'   oai (0.0.12) lib/oai/provider/response/record_response.rb:7:in `inherited'   oai (0.0.12) lib/oai/provider/response.rb:73:in `call'   oai (0.0.12) lib/oai/provider/response.rb:73:in `populate_defaults'   oai (0.0.12) lib/oai/provider/response.rb:72:in `each'   oai (0.0.12) lib/oai/provider/response.rb:72:in `populate_defaults'   oai (0.0.12) lib/oai/provider/response.rb:68:in `valid?'   oai (0.0.12) lib/oai/provider/response.rb:31:in `initialize'   oai (0.0.12) lib/oai/provider.rb:260:in `new'   oai (0.0.12) lib/oai/provider.rb:260:in `list_records'   oai (0.0.12) lib/oai/provider.rb:286:in `send'   oai (0.0.12) lib/oai/provider.rb:286:in `process_request'   app/controllers/oai_controller.rb:6:in `index'   /usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'   ...

Really have no idea what's going on here. :frowning:

Yeah, wish I could be of more help, but I don't use the ActiveRecord wrapper with the OAI gem. I use another one that ties directly into my search engine.

I recommend trying to contact Terry Reese (one of the gem's contributors). Here's his blog, he's helped me in the past:

http://people.oregonstate.edu/~reeset/blog/

Cheers, Walter

Walter McGinnis wrote:

Yeah, wish I could be of more help, but I don't use the ActiveRecord wrapper with the OAI gem. I use another one that ties directly into my search engine.

It is very strange to me. Seem that the problem is with parsing the date.

NoMethodError (private method `gsub!' called for Fri Jan 01 00:00:00 UTC 2010:Time):   /usr/lib/ruby/1.8/date/format.rb:1061:in `_parse'

I recommend trying to contact Terry Reese (one of the gem's contributors). Here's his blog, he's helped me in the past:

http://people.oregonstate.edu/~reeset/blog/

Ok, thanks! Will do so straight away

best of all, Szymon

Szymon Maka wrote:

Walter McGinnis wrote:

Yeah, wish I could be of more help, but I don't use the ActiveRecord wrapper with the OAI gem. I use another one that ties directly into my search engine.

It is very strange to me. Seem that the problem is with parsing the date.

NoMethodError (private method `gsub!' called for Fri Jan 01 00:00:00 UTC 2010:Time):   /usr/lib/ruby/1.8/date/format.rb:1061:in `_parse'

I recommend trying to contact Terry Reese (one of the gem's contributors). Here's his blog, he's helped me in the past:

http://people.oregonstate.edu/~reeset/blog/

Ok, thanks! Will do so straight away

best of all, Szymon

The problem here is that the parameter is not a string

Time.parse("2010-06-27 13:44:11") works Time.parse(myDateTimeObject) throws this error

TypeError ($_ value need to be String (nil given)):   /usr/lib/ruby/1.8/date/format.rb:1061:in `_parse'   /usr/lib/ruby/1.8/time.rb:240:in `parse'

Make sure you do

Time.parse(myDateTimeObject.to_s)