OPeNDAP Hyrax Back End Server (BES)  Updated for version 3.8.3
BESWWWTransmit.cc
Go to the documentation of this file.
1 // BESWWWTransmit.cc
2 
3 // This file is part of bes, A C++ back-end server implementation framework
4 // for the OPeNDAP Data Access Protocol.
5 
6 // Copyright (c) 2004,2005 University Corporation for Atmospheric Research
7 // Author: Patrick West <pwest@ucar.edu> and Jose Garcia <jgarcia@ucar.edu>
8 //
9 // This library is free software; you can redistribute it and/or
10 // modify it under the terms of the GNU Lesser General Public
11 // License as published by the Free Software Foundation; either
12 // version 2.1 of the License, or (at your option) any later version.
13 //
14 // This library is distributed in the hope that it will be useful,
15 // but WITHOUT ANY WARRANTY; without even the implied warranty of
16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 // Lesser General Public License for more details.
18 //
19 // You should have received a copy of the GNU Lesser General Public
20 // License along with this library; if not, write to the Free Software
21 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22 //
23 // You can contact University Corporation for Atmospheric Research at
24 // 3080 Center Green Drive, Boulder, CO 80301
25 
26 // (c) COPYRIGHT University Corporation for Atmospheric Research 2004-2005
27 // Please read the full copyright statement in the file COPYRIGHT_UCAR.
28 //
29 // Authors:
30 // pwest Patrick West <pwest@ucar.edu>
31 // jgarcia Jose Garcia <jgarcia@ucar.edu>
32 
33 #include <BESDapTransmit.h>
34 #if 0
35 #include <DODSFilter.h>
36 #endif
37 #include <BESWWWTransmit.h>
38 // #include <DODSFilter.h>
39 #include <BESContainer.h>
40 #include <BESDapNames.h>
41 #include <BESWWWNames.h>
42 #include <mime_util.h>
43 #include <BESWWW.h>
44 #include <util.h>
45 #include <InternalErr.h>
46 #include <BESDapError.h>
47 #include <BESInternalFatalError.h>
48 #include <BESServiceRegistry.h>
49 
50 #include <BESDebug.h>
51 
52 #include "get_html_form.h"
53 
54 using namespace dap_html_form;
55 
57 {
58  dhi.first_container();
59  try {
60  BESDEBUG("www", "converting dds to www dds" << endl);
61 
62  DDS *dds = dynamic_cast<BESWWW*>(obj)->get_dds()->get_dds();
63  DDS *wwwdds = dds_to_www_dds(dds);
64 #if 0
65  DAS *das = dynamic_cast<BESWWW*>(obj)->get_das()->get_das();
66  wwwdds->transfer_attributes( das );
67 #endif
68  BESDEBUG("www", "writing form" << endl);
69 
70  string url = dhi.data[WWW_URL];
71 
72  // Look for the netcdf format in the dap service. If present
73  // then have the interface make a button for it.
75  bool netcdf3_file_response = registry->service_available(OPENDAP_SERVICE, DATA_SERVICE, "netcdf");
76  // TODO change this so that it actually tests for the netcdf4 capability. I'm
77  // not sure how to do that, so just assume the handler has it. jhrg 9/23/13
78  bool netcdf4_file_response = registry->service_available(OPENDAP_SERVICE, DATA_SERVICE, "netcdf");
79  write_html_form_interface(dhi.get_output_stream(), wwwdds, url, false /*send mime headers*/,
80  netcdf3_file_response, netcdf4_file_response);
81 
82  BESDEBUG("www", "done transmitting form" << endl);
83 
84  delete wwwdds;
85  }
86  catch (InternalErr &e) {
87  string err = "Failed to write html form: " + e.get_error_message();
88  throw BESDapError(err, true, e.get_error_code(), __FILE__, __LINE__);
89  }
90  catch (Error &e) {
91  string err = "Failed to write html form: " + e.get_error_message();
92  throw BESDapError(err, false, e.get_error_code(), __FILE__, __LINE__);
93  }
94  catch (...) {
95  string err = "Failed to write html form: Unknown exception caught";
96  throw BESInternalFatalError(err, __FILE__, __LINE__);
97  }
98 }
99 
101 {
102  set_mime_text(dhi.get_output_stream(), unknown_type, x_plain);
104 }
105 
#define DATA_SERVICE
Definition: BESDapNames.h:71
static void send_http_form(BESResponseObject *obj, BESDataHandlerInterface &dhi)
exception thrown if an internal error is found and is fatal to the BES
#define OPENDAP_SERVICE
macros representing the default response objects handled
Definition: BESDapNames.h:52
static void send_basic_form(BESResponseObject *obj, BESDataHandlerInterface &dhi)
The service registry allows modules to register services with the BES that they provide.
void write_html_form_interface(ostream &strm, DDS *dds, const string &url, bool html_header, bool netcdf3_file_response, bool netcdf4_file_response, const string &admin_name, const string &help_location)
Using the stuff in WWWOutput and the hacked (specialized) print_val() methods in the WWW* classes...
BESDDSResponse * get_dds()
Definition: BESWWW.h:76
DDS * dds_to_www_dds(DDS *dds)
Given a DDS filled with variables that are one specialization of BaseType, build a second DDS which c...
static BESServiceRegistry * TheRegistry()
error object created from libdap error objects and can handle those errors
Definition: BESDapError.h:51
container for a DAS and DDS needed to write out the usage information for a dataset.
Definition: BESWWW.h:51
Structure storing information used by the BES to handle the request.
map< string, string > data
the map of string data that will be required for the current request.
void first_container()
set the container pointer to the first container in the containers list
#define BESDEBUG(x, y)
macro used to send debug information to the debug stream
Definition: BESDebug.h:64
virtual bool service_available(const string &name, const string &cmd="", const string &format="")
Determines if a service and, optionally, a command and a return format, is available.
#define WWW_URL
Definition: BESWWWNames.h:49
Abstract base class representing a specific set of information in response to a request to the BES...