[15844] | 1 | #include "identifyaction.h"
|
---|
[8182] | 2 |
|
---|
[15844] | 3 | bool identifyaction::validateAction(recptproto *protocol, oaiargs ¶ms)
|
---|
[8182] | 4 | {
|
---|
[16711] | 5 | // ----------------------------------------------------------------------------
|
---|
| 6 | // 1. Check for invalid arguments
|
---|
| 7 | // ----------------------------------------------------------------------------
|
---|
| 8 | bool invalid_argument_supplied = false;
|
---|
[15198] | 9 | text_tmap::const_iterator param_iterator = params.begin();
|
---|
| 10 | while (param_iterator != params.end())
|
---|
| 11 | {
|
---|
[16711] | 12 | // Check for arguments that aren't valid for this action
|
---|
[15198] | 13 | if (param_iterator->first != "verb")
|
---|
| 14 | {
|
---|
[16711] | 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
|
---|
[15198] | 19 | params.erase(param_iterator->first);
|
---|
| 20 | }
|
---|
| 21 |
|
---|
| 22 | param_iterator++;
|
---|
| 23 | }
|
---|
[16711] | 24 |
|
---|
| 25 | // If we found an invalid argument it's an error, so don't go any further
|
---|
| 26 | if (invalid_argument_supplied)
|
---|
| 27 | {
|
---|
[8182] | 28 | this->errorType = "badArgument";
|
---|
| 29 | return false;
|
---|
| 30 | }
|
---|
[16711] | 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 = "";
|
---|
[8182] | 52 | return true;
|
---|
| 53 | }
|
---|
| 54 |
|
---|
[15844] | 55 | bool identifyaction::output_content(ostream &output, recptproto *protocol, oaiargs ¶ms)
|
---|
[8182] | 56 | {
|
---|
[20707] | 57 | utf8outconvertclass utf8convert;
|
---|
| 58 |
|
---|
[8182] | 59 | // Get the repository name (some human-readable name for the site, or superset of collections)
|
---|
[22213] | 60 | text_t repositoryName = this->configuration->getRepositoryName();
|
---|
[22287] | 61 | text_t repositoryId = this->configuration->getRepositoryId();
|
---|
[8182] | 62 | // Get admin's email address (i.e. the site maintainer)
|
---|
[22213] | 63 | text_t maintainer = this->configuration->getMaintainer();
|
---|
[8182] | 64 | text_t version = (this->configuration->getOAIVersion() <= 110) ? (text_t)"1.1":(text_t)"2.0";
|
---|
[22287] | 65 | text_t id_version = this->configuration->getRepositoryIdVersion();
|
---|
| 66 |
|
---|
[22213] | 67 | text_t baseURL = this->configuration->getBaseURL();
|
---|
[8182] | 68 |
|
---|
[20707] | 69 | output << utf8convert << " <repositoryName>" << repositoryName << "</repositoryName>\n";
|
---|
| 70 | output << utf8convert << " <baseURL>" << baseURL << "</baseURL>\n";
|
---|
| 71 | output << utf8convert << " <protocolVersion>" << version << "</protocolVersion>\n";
|
---|
| 72 | output << utf8convert << " <adminEmail>" << maintainer << "</adminEmail>\n";
|
---|
[8182] | 73 |
|
---|
| 74 | if(version == "2.0"){
|
---|
| 75 | // earliestDatestamp *should* be the YYYY-MM-DD format of the oldest lastmodified record in the
|
---|
| 76 | // repository, but we're just setting it to be the default oldest possible date - ugly, but judged
|
---|
| 77 | // not to be worth the effort of trolling through all the lastmodified dates (by others with more
|
---|
| 78 | // say than me)
|
---|
[20707] | 79 | output << utf8convert << " <earliestDatestamp>1970-01-01</earliestDatestamp>\n";
|
---|
| 80 | output << utf8convert << " <deletedRecord>no</deletedRecord>\n";
|
---|
| 81 | output << utf8convert << " <granularity>YYYY-MM-DD</granularity>\n";
|
---|
[8182] | 82 | }
|
---|
[22287] | 83 | // list the oai identifier
|
---|
| 84 | output << " <description>\n";
|
---|
| 85 | if (id_version == "1.1") {
|
---|
| 86 |
|
---|
| 87 | output << " <oai-identifier xmlns=\"http://www.openarchives.org/OAI/1.1/oai-identifier\"\n";
|
---|
| 88 | output << " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n";
|
---|
| 89 | output << " xsi:schemaLocation=\"http://www.openarchives.org/OAI/1.1/oai-identifier http://www.openarchives.org/OAI/1.1/oai-identifier.xsd\">\n";
|
---|
| 90 | } else {
|
---|
| 91 |
|
---|
| 92 | output << " <oai-identifier xmlns=\"http://www.openarchives.org/OAI/2.0/oai-identifier\"\n";
|
---|
| 93 | output << " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n";
|
---|
| 94 | output << " xsi:schemaLocation=\"http://www.openarchives.org/OAI/2.0/oai-identifier\n";
|
---|
| 95 | output << " http://www.openarchives.org/OAI/2.0/oai-identifier.xsd\">\n";
|
---|
| 96 |
|
---|
| 97 |
|
---|
| 98 | }
|
---|
| 99 |
|
---|
| 100 | output << " <scheme>oai</scheme>\n";
|
---|
| 101 | output << " <repositoryIdentifier>"<< repositoryId <<"</repositoryIdentifier>\n";
|
---|
| 102 | output << " <delimiter>:</delimiter>\n";
|
---|
| 103 | output << " <sampleIdentifier>oai:"<<repositoryId<<":demo:HASH983080b052e9230b7ccf94</sampleIdentifier>\n";
|
---|
| 104 | output << " </oai-identifier>\n";
|
---|
| 105 |
|
---|
| 106 | output << utf8convert << " </description>\n";
|
---|
[8182] | 107 | // list all configuration information
|
---|
| 108 | text_tmap::iterator here = this->configuration->getInformation()->begin();
|
---|
| 109 | text_tmap::iterator end = this->configuration->getInformation()->end();
|
---|
| 110 | while (here != end) {
|
---|
[20707] | 111 | output << utf8convert << " <" << here->first << ">" << here->second;
|
---|
| 112 | output << utf8convert << " </" << here->first << ">\n";
|
---|
[9608] | 113 | ++here;
|
---|
[8182] | 114 | }
|
---|
| 115 |
|
---|
| 116 | return true;
|
---|
| 117 | }
|
---|
| 118 |
|
---|