Changeset 16716
- Timestamp:
- 2008-08-12T12:31:48+12:00 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
gsdl/trunk/runtime-src/src/oaiservr/metaformatsaction.cpp
r15428 r16716 6 6 bool metaformatsaction::validateAction(recptproto *protocol, oaiargs ¶ms) 7 7 { 8 int params_size = params.getSize(); 9 10 // Remove any parameters that aren't valid for this action 8 // ---------------------------------------------------------------------------- 9 // 1. Check for invalid arguments 10 // ---------------------------------------------------------------------------- 11 bool invalid_argument_supplied = false; 11 12 text_tmap::const_iterator param_iterator = params.begin(); 12 13 while (param_iterator != params.end()) 13 14 { 15 // Check for arguments that aren't valid for this action 14 16 if (param_iterator->first != "verb" && 15 17 param_iterator->first != "identifier") 16 18 { 19 // We've found an invalid argument 20 invalid_argument_supplied = true; 21 22 // Delete the invalid argument from the list so it doesn't end up in the <request> tag that is returned 17 23 params.erase(param_iterator->first); 18 24 } … … 21 27 } 22 28 23 int numArgs = 1; // the number of expected arguments 24 25 // increase the number of expected arguments if the optional 'identifier' argument 26 // is given 27 if (params["identifier"] != "") { 28 ++numArgs; 29 } 30 31 // If the total number of params isn't equal to the number of valid 32 // args (i.e. we have an arg but it isn't the identifier), throw an error 33 if((params_size != numArgs)){ 29 // If we found an invalid argument it's an error, so don't go any further 30 if (invalid_argument_supplied) 31 { 34 32 this->errorType = "badArgument"; 35 33 return false; 36 34 } 37 35 38 // Variables to hold identifier in Greenstone format39 text_t docID = params["identifier"];40 text_t collection = "";36 // ---------------------------------------------------------------------------- 37 // 2. Handle any exclusive arguments 38 // ---------------------------------------------------------------------------- 41 39 42 // The following two variables are used solely by the get_info() function call to test if 43 // the identifier supplied is an actual document. If it isn't, we need to throw an exception. 44 const text_tset metadata; 40 // None! 45 41 46 // Check for the existence, etc. of the record if an identifier is given. 47 if (docID != "") { 48 oaiclassifier::toGSDL(collection, docID); 49 50 // Only throw an error if we're using v2.0. 51 // v1.1 should simply return a response without a metadataFormat container. 1.1 52 // should still set the errorType so we know that the error was encountered 42 // ---------------------------------------------------------------------------- 43 // 3. Handle any required arguments 44 // ---------------------------------------------------------------------------- 53 45 54 // the information retrieved here is retained for the output_content function below 55 if (!get_info(docID, collection, "", metadata, false, protocol, this->gsdlResponse, cerr)){ 46 // None! 47 48 // ---------------------------------------------------------------------------- 49 // 4. Check any remaining arguments 50 // ---------------------------------------------------------------------------- 51 52 // Check "identifier" argument 53 if (params["identifier"] != "") 54 { 55 text_t identifier = params["identifier"]; 56 57 // Extract the collection name from the identifier specification 58 text_t collection = ""; 59 oaiclassifier::toGSDL(collection, identifier); 60 61 // Check a document with the specified identifier exists 62 text_tset metadata; 63 if (!get_info(identifier, collection, "", metadata, false, protocol, this->gsdlResponse, *logout)) 64 { 56 65 this->errorType = "idDoesNotExist"; 57 if(this->configuration->getOAIVersion() >= 200) { 66 67 // Only throw an error if we're using v2.0. 68 // v1.1 should simply return a response without a metadataFormat container. 1.1 69 // should still set the errorType so we know that the error was encountered 70 // the information retrieved here is retained for the output_content function below 71 if (this->configuration->getOAIVersion() >= 200) 72 { 58 73 return false; 59 74 } 60 75 } 61 76 } 77 78 // If we've reached here everything must be fine 79 this->errorType = ""; 62 80 return true; 63 81 }
Note:
See TracChangeset
for help on using the changeset viewer.