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

Last change on this file since 31390 was 31390, checked in by ak19, 7 years ago

Improved newly added oaiaction::getMeta(). Now return type is a bool and it now uses map.find() to locate requested meta.

  • Property svn:keywords set to Author Date Id Revision
File size: 4.2 KB
Line 
1/**********************************************************************
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
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
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 *********************************************************************/
26
27#ifndef _oaiaction_h_
28#define _oaiaction_h_
29// standard c++ includes
30//#include <ostream.h>
31
32// generic gsdl stuff
33#include "text_t.h"
34#include "htmlutils.h" // For converting characters in a string to URL encoding.
35
36// connection to a receptionist
37#include "receptionist.h"
38
39// oaistuff
40#include "oaiargs.h"
41#include "oaiconfig.h"
42#include <time.h>
43
44// Define hours & mins that separate local time from UTC (GMT) time; +ve is ahead of UTC, -ve behind
45#define _LOCALTIME_ "+12:00"
46
47class oaiaction
48{
49 public:
50 oaiaction(const text_t &name);
51
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_t &deleted_status, 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 getMeta(ResultDocInfo_t &doc_info, const text_t &metaname, text_t &metavalue);
69 bool inDateRange(const text_t &from, const text_t &until, const text_t &collection,
70 const text_t &OID, recptproto *protocol, ostream &logout);
71 /******
72 * The following function sets the isInnerObject flag. It is used by the nested recordaction
73 * object in the listrecs object. This flag provides a means for identifying whether the
74 * recordaction object is acting on its own or through a listrecsaction object. This is
75 * to allow for appropriate handling of errors regarding unsupported metadata formats. If
76 * we are using verb=GetRecord and the supplied metadata format is not supported by this
77 * particular item, then an error must be thrown. But if were using verb=ListRecords, we only
78 * want to exclude the item in question from the list, not throw an error.
79 */
80 void setAsInnerObject() { this->isInnerObject = true;}
81
82 protected:
83 oaiconfig *configuration;
84 virtual bool validateAction(recptproto *protocol, oaiargs &params); // Check that this is a valid action
85 virtual bool output_content(ostream &output, recptproto *protocol, oaiargs &params) = 0;
86 bool isInnerObject;
87 text_t name;
88 text_t errorType;
89 ostream * logout;
90 text_t mEarliestDatestamp;
91};
92#endif
93
Note: See TracBrowser for help on using the repository browser.