17#include <Poco/ActiveResult.h>
23std::vector<std::string> namesOfFacilitiesWithICAT() {
26 const auto facilityDoesNotHaveICAT = [&](
const std::string &name) {
27 return config.getFacility(name).catalogInfo().soapEndPoint().empty();
31 result.erase(std::remove_if(result.begin(), result.end(), facilityDoesNotHaveICAT), result.end());
36std::string defaultFacility() {
42 const auto facilitiesWithICAT = namesOfFacilitiesWithICAT();
43 if (std::find(facilitiesWithICAT.begin(), facilitiesWithICAT.end(), facility) != facilitiesWithICAT.end()) {
47 if (facilitiesWithICAT.size() > 0) {
48 return facilitiesWithICAT[0];
57 auto requireValue = std::make_shared<Kernel::MandatoryValidator<std::string>>();
58 declareProperty(
"Username",
"", requireValue,
"The username to log into the catalog.");
60 "The password of the related username to use.");
62 std::make_shared<Kernel::StringListValidator>(namesOfFacilitiesWithICAT()),
63 "Select a facility to log in to.");
64 declareProperty(
"KeepSessionAlive",
true,
"Keeps the session of the catalog alive if login was successful.");
65 declareProperty(std::make_unique<API::AlgorithmProperty>(
"KeepAlive", std::make_shared<Kernel::NullValidator>(),
67 "A handle to the KeepAlive algorithm instance that continues "
68 "to keep the catalog alive after this algorithm completes.");
74 if (catalogInfo.soapEndPoint().empty())
75 throw std::runtime_error(
"There is no soap end-point for the facility you have selected.");
77 g_log.
notice() <<
"Attempting to verify user credentials against " << catalogInfo.catalogName() <<
'\n';
78 progress(0.5,
"Verifying user credentials...");
85 catalogInfo.soapEndPoint(),
getProperty(
"FacilityName"));
87 progress(0,
"Keeping current sessions alive.");
91 keepAliveAlgorithm->initialize();
92 keepAliveAlgorithm->setPropertyValue(
"Session", session->getSessionId());
93 keepAliveAlgorithm->executeAsync();
#define DECLARE_ALGORITHM(classname)
void declareProperty(std::unique_ptr< Kernel::Property > p, const std::string &doc="") override
Add a property to the list of managed properties.
TypedValue getProperty(const std::string &name) const override
Get the value of a property.
void progress(double p, const std::string &msg="", double estimatedTime=0.0, int progressPrecision=0)
Sends ProgressNotification.
void exec() override
Overwrites Algorithm method.
void init() override
Overwrites Algorithm method.
IPropertyManager * setProperty(const std::string &name, const T &value)
Templated method to set the value of a PropertyWithValue.
void notice(const std::string &msg)
Logs at notice level.
A property class for masking the properties.
static T & Instance()
Return a reference to the Singleton instance, creating it if it does not already exist Creation is do...
@ Output
An output workspace.