[22739] | 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 |
|
---|
[8182] | 27 | #ifndef _oaiaction_h_
|
---|
| 28 | #define _oaiaction_h_
|
---|
| 29 | // standard c++ includes
|
---|
[8241] | 30 | //#include <ostream.h>
|
---|
[8182] | 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 |
|
---|
| 47 | class oaiaction
|
---|
| 48 | {
|
---|
| 49 | public:
|
---|
| 50 | oaiaction(const text_t &name);
|
---|
[24412] | 51 |
|
---|
[8182] | 52 | virtual void setConfiguration(oaiconfig *config) { this->configuration = config; }
|
---|
| 53 | text_t getName();
|
---|
[24412] | 54 | virtual text_t calcEarliestDatestamp(recptproto *protocol, oaiargs ¶ms);
|
---|
[8182] | 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 ¶ms, text_t &requestURL); // Get the URL of the request
|
---|
| 58 | void getResponse(ostream &output, recptproto *protocol, oaiargs ¶ms);
|
---|
| 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;}
|
---|
| 80 |
|
---|
| 81 | protected:
|
---|
| 82 | oaiconfig *configuration;
|
---|
| 83 | virtual bool validateAction(recptproto *protocol, oaiargs ¶ms); // Check that this is a valid action
|
---|
| 84 | virtual bool output_content(ostream &output, recptproto *protocol, oaiargs ¶ms) = 0;
|
---|
| 85 | bool isInnerObject;
|
---|
| 86 | text_t name;
|
---|
| 87 | text_t errorType;
|
---|
| 88 | ostream * logout;
|
---|
[24412] | 89 | text_t mEarliestDatestamp;
|
---|
[8182] | 90 | };
|
---|
| 91 | #endif
|
---|
| 92 |
|
---|