[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[EP-tech] Re: SWORD deposit



Ah, that looks very straightforward. Basically we're trying to piggyback
onto a form and populate new records straight off the back. So, I can
write a script (PHP) which bundles the form data into an acceptable format
and pushes it through into EPrints off the back of that. I should be able
to extrapolate from your example.

Thanks!

On 28/08/2014 08:57, "Ian Stuart" <Ian.Stuart at ed.ac.uk> wrote:

>I mis-read the original post..... you're looking for how to POST INTO a
>repo?
>
>That's simple.... its an http post request, with certain headers set.
>
>So - the first thing you need to know is how you are going to package
>your deposit (the EPrint XML format is the simplest solution, but
>requires work in your depositing service to create that XML.)
>
>   http://eprints.lincoln.ac.uk/sword-app/servicedocument
>
>will return all the formats your repo understands
>
>You will get a list something like:
>
>   <accept alternate="multipart-related">
>     application/x-bibtex
>   </accept>
>   <accept alternate="multipart-related">
>     application/x-eprints-import-bibtex; charset=utf-8
>   </accept>
>   <accept alternate="multipart-related">
>     application/x-eprints-import-doi; charset=utf-8
>   </accept>
>   <accept alternate="multipart-related">
>
>application/vnd.openxmlformats-officedocument.wordprocessingml.document
>   </accept>
>   <accept alternate="multipart-related">
>     application/vnd.openxmlformats</accept>
>   <accept alternate="multipart-related">
>     application/msword
>   </accept>
>   <accept alternate="multipart-related">
>     application/x-eprints-import-pubmedid
>   </accept>
>   <accept alternate="multipart-related">
>     application/x-eprints-import-pubmedxml
>   </accept>
>   <accept alternate="multipart-related">
>     application/vnd.rjbroker
>   </accept>
>   <sword:acceptPackaging>
>     http://opendepot.org/broker/1.0
>   </sword:acceptPackaging>
>   <accept alternate="multipart-related">
>     application/vnd.eprints.data+xml; charset=utf-8
>   </accept>
>   <sword:acceptPackaging>
>     http://eprints.org/ep2/data/2.0
>   </sword:acceptPackaging>
>   <acceptPackaging>
>     http://purl.org/net/sword/package/Binary
>   </acceptPackaging>
>   <accept alternate="multipart-related">
>     application/octet-stream
>   </accept>
>
>So the deposit is created (perl-wise) thus:
>
>   my $ep = $session->eprint($eprintid);
>   my $mime_type = 'foo'; # where "foo" is one of <accept> values above
>
>   my $ua = LWP::UserAgent->new;
>   my $auth = "Basic " . MIME::Base64::encode( "$username:$password", ''
>);
>   my %headers = (
>     'X-No-Op'             => 'false',
>     'X-Verbose'           => 'true',
>     'Content-Disposition' => "filename=" . $some_filename,
>     'Content-Type'        => $mime_type,
>     'User-Agent'          => 'Your external service',
>     'Authorization'       => $auth,
>   );
>
>   # This URL is for a new deposit ONLY!
>   my $url = 'http://eprints.lincoln.ac.uk/id/contents';
>
>   my $buffer = $scalar_string_of_whats_to_be_deposited;
>   my $r = $ua->post( $url, %headers, Content => $buffer );
>
>   my $content = $r->content;
>   if ( $r->is_success ) {
>     my $return_id;
>     print "SUCCESS.\n";
>     if ( $content =~ m#<id>([^<]+)</id># ) {
>       $return_id = $1 if $1;
>     }
>     print "return_id = $return_id\n";
>   } else {
>     print "FAIL\n";
>   }
>
>..... Enjoy!
>
>On 27/08/14 18:35, Tommy Ingulfsen wrote:
>> Hi Andrew
>>
>> David Kane and I wrote a basic PHP library for SWORD deposits:
>>
>> https://github.com/davidfkane/eprintsDepositHelper
>>
>> I think our use case is quite different to Ian's, and maybe yours too,
>>but
>> if you are somewhat familiar with PHP, you may be able to learn a little
>> from the spaghetti (the spaghetti is mine, David's code is nicer?). You
>> can use EPrints' own XML format to deposit, if that fits with what you
>> want to do, which EPrints can import automatically.
>>
>> The core of EPrints 3.3's SWORD/AtomPub implementation is
>> $EPRINTSPATH/perl_lib/EPrints/Apache/CRUD.pm - there is some
>>documentation
>> here:
>>
>> http://wiki.eprints.org/w/API:EPrints/Apache/CRUD
>
>
>--
>
>Ian Stuart.
>Developer: ORI, RJ-Broker, and OpenDepot.org
>Bibliographics and Multimedia Service Delivery team,
>EDINA,
>The University of Edinburgh.
>
>http://edina.ac.uk/
>
>This email was sent via the University of Edinburgh.
>
>The University of Edinburgh is a charitable body, registered in
>Scotland, with registration number SC005336.
>
>
>*** Options: http://mailman.ecs.soton.ac.uk/mailman/listinfo/eprints-tech
>*** Archive: http://www.eprints.org/tech.php/
>*** EPrints community wiki: http://wiki.eprints.org/
>*** EPrints developers Forum: http://forum.eprints.org/


The University of Lincoln, located in the heart of the city of Lincoln, has established an international reputation based on high student satisfaction, excellent graduate employment and world-class research.

The information in this e-mail and any attachments may be confidential. If you have received this email in error please notify the sender immediately and remove it from your system. Do not disclose the contents to another person or take copies.

Email is not secure and may contain viruses. The University of Lincoln makes every effort to ensure email is sent without viruses, but cannot guarantee this and recommends recipients take appropriate precautions.

The University may monitor email traffic data and content in accordance with its policies and English law. Further information can be found at: http://www.lincoln.ac.uk/legal.