Skip to content

Commit

Permalink
Created convenience method to set endpoint & SSLContext. Refs #8581.
Browse files Browse the repository at this point in the history
  • Loading branch information
jawrainey committed Dec 10, 2013
1 parent 1d0dfef commit bc5750b
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 23 deletions.
Expand Up @@ -86,6 +86,9 @@ namespace Mantid
std::string bytesToString(int64_t &fileSize);
// Helper method that formats a given timestamp.
std::string formatDateTime(const time_t &timestamp, const std::string &format);
// Sets the soap-endpoint & SSL context for the proxy being returned.
ICat4::ICATPortBindingProxy getICATProxy();

// Reference to the logger class.
Kernel::Logger& g_log;

Expand Down
49 changes: 26 additions & 23 deletions Code/Mantid/Framework/ICat/src/ICat4/ICat4Catalog.cpp
Expand Up @@ -28,11 +28,10 @@ namespace Mantid
*/
void ICat4Catalog::login(const std::string& username, const std::string& password, const std::string& url)
{
UNUSED_ARG(url)
ICat4::ICATPortBindingProxy icat;

// Define ssl authentication scheme
setSSLContext(icat);
// Store the soap end-point in the session for use later.
ICat::Session::Instance().setSoapEndPoint(url);
// Obtain the ICAT proxy that has been securely set, including soap-endpoint.
ICat4::ICATPortBindingProxy icat = getICATProxy();

// Used to authenticate the user.
ns1__login login;
Expand Down Expand Up @@ -86,8 +85,7 @@ namespace Mantid
*/
void ICat4Catalog::logout()
{
ICat4::ICATPortBindingProxy icat;
setSSLContext(icat);
ICat4::ICATPortBindingProxy icat = getICATProxy();

ns1__logout request;
ns1__logoutResponse response;
Expand Down Expand Up @@ -257,8 +255,7 @@ namespace Mantid

g_log.debug() << "ICat4Catalog::search -> Query is: { " << query << " }" << std::endl;

ICat4::ICATPortBindingProxy icat;
setSSLContext(icat);
ICat4::ICATPortBindingProxy icat = getICATProxy();

ns1__search request;
ns1__searchResponse response;
Expand All @@ -285,8 +282,7 @@ namespace Mantid
*/
int64_t ICat4Catalog::getNumberOfSearchResults(const CatalogSearchParam& inputs)
{
ICat4::ICATPortBindingProxy icat;
setSSLContext(icat);
ICat4::ICATPortBindingProxy icat = getICATProxy();

ns1__search request;
ns1__searchResponse response;
Expand Down Expand Up @@ -328,8 +324,7 @@ namespace Mantid
*/
void ICat4Catalog::myData(Mantid::API::ITableWorkspace_sptr& outputws)
{
ICat4::ICATPortBindingProxy icat;
setSSLContext(icat);
ICat4::ICATPortBindingProxy icat = getICATProxy();

ns1__search request;
ns1__searchResponse response;
Expand Down Expand Up @@ -434,8 +429,7 @@ namespace Mantid
*/
void ICat4Catalog::getDataSets(const long long& investigationId, Mantid::API::ITableWorkspace_sptr& outputws)
{
ICat4::ICATPortBindingProxy icat;
setSSLContext(icat);
ICat4::ICATPortBindingProxy icat = getICATProxy();

ns1__search request;
ns1__searchResponse response;
Expand Down Expand Up @@ -503,8 +497,7 @@ namespace Mantid
*/
void ICat4Catalog::getDataFiles(const long long& investigationId, Mantid::API::ITableWorkspace_sptr& outputws)
{
ICat4::ICATPortBindingProxy icat;
setSSLContext(icat);
ICat4::ICATPortBindingProxy icat = getICATProxy();

ns1__search request;
ns1__searchResponse response;
Expand Down Expand Up @@ -581,8 +574,7 @@ namespace Mantid
*/
void ICat4Catalog::listInstruments(std::vector<std::string>& instruments)
{
ICat4::ICATPortBindingProxy icat;
setSSLContext(icat);
ICat4::ICATPortBindingProxy icat = getICATProxy();

ns1__search request;
ns1__searchResponse response;
Expand Down Expand Up @@ -622,8 +614,7 @@ namespace Mantid
*/
void ICat4Catalog::listInvestigationTypes(std::vector<std::string>& invstTypes)
{
ICat4::ICATPortBindingProxy icat;
setSSLContext(icat);
ICat4::ICATPortBindingProxy icat = getICATProxy();

ns1__search request;
ns1__searchResponse response;
Expand Down Expand Up @@ -664,8 +655,7 @@ namespace Mantid
*/
void ICat4Catalog::getFileLocation(const long long & fileID, std::string & fileLocation)
{
ICat4::ICATPortBindingProxy icat;
setSSLContext(icat);
ICat4::ICATPortBindingProxy icat = getICATProxy();

ns1__get request;
ns1__getResponse response;
Expand Down Expand Up @@ -817,5 +807,18 @@ namespace Mantid
return (dateTime.toFormattedString(format));
}

/**
* Sets the soap-endpoint & SSL context for the proxy being returned.
* @return ICATPortBindingProxy :: The proxy with set endpoint & SSL context.
*/
ICat4::ICATPortBindingProxy ICat4Catalog::getICATProxy()
{
ICat4::ICATPortBindingProxy icat;
// Set the soap-endpoint of the catalog we want to use.
icat.soap_endpoint = ICat::Session::Instance().getSoapEndPoint().c_str();
// Sets SSL authentication scheme
setSSLContext(icat);
return icat;
}
}
}

0 comments on commit bc5750b

Please sign in to comment.