|
Packit |
a4aae4 |
/*
|
|
Packit |
a4aae4 |
* D4AsyncUtil.cc
|
|
Packit |
a4aae4 |
*
|
|
Packit |
a4aae4 |
* Created on: Feb 18, 2014
|
|
Packit |
a4aae4 |
* Author: ndp
|
|
Packit |
a4aae4 |
*/
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
#include "config.h"
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
#include <sstream>
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
#include "XMLWriter.h"
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
#include "Error.h"
|
|
Packit |
a4aae4 |
#include "InternalErr.h"
|
|
Packit |
a4aae4 |
#include "util.h"
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
#include "D4AsyncUtil.h"
|
|
Packit |
a4aae4 |
#include "DapXmlNamespaces.h"
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
namespace libdap {
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
const string D4AsyncUtil::STYLESHEET_REFERENCE_KEY = "DAP.Async.StyleSheet.Ref";
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
D4AsyncUtil::D4AsyncUtil() {}
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
D4AsyncUtil::~D4AsyncUtil() {}
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
/**
|
|
Packit |
a4aae4 |
* @brief Print the AsyncRequired response to the.
|
|
Packit |
a4aae4 |
* Print the AsyncRequired in XML form.
|
|
Packit |
a4aae4 |
* @param xml Print to this XMLWriter instance
|
|
Packit |
a4aae4 |
*/
|
|
Packit |
a4aae4 |
void D4AsyncUtil::writeD4AsyncRequired(XMLWriter &xml, long expectedDelay, long responseLifetime, string *stylesheet_ref) {
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
// ------ AsynchronousResponse Element and Attributes - BEGIN
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
/*
|
|
Packit |
a4aae4 |
int xmlTextWriterWriteAttributeNS (xmlTextWriterPtr writer,
|
|
Packit |
a4aae4 |
const xmlChar * prefix,
|
|
Packit |
a4aae4 |
const xmlChar * name,
|
|
Packit |
a4aae4 |
const xmlChar * namespaceURI,
|
|
Packit |
a4aae4 |
const xmlChar * content)
|
|
Packit |
a4aae4 |
*/
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
if(stylesheet_ref){
|
|
Packit |
a4aae4 |
string href = "href='" + *stylesheet_ref +"'";
|
|
Packit |
a4aae4 |
if(xmlTextWriterStartPI(xml.get_writer(), (const xmlChar*) "xml-stylesheet") < 0)
|
|
Packit |
a4aae4 |
throw InternalErr(__FILE__, __LINE__, "Could not start XML Processing Instruction.");
|
|
Packit |
a4aae4 |
if(xmlTextWriterWriteString(xml.get_writer(), (const xmlChar*) "type='text/xsl'") < 0)
|
|
Packit |
a4aae4 |
throw InternalErr(__FILE__, __LINE__, "Could not write Processing Instruction content.");
|
|
Packit |
a4aae4 |
if(xmlTextWriterWriteString(xml.get_writer(), (const xmlChar*) " ") < 0)
|
|
Packit |
a4aae4 |
throw InternalErr(__FILE__, __LINE__, "Could not write Processing Instruction content.");
|
|
Packit |
a4aae4 |
if(xmlTextWriterWriteString(xml.get_writer(), (const xmlChar*) href.c_str()) < 0)
|
|
Packit |
a4aae4 |
throw InternalErr(__FILE__, __LINE__, "Could not write Processing Instruction content.");
|
|
Packit |
a4aae4 |
if(xmlTextWriterEndPI(xml.get_writer()) < 0)
|
|
Packit |
a4aae4 |
throw InternalErr(__FILE__, __LINE__, "Could not Close XML Processing Instruction.");
|
|
Packit |
a4aae4 |
}
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
DapXmlNamspaces dapns;
|
|
Packit |
a4aae4 |
if (xmlTextWriterStartElementNS(xml.get_writer(),
|
|
Packit |
a4aae4 |
(const xmlChar*)"dap",
|
|
Packit |
a4aae4 |
(const xmlChar*) "AsynchronousResponse",
|
|
Packit |
a4aae4 |
(const xmlChar*) dapns.getDapNamespaceString(DAP_4_0).c_str()) < 0)
|
|
Packit |
a4aae4 |
throw InternalErr(__FILE__, __LINE__, "Could not write AsynchronousResponse element");
|
|
Packit |
a4aae4 |
if (xmlTextWriterWriteAttribute(xml.get_writer(), (const xmlChar*) "status", (const xmlChar *) "required") < 0)
|
|
Packit |
a4aae4 |
throw InternalErr(__FILE__, __LINE__, "Could not write attribute for 'status'");
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
// ------ expectedDelay Element and Attributes
|
|
Packit |
a4aae4 |
if (xmlTextWriterStartElement(xml.get_writer(), (const xmlChar*) "dap:expectedDelay") < 0)
|
|
Packit |
a4aae4 |
throw InternalErr(__FILE__, __LINE__, "Could not write expectedDelay element");
|
|
Packit |
a4aae4 |
ostringstream oss;
|
|
Packit |
a4aae4 |
oss << expectedDelay;
|
|
Packit |
a4aae4 |
if (xmlTextWriterWriteAttribute(xml.get_writer(), (const xmlChar*) "seconds", (const xmlChar*) oss.str().c_str()) < 0)
|
|
Packit |
a4aae4 |
throw InternalErr(__FILE__, __LINE__, "Could not write attribute for 'status'");
|
|
Packit |
a4aae4 |
if (xmlTextWriterEndElement(xml.get_writer()) < 0)
|
|
Packit |
a4aae4 |
throw InternalErr(__FILE__, __LINE__, "Could not end expectedDelay element");
|
|
Packit |
a4aae4 |
// ------ expectedDelay Element and Attributes - END
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
// ------ responseLifetime Element and Attributes
|
|
Packit |
a4aae4 |
if (xmlTextWriterStartElement(xml.get_writer(), (const xmlChar*) "dap:responseLifetime") < 0)
|
|
Packit |
a4aae4 |
throw InternalErr(__FILE__, __LINE__, "Could not write expectedDelay element");
|
|
Packit |
a4aae4 |
ostringstream oss2;
|
|
Packit |
a4aae4 |
oss2 << responseLifetime;
|
|
Packit |
a4aae4 |
if (xmlTextWriterWriteAttribute(xml.get_writer(), (const xmlChar*) "seconds", (const xmlChar*) oss2.str().c_str()) < 0)
|
|
Packit |
a4aae4 |
throw InternalErr(__FILE__, __LINE__, "Could not write attribute for 'seconds'");
|
|
Packit |
a4aae4 |
if (xmlTextWriterEndElement(xml.get_writer()) < 0)
|
|
Packit |
a4aae4 |
throw InternalErr(__FILE__, __LINE__, "Could not end responseLifetime element");
|
|
Packit |
a4aae4 |
// ------ responseLifetime Element and Attributes - END
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
if (xmlTextWriterEndElement(xml.get_writer()) < 0)
|
|
Packit |
a4aae4 |
throw InternalErr(__FILE__, __LINE__, "Could not end AsynchronousResponse element");
|
|
Packit |
a4aae4 |
// ------ AsynchronousResponse Element and Attributes - END
|
|
Packit |
a4aae4 |
}
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
/**
|
|
Packit |
a4aae4 |
* @brief Print the AsyncRequired response to the.
|
|
Packit |
a4aae4 |
* Print the AsyncRequired in XML form.
|
|
Packit |
a4aae4 |
* @param xml Print to this XMLWriter instance
|
|
Packit |
a4aae4 |
*/
|
|
Packit |
a4aae4 |
void D4AsyncUtil::writeD4AsyncAccepted(XMLWriter &xml, long expectedDelay, long responseLifetime, string asyncResourceUrl, string *stylesheet_ref) {
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
// ------ AsynchronousResponse Element and Attributes - BEGIN
|
|
Packit |
a4aae4 |
DapXmlNamspaces dapns;
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
if(stylesheet_ref){
|
|
Packit |
a4aae4 |
string href = "href='" + *stylesheet_ref +"'";
|
|
Packit |
a4aae4 |
if(xmlTextWriterStartPI(xml.get_writer(), (const xmlChar*) "xml-stylesheet") < 0)
|
|
Packit |
a4aae4 |
throw InternalErr(__FILE__, __LINE__, "Could not start XML Processing Instruction.");
|
|
Packit |
a4aae4 |
if(xmlTextWriterWriteString(xml.get_writer(), (const xmlChar*) "type='text/xsl'") < 0)
|
|
Packit |
a4aae4 |
throw InternalErr(__FILE__, __LINE__, "Could not write Processing Instruction content.");
|
|
Packit |
a4aae4 |
if(xmlTextWriterWriteString(xml.get_writer(), (const xmlChar*) " ") < 0)
|
|
Packit |
a4aae4 |
throw InternalErr(__FILE__, __LINE__, "Could not write Processing Instruction content.");
|
|
Packit |
a4aae4 |
if(xmlTextWriterWriteString(xml.get_writer(), (const xmlChar*) href.c_str()) < 0)
|
|
Packit |
a4aae4 |
throw InternalErr(__FILE__, __LINE__, "Could not write Processing Instruction content.");
|
|
Packit |
a4aae4 |
if(xmlTextWriterEndPI(xml.get_writer()) < 0)
|
|
Packit |
a4aae4 |
throw InternalErr(__FILE__, __LINE__, "Could not Close XML Processing Instruction.");
|
|
Packit |
a4aae4 |
}
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
if (xmlTextWriterStartElementNS(xml.get_writer(),
|
|
Packit |
a4aae4 |
(const xmlChar*)"dap",
|
|
Packit |
a4aae4 |
(const xmlChar*) "AsynchronousResponse",
|
|
Packit |
a4aae4 |
(const xmlChar*) dapns.getDapNamespaceString(DAP_4_0).c_str()) < 0)
|
|
Packit |
a4aae4 |
throw InternalErr(__FILE__, __LINE__, "Could not write AsynchronousResponse element");
|
|
Packit |
a4aae4 |
if (xmlTextWriterWriteAttribute(xml.get_writer(), (const xmlChar*) "status", (const xmlChar *) "accepted") < 0)
|
|
Packit |
a4aae4 |
throw InternalErr(__FILE__, __LINE__, "Could not write attribute for 'status'");
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
// ------ expectedDelay Element and Attributes
|
|
Packit |
a4aae4 |
if (xmlTextWriterStartElement(xml.get_writer(), (const xmlChar*) "dap:expectedDelay") < 0)
|
|
Packit |
a4aae4 |
throw InternalErr(__FILE__, __LINE__, "Could not write expectedDelay element");
|
|
Packit |
a4aae4 |
ostringstream oss;
|
|
Packit |
a4aae4 |
oss << expectedDelay;
|
|
Packit |
a4aae4 |
if (xmlTextWriterWriteAttribute(xml.get_writer(), (const xmlChar*) "seconds", (const xmlChar*) oss.str().c_str()) < 0)
|
|
Packit |
a4aae4 |
throw InternalErr(__FILE__, __LINE__, "Could not write attribute for 'seconds'");
|
|
Packit |
a4aae4 |
if (xmlTextWriterEndElement(xml.get_writer()) < 0)
|
|
Packit |
a4aae4 |
throw InternalErr(__FILE__, __LINE__, "Could not end expectedDelay element");
|
|
Packit |
a4aae4 |
// ------ expectedDelay Element and Attributes - END
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
// ------ responseLifetime Element and Attributes
|
|
Packit |
a4aae4 |
if (xmlTextWriterStartElement(xml.get_writer(), (const xmlChar*) "dap:responseLifetime") < 0)
|
|
Packit |
a4aae4 |
throw InternalErr(__FILE__, __LINE__, "Could not write expectedDelay element");
|
|
Packit |
a4aae4 |
ostringstream oss2;
|
|
Packit |
a4aae4 |
oss2 << responseLifetime;
|
|
Packit |
a4aae4 |
if (xmlTextWriterWriteAttribute(xml.get_writer(), (const xmlChar*) "seconds", (const xmlChar*) oss2.str().c_str()) < 0)
|
|
Packit |
a4aae4 |
throw InternalErr(__FILE__, __LINE__, "Could not write attribute for 'seconds'");
|
|
Packit |
a4aae4 |
if (xmlTextWriterEndElement(xml.get_writer()) < 0)
|
|
Packit |
a4aae4 |
throw InternalErr(__FILE__, __LINE__, "Could not end responseLifetime element");
|
|
Packit |
a4aae4 |
// ------ responseLifetime Element and Attributes - END
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
// ------ link Element and Attributes
|
|
Packit |
a4aae4 |
if (xmlTextWriterStartElement(xml.get_writer(), (const xmlChar*) "dap:link") < 0)
|
|
Packit |
a4aae4 |
throw InternalErr(__FILE__, __LINE__, "Could not write expectedDelay element");
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
if (xmlTextWriterWriteAttribute(xml.get_writer(), (const xmlChar*) "href", (const xmlChar*) asyncResourceUrl.c_str()) < 0)
|
|
Packit |
a4aae4 |
throw InternalErr(__FILE__, __LINE__, "Could not write attribute for 'href'");
|
|
Packit |
a4aae4 |
if (xmlTextWriterEndElement(xml.get_writer()) < 0)
|
|
Packit |
a4aae4 |
throw InternalErr(__FILE__, __LINE__, "Could not end link element");
|
|
Packit |
a4aae4 |
// ------ link Element and Attributes - END
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
if (xmlTextWriterEndElement(xml.get_writer()) < 0)
|
|
Packit |
a4aae4 |
throw InternalErr(__FILE__, __LINE__, "Could not end AsynchronousResponse element");
|
|
Packit |
a4aae4 |
// ------ AsynchronousResponse Element and Attributes - END
|
|
Packit |
a4aae4 |
}
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
/**
|
|
Packit |
a4aae4 |
* @brief Print the AsyncRequired response to the.
|
|
Packit |
a4aae4 |
* Print the AsyncRequired in XML form.
|
|
Packit |
a4aae4 |
* @param xml Print to this XMLWriter instance
|
|
Packit |
a4aae4 |
*/
|
|
Packit |
a4aae4 |
void D4AsyncUtil::writeD4AsyncPending(XMLWriter &xml, string *stylesheet_ref) {
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
// ------ AsynchronousResponse Element and Attributes - BEGIN
|
|
Packit |
a4aae4 |
DapXmlNamspaces dapns;
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
if(stylesheet_ref){
|
|
Packit |
a4aae4 |
string href = "href='" + *stylesheet_ref +"'";
|
|
Packit |
a4aae4 |
if(xmlTextWriterStartPI(xml.get_writer(), (const xmlChar*) "xml-stylesheet") < 0)
|
|
Packit |
a4aae4 |
throw InternalErr(__FILE__, __LINE__, "Could not start XML Processing Instruction.");
|
|
Packit |
a4aae4 |
if(xmlTextWriterWriteString(xml.get_writer(), (const xmlChar*) "type='text/xsl'") < 0)
|
|
Packit |
a4aae4 |
throw InternalErr(__FILE__, __LINE__, "Could not write Processing Instruction content.");
|
|
Packit |
a4aae4 |
if(xmlTextWriterWriteString(xml.get_writer(), (const xmlChar*) " ") < 0)
|
|
Packit |
a4aae4 |
throw InternalErr(__FILE__, __LINE__, "Could not write Processing Instruction content.");
|
|
Packit |
a4aae4 |
if(xmlTextWriterWriteString(xml.get_writer(), (const xmlChar*) href.c_str()) < 0)
|
|
Packit |
a4aae4 |
throw InternalErr(__FILE__, __LINE__, "Could not write Processing Instruction content.");
|
|
Packit |
a4aae4 |
if(xmlTextWriterEndPI(xml.get_writer()) < 0)
|
|
Packit |
a4aae4 |
throw InternalErr(__FILE__, __LINE__, "Could not Close XML Processing Instruction.");
|
|
Packit |
a4aae4 |
}
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
if (xmlTextWriterStartElementNS(xml.get_writer(),
|
|
Packit |
a4aae4 |
(const xmlChar*)"dap",
|
|
Packit |
a4aae4 |
(const xmlChar*) "AsynchronousResponse",
|
|
Packit |
a4aae4 |
(const xmlChar*) dapns.getDapNamespaceString(DAP_4_0).c_str()) < 0)
|
|
Packit |
a4aae4 |
throw InternalErr(__FILE__, __LINE__, "Could not write AsynchronousResponse element");
|
|
Packit |
a4aae4 |
if (xmlTextWriterWriteAttribute(xml.get_writer(), (const xmlChar*) "status", (const xmlChar *) "pending") < 0)
|
|
Packit |
a4aae4 |
throw InternalErr(__FILE__, __LINE__, "Could not write attribute for 'status'");
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
if (xmlTextWriterEndElement(xml.get_writer()) < 0)
|
|
Packit |
a4aae4 |
throw InternalErr(__FILE__, __LINE__, "Could not end AsynchronousResponse element");
|
|
Packit |
a4aae4 |
// ------ AsynchronousResponse Element and Attributes - END
|
|
Packit |
a4aae4 |
}
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
/**
|
|
Packit |
a4aae4 |
* @brief Print the AsyncRequired response to the.
|
|
Packit |
a4aae4 |
* Print the AsyncRequired in XML form.
|
|
Packit |
a4aae4 |
* @param xml Print to this XMLWriter instance
|
|
Packit |
a4aae4 |
*/
|
|
Packit |
a4aae4 |
void D4AsyncUtil::writeD4AsyncResponseGone(XMLWriter &xml, string *stylesheet_ref) {
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
// ------ AsynchronousResponse Element and Attributes - BEGIN
|
|
Packit |
a4aae4 |
DapXmlNamspaces dapns;
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
if(stylesheet_ref){
|
|
Packit |
a4aae4 |
string href = "href='" + *stylesheet_ref +"'";
|
|
Packit |
a4aae4 |
if(xmlTextWriterStartPI(xml.get_writer(), (const xmlChar*) "xml-stylesheet") < 0)
|
|
Packit |
a4aae4 |
throw InternalErr(__FILE__, __LINE__, "Could not start XML Processing Instruction.");
|
|
Packit |
a4aae4 |
if(xmlTextWriterWriteString(xml.get_writer(), (const xmlChar*) "type='text/xsl'") < 0)
|
|
Packit |
a4aae4 |
throw InternalErr(__FILE__, __LINE__, "Could not write Processing Instruction content.");
|
|
Packit |
a4aae4 |
if(xmlTextWriterWriteString(xml.get_writer(), (const xmlChar*) " ") < 0)
|
|
Packit |
a4aae4 |
throw InternalErr(__FILE__, __LINE__, "Could not write Processing Instruction content.");
|
|
Packit |
a4aae4 |
if(xmlTextWriterWriteString(xml.get_writer(), (const xmlChar*) href.c_str()) < 0)
|
|
Packit |
a4aae4 |
throw InternalErr(__FILE__, __LINE__, "Could not write Processing Instruction content.");
|
|
Packit |
a4aae4 |
if(xmlTextWriterEndPI(xml.get_writer()) < 0)
|
|
Packit |
a4aae4 |
throw InternalErr(__FILE__, __LINE__, "Could not Close XML Processing Instruction.");
|
|
Packit |
a4aae4 |
}
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
if (xmlTextWriterStartElementNS(xml.get_writer(),
|
|
Packit |
a4aae4 |
(const xmlChar*)"dap",
|
|
Packit |
a4aae4 |
(const xmlChar*) "AsynchronousResponse",
|
|
Packit |
a4aae4 |
(const xmlChar*) dapns.getDapNamespaceString(DAP_4_0).c_str()) < 0)
|
|
Packit |
a4aae4 |
throw InternalErr(__FILE__, __LINE__, "Could not write AsynchronousResponse element");
|
|
Packit |
a4aae4 |
if (xmlTextWriterWriteAttribute(xml.get_writer(), (const xmlChar*) "status", (const xmlChar *) "gone") < 0)
|
|
Packit |
a4aae4 |
throw InternalErr(__FILE__, __LINE__, "Could not write attribute for 'status'");
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
if (xmlTextWriterEndElement(xml.get_writer()) < 0)
|
|
Packit |
a4aae4 |
throw InternalErr(__FILE__, __LINE__, "Could not end AsynchronousResponse element");
|
|
Packit |
a4aae4 |
// ------ AsynchronousResponse Element and Attributes - END
|
|
Packit |
a4aae4 |
}
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
/**
|
|
Packit |
a4aae4 |
* @brief Print the AsyncRequired response to the.
|
|
Packit |
a4aae4 |
* Print the AsyncRequired in XML form.
|
|
Packit |
a4aae4 |
* @param xml Print to this XMLWriter instance
|
|
Packit |
a4aae4 |
*/
|
|
Packit |
a4aae4 |
void D4AsyncUtil::writeD4AsyncResponseRejected(XMLWriter &xml, RejectReasonCode code, string description, string *stylesheet_ref) {
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
// ------ AsynchronousResponse Element and Attributes - BEGIN
|
|
Packit |
a4aae4 |
DapXmlNamspaces dapns;
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
if(stylesheet_ref){
|
|
Packit |
a4aae4 |
string href = "href='" + *stylesheet_ref +"'";
|
|
Packit |
a4aae4 |
if(xmlTextWriterStartPI(xml.get_writer(), (const xmlChar*) "xml-stylesheet") < 0)
|
|
Packit |
a4aae4 |
throw InternalErr(__FILE__, __LINE__, "Could not start XML Processing Instruction.");
|
|
Packit |
a4aae4 |
if(xmlTextWriterWriteString(xml.get_writer(), (const xmlChar*) "type='text/xsl'") < 0)
|
|
Packit |
a4aae4 |
throw InternalErr(__FILE__, __LINE__, "Could not write Processing Instruction content.");
|
|
Packit |
a4aae4 |
if(xmlTextWriterWriteString(xml.get_writer(), (const xmlChar*) " ") < 0)
|
|
Packit |
a4aae4 |
throw InternalErr(__FILE__, __LINE__, "Could not write Processing Instruction content.");
|
|
Packit |
a4aae4 |
if(xmlTextWriterWriteString(xml.get_writer(), (const xmlChar*) href.c_str()) < 0)
|
|
Packit |
a4aae4 |
throw InternalErr(__FILE__, __LINE__, "Could not write Processing Instruction content.");
|
|
Packit |
a4aae4 |
if(xmlTextWriterEndPI(xml.get_writer()) < 0)
|
|
Packit |
a4aae4 |
throw InternalErr(__FILE__, __LINE__, "Could not Close XML Processing Instruction.");
|
|
Packit |
a4aae4 |
}
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
if (xmlTextWriterStartElementNS(xml.get_writer(),
|
|
Packit |
a4aae4 |
(const xmlChar*)"dap",
|
|
Packit |
a4aae4 |
(const xmlChar*) "AsynchronousResponse",
|
|
Packit |
a4aae4 |
(const xmlChar*) dapns.getDapNamespaceString(DAP_4_0).c_str()) < 0)
|
|
Packit |
a4aae4 |
throw InternalErr(__FILE__, __LINE__, "Could not write AsynchronousResponse element");
|
|
Packit |
a4aae4 |
if (xmlTextWriterWriteAttribute(xml.get_writer(), (const xmlChar*) "status", (const xmlChar *) "rejected") < 0)
|
|
Packit |
a4aae4 |
throw InternalErr(__FILE__, __LINE__, "Could not write attribute for 'status'");
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
// ------ reason Element and Attributes
|
|
Packit |
a4aae4 |
if (xmlTextWriterStartElement(xml.get_writer(), (const xmlChar*) "dap:reason") < 0)
|
|
Packit |
a4aae4 |
throw InternalErr(__FILE__, __LINE__, "Could not write reason element");
|
|
Packit |
a4aae4 |
if (xmlTextWriterWriteAttribute(xml.get_writer(), (const xmlChar*) "code", (const xmlChar*) getRejectReasonCodeString(code).c_str()) < 0)
|
|
Packit |
a4aae4 |
throw InternalErr(__FILE__, __LINE__, "Could not write attribute for 'code'");
|
|
Packit |
a4aae4 |
if (xmlTextWriterEndElement(xml.get_writer()) < 0)
|
|
Packit |
a4aae4 |
throw InternalErr(__FILE__, __LINE__, "Could not end reason element");
|
|
Packit |
a4aae4 |
// ------ reason Element and Attributes - END
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
// ------ description Element and Attributes
|
|
Packit |
a4aae4 |
if (xmlTextWriterWriteElement(xml.get_writer(), (const xmlChar*) "dap:description", (const xmlChar*) description.c_str()) < 0)
|
|
Packit |
a4aae4 |
throw InternalErr(__FILE__, __LINE__, "Could not write description element");
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
// ------ description Element and Attributes - END
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
if (xmlTextWriterEndElement(xml.get_writer()) < 0)
|
|
Packit |
a4aae4 |
throw InternalErr(__FILE__, __LINE__, "Could not end AsynchronousResponse element");
|
|
Packit |
a4aae4 |
// ------ AsynchronousResponse Element and Attributes - END
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
}
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
string D4AsyncUtil::getRejectReasonCodeString(RejectReasonCode code){
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
string codeStr;
|
|
Packit |
a4aae4 |
switch(code){
|
|
Packit |
a4aae4 |
case TIME:
|
|
Packit |
a4aae4 |
codeStr = "time";
|
|
Packit |
a4aae4 |
break;
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
case UNAVAILABLE:
|
|
Packit |
a4aae4 |
codeStr = "unavailable";
|
|
Packit |
a4aae4 |
break;
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
case PRIVILEGES:
|
|
Packit |
a4aae4 |
codeStr = "privileges";
|
|
Packit |
a4aae4 |
break;
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
case OTHER:
|
|
Packit |
a4aae4 |
codeStr = "other";
|
|
Packit |
a4aae4 |
break;
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
default:
|
|
Packit |
a4aae4 |
throw InternalErr(__FILE__, __LINE__, "D4AsyncUtil::getRejectReasonCodeString() - Unrecognized reject_reason_code.");
|
|
Packit |
a4aae4 |
break;
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
}
|
|
Packit |
a4aae4 |
return codeStr;
|
|
Packit |
a4aae4 |
}
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
// Unused paramters generate warnings, so I removed/commented them below. jhrg 3/12/14
|
|
Packit |
a4aae4 |
void D4AsyncUtil::writeD2AsyncRequired(XMLWriter &/*xml*/, long /*expectedDelay*/, long /*responseLifetime*/) {
|
|
Packit |
a4aae4 |
throw InternalErr(__FILE__, __LINE__, "DAP2 Doesn't handle Async.");
|
|
Packit |
a4aae4 |
}
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
void D4AsyncUtil::writeD2AsyncAccepted(XMLWriter &, long , long , string /*asyncResourceUrl*/) {
|
|
Packit |
a4aae4 |
throw InternalErr(__FILE__, __LINE__, "DAP2 Doesn't handle Async.");
|
|
Packit |
a4aae4 |
}
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
void D4AsyncUtil::writeD2AsyncPending(XMLWriter &) {
|
|
Packit |
a4aae4 |
throw InternalErr(__FILE__, __LINE__, "DAP2 Doesn't handle Async.");
|
|
Packit |
a4aae4 |
}
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
void D4AsyncUtil::writeD2AsyncResponseGone(XMLWriter &) {
|
|
Packit |
a4aae4 |
throw InternalErr(__FILE__, __LINE__, "DAP2 Doesn't handle Async.");
|
|
Packit |
a4aae4 |
}
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
void D4AsyncUtil::writeD2AsyncResponseRejected(XMLWriter &, RejectReasonCode /*code*/, string /*description*/) {
|
|
Packit |
a4aae4 |
throw InternalErr(__FILE__, __LINE__, "DAP2 Doesn't handle Async.");
|
|
Packit |
a4aae4 |
}
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
} /* namespace libdap */
|