Changeset 16715
- Timestamp:
- 2008-08-12T12:25:09+12:00 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
gsdl/trunk/runtime-src/src/oaiservr/recordaction.cpp
r15428 r16715 30 30 bool recordaction::validateAction(recptproto *protocol, oaiargs ¶ms) 31 31 { 32 int params_size = params.getSize(); 33 34 // Remove any parameters that aren't valid for this action 32 // ---------------------------------------------------------------------------- 33 // 1. Check for invalid arguments 34 // ---------------------------------------------------------------------------- 35 bool invalid_argument_supplied = false; 35 36 text_tmap::const_iterator param_iterator = params.begin(); 36 37 while (param_iterator != params.end()) 37 38 { 39 // Check for arguments that aren't valid for this action 38 40 if (param_iterator->first != "verb" && 39 41 param_iterator->first != "identifier" && 40 42 param_iterator->first != "metadataPrefix") 41 43 { 44 // We've found an invalid argument 45 invalid_argument_supplied = true; 46 47 // Delete the invalid argument from the list so it doesn't end up in the <request> tag that is returned 42 48 params.erase(param_iterator->first); 43 49 } … … 46 52 } 47 53 48 text_t meta = params["metadataPrefix"]; 49 text_t gsdlId = params["identifier"]; 50 text_t gsdlCollect; 51 text_t language = ""; 52 int oaiVersion = this->configuration->getOAIVersion(); 53 54 // The identifier and metadataPrefix args MUST be supplied, and are the only 55 // args allowed (excluding verb arg). If we don't have them, throw an error. 56 if(gsdlId == "" || meta == "" || params_size != 3){ 54 // If we found an invalid argument it's an error, so don't go any further 55 if (invalid_argument_supplied) 56 { 57 57 this->errorType = "badArgument"; 58 58 return false; 59 59 } 60 60 61 // Check to see if the metadataPrefix supplied is supported 62 if(this->formatNotSupported(meta)) { 61 // ---------------------------------------------------------------------------- 62 // 2. Handle any exclusive arguments 63 // ---------------------------------------------------------------------------- 64 65 // None! 66 67 // ---------------------------------------------------------------------------- 68 // 3. Handle any required arguments 69 // ---------------------------------------------------------------------------- 70 71 // The "metadataPrefix" argument is required 72 text_t metadataPrefix = params["metadataPrefix"]; 73 74 // Check that the metadataPrefix argument exists 75 if (metadataPrefix == "") 76 { 77 this->errorType = "badArgument"; 78 return false; 79 } 80 // Check that the metadataPrefix is a format we support 81 if (this->formatNotSupported(metadataPrefix)) 82 { 63 83 this->errorType = "cannotDisseminateFormat"; 64 if(oaiVersion == 200) 65 return false; 66 } 67 68 // convert record identifier into GSDL format from OAI 69 oaiclassifier::toGSDL(gsdlCollect, gsdlId); 70 71 // get the document information 72 text_tset metadata; 73 if (!get_info(gsdlId, gsdlCollect, language, metadata, false, protocol, this->gsdlResponse, *logout)) { 84 return false; 85 } 86 87 // The "identifier" argument is required 88 text_t identifier = params["identifier"]; 89 90 // Extract the collection name from the identifier specification 91 text_t collection = ""; 92 oaiclassifier::toGSDL(collection, identifier); 93 94 // Check a document with the specified identifier exists 95 text_tset metadata; 96 if (!get_info(identifier, collection, "", metadata, false, protocol, this->gsdlResponse, *logout)) 97 { 74 98 this->errorType = "idDoesNotExist"; 75 if(oaiVersion == 200) 76 return false; 77 } 78 99 return false; 100 } 101 102 // ---------------------------------------------------------------------------- 103 // 4. Check any remaining arguments 104 // ---------------------------------------------------------------------------- 105 106 // None! 107 108 // If we've reached here everything must be fine 109 this->errorType = ""; 79 110 return true; 80 111 }
Note:
See TracChangeset
for help on using the changeset viewer.