OPeNDAP Hyrax Back End Server (BES)  Updated for version 3.8.3
BESUsageTransmit.cc
Go to the documentation of this file.
1 // BESUsageTransmit.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 "BESUsageTransmit.h"
38 // #include "DODSFilter.h"
39 #include "BESContainer.h"
40 #include "BESDataNames.h"
41 #include "mime_util.h"
42 #include "BESUsage.h"
43 #include "usage.h"
44 //#include "util.h"
45 #include "InternalErr.h"
46 #include "BESDapError.h"
47 #include "BESInternalFatalError.h"
48 
49 #include "BESDebug.h"
50 
51 using namespace dap_usage;
52 
53 void
56 {
57  BESUsage *usage = dynamic_cast < BESUsage * >(obj);
58  DAS *das = usage->get_das()->get_das();
59  DDS *dds = usage->get_dds()->get_dds();
60 
61  dhi.first_container();
62 
63  string dataset_name = dhi.container->access();
64 
65  try {
66  BESDEBUG( "usage", "writing usage/info" << endl ) ;
67 
68  write_usage_response(dhi.get_output_stream(), *dds, *das, dataset_name, "", false);
69 
70  BESDEBUG( "usage", "done transmitting usage/info" << endl ) ;
71  }
72  catch( InternalErr &e )
73  {
74  string err = "Failed to write usage: " + e.get_error_message() ;
75  throw BESDapError(err, true, e.get_error_code(), __FILE__, __LINE__ );
76  }
77  catch( Error &e )
78  {
79  string err = "Failed to write usage: " + e.get_error_message() ;
80  throw BESDapError(err, false, e.get_error_code(), __FILE__, __LINE__ ) ;
81  }
82  catch(...)
83  {
84  string err = "Failed to write usage: Unknown exception caught";
85  throw BESInternalFatalError( err, __FILE__, __LINE__ ) ;
86  }
87 }
88 
89 void
92 {
93  // TODO: Is this used?
94  set_mime_html( dhi.get_output_stream(), unknown_type, x_plain ) ;
96 }
97 
void write_usage_response(ostream &strm, DDS &dds, DAS &das, const string &dataset_name, const string &server_name, bool httpheader)
Build an HTML page that summarizes the information held int eh DDS/DAS.
Definition: usage.cc:436
exception thrown if an internal error is found and is fatal to the BES
BESDASResponse * get_das()
Definition: BESUsage.h:67
virtual string access()=0
returns the true name of this container
BESDDSResponse * get_dds()
Definition: BESUsage.h:68
static void send_http_usage(BESResponseObject *obj, BESDataHandlerInterface &dhi)
error object created from libdap error objects and can handle those errors
Definition: BESDapError.h:51
Structure storing information used by the BES to handle the request.
container for a DAS and DDS needed to write out the usage information for a dataset.
Definition: BESUsage.h:51
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
static void send_basic_usage(BESResponseObject *obj, BESDataHandlerInterface &dhi)
Abstract base class representing a specific set of information in response to a request to the BES...
BESContainer * container
pointer to current container in this interface