00001
00002
00007 #ifndef __RESPONSE_H__
00008 #define __RESPONSE_H__
00009
00010 #include <string>
00011 #include <list>
00012 #include <map>
00013
00014 #include "libepp_nicbr.H"
00015 #include "StrUtil.H"
00016
00017 using std::string;
00018 using std::list;
00019 using std::map;
00020
00021 LIBEPP_NICBR_NS_BEGIN
00022
00024 class Response
00025 {
00026 public:
00028 enum ResultCode {
00029 UNSET = -1,
00030 OK = 1000,
00031 OK_ACTION_PENDING = 1001,
00032 OK_NO_MESSAGES = 1300,
00033 OK_ACK_DEQUEUE = 1301,
00034 OK_ENDING_SESSION = 1500,
00035 UNKNOWN_COMMAND = 2000,
00036 COMMAND_SYNTAX_ERROR = 2001,
00037 COMMAND_USE_ERROR = 2002,
00038 PARAMETER_MISSING = 2003,
00039 PARAMETER_RANGE_ERROR = 2004,
00040 PARAMETER_SYNTAX_ERROR = 2005,
00041 UNIMPLEMENTED_VERSION = 2100,
00042 UNIMPLEMENTED_COMMAND = 2101,
00043 UNIMPLEMENTED_OPTION = 2102,
00044 UNIMPLEMENTED_EXTENSION = 2103,
00045 BILLING_FAILURE = 2104,
00046 NOT_RENEWABLE = 2105,
00047 NOT_TRANSFERABLE = 2106,
00048 AUTHENTICATION_ERROR = 2200,
00049 AUTHORIZATION_ERROR = 2201,
00050 INVALID_AUTHORIZATION_INFO = 2202,
00051 PENDING_TRANSFER = 2300,
00052 NOT_PENDING_TRANSFER = 2301,
00053 OBJECT_EXISTS = 2302,
00054 OBJECT_DOESNT_EXIST = 2303,
00055 STATUS_PROHIBITS_OPERATION = 2304,
00056 ASSOCIATION_PROHIBITS_OPERATION = 2305,
00057 PARAMETER_POLICY_ERROR = 2306,
00058 UNIMPLEMENTED_SERVICE = 2307,
00059 DATA_MGMT_POLICY_VIOLATION = 2308,
00060 COMMAND_FAILED = 2400,
00061 COMMAND_FAILED_CLOSING_CONN = 2500,
00062 AUTHENTICATION_ERROR_CLOSING_CONN = 2501,
00063 SESSION_LIMIT_EXCEEDED = 2502
00064 };
00065
00066 struct ResultExtValue {
00067 string value;
00068 string xmlns;
00069 string reason;
00070 };
00071
00072 struct ResultInfo {
00073 string msg;
00074 list<ResultExtValue> ext_values;
00075 };
00076
00078 Response(bool reset = true)
00079 {
00080 if (reset) {
00081 this->reset();
00082 }
00083 }
00084
00086
00089 void set_clTRID(const string &clTRID) { _clTRID = clTRID; }
00090
00092
00095 void set_svTRID(const string &svTRID) { _svTRID = svTRID; }
00096
00098
00101 void set_result_lang(const string &result_lang)
00102 {
00103 _result_lang = result_lang;
00104 }
00105
00107
00114 void insert_result(const ResultCode &code, const string &msg,
00115 const string &value = "", const string &xmlns = "",
00116 const string &reason = "")
00117 {
00118 _result_list[code].msg = msg;
00119
00120 if (value != "" || xmlns != "" || reason != "") {
00121 struct ResultExtValue extValue;
00122 extValue.value = value;
00123 extValue.xmlns = xmlns;
00124 extValue.reason = reason;
00125 _result_list[code].ext_values.push_back(extValue);
00126 }
00127 }
00128
00130
00133 string get_clTRID() { return _clTRID; }
00134
00136
00139 string get_svTRID() { return _svTRID; }
00140
00142
00145 string get_result_lang() { return _result_lang; }
00146
00148
00151 map<ResultCode, ResultInfo> get_result_list()
00152 {
00153 return _result_list;
00154 }
00155
00157 void reset()
00158 {
00159 _clTRID = "";
00160 _svTRID = "";
00161 _result_lang = "en";
00162 _result_list.clear();
00163 }
00164
00165 protected:
00167 string _clTRID;
00168
00170 string _svTRID;
00171
00173 string _result_lang;
00174
00176 map<ResultCode, ResultInfo> _result_list;
00177 };
00178
00179 LIBEPP_NICBR_NS_END
00180 #endif //__RESPONSE_H__