Changeset 16717

Show
Ignore:
Timestamp:
12.08.2008 12:37:34 (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/listsetsaction.cpp

    r16708 r16717  
    1212bool listsetsaction::validateAction(recptproto *protocol, oaiargs &params) 
    1313{ 
    14   int params_size = params.getSize(); 
    15  
    16   // Remove any parameters that aren't valid for this action 
     14  // ---------------------------------------------------------------------------- 
     15  //  1. Check for invalid arguments 
     16  // ---------------------------------------------------------------------------- 
     17  bool invalid_argument_supplied = false; 
    1718  text_tmap::const_iterator param_iterator = params.begin(); 
    1819  while (param_iterator != params.end()) 
    1920  { 
    20     if (param_iterator->first != "verb" && param_iterator->first != "resumptionToken") 
    21     { 
     21    // Check for arguments that aren't valid for this action 
     22    if (param_iterator->first != "verb" && 
     23    param_iterator->first != "resumptionToken") 
     24    { 
     25      // We've found an invalid argument 
     26      invalid_argument_supplied = true; 
     27 
     28      // Delete the invalid argument from the list so it doesn't end up in the <request> tag that is returned 
    2229      params.erase(param_iterator->first); 
    2330    } 
     
    2633  } 
    2734 
    28   if (params_size != params.getSize()) { 
     35  // If we found an invalid argument it's an error, so don't go any further  
     36  if (invalid_argument_supplied) 
     37  { 
    2938    this->errorType = "badArgument"; 
    3039    return false; 
    3140  } 
    3241 
    33   if (params["resumptionToken"] != "") { 
     42  // ---------------------------------------------------------------------------- 
     43  //  2. Handle any exclusive arguments 
     44  // ---------------------------------------------------------------------------- 
     45 
     46  //  The resumptionToken argument is exclusive 
     47  if (params["resumptionToken"] != "") 
     48  { 
     49    // This argument is exclusive, so no other arguments are allowed (except "verb" of course) 
     50    if (params.getSize() != 2) 
     51    { 
     52      this->errorType = "badArgument"; 
     53      return false; 
     54    } 
     55 
     56    // Check the resumption token is valid 
    3457    ResumptionToken token(params["resumptionToken"]); 
    35     // TO DO: Resumption token validation checking (the token.isValid() function is useless for ListSets) 
    36     // if (!token.isValid()) { 
    37     //   this->errorType = "badResumptionToken"; 
    38     //   return false; 
    39     // } 
    40   } 
    41  
     58    if (true)  // TO DO: Fix this (the token.isValid() function is useless for ListSets) 
     59    { 
     60      // Everything is fine, and we don't continue further because this is an exclusive argument 
     61      this->errorType = ""; 
     62      return true; 
     63    } 
     64    else 
     65    { 
     66      // There was an error with the resumption token 
     67      this->errorType = "badResumptionToken"; 
     68      return false; 
     69    } 
     70  } 
     71 
     72  // ---------------------------------------------------------------------------- 
     73  //  3. Handle any required arguments 
     74  // ---------------------------------------------------------------------------- 
     75 
     76  // None! 
     77 
     78  // ---------------------------------------------------------------------------- 
     79  // 4. Check any remaining arguments 
     80  // ---------------------------------------------------------------------------- 
     81 
     82  // None! 
     83 
     84  // If we've reached here everything must be fine 
     85  this->errorType = ""; 
    4286  return true; 
    4387}