[EP-tech] Difficulty in getting object retrieval working in custom storage module

Simon McLeish simon.mcleish at gmail.com
Tue Feb 5 12:54:06 GMT 2013


I'm trying to set up a custom storage module which communicates with a REST
interface using LWP. I can store objects OK, and retrieve them directly
(i.e. not through eprints). But when I try to retrieve an object through
the EPrints interface I get the following in the log:

---------------- EPrints System Error ----------------------------
Error in file retrieval: failed to get file contents
 at /usr/share/eprints3/perl_lib/EPrints/Apache/Storage.pm line 261

called at -e line 0
    eval {...} called at -e line 0
[Tue Feb 05 12:35:20 2013] [error] [client]
EPrints::abort()\n, referer:

The retrieve sub in the module looks like this:

sub retrieve
    my( $self, $fileobj, $sourceid, $offset, $n, $f ) = @_;

    my $repository = $self->{session}->get_repository;
    $repository->log( "Attempting to set up user agent" ) if
($self->{debug}); # for testing
    if (create_ua( $self, $fileobj))
        $repository->log( "Attempting to access HCP " .
$self->{_url}->{$fileobj} ) if ($self->{debug}); # for testing
        my $ua = $self->{_ua}->{$fileobj};
        my $request = new
        my $response = $ua->request( $request,$f ); # feed the response to
the callback function
        $repository->log( "Have response" ) if ($self->{debug}); # for
        if( $response->is_error )
            $repository->log( $response->as_string );
        return $response->is_success;
        $repository->log("Could not define LWP user agent: aborting file
        return 0;

The log doesn't seem to be receiving the debug info, either (which works
fine in the open_write, write, and close_write subs). create_ua sets up the
LWP object with the cookies needed for authentication, and saves it as
$self->{_ua}->{$fileobj} - again, this works perfectly in the write
routines.  According to the LWP docs,

$ua->request( $request,$f )

should feed back the content from the response to the callback function
("this function will be called for each chunk of the response content as it
is received from the server" -

I've based the list of arguments to the sub on those in Local.pm - is is
much of the rest of the EPrints interacting part of the code. This list is
different from both the list at
http://wiki.eprints.org/w/API:EPrints/Storage ($self, $fileobj, $offset,
$n, CALLBACK ) and
Amazon S3 module) ($self, $fileobj, $uri, $f) - could you possibly
indicate which list is correct, if this isn't?

Any suggestions would be very welcome!

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ecs.soton.ac.uk/pipermail/eprints-tech/attachments/20130205/ba0c71df/attachment.html 

More information about the Eprints-tech mailing list