21Kernel::Logger
g_log(
"ISISDataArchive");
28constexpr std::string_view URL_PREFIX =
"http://data.isis.rl.ac.uk/where.py/windir?name=";
30constexpr std::string_view URL_PREFIX =
"http://data.isis.rl.ac.uk/where.py/unixdir?name=";
43 const std::vector<std::string> &exts)
const {
44 if (
g_log.
is(Kernel::Logger::Priority::PRIO_DEBUG)) {
45 for (
const auto &filename : filenames) {
48 for (
const auto &ext : exts) {
53 std::string errors =
"";
54 for (
const auto &filename : filenames) {
55 std::string path_without_extension =
getPath(filename);
56 if (!path_without_extension.empty()) {
59 constexpr std::string_view unixString =
"/archive/";
60 constexpr std::string_view macOSString =
"/Volumes/inst$/";
61 path_without_extension.replace(0, unixString.length(), macOSString);
64 if (!fullPath.empty())
66 errors +=
"No file found. ";
69 "If you are an IDAaaS user, and your file is in the ISIS archive, then check if the archive is mounted. If it is not mounted, \
70 \nthen click Applications->Data->Experiment Archive (Staff Only), and enter your federal ID credentials with 'clrc' as the domain.";
83 g_log.
debug() <<
"ISISDataArchive::getPath() - fName=" << fName <<
"\n";
88 os << std::string(1, std::filesystem::path::preferred_separator) << fName;
89 std::string expectedPath = os.str();
103 std::ostringstream os;
105 inetHelper.
sendRequest(URL_PREFIX.data() + fName, os);
122 for (
const auto &ext : exts) {
123 std::string temp_path = path + ext;
139 if (std::filesystem::exists(path))
141 }
catch (
const std::filesystem::filesystem_error &) {
#define DECLARE_ARCHIVESEARCH(classname, facility)
const API::Result< std::filesystem::path > getArchivePath(const std::set< std::string > &hintstrs, const std::vector< std::string > &exts) const override
Returns the path to a filename given the list of extensions to try.
std::string getPath(const std::string &fName) const
Gets the path to the file, or most recent set of files.
virtual std::string getCorrectExtension(const std::string &path, const std::vector< std::string > &exts) const
Public and virtual for testing purposes.
virtual bool fileExists(const std::string &path) const
Checks if the given file path exists or not.
virtual std::ostringstream sendRequest(const std::string &fName) const
Queries the archive & returns the path to a single file.
Exception thrown when error occurs accessing an internet resource.
const char * what() const noexcept override
Overloaded reporting method.
InternetHelper : A helper class for supporting access to resources through HTTP and HTTPS.
virtual HTTPStatus sendRequest(const std::string &url, std::ostream &responseStream)
Performs a request using http or https depending on the url.
void debug(const std::string &msg)
Logs at debug level.
void warning(const std::string &msg)
Logs at warning level.
bool is(int level) const
Returns true if at least the given log level is set.
Kernel::Logger g_log("ExperimentInfo")
static logger object