[Dspace-tech] Help with Sword Client API (Ruby)

2014-12-16 Thread Bruno Zanette
Hey everybody!

This is not a dspace specific question, but i hope someone can help me.

I'm implementing a Ruby sword client to submit itens to dspace using a
custom interface. I did some research and i found "sword2ruby"
library, but i'm trying to execute the example given on the project
git page (https://github.com/swordapp/sword2ruby) and it doesn't work.
The library is supposed to be compatible with sword 2.0 but when i
configure it to get swordv2/servicedocument it return an error on
document mime-type:

/home/bruno/.rvm/gems/ruby-2.1.4/gems/atom-tools-2.0.5/lib/atom/http.rb:492:in
`validate_content_type': unexpected response Content-Type:
"application/atomserv+xml". should be one of:
["application/atomsvc+xml"] (Atom::WrongMimetype)


When i use sword 1.0 app, the script successfully validate
servicedocument but it crashes on post_media command. The logs say
that there is no ingester for the type of file:

ERROR org.dspace.sword.CollectionDepositor @ Unacceptable content type
detected: text/plain for collection 1
2014-12-16 14:09:09,271 ERROR org.purl.sword.server.DepositServlet @
org.purl.sword.base.SWORDErrorException: Unacceptable content type in
deposit request: text/plain


I've already tried to modify swordv2 configs to set generate options
to use 1.3 version, but it didn't work.

I'm using dspace-4 (git version) on ubuntu 14.04.

Does anyone have some advice about it? Am I doing something wrong or
the library is broken?

Any thing is welcome!!!

Thanks!!

-- 
Bruno Nocera Zanette
+55 41 9992-2508

--
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=164703151&iu=/4140/ostg.clktrk
___
DSpace-tech mailing list
DSpace-tech@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/dspace-tech
List Etiquette: https://wiki.duraspace.org/display/DSPACE/Mailing+List+Etiquette


Re: [Dspace-tech] Help with Sword Client API (Ruby)

2014-12-16 Thread Brown, Jacob
I've never used the SWORD protocol, but it should be pretty easy to avoid the 
mimetype exception (for the SWORD V2 interface).

I'm assuming that "atomserv+xml" and "atomsvc+xml" are used by different 
services to identify the same SWORD/XML format. From some quick testing, it 
seems like this is the case, but it may be an unsafe assumption.

To avoid the exception, simply paste the following in your console/script 
somewhere after you require 'sword2ruby' and before you define your service:

Atom::HTTPResponse.module_eval { def validate_content_type(*); end }

Note: this could have unintended consequences for other aspects of your 
application. It would be much better to monkeypatch the `initialize` method of 
`Atom::Service` (defined in 
https://github.com/swordapp/sword2ruby/blob/v1.0.1/lib/sword2ruby/service.rb), 
but the developers haven't made it easy to do so (you would have to copy and 
paste the contents of that method into your patch, modifying all instances of 
"application/atomsvc+xml" to "application/atomserv+xml").

I've only tested this minimally, but was able to define a service successfully 
on a local DSpace SWORDV2 installation.

Jacob Brown

-Original Message-
From: Bruno Zanette [mailto:brunonzane...@gmail.com] 
Sent: Tuesday, December 16, 2014 10:15 AM
To: dspace-tech@lists.sourceforge.net
Subject: [Dspace-tech] Help with Sword Client API (Ruby)

Hey everybody!

This is not a dspace specific question, but i hope someone can help me.

I'm implementing a Ruby sword client to submit itens to dspace using a custom 
interface. I did some research and i found "sword2ruby"
library, but i'm trying to execute the example given on the project git page 
(https://github.com/swordapp/sword2ruby) and it doesn't work.
The library is supposed to be compatible with sword 2.0 but when i configure it 
to get swordv2/servicedocument it return an error on document mime-type:

/home/bruno/.rvm/gems/ruby-2.1.4/gems/atom-tools-2.0.5/lib/atom/http.rb:492:in
`validate_content_type': unexpected response Content-Type:
"application/atomserv+xml". should be one of:
["application/atomsvc+xml"] (Atom::WrongMimetype)


When i use sword 1.0 app, the script successfully validate servicedocument but 
it crashes on post_media command. The logs say that there is no ingester for 
the type of file:

ERROR org.dspace.sword.CollectionDepositor @ Unacceptable content type
detected: text/plain for collection 1
2014-12-16 14:09:09,271 ERROR org.purl.sword.server.DepositServlet @
org.purl.sword.base.SWORDErrorException: Unacceptable content type in deposit 
request: text/plain


I've already tried to modify swordv2 configs to set generate options to use 1.3 
version, but it didn't work.

I'm using dspace-4 (git version) on ubuntu 14.04.

Does anyone have some advice about it? Am I doing something wrong or the 
library is broken?

Any thing is welcome!!!

Thanks!!

--
Bruno Nocera Zanette
+55 41 9992-2508

--
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=164703151&iu=/4140/ostg.clktrk
___
DSpace-tech mailing list
DSpace-tech@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/dspace-tech
List Etiquette: https://wiki.duraspace.org/display/DSPACE/Mailing+List+Etiquette

--
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=164703151&iu=/4140/ostg.clktrk
___
DSpace-tech mailing list
DSpace-tech@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/dspace-tech
List Etiquette: https://wiki.duraspace.org/display/DSPACE/Mailing+List+Etiquette


Re: [Dspace-tech] Help with Sword Client API (Ruby)

2014-12-16 Thread Seth Robbins
Hi Bruno,
I'm not very familiar with swordv2, but the sword v1 error is coming from
dspace. Usually dspace expects a zipped package of some type (by default,
it expects the dspace mets format, though I think it can be configured to
accept SAF, look in the sword-server.cfg file in the dspace/config
directory to see and change how yours is set up). The tutorial code appears
to just send a text file, which would not be depositable to dspace without
being wrapped in a package. If you need a package to test with, there
appear to be some examples available at
http://swordapp.org/sword-v1/sword-v1-clients-and-demonstrator-repositories/


Also, when I've tested sword in the past the request needed to include a
header "X-Packaging: http://purl.org/net/sword-types/METSDSpaceSIP"; as well
as "Content-Type:application/zip". That means that where the example code
says
collection.post_media!(:filepath=>"test.txt", :content_type=>"text/plain")
you should try something like
 collection.post_media!(:filepath=>"/your/example/here.zip",
:content_type=>"application/zip", :packaging => "
http://purl.org/net/sword/package/METSDSpaceSIP";)

Hope that's helpful,
Seth Robbins


On Tue, Dec 16, 2014 at 10:15 AM, Bruno Zanette 
wrote:
>
> Hey everybody!
>
> This is not a dspace specific question, but i hope someone can help me.
>
> I'm implementing a Ruby sword client to submit itens to dspace using a
> custom interface. I did some research and i found "sword2ruby"
> library, but i'm trying to execute the example given on the project
> git page (https://github.com/swordapp/sword2ruby) and it doesn't work.
> The library is supposed to be compatible with sword 2.0 but when i
> configure it to get swordv2/servicedocument it return an error on
> document mime-type:
> 
>
> /home/bruno/.rvm/gems/ruby-2.1.4/gems/atom-tools-2.0.5/lib/atom/http.rb:492:in
> `validate_content_type': unexpected response Content-Type:
> "application/atomserv+xml". should be one of:
> ["application/atomsvc+xml"] (Atom::WrongMimetype)
> 
>
> When i use sword 1.0 app, the script successfully validate
> servicedocument but it crashes on post_media command. The logs say
> that there is no ingester for the type of file:
> 
> ERROR org.dspace.sword.CollectionDepositor @ Unacceptable content type
> detected: text/plain for collection 1
> 2014-12-16 14:09:09,271 ERROR org.purl.sword.server.DepositServlet @
> org.purl.sword.base.SWORDErrorException: Unacceptable content type in
> deposit request: text/plain
> 
>
> I've already tried to modify swordv2 configs to set generate options
> to use 1.3 version, but it didn't work.
>
> I'm using dspace-4 (git version) on ubuntu 14.04.
>
> Does anyone have some advice about it? Am I doing something wrong or
> the library is broken?
>
> Any thing is welcome!!!
>
> Thanks!!
>
> --
> Bruno Nocera Zanette
> +55 41 9992-2508
>
>
> --
> Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
> from Actuate! Instantly Supercharge Your Business Reports and Dashboards
> with Interactivity, Sharing, Native Excel Exports, App Integration & more
> Get technology previously reserved for billion-dollar corporations, FREE
>
> http://pubads.g.doubleclick.net/gampad/clk?id=164703151&iu=/4140/ostg.clktrk
> ___
> DSpace-tech mailing list
> DSpace-tech@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/dspace-tech
> List Etiquette:
> https://wiki.duraspace.org/display/DSPACE/Mailing+List+Etiquette
>


-- 
Seth Robbins | Research Programmer for Repository Development
Main Library | Room 422 | robbins...@gmail.com | srobb...@illinois.edu
--
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=164703151&iu=/4140/ostg.clktrk___
DSpace-tech mailing list
DSpace-tech@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/dspace-tech
List Etiquette: https://wiki.duraspace.org/display/DSPACE/Mailing+List+Etiquette

Re: [Dspace-tech] Help with Sword Client API (Ruby)

2014-12-18 Thread Bruno Zanette
Thank you so much for the all the helpful infos!
I'm still struggling to get it done but now it's because my
inexperience on Ruby.
When i manage to do it i will post the code here!
Ty!

2014-12-16 18:25 GMT-02:00 Seth Robbins :
> Hi Bruno,
> I'm not very familiar with swordv2, but the sword v1 error is coming from
> dspace. Usually dspace expects a zipped package of some type (by default, it
> expects the dspace mets format, though I think it can be configured to
> accept SAF, look in the sword-server.cfg file in the dspace/config directory
> to see and change how yours is set up). The tutorial code appears to just
> send a text file, which would not be depositable to dspace without being
> wrapped in a package. If you need a package to test with, there appear to be
> some examples available at
> http://swordapp.org/sword-v1/sword-v1-clients-and-demonstrator-repositories/
>
> Also, when I've tested sword in the past the request needed to include a
> header "X-Packaging: http://purl.org/net/sword-types/METSDSpaceSIP"; as well
> as "Content-Type:application/zip". That means that where the example code
> says
> collection.post_media!(:filepath=>"test.txt", :content_type=>"text/plain")
> you should try something like
>  collection.post_media!(:filepath=>"/your/example/here.zip",
> :content_type=>"application/zip", :packaging =>
> "http://purl.org/net/sword/package/METSDSpaceSIP";)
>
> Hope that's helpful,
> Seth Robbins
>
>
> On Tue, Dec 16, 2014 at 10:15 AM, Bruno Zanette 
> wrote:
>>
>> Hey everybody!
>>
>> This is not a dspace specific question, but i hope someone can help me.
>>
>> I'm implementing a Ruby sword client to submit itens to dspace using a
>> custom interface. I did some research and i found "sword2ruby"
>> library, but i'm trying to execute the example given on the project
>> git page (https://github.com/swordapp/sword2ruby) and it doesn't work.
>> The library is supposed to be compatible with sword 2.0 but when i
>> configure it to get swordv2/servicedocument it return an error on
>> document mime-type:
>> 
>>
>> /home/bruno/.rvm/gems/ruby-2.1.4/gems/atom-tools-2.0.5/lib/atom/http.rb:492:in
>> `validate_content_type': unexpected response Content-Type:
>> "application/atomserv+xml". should be one of:
>> ["application/atomsvc+xml"] (Atom::WrongMimetype)
>> 
>>
>> When i use sword 1.0 app, the script successfully validate
>> servicedocument but it crashes on post_media command. The logs say
>> that there is no ingester for the type of file:
>> 
>> ERROR org.dspace.sword.CollectionDepositor @ Unacceptable content type
>> detected: text/plain for collection 1
>> 2014-12-16 14:09:09,271 ERROR org.purl.sword.server.DepositServlet @
>> org.purl.sword.base.SWORDErrorException: Unacceptable content type in
>> deposit request: text/plain
>> 
>>
>> I've already tried to modify swordv2 configs to set generate options
>> to use 1.3 version, but it didn't work.
>>
>> I'm using dspace-4 (git version) on ubuntu 14.04.
>>
>> Does anyone have some advice about it? Am I doing something wrong or
>> the library is broken?
>>
>> Any thing is welcome!!!
>>
>> Thanks!!
>>
>> --
>> Bruno Nocera Zanette
>> +55 41 9992-2508
>>
>>
>> --
>> Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
>> from Actuate! Instantly Supercharge Your Business Reports and Dashboards
>> with Interactivity, Sharing, Native Excel Exports, App Integration & more
>> Get technology previously reserved for billion-dollar corporations, FREE
>>
>> http://pubads.g.doubleclick.net/gampad/clk?id=164703151&iu=/4140/ostg.clktrk
>> ___
>> DSpace-tech mailing list
>> DSpace-tech@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/dspace-tech
>> List Etiquette:
>> https://wiki.duraspace.org/display/DSPACE/Mailing+List+Etiquette
>
>
>
> --
> Seth Robbins | Research Programmer for Repository Development
> Main Library | Room 422 | robbins...@gmail.com | srobb...@illinois.edu



-- 
Bruno Nocera Zanette
+55 41 9992-2508

--
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=164703151&iu=/4140/ostg.clktrk
___
DSpace-tech mailing list
DSpace-tech@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/dspace-tech
List Etiquette: https://wiki.duraspace.org/display/DSPACE/Mailing+List+Etiquette