Skip to content

Commit

Permalink
Adjustments to function names, splitted metadata function part
Browse files Browse the repository at this point in the history
  • Loading branch information
LuomaJuha committed Dec 13, 2024
1 parent 8736fe3 commit 29147a5
Showing 1 changed file with 20 additions and 12 deletions.
32 changes: 20 additions & 12 deletions module/VuFind/src/VuFind/OAI/Server.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
use VuFind\Db\Service\ChangeTrackerServiceInterface;
use VuFind\Db\Service\OaiResumptionServiceInterface;
use VuFind\Exception\RecordMissing as RecordMissingException;
use VuFind\RecordDriver\AbstractBase as AbstractRecordDriver;
use VuFind\SimpleXML;
use VuFindApi\Formatter\RecordFormatter;

Expand Down Expand Up @@ -444,17 +445,8 @@ protected function attachNonDeleted(
$headerOnly = false,
$set = ''
) {
// Get the XML (and display an error if it is unsupported):
if ($format === false) {
$xml = ''; // no metadata if in header-only mode!
} elseif ('oai_vufind_json' === $format && $this->supportsVuFindMetadata()) {
$xml = $this->getVuFindMetadata($record); // special case
} else {
$xml = $record
->getXML($format, $this->baseHostURL, $this->recordLinkerHelper);
if ($xml === false) {
return false;
}
if ($format !== false) {
$xml = $this->getRecordAsXML($record, $format);
}

// Headers should be returned only if the metadata format matching
Expand Down Expand Up @@ -492,14 +484,30 @@ protected function attachNonDeleted(
);

// Inject metadata if necessary:
if (!$headerOnly && !empty($xml)) {
if (!$headerOnly) {
$metadata = $recXml->addChild('metadata');
SimpleXML::appendElement($metadata, $xml);
}

return true;
}

/**
* Get record as a metadata presentation
*
* @param AbstractRecordDriver $record A record driver object
* @param string $format Metadata format to obtain
*
* @return string|bool String on success or false if error occurs
*/
protected function getRecordAsXML(AbstractRecordDriver $record, string $format): string|false
{
if ('oai_vufind_json' === $format && $this->supportsVuFindMetadata()) {
return $this->getVuFindMetadata($record); // special case
}
return $record->getXML($format, $this->baseHostURL, $this->recordLinkerHelper);
}

/**
* Respond to a GetRecord request.
*
Expand Down

0 comments on commit 29147a5

Please sign in to comment.