35 string *stylesheet_ref) {
48 string href =
"href='" + *stylesheet_ref +
"'";
49 if (xmlTextWriterStartPI(xml.
get_writer(), (
const xmlChar *)
"xml-stylesheet") < 0)
50 throw InternalErr(__FILE__, __LINE__,
"Could not start XML Processing Instruction.");
51 if (xmlTextWriterWriteString(xml.
get_writer(), (
const xmlChar *)
"type='text/xsl'") < 0)
52 throw InternalErr(__FILE__, __LINE__,
"Could not write Processing Instruction content.");
53 if (xmlTextWriterWriteString(xml.
get_writer(), (
const xmlChar *)
" ") < 0)
54 throw InternalErr(__FILE__, __LINE__,
"Could not write Processing Instruction content.");
55 if (xmlTextWriterWriteString(xml.
get_writer(), (
const xmlChar *)href.c_str()) < 0)
56 throw InternalErr(__FILE__, __LINE__,
"Could not write Processing Instruction content.");
58 throw InternalErr(__FILE__, __LINE__,
"Could not Close XML Processing Instruction.");
62 if (xmlTextWriterStartElementNS(xml.
get_writer(), (
const xmlChar *)
"dap", (
const xmlChar *)
"AsynchronousResponse",
64 throw InternalErr(__FILE__, __LINE__,
"Could not write AsynchronousResponse element");
65 if (xmlTextWriterWriteAttribute(xml.
get_writer(), (
const xmlChar *)
"status", (
const xmlChar *)
"required") < 0)
66 throw InternalErr(__FILE__, __LINE__,
"Could not write attribute for 'status'");
69 if (xmlTextWriterStartElement(xml.
get_writer(), (
const xmlChar *)
"dap:expectedDelay") < 0)
70 throw InternalErr(__FILE__, __LINE__,
"Could not write expectedDelay element");
73 if (xmlTextWriterWriteAttribute(xml.
get_writer(), (
const xmlChar *)
"seconds", (
const xmlChar *)oss.str().c_str()) <
75 throw InternalErr(__FILE__, __LINE__,
"Could not write attribute for 'status'");
76 if (xmlTextWriterEndElement(xml.
get_writer()) < 0)
77 throw InternalErr(__FILE__, __LINE__,
"Could not end expectedDelay element");
81 if (xmlTextWriterStartElement(xml.
get_writer(), (
const xmlChar *)
"dap:responseLifetime") < 0)
82 throw InternalErr(__FILE__, __LINE__,
"Could not write expectedDelay element");
84 oss2 << responseLifetime;
85 if (xmlTextWriterWriteAttribute(xml.
get_writer(), (
const xmlChar *)
"seconds", (
const xmlChar *)oss2.str().c_str()) <
87 throw InternalErr(__FILE__, __LINE__,
"Could not write attribute for 'seconds'");
88 if (xmlTextWriterEndElement(xml.
get_writer()) < 0)
89 throw InternalErr(__FILE__, __LINE__,
"Could not end responseLifetime element");
92 if (xmlTextWriterEndElement(xml.
get_writer()) < 0)
93 throw InternalErr(__FILE__, __LINE__,
"Could not end AsynchronousResponse element");
103 string asyncResourceUrl,
string *stylesheet_ref) {
108 if (stylesheet_ref) {
109 string href =
"href='" + *stylesheet_ref +
"'";
110 if (xmlTextWriterStartPI(xml.
get_writer(), (
const xmlChar *)
"xml-stylesheet") < 0)
111 throw InternalErr(__FILE__, __LINE__,
"Could not start XML Processing Instruction.");
112 if (xmlTextWriterWriteString(xml.
get_writer(), (
const xmlChar *)
"type='text/xsl'") < 0)
113 throw InternalErr(__FILE__, __LINE__,
"Could not write Processing Instruction content.");
114 if (xmlTextWriterWriteString(xml.
get_writer(), (
const xmlChar *)
" ") < 0)
115 throw InternalErr(__FILE__, __LINE__,
"Could not write Processing Instruction content.");
116 if (xmlTextWriterWriteString(xml.
get_writer(), (
const xmlChar *)href.c_str()) < 0)
117 throw InternalErr(__FILE__, __LINE__,
"Could not write Processing Instruction content.");
119 throw InternalErr(__FILE__, __LINE__,
"Could not Close XML Processing Instruction.");
122 if (xmlTextWriterStartElementNS(xml.
get_writer(), (
const xmlChar *)
"dap", (
const xmlChar *)
"AsynchronousResponse",
124 throw InternalErr(__FILE__, __LINE__,
"Could not write AsynchronousResponse element");
125 if (xmlTextWriterWriteAttribute(xml.
get_writer(), (
const xmlChar *)
"status", (
const xmlChar *)
"accepted") < 0)
126 throw InternalErr(__FILE__, __LINE__,
"Could not write attribute for 'status'");
129 if (xmlTextWriterStartElement(xml.
get_writer(), (
const xmlChar *)
"dap:expectedDelay") < 0)
130 throw InternalErr(__FILE__, __LINE__,
"Could not write expectedDelay element");
132 oss << expectedDelay;
133 if (xmlTextWriterWriteAttribute(xml.
get_writer(), (
const xmlChar *)
"seconds", (
const xmlChar *)oss.str().c_str()) <
135 throw InternalErr(__FILE__, __LINE__,
"Could not write attribute for 'seconds'");
136 if (xmlTextWriterEndElement(xml.
get_writer()) < 0)
137 throw InternalErr(__FILE__, __LINE__,
"Could not end expectedDelay element");
141 if (xmlTextWriterStartElement(xml.
get_writer(), (
const xmlChar *)
"dap:responseLifetime") < 0)
142 throw InternalErr(__FILE__, __LINE__,
"Could not write expectedDelay element");
144 oss2 << responseLifetime;
145 if (xmlTextWriterWriteAttribute(xml.
get_writer(), (
const xmlChar *)
"seconds", (
const xmlChar *)oss2.str().c_str()) <
147 throw InternalErr(__FILE__, __LINE__,
"Could not write attribute for 'seconds'");
148 if (xmlTextWriterEndElement(xml.
get_writer()) < 0)
149 throw InternalErr(__FILE__, __LINE__,
"Could not end responseLifetime element");
153 if (xmlTextWriterStartElement(xml.
get_writer(), (
const xmlChar *)
"dap:link") < 0)
154 throw InternalErr(__FILE__, __LINE__,
"Could not write expectedDelay element");
156 if (xmlTextWriterWriteAttribute(xml.
get_writer(), (
const xmlChar *)
"href",
157 (
const xmlChar *)asyncResourceUrl.c_str()) < 0)
158 throw InternalErr(__FILE__, __LINE__,
"Could not write attribute for 'href'");
159 if (xmlTextWriterEndElement(xml.
get_writer()) < 0)
160 throw InternalErr(__FILE__, __LINE__,
"Could not end link element");
163 if (xmlTextWriterEndElement(xml.
get_writer()) < 0)
164 throw InternalErr(__FILE__, __LINE__,
"Could not end AsynchronousResponse element");
178 if (stylesheet_ref) {
179 string href =
"href='" + *stylesheet_ref +
"'";
180 if (xmlTextWriterStartPI(xml.
get_writer(), (
const xmlChar *)
"xml-stylesheet") < 0)
181 throw InternalErr(__FILE__, __LINE__,
"Could not start XML Processing Instruction.");
182 if (xmlTextWriterWriteString(xml.
get_writer(), (
const xmlChar *)
"type='text/xsl'") < 0)
183 throw InternalErr(__FILE__, __LINE__,
"Could not write Processing Instruction content.");
184 if (xmlTextWriterWriteString(xml.
get_writer(), (
const xmlChar *)
" ") < 0)
185 throw InternalErr(__FILE__, __LINE__,
"Could not write Processing Instruction content.");
186 if (xmlTextWriterWriteString(xml.
get_writer(), (
const xmlChar *)href.c_str()) < 0)
187 throw InternalErr(__FILE__, __LINE__,
"Could not write Processing Instruction content.");
189 throw InternalErr(__FILE__, __LINE__,
"Could not Close XML Processing Instruction.");
192 if (xmlTextWriterStartElementNS(xml.
get_writer(), (
const xmlChar *)
"dap", (
const xmlChar *)
"AsynchronousResponse",
194 throw InternalErr(__FILE__, __LINE__,
"Could not write AsynchronousResponse element");
195 if (xmlTextWriterWriteAttribute(xml.
get_writer(), (
const xmlChar *)
"status", (
const xmlChar *)
"pending") < 0)
196 throw InternalErr(__FILE__, __LINE__,
"Could not write attribute for 'status'");
198 if (xmlTextWriterEndElement(xml.
get_writer()) < 0)
199 throw InternalErr(__FILE__, __LINE__,
"Could not end AsynchronousResponse element");
213 if (stylesheet_ref) {
214 string href =
"href='" + *stylesheet_ref +
"'";
215 if (xmlTextWriterStartPI(xml.
get_writer(), (
const xmlChar *)
"xml-stylesheet") < 0)
216 throw InternalErr(__FILE__, __LINE__,
"Could not start XML Processing Instruction.");
217 if (xmlTextWriterWriteString(xml.
get_writer(), (
const xmlChar *)
"type='text/xsl'") < 0)
218 throw InternalErr(__FILE__, __LINE__,
"Could not write Processing Instruction content.");
219 if (xmlTextWriterWriteString(xml.
get_writer(), (
const xmlChar *)
" ") < 0)
220 throw InternalErr(__FILE__, __LINE__,
"Could not write Processing Instruction content.");
221 if (xmlTextWriterWriteString(xml.
get_writer(), (
const xmlChar *)href.c_str()) < 0)
222 throw InternalErr(__FILE__, __LINE__,
"Could not write Processing Instruction content.");
224 throw InternalErr(__FILE__, __LINE__,
"Could not Close XML Processing Instruction.");
227 if (xmlTextWriterStartElementNS(xml.
get_writer(), (
const xmlChar *)
"dap", (
const xmlChar *)
"AsynchronousResponse",
229 throw InternalErr(__FILE__, __LINE__,
"Could not write AsynchronousResponse element");
230 if (xmlTextWriterWriteAttribute(xml.
get_writer(), (
const xmlChar *)
"status", (
const xmlChar *)
"gone") < 0)
231 throw InternalErr(__FILE__, __LINE__,
"Could not write attribute for 'status'");
233 if (xmlTextWriterEndElement(xml.
get_writer()) < 0)
234 throw InternalErr(__FILE__, __LINE__,
"Could not end AsynchronousResponse element");
244 string *stylesheet_ref) {
249 if (stylesheet_ref) {
250 string href =
"href='" + *stylesheet_ref +
"'";
251 if (xmlTextWriterStartPI(xml.
get_writer(), (
const xmlChar *)
"xml-stylesheet") < 0)
252 throw InternalErr(__FILE__, __LINE__,
"Could not start XML Processing Instruction.");
253 if (xmlTextWriterWriteString(xml.
get_writer(), (
const xmlChar *)
"type='text/xsl'") < 0)
254 throw InternalErr(__FILE__, __LINE__,
"Could not write Processing Instruction content.");
255 if (xmlTextWriterWriteString(xml.
get_writer(), (
const xmlChar *)
" ") < 0)
256 throw InternalErr(__FILE__, __LINE__,
"Could not write Processing Instruction content.");
257 if (xmlTextWriterWriteString(xml.
get_writer(), (
const xmlChar *)href.c_str()) < 0)
258 throw InternalErr(__FILE__, __LINE__,
"Could not write Processing Instruction content.");
260 throw InternalErr(__FILE__, __LINE__,
"Could not Close XML Processing Instruction.");
263 if (xmlTextWriterStartElementNS(xml.
get_writer(), (
const xmlChar *)
"dap", (
const xmlChar *)
"AsynchronousResponse",
265 throw InternalErr(__FILE__, __LINE__,
"Could not write AsynchronousResponse element");
266 if (xmlTextWriterWriteAttribute(xml.
get_writer(), (
const xmlChar *)
"status", (
const xmlChar *)
"rejected") < 0)
267 throw InternalErr(__FILE__, __LINE__,
"Could not write attribute for 'status'");
270 if (xmlTextWriterStartElement(xml.
get_writer(), (
const xmlChar *)
"dap:reason") < 0)
271 throw InternalErr(__FILE__, __LINE__,
"Could not write reason element");
272 if (xmlTextWriterWriteAttribute(xml.
get_writer(), (
const xmlChar *)
"code",
274 throw InternalErr(__FILE__, __LINE__,
"Could not write attribute for 'code'");
275 if (xmlTextWriterEndElement(xml.
get_writer()) < 0)
276 throw InternalErr(__FILE__, __LINE__,
"Could not end reason element");
280 if (xmlTextWriterWriteElement(xml.
get_writer(), (
const xmlChar *)
"dap:description",
281 (
const xmlChar *)description.c_str()) < 0)
282 throw InternalErr(__FILE__, __LINE__,
"Could not write description element");
286 if (xmlTextWriterEndElement(xml.
get_writer()) < 0)
287 throw InternalErr(__FILE__, __LINE__,
"Could not end AsynchronousResponse element");
300 codeStr =
"unavailable";
304 codeStr =
"privileges";
313 "D4AsyncUtil::getRejectReasonCodeString() - Unrecognized reject_reason_code.");
321 throw InternalErr(__FILE__, __LINE__,
"DAP2 Doesn't handle Async.");
325 throw InternalErr(__FILE__, __LINE__,
"DAP2 Doesn't handle Async.");
329 throw InternalErr(__FILE__, __LINE__,
"DAP2 Doesn't handle Async.");
333 throw InternalErr(__FILE__, __LINE__,
"DAP2 Doesn't handle Async.");
337 throw InternalErr(__FILE__, __LINE__,
"DAP2 Doesn't handle Async.");
string getRejectReasonCodeString(RejectReasonCode code)
void writeD2AsyncPending(XMLWriter &xml)
void writeD4AsyncResponseRejected(XMLWriter &xml, RejectReasonCode code, string description, string *stylesheet_ref=0)
Write the DAP4 ResponseRejected response. Write the DAP4 AsyncRequired in XML form.
static const string STYLESHEET_REFERENCE_KEY
void writeD2AsyncResponseRejected(XMLWriter &xml, RejectReasonCode code, string description)
void writeD2AsyncAccepted(XMLWriter &xml, long expectedDelay, long responseLifetime, string asyncResourceUrl)
void writeD4AsyncPending(XMLWriter &xml, string *stylesheet_ref=0)
Write the DAP4 AsyncPending response. Write the DAP4 AsyncPending in XML form.
void writeD4AsyncRequired(XMLWriter &xml, long expectedDelay, long responseLifetime, string *stylesheet_ref=0)
Write the DAP4 AsyncRequired response. Print the AsyncRequired in XML form.
void writeD2AsyncResponseGone(XMLWriter &xml)
void writeD2AsyncRequired(XMLWriter &xml, long expectedDelay, long responseLifetime)
Write the DAP2 AsyncRequired response . Write the DAP2 AsyncRequired in XML form.
void writeD4AsyncAccepted(XMLWriter &xml, long expectedDelay, long responseLifetime, string asyncResourceUrl, string *stylesheet_ref=0)
Write the DAP4 AsyncAccepted response. Write the AsyncAccepted in XML form.
void writeD4AsyncResponseGone(XMLWriter &xml, string *stylesheet_ref=0)
Write the DAP4 AsyncResponseGone response. Write the DAP4 AsyncRequired in XML form.
static std::string getDapNamespaceString(DAPVersion version)
A class for software fault reporting.
xmlTextWriterPtr get_writer() const
top level DAP object to house generic methods