2013-05-07 19:48:37 +02:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* \file
|
|
|
|
* \brief Response to Verb GetRecord
|
|
|
|
*
|
|
|
|
* Retrieve a record based its identifier.
|
|
|
|
*
|
|
|
|
* Local variables <B>$metadataPrefix</B> and <B>$identifier</B> need to be provided through global array variable <B>$args</B>
|
|
|
|
* by their indexes 'metadataPrefix' and 'identifier'.
|
|
|
|
* The reset of information will be extracted from database based those two parameters.
|
|
|
|
*/
|
|
|
|
|
|
|
|
debug_message("\nI am debuging". __FILE__) ;
|
|
|
|
|
|
|
|
$metadataPrefix = $args['metadataPrefix'];
|
|
|
|
// myhandler is a php file which will be included to generate metadata node.
|
|
|
|
// $inc_record = $METADATAFORMATS[$metadataPrefix]['myhandler'];
|
|
|
|
|
2013-05-07 22:01:22 +02:00
|
|
|
if (is_array($METADATAFORMATS[$metadataPrefix]) && isset($METADATAFORMATS[$metadataPrefix]['myhandler'])) {
|
|
|
|
$inc_record = $METADATAFORMATS[$metadataPrefix]['myhandler'];
|
2013-05-07 19:48:37 +02:00
|
|
|
} else {
|
2013-05-07 22:01:22 +02:00
|
|
|
$errors[] = oai_error('cannotDisseminateFormat', 'metadataPrefix', $metadataPrefix);
|
2013-05-07 19:48:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
$identifier = $args['identifier'];
|
|
|
|
$query = selectallQuery($metadataPrefix, $identifier);
|
|
|
|
|
|
|
|
debug_message("Query: $query") ;
|
|
|
|
|
|
|
|
$res = $db->query($query);
|
|
|
|
|
|
|
|
if ($res===false) {
|
2013-05-07 22:01:22 +02:00
|
|
|
if (SHOW_QUERY_ERROR) {
|
|
|
|
echo __FILE__.','.__LINE__."<br />";
|
|
|
|
echo "Query: $query<br />\n";
|
|
|
|
die($db->errorInfo());
|
|
|
|
} else {
|
|
|
|
$errors[] = oai_error('idDoesNotExist', '', $identifier);
|
|
|
|
}
|
2013-05-07 19:48:37 +02:00
|
|
|
} elseif (!$res->rowCount()) { // based on PHP manual, it might only work for some DBs
|
2013-05-07 22:01:22 +02:00
|
|
|
$errors[] = oai_error('idDoesNotExist', '', $identifier);
|
2013-05-07 19:48:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!empty($errors)) {
|
2013-05-07 22:01:22 +02:00
|
|
|
oai_exit();
|
2013-05-07 19:48:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
$record = $res->fetch(PDO::FETCH_ASSOC);
|
|
|
|
if ($record===false) {
|
2013-05-07 22:01:22 +02:00
|
|
|
if (SHOW_QUERY_ERROR) {
|
|
|
|
echo __FILE__.','.__LINE__."<br />";
|
|
|
|
echo "Query: $query<br />\n";
|
|
|
|
}
|
|
|
|
$errors[] = oai_error('idDoesNotExist', '', $identifier);
|
2013-05-07 19:48:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
$identifier = $record[$SQL['identifier']];;
|
|
|
|
|
|
|
|
$datestamp = formatDatestamp($record[$SQL['datestamp']]);
|
|
|
|
|
2013-05-07 22:01:22 +02:00
|
|
|
$status_deleted = (isset($record[$SQL['deleted']]) && ($record[$SQL['deleted']] == 'true') &&
|
|
|
|
($deletedRecord == 'transient' || $deletedRecord == 'persistent'));
|
2013-05-07 19:48:37 +02:00
|
|
|
|
|
|
|
$outputObj = new ANDS_Response_XML($args);
|
|
|
|
$cur_record = $outputObj->create_record();
|
|
|
|
$cur_header = $outputObj->create_header($identifier, $datestamp,$record[$SQL['set']],$cur_record);
|
|
|
|
// return the metadata record itself
|
|
|
|
if (!$status_deleted) {
|
2013-05-07 22:01:22 +02:00
|
|
|
include($inc_record); // where the metadata node is generated.
|
|
|
|
create_metadata($outputObj, $cur_record, $identifier, $record[$SQL['set']], $db);
|
2013-05-07 19:48:37 +02:00
|
|
|
} else {
|
2013-05-07 22:01:22 +02:00
|
|
|
$cur_header->setAttribute("status","deleted");
|
2013-05-07 19:48:37 +02:00
|
|
|
}
|