bes Updated for version 3.21.1
The Backend Server (BES) is the lower two tiers of the Hyrax data server
BESDapResponseBuilder Class Reference

#include <BESDapResponseBuilder.h>

Collaboration diagram for BESDapResponseBuilder:
Collaboration graph

Public Member Functions

 BESDapResponseBuilder ()
 
virtual void dap4_process_ce_for_intern_data (libdap::DMR &dmr)
 Parse the DAP4 CE and throw if the request is too large.
 
virtual std::string get_async_accepted () const
 
virtual std::string get_btp_func_ce () const
 
virtual std::string get_ce () const
 Get the constraint expression.
 
virtual std::string get_dap4ce () const
 Get the DAP4 constraint expression.
 
virtual std::string get_dap4function () const
 Get the DAP4 server side function expression.
 
virtual std::string get_dataset_name () const
 Get the dataset name.
 
virtual std::string get_store_result () const
 
virtual libdap::DDS * intern_dap2_data (BESResponseObject *obj, BESDataHandlerInterface &dhi)
 
virtual libdap::DMR * intern_dap4_data (BESResponseObject *obj, BESDataHandlerInterface &dhi)
 
virtual libdap::DDS * process_dap2_dds (BESResponseObject *obj, BESDataHandlerInterface &dhi)
 Transmit data.
 
virtual libdap::DMR * process_dap4_dmr (BESResponseObject *obj, BESDataHandlerInterface &dhi)
 
virtual void send_dap2_data (BESDataHandlerInterface &dhi, libdap::DDS **dds, libdap::ConstraintEvaluator &eval, bool with_mime_headers=true)
 
virtual void send_dap2_data (std::ostream &data_stream, libdap::DDS **dds, libdap::ConstraintEvaluator &eval, bool with_mime_headers=true)
 
virtual void send_dap4_data (std::ostream &out, libdap::DMR &dmr, bool with_mime_headers=true)
 
virtual void send_das (std::ostream &out, libdap::DAS &das, bool with_mime_headers=true) const
 
virtual void send_das (std::ostream &out, libdap::DDS **dds, libdap::ConstraintEvaluator &eval, bool constrained=false, bool with_mime_headers=true)
 
virtual void send_dds (std::ostream &out, libdap::DDS **dds, libdap::ConstraintEvaluator &eval, bool constrained=false, bool with_mime_headers=true)
 Transmit a DDS.
 
virtual void send_ddx (std::ostream &out, libdap::DDS **dds, libdap::ConstraintEvaluator &eval, bool with_mime_headers=true)
 
virtual void send_dmr (std::ostream &out, libdap::DMR &dmr, bool with_mime_headers=true)
 
virtual void serialize_dap2_data_dds (std::ostream &out, libdap::DDS **dds, libdap::ConstraintEvaluator &eval, bool ce_eval=true)
 
virtual void serialize_dap4_data (std::ostream &out, libdap::DMR &dmr, bool with_mime_headers=true)
 
virtual void set_async_accepted (const std::string &_aa)
 
virtual void set_btp_func_ce (const std::string &_ce)
 
virtual void set_ce (std::string _ce)
 
virtual void set_dap4ce (const std::string &_ce)
 
virtual void set_dap4function (const std::string &_func)
 
virtual void set_dataset_name (const std::string &_dataset)
 Set the dataset pathname.
 
virtual void set_store_result (const std::string &_sr)
 
std::unique_ptr< libdap::DMR > setup_dap4_intern_data (BESResponseObject *obj, BESDataHandlerInterface &dhi)
 
virtual void split_ce (libdap::ConstraintEvaluator &eval, const std::string &expr="")
 
virtual bool store_dap4_result (std::ostream &out, libdap::DMR &dmr)
 

Protected Member Functions

void intern_dap4_data_grp (libdap::D4Group *grp)
 
void send_dap4_data_using_ce (std::ostream &out, libdap::DMR &dmr, bool with_mime_headersr)
 

Protected Attributes

std::string d_async_accepted
 Version string for the library's default protocol version.
 
std::string d_btp_func_ce
 DAP4 Server Side Function expression.
 
std::string d_dap2ce
 Name of the dataset/database.
 
std::string d_dap4ce
 DAP2 Constraint expression.
 
std::string d_dap4function
 DAP4 Constraint expression.
 
std::string d_dataset
 
std::string d_default_protocol
 The BTP functions, extracted from the CE.
 
std::string d_store_result
 

Friends

class ResponseBuilderTest
 

Detailed Description

This class is used to build responses for/by the BES. This class replaces DODSFilter (although DODSFilter is still included in the library, its use is deprecated). and it does not have a provision for command line arguments.

Author
jhrg 1/28/2011

Definition at line 63 of file BESDapResponseBuilder.h.

Constructor & Destructor Documentation

◆ BESDapResponseBuilder()

BESDapResponseBuilder::BESDapResponseBuilder ( )
inline

Make an empty instance. Use the set_*() methods to load with needed values. You must call at least set_dataset_name() or be requesting version information.

Definition at line 102 of file BESDapResponseBuilder.h.

◆ ~BESDapResponseBuilder()

BESDapResponseBuilder::~BESDapResponseBuilder ( )
virtual

Definition at line 134 of file BESDapResponseBuilder.cc.

Member Function Documentation

◆ dap4_process_ce_for_intern_data()

void BESDapResponseBuilder::dap4_process_ce_for_intern_data ( libdap::DMR & dmr)
virtual

Parse the DAP4 CE and throw if the request is too large.

The CE parsed is the one set in this BESDapREsponseBuilder instance and is parsed using the DMR passed to this method.

Parameters
dmrParse the CE using this DMR

Definition at line 1397 of file BESDapResponseBuilder.cc.

◆ get_async_accepted()

std::string BESDapResponseBuilder::get_async_accepted ( ) const
virtual

Definition at line 228 of file BESDapResponseBuilder.cc.

◆ get_btp_func_ce()

virtual std::string BESDapResponseBuilder::get_btp_func_ce ( ) const
inlinevirtual

Definition at line 128 of file BESDapResponseBuilder.h.

◆ get_ce()

string BESDapResponseBuilder::get_ce ( ) const
virtual

Get the constraint expression.

Return the entire DAP2 constraint expression in a string. This includes both the projection and selection clauses, but not the question mark.

Returns
A string object that contains the constraint expression.

Definition at line 150 of file BESDapResponseBuilder.cc.

◆ get_dap4ce()

string BESDapResponseBuilder::get_dap4ce ( ) const
virtual

Get the DAP4 constraint expression.

Return the entire DAP4 constraint expression in a string.

Returns
A string object that contains the constraint expression.

Definition at line 173 of file BESDapResponseBuilder.cc.

◆ get_dap4function()

string BESDapResponseBuilder::get_dap4function ( ) const
virtual

Get the DAP4 server side function expression.

Return the entire DAP4 server side function expression in a string.

Returns
A string object that contains the constraint expression.

Definition at line 196 of file BESDapResponseBuilder.cc.

◆ get_dataset_name()

string BESDapResponseBuilder::get_dataset_name ( ) const
virtual

Get the dataset name.

The `‘dataset name’' is the filename or other string that the filter program will use to access the data. In some cases this will indicate a disk file containing the data. In others, it may represent a database query or some other exotic data access method.

Returns
A string object that contains the name of the dataset.

Definition at line 247 of file BESDapResponseBuilder.cc.

◆ get_store_result()

std::string BESDapResponseBuilder::get_store_result ( ) const
virtual

Definition at line 217 of file BESDapResponseBuilder.cc.

◆ intern_dap2_data()

libdap::DDS * BESDapResponseBuilder::intern_dap2_data ( BESResponseObject * obj,
BESDataHandlerInterface & dhi )
virtual

Read data into the ResponseObject (a DAP2 DDS). Instead of serializing the data as with send_dap2_data(), this uses the variables' intern_data() method to load the variables so that a transmitter other than libdap::BaseType::serialize() can be used (e.g., AsciiTransmitter).

Note
Other versions of the methods here (e.g., send_dap2_data()) optionally print MIME headers because this code was used in the past to build HTTP responses. That's only the case with the CEDAR server and I'm not sure we need to maintain that code. TBD. This method will not be used by CEDAR, so I've not included the 'print_mime_headers' bool.
Parameters
objThe BESResponseObject. Holds the DDS for this request.
dhiThe BESDataHandlerInterface. Holds many parameters for this request.
Returns
The DDS* is returned where each variable marked to be sent is loaded with data (as per the current constraint expression).

Definition at line 881 of file BESDapResponseBuilder.cc.

◆ intern_dap4_data()

libdap::DMR * BESDapResponseBuilder::intern_dap4_data ( BESResponseObject * obj,
BESDataHandlerInterface & dhi )
virtual

The description is mostly cloned from the function intern_dap2_data(). Read data into the ResponseObject (a DAP4 DMR). Instead of serializing the data as with send_dap4_data(), this uses the variables' intern_dap4_data() method to load the variables so that a transmitter other than libdap::BaseType::serialize() can be used (e.g., AsciiTransmitter).

Note
Other versions of the methods here (e.g., send_dap4_data()) optionally print MIME headers because this code was used in the past to build HTTP responses. That's only the case with the CEDAR server and I'm not sure we need to maintain that code. TBD. This method will not be used by CEDAR, so I've not included the 'print_mime_headers' bool.
Parameters
objThe BESResponseObject. Holds the DMR for this request.
dhiThe BESDataHandlerInterface. Holds many parameters for this request.
Returns
The DMR* is returned where each variable marked to be sent is loaded with data (as per the current constraint expression).

Definition at line 1607 of file BESDapResponseBuilder.cc.

◆ intern_dap4_data_grp()

void BESDapResponseBuilder::intern_dap4_data_grp ( libdap::D4Group * grp)
protected

Definition at line 1690 of file BESDapResponseBuilder.cc.

◆ process_dap2_dds()

libdap::DDS * BESDapResponseBuilder::process_dap2_dds ( BESResponseObject * obj,
BESDataHandlerInterface & dhi )
virtual

Transmit data.

Send the data in the DDS object back to the client program. The data is encoded using a Marshaller, and enclosed in a MIME document which is all sent to data_stream.

Note
This is the DAP2 data response.
Parameters
ddsA DDS object containing the data to be sent.
evalA reference to the ConstraintEvaluator to use.
data_streamWrite the response to this stream.
anc_locationA directory to search for ancillary files (in addition to the CWD). This is used in a call to get_data_last_modified_time().
with_mime_headersIf true, include the MIME headers in the response. Defaults to true.
Returns
void

Process a DDS (i.e., apply a constraint) for a non-DAP transmitter.

This is a companion method to the intern_dap2_data() method. Unlike that, this simply evaluates the CE against the DDS, including any functions.

Note
If there is no constraint, there's no need to call this.
Parameters
objResponseObject wrapper
dhiVarious parameters to the handler
Returns
The DDS* after the CE, including functions, has been evaluated. The returned pointer is managed by the ResponseObject

Definition at line 811 of file BESDapResponseBuilder.cc.

◆ process_dap4_dmr()

libdap::DMR * BESDapResponseBuilder::process_dap4_dmr ( BESResponseObject * obj,
BESDataHandlerInterface & dhi )
virtual

Definition at line 1620 of file BESDapResponseBuilder.cc.

◆ send_dap4_data()

void BESDapResponseBuilder::send_dap4_data ( std::ostream & out,
libdap::DMR & dmr,
bool with_mime_headers = true )
virtual

Definition at line 1420 of file BESDapResponseBuilder.cc.

◆ send_dap4_data_using_ce()

void BESDapResponseBuilder::send_dap4_data_using_ce ( std::ostream & out,
libdap::DMR & dmr,
bool with_mime_headersr )
protected

Definition at line 1346 of file BESDapResponseBuilder.cc.

◆ send_dds()

void BESDapResponseBuilder::send_dds ( std::ostream & out,
libdap::DDS ** dds,
libdap::ConstraintEvaluator & eval,
bool constrained = false,
bool with_mime_headers = true )
virtual

Transmit a DDS.

This function formats and prints an ASCII representation of a DDS on stdout. Either an entire DDS or a constrained DDS may be sent. This function looks in the local cache and uses a DDS object there if it's valid. Otherwise, if the request CE contains server functions that build data for the response, the resulting DDS will be cached.

Parameters
outThe output stream to which the DAS is to be sent.
ddsThe DDS to send back to a client.
evalA reference to the ConstraintEvaluator to use.
constrainedIf this argument is true, evaluate the current constraint expression and send the ‘constrained DDS’ back to the client.
constrainedIf true, apply the constraint bound to this instance of ResponseBuilder
with_mime_headersIf true (default) send MIME headers.
Returns
void
See also
DDS

Definition at line 495 of file BESDapResponseBuilder.cc.

◆ send_ddx()

void BESDapResponseBuilder::send_ddx ( std::ostream & out,
libdap::DDS ** dds,
libdap::ConstraintEvaluator & eval,
bool with_mime_headers = true )
virtual

Send the DDX response. The DDX never contains data, instead it holds a reference to a Blob response which is used to get the data values. The DDS and DAS objects are built using code that already exists in the servers.

Note
This is the DAP3.x metadata response; it is supported by most DAP2 servers as well. The DAP4 DDX will contain types not present in DAP2 or 3.x
Parameters
ddsThe dataset's DDS with attributes in the variables.
evalA reference to the ConstraintEvaluator to use.
outDestination
with_mime_headersIf true, include the MIME headers in the response. Defaults to true.

Definition at line 1226 of file BESDapResponseBuilder.cc.

◆ send_dmr()

void BESDapResponseBuilder::send_dmr ( std::ostream & out,
libdap::DMR & dmr,
bool with_mime_headers = true )
virtual

Definition at line 1302 of file BESDapResponseBuilder.cc.

◆ serialize_dap2_data_dds()

void BESDapResponseBuilder::serialize_dap2_data_dds ( std::ostream & out,
libdap::DDS ** dds,
libdap::ConstraintEvaluator & eval,
bool ce_eval = true )
virtual

Build/return the BLOB part of the DAP2 data response.

Definition at line 690 of file BESDapResponseBuilder.cc.

◆ serialize_dap4_data()

void BESDapResponseBuilder::serialize_dap4_data ( std::ostream & out,
libdap::DMR & dmr,
bool with_mime_headers = true )
virtual

Serialize the DAP4 data response to the passed stream

Definition at line 1459 of file BESDapResponseBuilder.cc.

◆ set_async_accepted()

void BESDapResponseBuilder::set_async_accepted ( const std::string & _aa)
virtual

Definition at line 233 of file BESDapResponseBuilder.cc.

◆ set_btp_func_ce()

virtual void BESDapResponseBuilder::set_btp_func_ce ( const std::string & _ce)
inlinevirtual

Definition at line 132 of file BESDapResponseBuilder.h.

◆ set_ce()

void BESDapResponseBuilder::set_ce ( std::string _ce)
virtual

Set the DAP2 constraint expression. This will filter the CE text removing any 'WWW' escape characters except space. Spaces are left in the CE because the CE parser uses whitespace to delimit tokens while some datasets have identifiers that contain spaces. It's possible to use double quotes around identifiers too, but most client software doesn't know about that.

@brief Set the CE

Parameters
_ceThe constraint expression

Definition at line 165 of file BESDapResponseBuilder.cc.

◆ set_dap4ce()

void BESDapResponseBuilder::set_dap4ce ( const std::string & _ce)
virtual

Set the DAP4 constraint expression. This will filter the DAP4 CE text removing any 'WWW' escape characters except space. Spaces are left in the CE because the CE parser uses whitespace to delimit tokens while some datasets have identifiers that contain spaces. It's possible to use double quotes around identifiers too, but most client software doesn't know about that.

@brief Set the CE

Parameters
_ceThe constraint expression

Definition at line 188 of file BESDapResponseBuilder.cc.

◆ set_dap4function()

void BESDapResponseBuilder::set_dap4function ( const std::string & _func)
virtual

Set the DAP4 Server Side Function expression. This will filter the function expression text removing any 'WWW' escape characters except space. Spaces are left in the CE because the CE parser uses whitespace to delimit tokens while some datasets have identifiers that contain spaces. It's possible to use double quotes around identifiers too, but most client software doesn't know about that.

@brief Set the CE

Parameters
_ceThe constraint expression

Definition at line 212 of file BESDapResponseBuilder.cc.

◆ set_dataset_name()

void BESDapResponseBuilder::set_dataset_name ( const std::string & _dataset)
virtual

Set the dataset pathname.

Set the dataset name, which is a string used to access the dataset on the machine running the server. That is, this is typically a pathname to a data file, although it doesn't have to be. This is not echoed in error messages (because that would reveal server storage patterns that data providers might want to hide). All WWW-style escapes are replaced except for spaces.

Parameters
dsThe pathname (or equivalent) to the dataset.

Definition at line 262 of file BESDapResponseBuilder.cc.

◆ set_store_result()

void BESDapResponseBuilder::set_store_result ( const std::string & _sr)
virtual

Definition at line 222 of file BESDapResponseBuilder.cc.

◆ setup_dap4_intern_data()

unique_ptr< DMR > BESDapResponseBuilder::setup_dap4_intern_data ( BESResponseObject * obj,
BESDataHandlerInterface & dhi )

Definition at line 1631 of file BESDapResponseBuilder.cc.

◆ split_ce()

void BESDapResponseBuilder::split_ce ( libdap::ConstraintEvaluator & eval,
const std::string & expr = "" )
virtual

Split the CE so that the server functions that compute new values are separated into their own string and can be evaluated separately from the rest of the CE (which can contain simple and slicing projection as well as other types of function calls).

Definition at line 311 of file BESDapResponseBuilder.cc.

◆ store_dap4_result()

bool BESDapResponseBuilder::store_dap4_result ( std::ostream & out,
libdap::DMR & dmr )
virtual

Should this DAP4 result be stored and the client sent an Asynchronous response? This code looks at the 'store_result' property to determine if the response should be asynchronous and then, if so, churns through the options, sorting out if the client sent the correct information indicating it knows how to process them. If the 'store_result' property is not set, then this method simply returns false, indicating that the response should be returned using the normal synchronous response pattern.

Parameters
outWrite information about the response here
dmrThis DMR will be serialized to build the response, at some point in time
Returns
True if the response will be Asynchronous, false if the DMR should be sent right away.

OOPS. Looks like the BES is not configured to use a Stored Result Cache. Looks like need to reject the request and move on.

Client accepts async responses so, woot! lets store this thing and tell them where to find it.

Client didn't indicate a willingness to accept an async response So - we tell them that async is required.

Definition at line 1511 of file BESDapResponseBuilder.cc.

Friends And Related Symbol Documentation

◆ ResponseBuilderTest

friend class ResponseBuilderTest
friend

Definition at line 65 of file BESDapResponseBuilder.h.

Member Data Documentation

◆ d_async_accepted

std::string BESDapResponseBuilder::d_async_accepted
protected

Version string for the library's default protocol version.

Time, if any, that the client will wait for an async response. An empty string (length=0) means the client didn't supply an async parameter

Definition at line 79 of file BESDapResponseBuilder.h.

◆ d_btp_func_ce

std::string BESDapResponseBuilder::d_btp_func_ce
protected

DAP4 Server Side Function expression.

Definition at line 72 of file BESDapResponseBuilder.h.

◆ d_dap2ce

std::string BESDapResponseBuilder::d_dap2ce
protected

Name of the dataset/database.

Definition at line 69 of file BESDapResponseBuilder.h.

◆ d_dap4ce

std::string BESDapResponseBuilder::d_dap4ce
protected

DAP2 Constraint expression.

Definition at line 70 of file BESDapResponseBuilder.h.

◆ d_dap4function

std::string BESDapResponseBuilder::d_dap4function
protected

DAP4 Constraint expression.

Definition at line 71 of file BESDapResponseBuilder.h.

◆ d_dataset

std::string BESDapResponseBuilder::d_dataset
protected

Definition at line 68 of file BESDapResponseBuilder.h.

◆ d_default_protocol

std::string BESDapResponseBuilder::d_default_protocol
protected

The BTP functions, extracted from the CE.

Definition at line 73 of file BESDapResponseBuilder.h.

◆ d_store_result

std::string BESDapResponseBuilder::d_store_result
protected

If set (i.e. non-null) then the client has asked for the result to be stored for later retrieval. The value is the service URL used to construct the stored result access URL to be returned to the client. An empty string (length=0) means the client didn't supply a store_result async parameter

Definition at line 87 of file BESDapResponseBuilder.h.


The documentation for this class was generated from the following files: