bes  Updated for version 3.20.6
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 "../usage/BESUsageTransmit.h"
34 
35 #include "../usage/BESUsage.h"
36 #include "../usage/usage.h"
37 #include "BESDapTransmit.h"
38 #include "BESContainer.h"
39 #include "BESDataNames.h"
40 #include "mime_util.h"
41 #include "InternalErr.h"
42 #include "BESDapError.h"
43 #include "BESInternalFatalError.h"
44 
45 #include "BESDebug.h"
46 
47 using std::endl;
48 using namespace dap_usage;
49 using namespace libdap;
50 
51 void
52  BESUsageTransmit::send_basic_usage(BESResponseObject * obj,
54 {
55  BESUsage &usage = dynamic_cast < BESUsage & >(*obj);
56  DAS *das = usage.get_das()->get_das();
57  DDS *dds = usage.get_dds()->get_dds();
58 
59  dhi.first_container();
60 
61  string dataset_name = dhi.container->access();
62 
63  try {
64  BESDEBUG( "usage", "writing usage/info" << endl ) ;
65 
66  write_usage_response(dhi.get_output_stream(), *dds, *das, dataset_name, "", false);
67 
68  BESDEBUG( "usage", "done transmitting usage/info" << endl ) ;
69  }
70  catch( InternalErr &e )
71  {
72  string err = "Failed to write usage: " + e.get_error_message() ;
73  throw BESDapError(err, true, e.get_error_code(), __FILE__, __LINE__ );
74  }
75  catch( Error &e )
76  {
77  string err = "Failed to write usage: " + e.get_error_message() ;
78  throw BESDapError(err, false, e.get_error_code(), __FILE__, __LINE__ ) ;
79  }
80  catch (BESError &e) {
81  throw;
82  }
83  catch(...)
84  {
85  string err = "Failed to write usage: Unknown exception caught";
86  throw BESInternalFatalError( err, __FILE__, __LINE__ ) ;
87  }
88 }
89 
90 void
91 BESUsageTransmit::send_http_usage( BESResponseObject *obj,
93 {
94  // TODO: Is this used?
95  set_mime_html( dhi.get_output_stream(), unknown_type, x_plain ) ;
96  BESUsageTransmit::send_basic_usage( obj, dhi ) ;
97 }
98 
BESDataHandlerInterface::container
BESContainer * container
pointer to current container in this interface
Definition: BESDataHandlerInterface.h:75
BESInternalFatalError
exception thrown if an internal error is found and is fatal to the BES
Definition: BESInternalFatalError.h:43
BESUsage
container for a DAS and DDS needed to write out the usage information for a dataset.
Definition: BESUsage.h:51
libdap
Definition: BESDapFunctionResponseCache.h:35
BESContainer::access
virtual std::string access()=0
returns the true name of this container
Error
BESDataHandlerInterface::first_container
void first_container()
set the container pointer to the first container in the containers list
Definition: BESDataHandlerInterface.h:135
BESDapError
error object created from libdap error objects and can handle those errors
Definition: BESDapError.h:59
BESDataHandlerInterface
Structure storing information used by the BES to handle the request.
Definition: BESDataHandlerInterface.h:56
BESError
Abstract exception class for the BES with basic string message.
Definition: BESError.h:58
BESResponseObject
Abstract base class representing a specific set of information in response to a request to the BES.
Definition: BESResponseObject.h:45