source: trunk/gsdl/src/oaiservr/listidsaction.cpp@ 8310

Last change on this file since 8310 was 8310, checked in by kjdon, 20 years ago

renamed ctv1.log to oai.log

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