#include "listidsaction.h" #include "recptprototools.h" #include "oaitools.h" //-------------------------------------------------------------------------------------------------- bool listidsaction::validateAction(recptproto *protocol, oaiargs ¶ms) { int params_size = params.getSize(); int numArgs = 1; // For "verb" arg if (!abstractlistaction::validateAction(protocol, params, numArgs)) { return false; } // In OAI v1.1 metadataPrefix is not allowed. if (this->configuration->getOAIVersion() <= 110){ if(numArgs != params_size){ this->errorType = "badArgument"; return false; } } else { // In OAI v2.0, it is compulsory text_t metaFormat = params["metadataPrefix"]; if (metaFormat == ""){ this->errorType = "badArgument"; return false; } else { // If it isn't empty, increase the valid args count and compare this to the total num of args if (++numArgs != params_size){ this->errorType = "badArgument"; return false; } } // Check that the metadataPrefix is a format we support if (this->formatNotSupported(metaFormat)){ this->errorType = "cannotDisseminateFormat"; return false; } } this->errorType = ""; return true; } //-------------------------------------------------------------------------------------------------- bool listidsaction::output_document(ostream& output, recptproto *protocol, const text_t &collection, const text_t &OID, const text_t &metadataPrefix /* ignored */) { FilterResponse_t response; ResultDocInfo_t doc_info; text_tset metadata; ofstream logout("oai.log", ios::app); text_t lastModified; int oaiVersion = this->configuration->getOAIVersion(); get_info(OID, collection, "", metadata, false, protocol, response, logout); doc_info = response.docInfo[0]; this->getLastModifiedDate(doc_info, lastModified); // output the record for this document text_t oaiLabel = OID; oaiclassifier::toOAI(collection, oaiLabel); if(oaiVersion <= 110) output << " " << oaiLabel << "\n"; else this->output_record_header(output, oaiLabel, lastModified, doc_info.metadata["memberof"].values, oaiVersion); return true; }