source: gsdl/trunk/runtime-src/src/oaiservr/listrecsaction.cpp@ 16708

Last change on this file since 16708 was 15198, checked in by mdewsnip, 16 years ago

Now each action checks for invalid arguments in the params structure and deletes any that aren't valid, so they don't get into the "<request>" tag in the resulting XML and cause OAI validation errors. By DL Consulting Ltd.

  • Property svn:keywords set to Author Date Id Revision
File size: 1.8 KB
Line 
1#include "listrecsaction.h"
2
3#include "oaitools.h"
4#include "recordaction.h"
5
6bool listrecsaction::validateAction(recptproto *protocol, oaiargs &params)
7{
8 int params_size = params.getSize();
9
10 text_t meta = params["metadataPrefix"];
11 int numArgs = 1; // 1st arg (Verb=ListRecords) must be present for us to be here
12
13 if (!abstractlistaction::validateAction(protocol, params, numArgs)) {
14 return false;
15 }
16
17 // metadataPrefix is required - if it's not there, throw an error. Note that the arg isn't
18 // required (or allowed) if a resumptionToken is given, but as we don't handle resumption
19 // tokens this is sufficient. When we DO handle the tokens, this will have to change.
20 if (meta == "") {
21 this->errorType = "badArgument";
22 return false;
23 }
24 else {
25 ++numArgs; // If it's there, increase arg count
26 }
27
28 // The number of valid args should be exactly equal to the number of args actually there.
29 // If not, throw a 'badArgument' error.
30 if (numArgs != params_size) {
31 this->errorType = "badArgument";
32 return false;
33 }
34
35 if (this->formatNotSupported(meta)) { // Check that the metadataPrefix is supported
36 this->errorType = "cannotDisseminateFormat";
37 this->record_action->setErrorType(this->errorType);
38 return false;
39 }
40
41 return true;
42}
43
44//-----------------------------------------------------------------------------------------------
45
46bool listrecsaction::output_document(ostream &output, recptproto *protocol, const text_t &collection,
47 const text_t &OID, const text_t &metadataPrefix)
48{
49 this->record_action->output_record(output, protocol, collection, OID, metadataPrefix);
50 return true;
51}
52
53//-----------------------------------------------------------------------------------------------
54
55
56
Note: See TracBrowser for help on using the repository browser.