CONNECTORS-934 : Check if log level is enabled before constructing log message.
git-svn-id: https://svn.apache.org/repos/asf/manifoldcf/integration/solr-4.x/trunk@1591628 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/CHANGES.txt b/CHANGES.txt
index 96e19ea..26ffbc2 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -6,6 +6,9 @@
CONNECTORS-914: Go to a Maven build system.
(Ahmet Arslan)
+CONNECTORS-934 : Check if log level is enabled before constructing log message.
+(Ahmet Arslan)
+
======================= Release 2.0 =====================
CONNECTORS-886: Provide [allow|deny]_token_parent fields.
diff --git a/src/main/java/org/apache/solr/mcf/ManifoldCFQParserPlugin.java b/src/main/java/org/apache/solr/mcf/ManifoldCFQParserPlugin.java
index 551a325..bbfe9d7 100644
--- a/src/main/java/org/apache/solr/mcf/ManifoldCFQParserPlugin.java
+++ b/src/main/java/org/apache/solr/mcf/ManifoldCFQParserPlugin.java
@@ -45,8 +45,6 @@
*/
public class ManifoldCFQParserPlugin extends QParserPlugin
{
- /** The component name */
- static final public String COMPONENT_NAME = "mcf";
/** The parameter that is supposed to contain the authenticated user name, possibly including the AD domain */
static final public String AUTHENTICATED_USER_NAME = "AuthenticatedUserName";
/** The parameter that is supposed to contain the MCF authorization domain, if any */
@@ -63,10 +61,7 @@
/** Special token for null security fields */
static final public String NOSECURITY_TOKEN = "__nosecurity__";
-
- /** The queries that we will not attempt to interfere with */
- static final private String[] globalAllowed = { "solrpingquery" };
-
+
/** A logger we can use */
private static final Logger LOG = LoggerFactory.getLogger(ManifoldCFQParserPlugin.class);
@@ -207,26 +202,25 @@
{
// Only return 'public' documents (those with no security tokens at all)
LOG.info("Group tokens received from caller");
- for (String passedToken : passedTokens)
- {
- userAccessTokens.add(passedToken);
- }
+ userAccessTokens.addAll(Arrays.asList(passedTokens));
}
}
else
{
- StringBuilder sb = new StringBuilder("[");
- boolean first = true;
- for (String domain : domainMap.keySet())
- {
- if (!first)
- sb.append(",");
- else
- first = false;
- sb.append(domain).append(":").append(domainMap.get(domain));
+ if(LOG.isInfoEnabled()){
+ StringBuilder sb = new StringBuilder("[");
+ boolean first = true;
+ for (String domain : domainMap.keySet())
+ {
+ if (!first)
+ sb.append(",");
+ else
+ first = false;
+ sb.append(domain).append(":").append(domainMap.get(domain));
+ }
+ sb.append("]");
+ LOG.info("Trying to match docs for user '"+sb.toString()+"'");
}
- sb.append("]");
- LOG.info("Trying to match docs for user '"+sb.toString()+"'");
// Valid authenticated user name. Look up access tokens for the user.
// Check the configuration arguments for validity
if (authorityBaseURL == null)
diff --git a/src/main/java/org/apache/solr/mcf/ManifoldCFSearchComponent.java b/src/main/java/org/apache/solr/mcf/ManifoldCFSearchComponent.java
index bf18d0a..2a8d733 100644
--- a/src/main/java/org/apache/solr/mcf/ManifoldCFSearchComponent.java
+++ b/src/main/java/org/apache/solr/mcf/ManifoldCFSearchComponent.java
@@ -99,7 +99,7 @@
authorityBaseURL = (String)args.get("AuthorityServiceBaseURL");
if (authorityBaseURL == null)
{
- System.out.println("USING DEFAULT BASE URL!!");
+ LOG.info("USING DEFAULT BASE URL!!");
authorityBaseURL = "http://localhost:8345/mcf-authority-service";
}
Integer cTimeOut = (Integer)args.get("ConnectionTimeOut");
@@ -203,26 +203,25 @@
{
// Only return 'public' documents (those with no security tokens at all)
LOG.info("Group tokens received from caller");
- for (String passedToken : passedTokens)
- {
- userAccessTokens.add(passedToken);
- }
+ userAccessTokens.addAll(Arrays.asList(passedTokens));
}
}
else
{
- StringBuilder sb = new StringBuilder("[");
- boolean first = true;
- for (String domain : domainMap.keySet())
- {
- if (!first)
- sb.append(",");
- else
- first = false;
- sb.append(domain).append(":").append(domainMap.get(domain));
+ if(LOG.isInfoEnabled()){
+ StringBuilder sb = new StringBuilder("[");
+ boolean first = true;
+ for (String domain : domainMap.keySet())
+ {
+ if (!first)
+ sb.append(",");
+ else
+ first = false;
+ sb.append(domain).append(":").append(domainMap.get(domain));
+ }
+ sb.append("]");
+ LOG.info("Trying to match docs for user '"+sb.toString()+"'");
}
- sb.append("]");
- LOG.info("Trying to match docs for user '"+sb.toString()+"'");
// Valid authenticated user name. Look up access tokens for the user.
// Check the configuration arguments for validity
if (authorityBaseURL == null)
@@ -450,7 +449,6 @@
if (httpConnectionManager != null)
{
httpConnectionManager.shutdown();
- System.out.println("Just shutdown httpConnectionmanager");
httpConnectionManager = null;
client = null;
}
diff --git a/src/test/java/org/apache/solr/mcf/ManifoldCFSCLoadTest.java b/src/test/java/org/apache/solr/mcf/ManifoldCFSCLoadTest.java
index 51e4eba..02417e7 100644
--- a/src/test/java/org/apache/solr/mcf/ManifoldCFSCLoadTest.java
+++ b/src/test/java/org/apache/solr/mcf/ManifoldCFSCLoadTest.java
@@ -18,6 +18,7 @@
package org.apache.solr.mcf;
import java.io.IOException;
+import java.util.concurrent.TimeUnit;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
@@ -80,7 +81,7 @@
@Test
public void testTimeQueries() throws Exception {
int i = 0;
- long startTime = System.currentTimeMillis();
+ long startTime = System.nanoTime();
while (i < 1000)
{
assertQ(req("qt", "/mcf", "q", "*:*", "fl", "id", "AuthenticatedUserName", "user1"),
@@ -94,7 +95,7 @@
i++;
}
- System.out.println("Query time = "+new Long(System.currentTimeMillis()-startTime));
+ System.out.println("Query time (milliseconds) = " + TimeUnit.NANOSECONDS.toMillis(System.nanoTime()-startTime));
}
static class MockMCFAuthorityService {