From: Qing L. G. <qin...@ut...> - 2004-05-31 18:17:28
|
Hello, Just try to set up a lsid resolver for both data and metadata services support. The metadata part works wonderfully; however, I only got an empty string of data. According to the spec, if the given lsid represents an abstract entity, the getData method returns an empty array of bytes. We want our lsid to represent a string, not an abstract concept. Here is the code in our lsid resolver, sub load_data { my ($lsid, $format) = @_; $lsid = $lsid->canonical; my $id = $lsid->object; $id .= ':' . $lsid->revision if($lsid->revision); my $dbh = DBI->connect("dbi:mysql:$DBNAME", $DBUSER, $DBPASS); return LS::Service::Fault->serverFault('Can not access database', 500) unless($dbh); my $lookup; $lookup = $dbh->prepare( 'SELECT definition ' . 'FROM namespace WHERE name=? ' ); my $rdfDoc = new LS::RDF::SimpleDocument; return LS::Service::Fault->serverFault('Internal error, unable to initialize RDF document', 500) unless($rdfDoc); if ($lookup) { my $rs = $lookup->execute($id); return LS::Service::Fault->fault('Unknown LSID') unless($rs); my ($def) = $lookup->fetchrow_array; #$rdfDoc->add_triple_literal($lsid->as_string, 'urn:lsid:schematikon.org:predicates:definition', $def) if($def); } $lookup->finish(); # return whatever data is associated with the LSID $format='text/plain'; return new LS::Service::Response(response=> 'AAAAAAAAAAAAAAAAAAAAAAAAAa!', format=>$format); } and here is how we parse it in lsid_client.pl my $locations = $resource->get_data_locations(); # Retrieve data if available if (defined($locations)) { print("Retrieving data...\n"); print("<br><xmp>"); my $data = $resource->getData(); if (! defined($data)) { print("Error retrieving data:\n"); print $resource->error_string; } #open FILE, '>data'; #print FILE $data; #close FILE; printf("|%s|</xmp>\n<br>", $data); } What I did wrong? Thanks, Lynn |