From 7e72424fa76c167db9f667195ce97077feaf0211 Mon Sep 17 00:00:00 2001
From: Michael Davis <michael.davis@cern.ch>
Date: Tue, 14 Jan 2020 17:37:02 +0100
Subject: [PATCH] [frontend] Only query endpoint if -l option is specified

---
 xroot_plugins/GrpcEndpoint.hpp             |  4 +---
 xroot_plugins/XrdSsiCtaRequestMessage.cpp  | 11 +++++++++--
 xroot_plugins/XrdSsiCtaServiceProvider.cpp |  2 +-
 3 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/xroot_plugins/GrpcEndpoint.hpp b/xroot_plugins/GrpcEndpoint.hpp
index 95fd988f4e..98b2bc64ff 100644
--- a/xroot_plugins/GrpcEndpoint.hpp
+++ b/xroot_plugins/GrpcEndpoint.hpp
@@ -40,11 +40,9 @@ class EndpointMap
 {
 public:
   EndpointMap(NamespaceMap_t nsMap) {
-#if 0
     for(auto &ns : nsMap) {
-      m_endpointMap[ns.first] = Endpoint(ns.second);
+      m_endpointMap.insert(std::make_pair(ns.first, Endpoint(ns.second)));
     }
-#endif
   }
 
   std::string getPath(const std::string &diskInstance, const std::string &diskFileId) const {
diff --git a/xroot_plugins/XrdSsiCtaRequestMessage.cpp b/xroot_plugins/XrdSsiCtaRequestMessage.cpp
index 31fb41aeb5..3de23c3485 100644
--- a/xroot_plugins/XrdSsiCtaRequestMessage.cpp
+++ b/xroot_plugins/XrdSsiCtaRequestMessage.cpp
@@ -1483,8 +1483,15 @@ void RequestMessage::processTapeFile_Ls(cta::xrd::Response &response, XrdSsiStre
 {
   using namespace cta::admin;
 
-  // Create a XrdSsi stream object to return the results
-  stream = new TapeFileLsStream(*this, m_catalogue, m_scheduler, m_namespaceMap);
+  auto isLookupNamespace = getOptional(OptionBoolean::LOOKUP_NAMESPACE);
+
+  if(isLookupNamespace && isLookupNamespace.value()) {
+    // Get a stream including filename lookup in the namespace
+    stream = new TapeFileLsStream(*this, m_catalogue, m_scheduler, m_namespaceMap);
+  } else {
+    // Get a stream without namespace lookup
+    stream = new TapeFileLsStream(*this, m_catalogue, m_scheduler);
+  }
 
   response.set_show_header(HeaderType::TAPEFILE_LS);
   response.set_type(cta::xrd::Response::RSP_SUCCESS);
diff --git a/xroot_plugins/XrdSsiCtaServiceProvider.cpp b/xroot_plugins/XrdSsiCtaServiceProvider.cpp
index 03875142ba..5b9025c60e 100644
--- a/xroot_plugins/XrdSsiCtaServiceProvider.cpp
+++ b/xroot_plugins/XrdSsiCtaServiceProvider.cpp
@@ -160,7 +160,7 @@ void XrdSsiCtaServiceProvider::ExceptionThrowingInit(XrdSsiLogger *logP, XrdSsiC
    //m_nsEndpoint = nsEndpointConf.first ? nsEndpointConf.second : "";
    auto nsTokenConf = config.getOptionValueStr("cta.ns.token");
    //m_nsToken = nsTokenConf.first ? nsTokenConf.second : "";
-   //m_namespaceMap["endpoint"] = Namespace(nsEndpointConf.second, nsTokenConf.second);
+   m_namespaceMap.insert(std::make_pair("endpoint", Namespace(nsEndpointConf.second, nsTokenConf.second)));
   
    // Start the heartbeat thread for the agent object. The thread is guaranteed to have started before we call the unique_ptr deleter
    auto aht = new cta::objectstore::AgentHeartbeatThread(m_backendPopulator->getAgentReference(), *m_backend, *m_log);
-- 
GitLab