source: main/trunk/greenstone2/runtime-src/src/oaiservr/oaiaction.h@ 24412

Last change on this file since 24412 was 24412, checked in by ak19, 10 years ago

Fixed a new failure of the OAI validation test of GS2's OAI server: where list records is given an Until date that is earlier than the earliestDatestamp. Needs to return a noRecordsMatch. It does now. The calculation of the earliestDatestamp is now shifted to the oaiaction.cpp superclass and called by both identifyaction and listrecordsaction for the identify and listrecords OAI queries, since these tasks need to work with earliestDatestamp.

  • Property svn:keywords set to Author Date Id Revision
File size: 4.0 KB
2 *
3 * oaiaction.h --
4 *
5 * Copyright (C) 2004-2010 The New Zealand Digital Library Project
6 *
7 * A component of the Greenstone digital library software
8 * from the New Zealand Digital Library Project at the
9 * University of Waikato, New Zealand.
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 *
25 *********************************************************************/
27#ifndef _oaiaction_h_
28#define _oaiaction_h_
29// standard c++ includes
30//#include <ostream.h>
32// generic gsdl stuff
33#include "text_t.h"
34#include "htmlutils.h" // For converting characters in a string to URL encoding.
36// connection to a receptionist
37#include "receptionist.h"
39// oaistuff
40#include "oaiargs.h"
41#include "oaiconfig.h"
42#include <time.h>
44// Define hours & mins that separate local time from UTC (GMT) time; +ve is ahead of UTC, -ve behind
45#define _LOCALTIME_ "+12:00"
47class oaiaction
49 public:
50 oaiaction(const text_t &name);
52 virtual void setConfiguration(oaiconfig *config) { this->configuration = config; }
53 text_t getName();
54 virtual text_t calcEarliestDatestamp(recptproto *protocol, oaiargs &params);
55 text_t parseDatestamp(time_t &rawtime);// Convert date from raw time_t format to the string YYYY-MM-DD
56 void getResponseDate(text_t &date); // Get the response date in UTC (GMT) time, plus local offset
57 void getRequestURL(oaiargs &params, text_t &requestURL); // Get the URL of the request
58 void getResponse(ostream &output, recptproto *protocol, oaiargs &params);
59 void output_action_tag(ostream &output, bool openTag);
60 void output_record_header(ostream &output, const text_t &oaiLabel, const text_t &lastModified,
61 const text_tarray &memberOf, int oaiVersion);
62 void output_error(ostream &output, text_t &errorType); // Output any error conditions
63 bool formatNotSupported(text_t &metaFormat); // Return true if the supplied metadataPrefix
64 // format is not supported
65 void setErrorType(text_t &err){this->errorType = err;};
66 text_t getErrorType(){return this->errorType;};
67 void getLastModifiedDate(ResultDocInfo_t &doc_info, text_t &lastModified);
68 bool inDateRange(const text_t &from, const text_t &until, const text_t &collection,
69 const text_t &OID, recptproto *protocol, ostream &logout);
70 /******
71 * The following function sets the isInnerObject flag. It is used by the nested recordaction
72 * object in the listrecs object. This flag provides a means for identifying whether the
73 * recordaction object is acting on its own or through a listrecsaction object. This is
74 * to allow for appropriate handling of errors regarding unsupported metadata formats. If
75 * we are using verb=GetRecord and the supplied metadata format is not supported by this
76 * particular item, then an error must be thrown. But if were using verb=ListRecords, we only
77 * want to exclude the item in question from the list, not throw an error.
78 */
79 void setAsInnerObject() { this->isInnerObject = true;}
81 protected:
82 oaiconfig *configuration;
83 virtual bool validateAction(recptproto *protocol, oaiargs &params); // Check that this is a valid action
84 virtual bool output_content(ostream &output, recptproto *protocol, oaiargs &params) = 0;
85 bool isInnerObject;
86 text_t name;
87 text_t errorType;
88 ostream * logout;
89 text_t mEarliestDatestamp;
Note: See TracBrowser for help on using the repository browser.