#include <Server.h>
Collaboration diagram for Server:
Public Member Functions | |
Server () | |
Server (string address) | |
~Server () | |
bool | requestConversion (Document &doc) |
Result | listConversionDB () |
Result | listRepesentationTypes (string representationType) |
Result | listFeatureTypes (string featureType) |
Private Member Functions | |
bool | getFile (Document &doc) |
Private Attributes | |
string | serverAddress |
const string | DEFAULT_ADDRESS |
|
Definition at line 46 of file Server.cpp. References DEFAULT_ADDRESS, and serverAddress.
00047 { 00048 serverAddress = DEFAULT_ADDRESS; 00049 return; 00050 } |
|
Definition at line 61 of file Server.cpp. References serverAddress.
00062 { 00063 serverAddress = address; 00064 return; 00065 } |
|
Definition at line 76 of file Server.cpp.
00077 {
00078 return;
00079 }
|
|
Definition at line 95 of file Server.cpp. References Document::getDocumentFile(), Document::getDocumentUrl(), and Document::setFileLocation(). Referenced by requestConversion().
00096 { 00097 string download; // to be set for curl/wget. 00098 00099 // Checking if file already exists in /tmp. 00100 ifstream inputFile; 00101 string tmpDocFile = "/tmp/" + doc.getDocumentFile(); 00102 inputFile.open( tmpDocFile.c_str() ); 00103 if ( !inputFile ) 00104 { 00105 // need to pull the file, so setup either curl or wget. 00106 if ( system( "curl -s http://www.google.com >> /dev/null" ) == 0) 00107 { 00108 download = "curl -O "; 00109 } 00110 else 00111 { 00112 if ( system( "wget -V >> /dev/null " ) == 0 ) 00113 { 00114 download = "wget "; 00115 } 00116 else 00117 { 00118 cout << "Server Error: neither Curl or Wget are operational on this system."; 00119 cout << endl; 00120 exit(1); 00121 } 00122 } 00123 00124 // building system call. 00125 string linuxUrlCall = "cd /tmp; " + download + doc.getDocumentUrl(); 00126 cout << "File is being retrieved..." << endl; 00127 int results = system( linuxUrlCall.c_str() ); 00128 if ( results > 0 ) 00129 { 00130 cout << "Server Error: I am unable to retrieve your URL..."; 00131 cout << endl << "Server Error: Please verify the url before trying again."; 00132 cout << endl; 00133 doc.setFileLocation( "ErrorURL" ); 00134 return false; 00135 } 00136 else 00137 { 00138 // determine document name in url, using basename() function. 00139 string location = "/tmp/" + doc.getDocumentFile(); 00140 doc.setFileLocation( location ); 00141 return true; 00142 } 00143 } 00144 else 00145 { 00146 // file exists in /tmp. 00147 cout << "Server: File has been found locally." << endl; 00148 inputFile.close(); 00149 string location = "/tmp/" + doc.getDocumentFile(); 00150 doc.setFileLocation( location ); 00151 return true; 00152 } 00153 } |
Here is the call graph for this function:
|
Definition at line 222 of file Server.cpp. Referenced by Broker::getConversionListing().
00223 { 00224 try 00225 { 00226 // my query. 00227 string query = "SELECT DISTINCT Filter.routine_name, Filter.from_feature_type, Filter.to_feature_type, "; 00228 query = query + "Filter.from_representation_type, Filter.to_representation_type FROM Filter, Routine "; 00229 query = query + "WHERE Filter.routine_name = Routine.name;"; 00230 00231 // setup connection. 00232 Connection myConnect( "dbname=clearinghouse user=pronir" ); 00233 00234 // Begin a transaction acting on our current connection. 00235 Transaction myTrans(myConnect, "listingConversions"); 00236 00237 // Perform a query on the database, storing result tuples in R 00238 Result myResult = myTrans.Exec( query.c_str() ); 00239 00240 // Tell transation that it was successful. 00241 myTrans.Commit(); 00242 00243 // return the results object. 00244 return myResult; 00245 } 00246 catch ( const exception &e) 00247 { 00248 // All exceptions thrown by libpqxx are derived from std::exception. 00249 cerr << "Exception: " << e.what() << endl; 00250 exit(2); 00251 } 00252 catch (...) 00253 { 00254 // This is really unexpected (see above). 00255 cerr << "Unhandled exception..." << endl; 00256 exit(100); 00257 } 00258 } |
|
Definition at line 342 of file Server.cpp. Referenced by Broker::getFeatureTypeListing().
00343 { 00344 try 00345 { 00346 // 00347 // my query, careful with the spacing... 00348 // 00349 string query = "SELECT DISTINCT Filter.routine_name, Filter.from_feature_type, Filter.to_feature_type, "; 00350 query = query + "Filter.from_representation_type, Filter.to_representation_type FROM Filter, Routine "; 00351 query = query + "WHERE Filter.from_feature_type='"; 00352 query = query + featureType + "' "; 00353 // query = query + "OR Filter.from_feature_type='*' "; 00354 query = query + "OR Filter.to_feature_type='"; 00355 query = query + featureType + "' "; 00356 query = query + ";"; 00357 // query = query + "OR Filter.to_feature_type='*'; "; 00358 00359 // setup connection. 00360 Connection myConnect( "dbname=clearinghouse user=pronir" ); 00361 00362 // Begin a transaction acting on our current connection. 00363 Transaction myTrans(myConnect, "listingFeatureTypes"); 00364 00365 // Perform a query on the database, storing result tuples in R 00366 Result myResult = myTrans.Exec( query.c_str() ); 00367 00368 // Tell transation that it was successful. 00369 myTrans.Commit(); 00370 00371 // return the results object. 00372 return myResult; 00373 } 00374 catch ( const exception &e) 00375 { 00376 // All exceptions thrown by libpqxx are derived from std::exception. 00377 cerr << "Exception: " << e.what() << endl; 00378 exit(2); 00379 } 00380 catch (...) 00381 { 00382 // This is really unexpected (see above). 00383 cerr << "Unhandled exception..." << endl; 00384 exit(100); 00385 } 00386 } |
|
Definition at line 278 of file Server.cpp. Referenced by Broker::getRepresentationTypeListing().
00279 { 00280 try 00281 { 00282 // 00283 // my query, careful with the spacing... 00284 // 00285 string query = "SELECT DISTINCT Filter.routine_name, Filter.from_feature_type, Filter.to_feature_type, "; 00286 query = query + "Filter.from_representation_type, Filter.to_representation_type FROM Filter, Routine "; 00287 query = query + "WHERE Filter.from_representation_type='"; 00288 query = query + representationType + "' "; 00289 // query = query + "OR Filter.from_representation_type='*' "; 00290 query = query + "OR Filter.to_representation_type='"; 00291 query = query + representationType + "' "; 00292 query = query + ";"; 00293 // query = query + "OR Filter.to_representation_type='*'; "; 00294 00295 // setup connection. 00296 Connection myConnect( "dbname=clearinghouse user=pronir" ); 00297 00298 // Begin a transaction acting on our current connection. 00299 Transaction myTrans(myConnect, "listingRepresentationTypes"); 00300 00301 // Perform a query on the database, storing result tuples in R 00302 Result myResult = myTrans.Exec( query.c_str() ); 00303 00304 // Tell transation that it was successful. 00305 myTrans.Commit(); 00306 00307 // return the results object. 00308 return myResult; 00309 } 00310 catch ( const exception &e) 00311 { 00312 // All exceptions thrown by libpqxx are derived from std::exception. 00313 cerr << "Exception: " << e.what() << endl; 00314 exit(2); 00315 } 00316 catch (...) 00317 { 00318 // This is really unexpected (see above). 00319 cerr << "Unhandled exception..." << endl; 00320 exit(100); 00321 } 00322 } |
|
Definition at line 171 of file Server.cpp. References Document::getDocumentConversion(), Document::getDocumentFile(), getFile(), Document::getFileLocation(), Document::setConversionLocation(), and Document::setFileLocation(). Referenced by Broker::convertDocument(), and DocConversionTestSuite::testServerRequestConversion().
00172 { 00173 // check if file has been retrieved before converting. 00174 if ( doc.getFileLocation() == "0" ) 00175 { 00176 // file needs to be retrieved first. 00177 if ( getFile( doc ) ) 00178 { 00179 string location = "/tmp/" + doc.getDocumentFile(); 00180 doc.setFileLocation( location ); 00181 } 00182 } 00183 00184 // attempt to convert file. 00185 string call = "cd /tmp; " + 00186 doc.getDocumentConversion() + 00187 " " + 00188 doc.getFileLocation(); 00189 int results = system( call.c_str() ); 00190 00191 if ( results >= 0 ) 00192 { 00193 // conversion successfull! 00194 doc.setConversionLocation( "/tmp" ); 00195 return true; 00196 } 00197 else 00198 { 00199 // system call has problems. 00200 cout << "Server Error: Conversion failed!!!!!" << endl; 00201 return false; 00202 } 00203 } |
Here is the call graph for this function:
|
|
|
Definition at line 153 of file Server.h. Referenced by Server(). |