root/main/trunk/greenstone2/runtime-src/src/oaiservr/oaiaction.h @ 22739

Revision 22739, 3.9 KB (checked in by mdewsnip, 10 years ago)

Added copyright header to runtime-src/src/oaiserver/*.cpp and runtime-src/src/oaiserver/*.h.

  • Property svn:keywords set to Author Date Id Revision
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  text_t parseDatestamp(time_t &rawtime);// Convert date from raw time_t format to the string YYYY-MM-DD
55  void   getResponseDate(text_t &date);  // Get the response date in UTC (GMT) time, plus local offset
56  void   getRequestURL(oaiargs &params, text_t &requestURL); // Get the URL of the request
57  void   getResponse(ostream &output, recptproto *protocol, oaiargs &params);
58  void   output_action_tag(ostream &output, bool openTag);
59  void   output_record_header(ostream &output, const text_t &oaiLabel, const text_t &lastModified,
60                  const text_tarray &memberOf, int oaiVersion);
61  void   output_error(ostream &output, text_t &errorType); // Output any error conditions
62  bool   formatNotSupported(text_t &metaFormat);           // Return true if the supplied metadataPrefix
63                                                           // format is not supported
64  void   setErrorType(text_t &err){this->errorType = err;};
65  text_t getErrorType(){return this->errorType;};
66  void   getLastModifiedDate(ResultDocInfo_t &doc_info, text_t &lastModified);
67  bool   inDateRange(const text_t &from, const text_t &until, const text_t &collection,
68             const text_t &OID, recptproto *protocol, ostream &logout);
69  /******
70   * The following function sets the isInnerObject flag. It is used by the nested recordaction
71   * object in the listrecs object. This flag provides a means for identifying whether the
72   * recordaction object is acting on its own or through a listrecsaction object. This is
73   * to allow for appropriate handling of errors regarding unsupported metadata formats. If
74   * we are using verb=GetRecord and the supplied metadata format is not supported by this
75   * particular item, then an error must be thrown. But if were using verb=ListRecords, we only
76   * want to exclude the item in question from the list, not throw an error.
77   */
78  void       setAsInnerObject() { this->isInnerObject = true;}
79
80 protected:
81  oaiconfig *configuration;
82  virtual    bool validateAction(recptproto *protocol, oaiargs &params); // Check that this is a valid action
83  virtual    bool output_content(ostream &output, recptproto *protocol, oaiargs &params) = 0;
84  bool       isInnerObject;
85  text_t     name;
86  text_t     errorType;
87  ostream  * logout;
88};
89#endif
90
Note: See TracBrowser for help on using the browser.