bes  Updated for version 3.20.10
BESUsageTransmit.cc
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 "config.h"
34 
35 #include "../usage/BESUsageTransmit.h"
36 
37 #include "../usage/BESUsage.h"
38 #include "../usage/usage.h"
39 #include "BESDapTransmit.h"
40 #include "BESContainer.h"
41 #include "BESDataNames.h"
42 #include <libdap/mime_util.h>
43 #include <libdap/InternalErr.h>
44 #include "BESDapError.h"
45 #include "BESInternalFatalError.h"
46 
47 #include "BESDebug.h"
48 
49 using std::endl;
50 using namespace dap_usage;
51 using namespace libdap;
52 
53 void
54  BESUsageTransmit::send_basic_usage(BESResponseObject * obj,
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 (BESError &e) {
83  throw;
84  }
85  catch(...)
86  {
87  string err = "Failed to write usage: Unknown exception caught";
88  throw BESInternalFatalError( err, __FILE__, __LINE__ ) ;
89  }
90 }
91 
92 void
93 BESUsageTransmit::send_http_usage( BESResponseObject *obj,
95 {
96  // TODO: Is this used?
97  set_mime_html( dhi.get_output_stream(), unknown_type, x_plain ) ;
98  BESUsageTransmit::send_basic_usage( obj, dhi ) ;
99 }
100 
virtual std::string access()=0
returns the true name of this container
error object created from libdap error objects and can handle those errors
Definition: BESDapError.h:59
Structure storing information used by the BES to handle the request.
void first_container()
set the container pointer to the first container in the containers list
BESContainer * container
pointer to current container in this interface
Abstract exception class for the BES with basic string message.
Definition: BESError.h:58
exception thrown if an internal error is found and is fatal to the BES
Abstract base class representing a specific set of information in response to a request to the BES.
container for a DAS and DDS needed to write out the usage information for a dataset.
Definition: BESUsage.h:52