00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033 #include "BESXMLGetDataDDXCommand.h"
00034 #include "BESDefinitionStorageList.h"
00035 #include "BESDefinitionStorage.h"
00036 #include "BESDefine.h"
00037 #include "BESDapNames.h"
00038 #include "BESResponseNames.h"
00039 #include "BESXMLUtils.h"
00040 #include "BESUtil.h"
00041 #include "BESSyntaxUserError.h"
00042 #include "BESDebug.h"
00043
00044 BESXMLGetDataDDXCommand::BESXMLGetDataDDXCommand( const BESDataHandlerInterface &base_dhi )
00045 : BESXMLGetCommand( base_dhi )
00046 {
00047 }
00048
00055 void
00056 BESXMLGetDataDDXCommand::parse_request( xmlNode *node )
00057 {
00058 string name ;
00059 string value ;
00060 map<string, string> props ;
00061 BESXMLUtils::GetNodeInfo( node, name, value, props ) ;
00062
00063 if( name != GET_RESPONSE )
00064 {
00065 string err = "The specified command " + name
00066 + " is not a get command" ;
00067 throw BESSyntaxUserError( err, __FILE__, __LINE__ ) ;
00068 }
00069
00070 string type = props["type"] ;
00071 if( type.empty() || type != DATADDX_SERVICE )
00072 {
00073 string err = name + " command: data product must be "
00074 + DATADDX_SERVICE ;
00075 throw BESSyntaxUserError( err, __FILE__, __LINE__ ) ;
00076 }
00077
00078 parse_basic_get( node, name, type, value, props ) ;
00079
00080
00081 map<string,string> cprops ;
00082 string cname ;
00083 string cval ;
00084 int elems = 0 ;
00085 xmlNode *cnode = BESXMLUtils::GetFirstChild( node, cname, cval, cprops ) ;
00086 while( cnode && (elems < 2) )
00087 {
00088 if( cname == "contentStartId" )
00089 {
00090 if( !_contentStartId.empty() )
00091 {
00092 string err = name
00093 + " command: contentStartId has multiple values" ;
00094 throw BESSyntaxUserError( err, __FILE__, __LINE__ ) ;
00095 }
00096 _contentStartId = cval ;
00097 _str_cmd += " contentStartId " + _contentStartId ;
00098 elems++ ;
00099 }
00100 if( cname == "mimeBoundary" )
00101 {
00102 if( !_mimeBoundary.empty() )
00103 {
00104 string err = name
00105 + " command: mimeBoundary has multiple values" ;
00106 throw BESSyntaxUserError( err, __FILE__, __LINE__ ) ;
00107 }
00108 _mimeBoundary = cval ;
00109 _str_cmd += " mimeBoundary " + _mimeBoundary ;
00110 elems++ ;
00111 }
00112 cprops.clear() ;
00113 cnode = BESXMLUtils::GetNextChild( cnode, cname, cval, cprops ) ;
00114 }
00115 if( _contentStartId.empty() )
00116 {
00117 string err = name + " command: contentStartId not specified" ;
00118 throw BESSyntaxUserError( err, __FILE__, __LINE__ ) ;
00119 }
00120 if( _mimeBoundary.empty() )
00121 {
00122 string err = name + " command: mimeBoundary not specified" ;
00123 throw BESSyntaxUserError( err, __FILE__, __LINE__ ) ;
00124 }
00125
00126
00127
00128 BESXMLCommand::set_response() ;
00129 }
00130
00136 void
00137 BESXMLGetDataDDXCommand::prep_request()
00138 {
00139 BESXMLGetCommand::prep_request() ;
00140 _dhi.data[DATADDX_STARTID] = _contentStartId ;
00141 _dhi.data[DATADDX_BOUNDARY] = _mimeBoundary ;
00142 }
00143
00150 void
00151 BESXMLGetDataDDXCommand::dump( ostream &strm ) const
00152 {
00153 strm << BESIndent::LMarg << "BESXMLGetDataDDXCommand::dump - ("
00154 << (void *)this << ")" << endl ;
00155 BESIndent::Indent() ;
00156 BESXMLCommand::dump( strm ) ;
00157 BESIndent::UnIndent() ;
00158 }
00159
00160 BESXMLCommand *
00161 BESXMLGetDataDDXCommand::CommandBuilder( const BESDataHandlerInterface &base_dhi )
00162 {
00163 return new BESXMLGetDataDDXCommand( base_dhi ) ;
00164 }
00165