[8182] | 1 | #include "listidsaction.h"
|
---|
[15428] | 2 | #include "recptprototools.h"
|
---|
[8182] | 3 | #include "oaitools.h"
|
---|
| 4 |
|
---|
| 5 | //--------------------------------------------------------------------------------------------------
|
---|
| 6 |
|
---|
| 7 | bool listidsaction::validateAction(recptproto *protocol, oaiargs ¶ms)
|
---|
| 8 | {
|
---|
[15198] | 9 | int params_size = params.getSize();
|
---|
[8182] | 10 | int numArgs = 1; // For "verb" arg
|
---|
| 11 |
|
---|
| 12 | if (!abstractlistaction::validateAction(protocol, params, numArgs)) {
|
---|
| 13 | return false;
|
---|
| 14 | }
|
---|
| 15 |
|
---|
| 16 | // In OAI v1.1 metadataPrefix is not allowed.
|
---|
| 17 | if (this->configuration->getOAIVersion() <= 110){
|
---|
[15198] | 18 | if(numArgs != params_size){
|
---|
[8182] | 19 | this->errorType = "badArgument";
|
---|
| 20 | return false;
|
---|
| 21 | }
|
---|
| 22 | }
|
---|
| 23 | else { // In OAI v2.0, it is compulsory
|
---|
| 24 | text_t metaFormat = params["metadataPrefix"];
|
---|
| 25 | if (metaFormat == ""){
|
---|
| 26 | this->errorType = "badArgument";
|
---|
| 27 | return false;
|
---|
| 28 | }
|
---|
| 29 | else { // If it isn't empty, increase the valid args count and compare this to the total num of args
|
---|
[15198] | 30 | if (++numArgs != params_size){
|
---|
[8182] | 31 | this->errorType = "badArgument";
|
---|
| 32 | return false;
|
---|
| 33 | }
|
---|
| 34 | }
|
---|
| 35 | // Check that the metadataPrefix is a format we support
|
---|
| 36 | if (this->formatNotSupported(metaFormat)){
|
---|
| 37 | this->errorType = "cannotDisseminateFormat";
|
---|
| 38 | return false;
|
---|
| 39 | }
|
---|
| 40 | }
|
---|
| 41 | this->errorType = "";
|
---|
| 42 | return true;
|
---|
| 43 | }
|
---|
| 44 |
|
---|
| 45 | //--------------------------------------------------------------------------------------------------
|
---|
| 46 |
|
---|
| 47 | bool listidsaction::output_document(ostream& output, recptproto *protocol, const text_t &collection,
|
---|
| 48 | const text_t &OID, const text_t &metadataPrefix /* ignored */)
|
---|
| 49 | {
|
---|
| 50 | FilterResponse_t response;
|
---|
| 51 | ResultDocInfo_t doc_info;
|
---|
| 52 | text_tset metadata;
|
---|
[8310] | 53 | ofstream logout("oai.log", ios::app);
|
---|
[8182] | 54 | text_t lastModified;
|
---|
| 55 | int oaiVersion = this->configuration->getOAIVersion();
|
---|
| 56 |
|
---|
| 57 | get_info(OID, collection, "", metadata, false, protocol, response, logout);
|
---|
| 58 | doc_info = response.docInfo[0];
|
---|
| 59 | this->getLastModifiedDate(doc_info, lastModified);
|
---|
| 60 |
|
---|
| 61 | // output the record for this document
|
---|
| 62 | text_t oaiLabel = OID;
|
---|
| 63 | oaiclassifier::toOAI(collection, oaiLabel);
|
---|
| 64 |
|
---|
| 65 | if(oaiVersion <= 110)
|
---|
| 66 | output << " <identifier>" << oaiLabel << "</identifier>\n";
|
---|
| 67 | else
|
---|
| 68 | this->output_record_header(output, oaiLabel, lastModified,
|
---|
| 69 | doc_info.metadata["memberof"].values, oaiVersion);
|
---|
| 70 |
|
---|
| 71 | return true;
|
---|
| 72 | }
|
---|