34#include "TheBESKeys.h"
38#include "BESInternalFatalError.h"
40#include "ServerAdministrator.h"
49#define prolog std::string("ServerAdministrator::").append(__func__).append("() - ")
64#define EMAIL_KEY "email"
65#define EMAIL_DEFAULT "support@opendap.org"
67#define ORGANIZATION_KEY "organization"
68#define ORGANIZATION_DEFAULT "OPeNDAP Inc."
70#define STREET_KEY "street"
71#define STREET_DEFAULT "165 NW Dean Knauss Dr."
73#define CITY_KEY "city"
74#define CITY_DEFAULT "Narragansett"
76#define REGION_KEY "region"
77#define STATE_KEY "state"
78#define REGION_DEFAULT "RI"
80#define POSTAL_CODE_KEY "postalCode"
81#define POSTAL_CODE_DEFAULT "02882"
83#define COUNTRY_KEY "country"
84#define COUNTRY_DEFAULT "US"
86#define TELEPHONE_KEY "telephone"
87#define TELEPHONE_DEFAULT "+1.401.575.4835"
89#define WEBSITE_KEY "website"
90#define WEBSITE_DEFAULT "http://www.opendap.org"
106 bool bad_flag =
false;
108 d_organization = get(ORGANIZATION_KEY);
109 if(d_organization.empty()){
110 BESDEBUG(MODULE,__func__ <<
"() - The configuration entry for the " <<
111 SERVER_ADMINISTRATOR_KEY <<
"[" << ORGANIZATION_KEY <<
"] was missing." << endl);
115 d_street = get(STREET_KEY);
116 if(d_street.empty()){
117 BESDEBUG(MODULE,__func__ <<
"() - The configuration entry for the " <<
118 SERVER_ADMINISTRATOR_KEY <<
"[" << STREET_KEY <<
"] was missing." << endl);
122 d_city = get(CITY_KEY);
124 BESDEBUG(MODULE,__func__ <<
"() - The configuration entry for the " <<
125 SERVER_ADMINISTRATOR_KEY <<
"[" << CITY_KEY <<
"] was missing." << endl);
129 d_region = get(REGION_KEY);
130 if(d_region.empty()){
131 BESDEBUG(MODULE,__func__ <<
"() - The configuration entry for the " <<
132 SERVER_ADMINISTRATOR_KEY <<
"[" << REGION_KEY <<
"] was missing." << endl);
133 d_region = get(STATE_KEY);
135 if(d_region.empty()){
136 BESDEBUG(MODULE,__func__ <<
"() - The configuration entry for the " <<
137 SERVER_ADMINISTRATOR_KEY <<
"[" << STATE_KEY <<
"] was missing." << endl);
142 d_postal_code = get(POSTAL_CODE_KEY);
143 if(d_postal_code.empty()){
144 BESDEBUG(MODULE,__func__ <<
"() - The configuration entry for the " <<
145 SERVER_ADMINISTRATOR_KEY <<
"[" << POSTAL_CODE_KEY <<
"] was missing." << endl);
149 d_country = get(COUNTRY_KEY);
150 if(d_country.empty()){
151 BESDEBUG(MODULE,__func__ <<
"() - The configuration entry for the " <<
152 SERVER_ADMINISTRATOR_KEY <<
"[" << COUNTRY_KEY <<
"] was missing." << endl);
156 d_telephone = get(TELEPHONE_KEY);
157 if(d_telephone.empty()){
158 BESDEBUG(MODULE,__func__ <<
"() - The configuration entry for the " <<
159 SERVER_ADMINISTRATOR_KEY <<
"[" << TELEPHONE_KEY <<
"] was missing." << endl);
163 d_email = get(EMAIL_KEY);
165 BESDEBUG(MODULE,__func__ <<
"() - The configuration entry for the " <<
166 SERVER_ADMINISTRATOR_KEY <<
"[" << EMAIL_KEY <<
"] was missing." << endl);
170 d_website = get(WEBSITE_KEY);
171 if(d_website.empty()){
172 BESDEBUG(MODULE,__func__ <<
"() - The configuration entry for the " <<
173 SERVER_ADMINISTRATOR_KEY <<
"[" << WEBSITE_KEY <<
"] was missing." << endl);
180 BESDEBUG(MODULE,__func__ <<
"() - The configuration entry for the " << SERVER_ADMINISTRATOR_KEY <<
" was missing crucial information. jdump(): " << jdump(
true) << endl);
186std::string ServerAdministrator::get(
const string &key){
188 auto result = d_admin_info.find(lkey);
189 if(result == d_admin_info.end()){
192 return result->second;
199std::string ServerAdministrator::xdump()
const {
200 std::stringstream ss;
201 ss << R
"(<ServerAdministrator )";
202 ss << R"(organization=")" << d_organization << R"(" )";
203 ss << R"(street=")" << d_street << R"(" )";
204 ss << R"(city=")" << d_city << R"(" )";
205 ss << R"(region=")" << d_region << R"(" )";
206 ss << R"(country=")" << d_country << R"(" )";
207 ss << R"(postalcode=")" << d_postal_code << R"(" )";
208 ss << R"(telephone=")" << d_telephone << R"(" )";
209 ss << R"(email=")" << d_email << R"(" )";
210 ss << R"(website=")" << d_website << R"(" )";
215std::string ServerAdministrator::jdump(
bool compact)
const {
216 std::stringstream ss;
220 ss << R
"("ServerAdministrator":)";
224 if(!compact) ss <<
" ";
225 if(!compact) ss <<
" ";
227 if(!compact){ ss << endl <<
" "; }
228 ss << R
"("organization": ")" << d_organization << R"(", )";
229 if(!compact){ ss << endl <<
" "; }
230 ss << R
"("street": ")" << d_street << R"(", )";
231 if(!compact){ ss << endl <<
" "; }
232 ss << R
"("city": ")" << d_city << R"(", )";
233 if(!compact){ ss << endl <<
" "; }
234 ss << R
"("region": ")" << d_region << R"(", )";
235 if(!compact){ ss << endl <<
" "; }
236 ss << R
"("country": ")" << d_country << R"(", )";
237 if(!compact){ ss << endl <<
" "; }
238 ss << R
"("postalcode": ")" << d_postal_code << R"(", )";
239 if(!compact){ ss << endl <<
" "; }
240 ss << R
"("telephone": ")" << d_telephone << R"(", )";
241 if(!compact){ ss << endl <<
" "; }
242 ss << R
"("email": ")" << d_email << R"(", )";
243 if(!compact){ ss << endl <<
" "; }
244 ss << R
"("website": ")" << d_website << R"(" )";
245 if(!compact){ ss << endl <<
" "; }
256void ServerAdministrator::mk_default() {
257 this->d_admin_info.clear();
258 d_admin_info.insert( std::pair<string,string>(EMAIL_KEY,EMAIL_DEFAULT));
259 d_admin_info.insert( std::pair<string,string>(ORGANIZATION_KEY,ORGANIZATION_DEFAULT));
260 d_admin_info.insert( std::pair<string,string>(STREET_KEY,STREET_DEFAULT));
261 d_admin_info.insert( std::pair<string,string>(CITY_KEY,CITY_DEFAULT));
262 d_admin_info.insert( std::pair<string,string>(REGION_KEY,REGION_DEFAULT));
263 d_admin_info.insert( std::pair<string,string>(POSTAL_CODE_KEY,POSTAL_CODE_DEFAULT));
264 d_admin_info.insert( std::pair<string,string>(COUNTRY_KEY,COUNTRY_DEFAULT));
265 d_admin_info.insert( std::pair<string,string>(TELEPHONE_KEY,TELEPHONE_DEFAULT));
266 d_admin_info.insert( std::pair<string,string>(WEBSITE_KEY,WEBSITE_DEFAULT));
267 BESDEBUG(MODULE,__func__ <<
"() - ServerAdministrator values have been set to the defaults: " << jdump(
true) << endl);
static std::string lowercase(const std::string &s)
static TheBESKeys * TheKeys()
Access to the singleton.
void get_values(const std::string &s, std::vector< std::string > &vals, bool &found)
Retrieve the values of a given key, if set.