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