1 | #ifndef _oaiaction_h_
|
---|
2 | #define _oaiaction_h_
|
---|
3 | // standard c++ includes
|
---|
4 | #include <ostream.h>
|
---|
5 |
|
---|
6 | // generic gsdl stuff
|
---|
7 | #include "text_t.h"
|
---|
8 | #include "htmlutils.h" // For converting characters in a string to URL encoding.
|
---|
9 |
|
---|
10 | // connection to a receptionist
|
---|
11 | #include "receptionist.h"
|
---|
12 |
|
---|
13 | // oaistuff
|
---|
14 | #include "oaiargs.h"
|
---|
15 | #include "oaiconfig.h"
|
---|
16 | #include <time.h>
|
---|
17 |
|
---|
18 | // Define hours & mins that separate local time from UTC (GMT) time; +ve is ahead of UTC, -ve behind
|
---|
19 | #define _LOCALTIME_ "+12:00"
|
---|
20 |
|
---|
21 | class oaiaction
|
---|
22 | {
|
---|
23 | public:
|
---|
24 | oaiaction(const text_t &name);
|
---|
25 |
|
---|
26 | virtual void setConfiguration(oaiconfig *config) { this->configuration = config; }
|
---|
27 | text_t getName();
|
---|
28 | text_t parseDatestamp(time_t &rawtime);// Convert date from raw time_t format to the string YYYY-MM-DD
|
---|
29 | void getResponseDate(text_t &date); // Get the response date in UTC (GMT) time, plus local offset
|
---|
30 | void getRequestURL(oaiargs ¶ms, text_t &requestURL); // Get the URL of the request
|
---|
31 | void getResponse(ostream &output, recptproto *protocol, oaiargs ¶ms);
|
---|
32 | void output_action_tag(ostream &output, bool openTag);
|
---|
33 | void output_record_header(ostream &output, const text_t &oaiLabel, const text_t &lastModified,
|
---|
34 | const text_tarray &memberOf, int oaiVersion);
|
---|
35 | void output_error(ostream &output, text_t &errorType); // Output any error conditions
|
---|
36 | bool formatNotSupported(text_t &metaFormat); // Return true if the supplied metadataPrefix
|
---|
37 | // format is not supported
|
---|
38 | void setErrorType(text_t &err){this->errorType = err;};
|
---|
39 | text_t getErrorType(){return this->errorType;};
|
---|
40 | void getLastModifiedDate(ResultDocInfo_t &doc_info, text_t &lastModified);
|
---|
41 | bool inDateRange(const text_t &from, const text_t &until, const text_t &collection,
|
---|
42 | const text_t &OID, recptproto *protocol, ostream &logout);
|
---|
43 | /******
|
---|
44 | * The following function sets the isInnerObject flag. It is used by the nested recordaction
|
---|
45 | * object in the listrecs object. This flag provides a means for identifying whether the
|
---|
46 | * recordaction object is acting on its own or through a listrecsaction object. This is
|
---|
47 | * to allow for appropriate handling of errors regarding unsupported metadata formats. If
|
---|
48 | * we are using verb=GetRecord and the supplied metadata format is not supported by this
|
---|
49 | * particular item, then an error must be thrown. But if were using verb=ListRecords, we only
|
---|
50 | * want to exclude the item in question from the list, not throw an error.
|
---|
51 | */
|
---|
52 | void setAsInnerObject() { this->isInnerObject = true;}
|
---|
53 |
|
---|
54 | protected:
|
---|
55 | oaiconfig *configuration;
|
---|
56 | virtual bool validateAction(recptproto *protocol, oaiargs ¶ms); // Check that this is a valid action
|
---|
57 | virtual bool output_content(ostream &output, recptproto *protocol, oaiargs ¶ms) = 0;
|
---|
58 | bool isInnerObject;
|
---|
59 | text_t name;
|
---|
60 | text_t errorType;
|
---|
61 | ostream * logout;
|
---|
62 | };
|
---|
63 | #endif
|
---|
64 |
|
---|