Changeset 16711

Show
Ignore:
Timestamp:
12.08.2008 12:04:01 (11 years ago)
Author:
mdewsnip
Message:

Tidied up the validateAction() function to be consistently structured.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • gsdl/trunk/runtime-src/src/oaiservr/identifyaction.cpp

    r15844 r16711  
    33bool identifyaction::validateAction(recptproto *protocol, oaiargs &params) 
    44{  
    5   int params_size = params.getSize(); 
    6  
    7   // Remove any parameters that aren't valid for this action 
     5  // ---------------------------------------------------------------------------- 
     6  //  1. Check for invalid arguments 
     7  // ---------------------------------------------------------------------------- 
     8  bool invalid_argument_supplied = false; 
    89  text_tmap::const_iterator param_iterator = params.begin(); 
    910  while (param_iterator != params.end()) 
    1011  { 
     12    // Check for arguments that aren't valid for this action 
    1113    if (param_iterator->first != "verb") 
    1214    { 
     15      // We've found an invalid argument 
     16      invalid_argument_supplied = true; 
     17 
     18      // Delete the invalid argument from the list so it doesn't end up in the <request> tag that is returned 
    1319      params.erase(param_iterator->first); 
    1420    } 
     
    1622    param_iterator++; 
    1723  } 
    18    
    19   //"Verb=Identify" should be the only parameter - if there are others, throw an error. 
    20   // Don't need to check that the param we have is "Verb=Identify", as it has to be to get to here. 
    21   if(params_size != 1){ 
     24 
     25  // If we found an invalid argument it's an error, so don't go any further  
     26  if (invalid_argument_supplied) 
     27  { 
    2228    this->errorType = "badArgument"; 
    2329    return false; 
    2430  } 
    25    
     31 
     32  // ---------------------------------------------------------------------------- 
     33  //  2. Handle any exclusive arguments 
     34  // ---------------------------------------------------------------------------- 
     35 
     36  // None! 
     37 
     38  // ---------------------------------------------------------------------------- 
     39  //  3. Handle any required arguments 
     40  // ---------------------------------------------------------------------------- 
     41 
     42  // None! 
     43 
     44  // ---------------------------------------------------------------------------- 
     45  // 4. Check any remaining arguments 
     46  // ---------------------------------------------------------------------------- 
     47 
     48  // None! 
     49 
     50  // If we've reached here everything must be fine 
     51  this->errorType = ""; 
    2652  return true; 
    2753}