1 | #include "identifyaction.h"
|
---|
2 |
|
---|
3 | bool identifyaction::validateAction(recptproto *protocol, oaiargs ¶ms)
|
---|
4 | {
|
---|
5 | int params_size = params.getSize();
|
---|
6 |
|
---|
7 | // Remove any parameters that aren't valid for this action
|
---|
8 | text_tmap::const_iterator param_iterator = params.begin();
|
---|
9 | while (param_iterator != params.end())
|
---|
10 | {
|
---|
11 | if (param_iterator->first != "verb")
|
---|
12 | {
|
---|
13 | params.erase(param_iterator->first);
|
---|
14 | }
|
---|
15 |
|
---|
16 | param_iterator++;
|
---|
17 | }
|
---|
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){
|
---|
22 | this->errorType = "badArgument";
|
---|
23 | return false;
|
---|
24 | }
|
---|
25 |
|
---|
26 | return true;
|
---|
27 | }
|
---|
28 |
|
---|
29 | bool identifyaction::output_content(ostream &output, recptproto *protocol, oaiargs ¶ms)
|
---|
30 | {
|
---|
31 | // Get the repository name (some human-readable name for the site, or superset of collections)
|
---|
32 | text_t repositoryName = this->configuration->getCollectionConfig("", "repositoryName");
|
---|
33 | // Get admin's email address (i.e. the site maintainer)
|
---|
34 | text_t maintainer = this->configuration->getCollectionConfig("", "maintainer");
|
---|
35 | text_t version = (this->configuration->getOAIVersion() <= 110) ? (text_t)"1.1":(text_t)"2.0";
|
---|
36 |
|
---|
37 | text_t baseURL = this->configuration->getCollectionConfig("", "baseURL");
|
---|
38 |
|
---|
39 | output << " <repositoryName>" << repositoryName << "</repositoryName>" << endl;
|
---|
40 | output << " <baseURL>" << baseURL << "</baseURL>" << endl; // Tack on the app name
|
---|
41 | output << " <protocolVersion>" << version << "</protocolVersion>" << endl;
|
---|
42 | output << " <adminEmail>" << maintainer << "</adminEmail>" << endl;
|
---|
43 |
|
---|
44 | if(version == "2.0"){
|
---|
45 | // earliestDatestamp *should* be the YYYY-MM-DD format of the oldest lastmodified record in the
|
---|
46 | // repository, but we're just setting it to be the default oldest possible date - ugly, but judged
|
---|
47 | // not to be worth the effort of trolling through all the lastmodified dates (by others with more
|
---|
48 | // say than me)
|
---|
49 | output << " <earliestDatestamp>1970-01-01</earliestDatestamp>\n"
|
---|
50 | << " <deletedRecord>no</deletedRecord>\n"
|
---|
51 | << " <granularity>YYYY-MM-DD</granularity>\n";
|
---|
52 | }
|
---|
53 | // list all configuration information
|
---|
54 | text_tmap::iterator here = this->configuration->getInformation()->begin();
|
---|
55 | text_tmap::iterator end = this->configuration->getInformation()->end();
|
---|
56 | while (here != end) {
|
---|
57 | output << " <" << here->first << ">" << here->second;
|
---|
58 | output << " </" << here->first << ">" << endl;
|
---|
59 | ++here;
|
---|
60 | }
|
---|
61 |
|
---|
62 | return true;
|
---|
63 | }
|
---|
64 |
|
---|