source: gsdl/trunk/src/oaiservr/identityaction.cpp@ 15198

Last change on this file since 15198 was 15198, checked in by mdewsnip, 16 years ago

Now each action checks for invalid arguments in the params structure and deletes any that aren't valid, so they don't get into the "<request>" tag in the resulting XML and cause OAI validation errors. By DL Consulting Ltd.

  • Property svn:keywords set to Author Date Id Revision
File size: 2.7 KB
Line 
1#include "identityaction.h"
2#include "recptconfig.h"
3
4bool identityaction::validateAction(recptproto *protocol, oaiargs &params)
5{
6 int params_size = params.getSize();
7
8 // Remove any parameters that aren't valid for this action
9 text_tmap::const_iterator param_iterator = params.begin();
10 while (param_iterator != params.end())
11 {
12 if (param_iterator->first != "verb")
13 {
14 params.erase(param_iterator->first);
15 }
16
17 param_iterator++;
18 }
19
20 //"Verb=Identify" should be the only parameter - if there are others, throw an error.
21 // Don't need to check that the param we have is "Verb=Identify", as it has to be to get to here.
22 if(params_size != 1){
23 this->errorType = "badArgument";
24 return false;
25 }
26
27 return true;
28}
29
30bool identityaction::output_content(ostream &output, recptproto *protocol, oaiargs &params)
31{
32 text_t gsdlhome, httpdomain, httpprefix;
33
34 // Get the repository name (some human-readable name for the site, or superset of collections)
35 text_t repositoryName = this->configuration->getCollectionConfig("", "repositoryName");
36 // Get admin's email address (i.e. the site maintainer)
37 text_t maintainer = this->configuration->getCollectionConfig("", "maintainer");
38 // Get baseURL by extracting httpdomain from the gsdlsite.cfg file
39 text_t version = (this->configuration->getOAIVersion() <= 110) ? (text_t)"1.1":(text_t)"2.0";
40
41 //site_cfg_read(gsdlhome, httpdomain, httpprefix);
42 text_t baseURL = this->configuration->getCollectionConfig("", "baseURL");
43
44 output << " <repositoryName>" << repositoryName << "</repositoryName>" << endl;
45 output << " <baseURL>" << baseURL << "</baseURL>" << endl; // Tack on the app name
46 output << " <protocolVersion>" << version << "</protocolVersion>" << endl;
47 output << " <adminEmail>" << maintainer << "</adminEmail>" << endl;
48
49 if(version == "2.0"){
50 // earliestDatestamp *should* be the YYYY-MM-DD format of the oldest lastmodified record in the
51 // repository, but we're just setting it to be the default oldest possible date - ugly, but judged
52 // not to be worth the effort of trolling through all the lastmodified dates (by others with more
53 // say than me)
54 output << " <earliestDatestamp>1970-01-01</earliestDatestamp>\n"
55 << " <deletedRecord>no</deletedRecord>\n"
56 << " <granularity>YYYY-MM-DD</granularity>\n";
57 }
58 // list all configuration information
59 text_tmap::iterator here = this->configuration->getInformation()->begin();
60 text_tmap::iterator end = this->configuration->getInformation()->end();
61 while (here != end) {
62 output << " <" << here->first << ">" << here->second;
63 output << " </" << here->first << ">" << endl;
64 ++here;
65 }
66
67 return true;
68}
69
Note: See TracBrowser for help on using the repository browser.