BESDapTransmit.cc

Go to the documentation of this file.
00001 // BESDapTransmit.cc
00002 
00003 // This file is part of bes, A C++ back-end server implementation framework
00004 // for the OPeNDAP Data Access Protocol.
00005 
00006 // Copyright (c) 2004,2005 University Corporation for Atmospheric Research
00007 // Author: Patrick West <pwest@ucar.edu> and Jose Garcia <jgarcia@ucar.edu>
00008 //
00009 // This library is free software; you can redistribute it and/or
00010 // modify it under the terms of the GNU Lesser General Public
00011 // License as published by the Free Software Foundation; either
00012 // version 2.1 of the License, or (at your option) any later version.
00013 // 
00014 // This library is distributed in the hope that it will be useful,
00015 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00016 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00017 // Lesser General Public License for more details.
00018 // 
00019 // You should have received a copy of the GNU Lesser General Public
00020 // License along with this library; if not, write to the Free Software
00021 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00022 //
00023 // You can contact University Corporation for Atmospheric Research at
00024 // 3080 Center Green Drive, Boulder, CO 80301
00025 
00026 // (c) COPYRIGHT University Corporation for Atmospheric Research 2004-2005
00027 // Please read the full copyright statement in the file COPYRIGHT_UCAR.
00028 //
00029 // Authors:
00030 //      pwest       Patrick West <pwest@ucar.edu>
00031 //      jgarcia     Jose Garcia <jgarcia@ucar.edu>
00032 
00033 #include <sstream>
00034 
00035 using std::ostringstream;
00036 
00037 #include "BESDapTransmit.h"
00038 #include "DODSFilter.h"
00039 #include "BESContainer.h"
00040 #include "BESDataNames.h"
00041 #include "cgi_util.h"
00042 #include "BESDASResponse.h"
00043 #include "BESDDSResponse.h"
00044 #include "BESDataDDSResponse.h"
00045 #include "BESDapError.h"
00046 #include "BESInternalFatalError.h"
00047 #include "Error.h"
00048 
00049 void
00050 BESDapTransmit::send_basic_das(BESResponseObject * obj,
00051                                BESDataHandlerInterface & dhi)
00052 {
00053     BESDASResponse *bdas = dynamic_cast < BESDASResponse * >(obj);
00054     DAS *das = bdas->get_das();
00055     dhi.first_container();
00056 
00057     try
00058     {
00059         DODSFilter df ;
00060         df.set_dataset_name( dhi.container->get_real_name() ) ;
00061         df.send_das( dhi.get_output_stream(), *das, "", false ) ;
00062     }
00063     catch( InternalErr &e )
00064     {
00065         string err = "libdap error transmitting DAS: "
00066             + e.get_error_message() ;
00067         throw BESDapError( err, true, e.get_error_code(), __FILE__, __LINE__ ) ;
00068     }
00069     catch( Error &e )
00070     {
00071         string err = "libdap error transmitting DAS: "
00072             + e.get_error_message() ;
00073         throw BESDapError( err, false, e.get_error_code(), __FILE__, __LINE__ );
00074     }
00075     catch(...)
00076     {
00077         string s = "unknown error caught transmitting DAS" ;
00078         BESInternalFatalError ex( s, __FILE__, __LINE__ ) ;
00079         throw ex;
00080     }
00081 }
00082 
00083 void BESDapTransmit::send_http_das(BESResponseObject * obj,
00084                                    BESDataHandlerInterface & dhi)
00085 {
00086     set_mime_text(dhi.get_output_stream(), dods_das);
00087     BESDapTransmit::send_basic_das(obj, dhi);
00088 }
00089 
00090 void BESDapTransmit::send_basic_dds(BESResponseObject * obj,
00091                                     BESDataHandlerInterface & dhi)
00092 {
00093     BESDDSResponse *bdds = dynamic_cast < BESDDSResponse * >(obj);
00094     DDS *dds = bdds->get_dds();
00095     ConstraintEvaluator & ce = bdds->get_ce();
00096     dhi.first_container();
00097 
00098     try {
00099         DODSFilter df;
00100         df.set_dataset_name(dhi.container->get_real_name());
00101         df.set_ce(dhi.data[POST_CONSTRAINT]);
00102         df.send_dds(dhi.get_output_stream(), *dds, ce, true, "", false);
00103     }
00104     catch( InternalErr &e )
00105     {
00106         string err = "libdap error transmitting DDS: "
00107             + e.get_error_message() ;
00108         throw BESDapError( err, true, e.get_error_code(), __FILE__, __LINE__ ) ;
00109     }
00110     catch( Error &e )
00111     {
00112         string err = "libdap error transmitting DDS: "
00113             + e.get_error_message() ;
00114         throw BESDapError( err, false, e.get_error_code(), __FILE__, __LINE__ );
00115     }
00116     catch(...)
00117     {
00118         string s = "unknown error caught transmitting DDS" ;
00119         BESInternalFatalError ex( s, __FILE__, __LINE__ ) ;
00120         throw ex;
00121     }
00122 }
00123 
00124 void BESDapTransmit::send_http_dds(BESResponseObject * obj,
00125                                    BESDataHandlerInterface & dhi)
00126 {
00127     set_mime_text(dhi.get_output_stream(), dods_dds);
00128     BESDapTransmit::send_basic_dds(obj, dhi);
00129 }
00130 
00131 void BESDapTransmit::send_basic_data(BESResponseObject * obj,
00132                                      BESDataHandlerInterface & dhi)
00133 {
00134     BESDataDDSResponse *bdds = dynamic_cast < BESDataDDSResponse * >(obj);
00135     DataDDS *dds = bdds->get_dds();
00136     ConstraintEvaluator & ce = bdds->get_ce();
00137     dhi.first_container();
00138 
00139     try {
00140         DODSFilter df;
00141         df.set_dataset_name(dds->filename());
00142         df.set_ce(dhi.data[POST_CONSTRAINT]);
00143         df.send_data(*dds, ce, dhi.get_output_stream(), "", false);
00144     }
00145     catch( InternalErr &e )
00146     {
00147         string err = "libdap error transmitting DataDDS: "
00148             + e.get_error_message() ;
00149         throw BESDapError( err, true, e.get_error_code(), __FILE__, __LINE__ ) ;
00150     }
00151     catch( Error &e )
00152     {
00153         string err = "libdap error transmitting DataDDS: "
00154             + e.get_error_message() ;
00155         throw BESDapError( err, false, e.get_error_code(), __FILE__, __LINE__ );
00156     }
00157     catch(...)
00158     {
00159         string s = "unknown error caught transmitting DataDDS" ;
00160         BESInternalFatalError ex( s, __FILE__, __LINE__ ) ;
00161         throw ex;
00162     }
00163 }
00164 
00165 void BESDapTransmit::send_http_data(BESResponseObject * obj,
00166                                     BESDataHandlerInterface & dhi)
00167 {
00168     //set_mime_binary( dhi.get_output_stream(), dods_data ) ;
00169     BESDapTransmit::send_basic_data(obj, dhi);
00170 }
00171 
00172 void BESDapTransmit::send_basic_ddx(BESResponseObject * obj,
00173                                     BESDataHandlerInterface & dhi)
00174 {
00175     BESDDSResponse *bdds = dynamic_cast < BESDDSResponse * >(obj);
00176     DDS *dds = bdds->get_dds();
00177     ConstraintEvaluator & ce = bdds->get_ce();
00178     dhi.first_container();
00179 
00180     try {
00181         DODSFilter df;
00182         df.set_dataset_name(dhi.container->get_real_name());
00183         df.set_ce(dhi.data[POST_CONSTRAINT]);
00184         df.send_ddx(*dds, ce, dhi.get_output_stream(), false);
00185     }
00186     catch( InternalErr &e )
00187     {
00188         string err = "libdap error transmitting DDX: "
00189             + e.get_error_message() ;
00190         throw BESDapError( err, true, e.get_error_code(), __FILE__, __LINE__ ) ;
00191     }
00192     catch( Error &e )
00193     {
00194         string err = "libdap error transmitting DDX: "
00195             + e.get_error_message() ;
00196         throw BESDapError( err, false, e.get_error_code(), __FILE__, __LINE__ );
00197     }
00198     catch(...)
00199     {
00200         string s = "unknown error caught transmitting DDX" ;
00201         BESInternalFatalError ex( s, __FILE__, __LINE__ ) ;
00202         throw ex;
00203     }
00204 }
00205 
00206 void BESDapTransmit::send_http_ddx(BESResponseObject * obj,
00207                                    BESDataHandlerInterface & dhi)
00208 {
00209     set_mime_text(dhi.get_output_stream(), dods_dds);
00210     BESDapTransmit::send_basic_ddx(obj, dhi);
00211 }

Generated on Tue Mar 4 23:13:34 2008 for OPeNDAP Back End Server (BES) by  doxygen 1.5.1