20Kernel::Logger
g_log(
"ISISDataArchive");
27constexpr std::string_view URL_PREFIX =
"http://data.isis.rl.ac.uk/where.py/windir?name=";
29constexpr std::string_view URL_PREFIX =
"http://data.isis.rl.ac.uk/where.py/unixdir?name=";
42 const std::vector<std::string> &exts)
const {
43 if (
g_log.
is(Kernel::Logger::Priority::PRIO_DEBUG)) {
44 for (
const auto &filename : filenames) {
47 for (
const auto &ext : exts) {
52 std::string errors =
"";
53 for (
const auto &filename : filenames) {
54 std::string path_without_extension =
getPath(filename);
55 if (!path_without_extension.empty()) {
58 constexpr std::string_view unixString =
"/archive/";
59 constexpr std::string_view macOSString =
"/Volumes/inst$/";
60 path_without_extension.replace(0, unixString.length(), macOSString);
63 if (!fullPath.empty())
65 errors +=
"No file found. ";
68 "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, \
69 \nthen click Applications->Data->Experiment Archive (Staff Only), and enter your federal ID credentials with 'clrc' as the domain.";
82 g_log.
debug() <<
"ISISDataArchive::getPath() - fName=" << fName <<
"\n";
87 os << std::string(1, std::filesystem::path::preferred_separator) << fName;
88 std::string expectedPath = os.str();
102 std::ostringstream os;
104 inetHelper.
sendRequest(URL_PREFIX.data() + fName, os);
121 for (
const auto &ext : exts) {
122 std::string temp_path = path + ext;
138 if (std::filesystem::exists(path))
140 }
catch (
const std::filesystem::filesystem_error &) {
#define DECLARE_ARCHIVESEARCH(classname, facility)
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.
const API::Result< std::string > getArchivePath(const std::set< std::string > &filenames, const std::vector< std::string > &exts) const override
Returns the path to a filename given the list of extensions to try.
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