/** * Calls a web service to get a full path to a file. * Only returns a full path string if the file exists * @param fName :: The file name. * @return The path to the file or an empty string in case of error/non-existing * file. */ std::string ISISDataArchive::getPath(const std::string &fName) const { g_log.debug() << "ISISDataArchive::getPath() - fName=" << fName << "\n"; if (fName.empty()) return ""; // Avoid pointless call to service Kernel::InternetHelper inetHelper; std::ostringstream os; try { inetHelper.sendRequest(URL_PREFIX + fName,os); os << Poco::Path::separator() << fName; try { const std::string expectedPath = os.str(); if (Poco::File(expectedPath).exists()) return expectedPath; } catch (Poco::Exception &) { } } catch (Kernel::Exception::InternetError& ie) { g_log.warning() << "Could not access archive index " << ie.what(); } return ""; }
void SendUsage::sendReport(const std::string &json) { g_log.debug() << json << "\n"; int status = STATUS_DEFAULT; try { Kernel::InternetHelper helper; std::stringstream responseStream; helper.setBody(json); status = helper.sendRequest(URL, responseStream); g_log.debug() << "Call to \"" << URL << "\" responded with " << status << "\n" << responseStream.str() << "\n"; } catch (Mantid::Kernel::Exception::InternetError &e) { status = e.errorCode(); g_log.information() << "Call to \"" << URL << "\" responded with " << status << "\n" << e.what() << "\n"; } this->setProperty("HtmlCode", status); }