[8182] | 1 | #include "listrecsaction.h"
|
---|
| 2 |
|
---|
| 3 | #include "oaitools.h"
|
---|
| 4 | #include "recordaction.h"
|
---|
| 5 |
|
---|
| 6 | bool listrecsaction::validateAction(recptproto *protocol, oaiargs ¶ms)
|
---|
| 7 | {
|
---|
[15198] | 8 | int params_size = params.getSize();
|
---|
| 9 |
|
---|
[8182] | 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 {
|
---|
[9608] | 25 | ++numArgs; // If it's there, increase arg count
|
---|
[8182] | 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.
|
---|
[15198] | 30 | if (numArgs != params_size) {
|
---|
[8182] | 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 |
|
---|
| 46 | bool 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 |
|
---|