Author: kwright
Date: Sat Nov 1 12:07:48 2014
New Revision: 1635936
URL: http://svn.apache.org/r1635936
Log:
Make security switch look the same as for other connectors.
Modified:
manifoldcf/branches/CONNECTORS-1089/connectors/jdbc/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/jdbc/JDBCConnector.java
Modified:
manifoldcf/branches/CONNECTORS-1089/connectors/jdbc/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/jdbc/JDBCConnector.java
URL:
http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-1089/connectors/jdbc/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/jdbc/JDBCConnector.java?rev=1635936&r1=1635935&r2=1635936&view=diff
==============================================================================
---
manifoldcf/branches/CONNECTORS-1089/connectors/jdbc/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/jdbc/JDBCConnector.java
(original)
+++
manifoldcf/branches/CONNECTORS-1089/connectors/jdbc/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/jdbc/JDBCConnector.java
Sat Nov 1 12:07:48 2014
@@ -409,85 +409,85 @@ public class JDBCConnector extends org.a
// Pick up document acls
Map<String,Set<String>> documentAcls = new HashMap<String,Set<String>>();
- if (ts.securityOn && ts.aclQuery != null && ts.aclQuery.length() > 0)
+ if (ts.securityOn)
{
- // If there IS an acls query, do it. First set up the variables, then
do the substitution.
- VariableMap vm = new VariableMap();
-
addConstant(vm,JDBCConstants.idReturnVariable,JDBCConstants.idReturnColumnName);
-
addConstant(vm,JDBCConstants.tokenReturnVariable,JDBCConstants.tokenReturnColumnName);
- if
(addIDList(vm,JDBCConstants.idListVariable,documentIdentifiers,fetchDocuments))
+ if (acls.size() == 0 && ts.aclQuery != null && ts.aclQuery.length() > 0)
{
- // Do the substitution
- ArrayList paramList = new ArrayList();
- StringBuilder sb = new StringBuilder();
- substituteQuery(ts.aclQuery,vm,sb,paramList);
-
- // Fire off the query!
- getSession();
- IDynamicResultSet result;
- String queryText = sb.toString();
- long startTime = System.currentTimeMillis();
- // Get a dynamic resultset. Contract for dynamic resultset is that if
- // one is returned, it MUST be closed, or a connection will leak.
- try
- {
- result = connection.executeUncachedQuery(queryText,paramList,-1);
- }
- catch (ManifoldCFException e)
- {
- // If failure, record the failure.
- if (e.getErrorCode() != ManifoldCFException.INTERRUPTED)
- activities.recordActivity(new Long(startTime),
ACTIVITY_EXTERNAL_QUERY, null,
- createQueryString(queryText,paramList), "ERROR", e.getMessage(),
null);
- throw e;
- }
- try
- {
- // If success, record that too.
- activities.recordActivity(new Long(startTime),
ACTIVITY_EXTERNAL_QUERY, null,
- createQueryString(queryText,paramList), "OK", null, null);
- // Now, go through resultset
- while (true)
+ // If there IS an acls query, do it. First set up the variables, then
do the substitution.
+ VariableMap vm = new VariableMap();
+
addConstant(vm,JDBCConstants.idReturnVariable,JDBCConstants.idReturnColumnName);
+
addConstant(vm,JDBCConstants.tokenReturnVariable,JDBCConstants.tokenReturnColumnName);
+ if
(addIDList(vm,JDBCConstants.idListVariable,documentIdentifiers,fetchDocuments))
+ {
+ // Do the substitution
+ ArrayList paramList = new ArrayList();
+ StringBuilder sb = new StringBuilder();
+ substituteQuery(ts.aclQuery,vm,sb,paramList);
+
+ // Fire off the query!
+ getSession();
+ IDynamicResultSet result;
+ String queryText = sb.toString();
+ long startTime = System.currentTimeMillis();
+ // Get a dynamic resultset. Contract for dynamic resultset is that
if
+ // one is returned, it MUST be closed, or a connection will leak.
+ try
{
- IDynamicResultRow row = result.getNextRow();
- if (row == null)
- break;
- try
+ result = connection.executeUncachedQuery(queryText,paramList,-1);
+ }
+ catch (ManifoldCFException e)
+ {
+ // If failure, record the failure.
+ if (e.getErrorCode() != ManifoldCFException.INTERRUPTED)
+ activities.recordActivity(new Long(startTime),
ACTIVITY_EXTERNAL_QUERY, null,
+ createQueryString(queryText,paramList), "ERROR",
e.getMessage(), null);
+ throw e;
+ }
+ try
+ {
+ // If success, record that too.
+ activities.recordActivity(new Long(startTime),
ACTIVITY_EXTERNAL_QUERY, null,
+ createQueryString(queryText,paramList), "OK", null, null);
+ // Now, go through resultset
+ while (true)
{
- Object o = row.getValue(JDBCConstants.idReturnColumnName);
- if (o == null)
- throw new ManifoldCFException("Bad acl query; doesn't return
$(IDCOLUMN) column. Try using quotes around $(IDCOLUMN) variable, e.g.
\"$(IDCOLUMN)\", or, for MySQL, select \"by label\" in your repository
connection.");
- String idValue = JDBCConnection.readAsString(o);
- o = row.getValue(JDBCConstants.tokenReturnColumnName);
- String tokenValue;
- if (o == null)
- tokenValue = "";
- else
- tokenValue = JDBCConnection.readAsString(o);
- // Versions that are "", when processed, will have their acls
fetched at that time...
- Set<String> dcs = documentAcls.get(idValue);
- if (dcs == null)
+ IDynamicResultRow row = result.getNextRow();
+ if (row == null)
+ break;
+ try
+ {
+ Object o = row.getValue(JDBCConstants.idReturnColumnName);
+ if (o == null)
+ throw new ManifoldCFException("Bad acl query; doesn't return
$(IDCOLUMN) column. Try using quotes around $(IDCOLUMN) variable, e.g.
\"$(IDCOLUMN)\", or, for MySQL, select \"by label\" in your repository
connection.");
+ String idValue = JDBCConnection.readAsString(o);
+ o = row.getValue(JDBCConstants.tokenReturnColumnName);
+ String tokenValue;
+ if (o == null)
+ tokenValue = "";
+ else
+ tokenValue = JDBCConnection.readAsString(o);
+ // Versions that are "", when processed, will have their acls
fetched at that time...
+ Set<String> dcs = documentAcls.get(idValue);
+ if (dcs == null)
+ {
+ dcs = new HashSet<String>();
+ documentAcls.put(idValue,dcs);
+ }
+ dcs.add(tokenValue);
+ }
+ finally
{
- dcs = new HashSet<String>();
- documentAcls.put(idValue,dcs);
+ row.close();
}
- dcs.add(tokenValue);
- }
- finally
- {
- row.close();
}
}
- }
- finally
- {
- result.close();
+ finally
+ {
+ result.close();
+ }
}
}
- }
- else
- {
- if (ts.securityOn)
+ else
{
for (String documentIdentifier : fetchDocuments)
{