Author: shawkins
Date: 2011-10-27 15:27:00 -0400 (Thu, 27 Oct 2011)
New Revision: 3592
Modified:
trunk/connectors/connector-ldap/src/test/java/org/teiid/resource/adapter/ldap/TestLDAPConnection.java
trunk/connectors/translator-ldap/src/main/java/org/teiid/translator/ldap/LDAPExecutionFactory.java
trunk/connectors/translator-ldap/src/main/java/org/teiid/translator/ldap/LDAPSyncQueryExecution.java
trunk/documentation/reference/src/main/docbook/en-US/content/translators.xml
Log:
TEIID-1797 refining the handling of sizelimitexceededexceptions
Modified:
trunk/connectors/connector-ldap/src/test/java/org/teiid/resource/adapter/ldap/TestLDAPConnection.java
===================================================================
---
trunk/connectors/connector-ldap/src/test/java/org/teiid/resource/adapter/ldap/TestLDAPConnection.java 2011-10-27
17:05:18 UTC (rev 3591)
+++
trunk/connectors/connector-ldap/src/test/java/org/teiid/resource/adapter/ldap/TestLDAPConnection.java 2011-10-27
19:27:00 UTC (rev 3592)
@@ -30,10 +30,8 @@
import org.junit.Test;
import org.mockito.Mockito;
-import org.teiid.resource.adapter.ldap.LDAPConnectionImpl;
-import org.teiid.resource.adapter.ldap.LDAPManagedConnectionFactory;
-
+@SuppressWarnings("nls")
public class TestLDAPConnection {
public static class FakeFactory implements InitialContextFactory {
Modified:
trunk/connectors/translator-ldap/src/main/java/org/teiid/translator/ldap/LDAPExecutionFactory.java
===================================================================
---
trunk/connectors/translator-ldap/src/main/java/org/teiid/translator/ldap/LDAPExecutionFactory.java 2011-10-27
17:05:18 UTC (rev 3591)
+++
trunk/connectors/translator-ldap/src/main/java/org/teiid/translator/ldap/LDAPExecutionFactory.java 2011-10-27
19:27:00 UTC (rev 3592)
@@ -54,6 +54,7 @@
private boolean restrictToObjectClass;
private SearchDefaultScope searchDefaultScope = SearchDefaultScope.ONELEVEL_SCOPE;
private boolean usePagination;
+ private boolean exceptionOnSizeLimitExceeded;
public LDAPExecutionFactory() {
this.setMaxInCriteriaSize(1000);
@@ -154,4 +155,14 @@
this.usePagination = usePagination;
}
+ @TranslatorProperty(display="Exception on Size Limit Exceeded",
description="Set to true to throw an exception when a SizeLimitExceededException is
received and a LIMIT is not properly enforced.")
+ public boolean isExceptionOnSizeLimitExceeded() {
+ return exceptionOnSizeLimitExceeded;
+ }
+
+ public void setExceptionOnSizeLimitExceeded(
+ boolean exceptionOnSizeLimitExceeded) {
+ this.exceptionOnSizeLimitExceeded = exceptionOnSizeLimitExceeded;
+ }
+
}
Modified:
trunk/connectors/translator-ldap/src/main/java/org/teiid/translator/ldap/LDAPSyncQueryExecution.java
===================================================================
---
trunk/connectors/translator-ldap/src/main/java/org/teiid/translator/ldap/LDAPSyncQueryExecution.java 2011-10-27
17:05:18 UTC (rev 3591)
+++
trunk/connectors/translator-ldap/src/main/java/org/teiid/translator/ldap/LDAPSyncQueryExecution.java 2011-10-27
19:27:00 UTC (rev 3592)
@@ -124,6 +124,7 @@
private LDAPExecutionFactory executionFactory;
private ExecutionContext executionContext;
private SearchControls ctrls;
+ private int resultCount;
/**
* Constructor
@@ -323,16 +324,21 @@
return next();
}
+ if (result != null) {
+ resultCount++;
+ }
return result;
} catch (SizeLimitExceededException e) {
- LogManager.logWarning(LogConstants.CTX_CONNECTOR, "Search results exceeded size
limit. Results may be incomplete."); //$NON-NLS-1$
- searchEnumeration = null; // GHH 20080326 - NamingEnumartion's are no longer good
after an exception so toss it
+ if (resultCount != searchDetails.getCountLimit()) {
+ String msg = "LDAP Search results exceeded size limit. Results may be
incomplete."; //$NON-NLS-1$
+ if (executionFactory.isExceptionOnSizeLimitExceeded()) {
+ throw new TranslatorException(e, msg);
+ }
+ LogManager.logWarning(LogConstants.CTX_CONNECTOR, e, msg);
+ }
return null; // GHH 20080326 - if size limit exceeded don't try to read more
results
} catch (NamingException ne) {
- final String msg = "Ldap error while processing next batch of results: " +
ne.getExplanation(); //$NON-NLS-1$
- LogManager.logError(LogConstants.CTX_CONNECTOR, msg); // GHH 20080326 - changed to
output explanation from LDAP server
- searchEnumeration = null; // GHH 20080326 - NamingEnumertion's are no longer good
after an exception so toss it
- throw new TranslatorException(msg);
+ throw new TranslatorException(ne, "Ldap error while processing next batch of
results"); //$NON-NLS-1$
}
}
Modified: trunk/documentation/reference/src/main/docbook/en-US/content/translators.xml
===================================================================
---
trunk/documentation/reference/src/main/docbook/en-US/content/translators.xml 2011-10-27
17:05:18 UTC (rev 3591)
+++
trunk/documentation/reference/src/main/docbook/en-US/content/translators.xml 2011-10-27
19:27:00 UTC (rev 3592)
@@ -566,6 +566,11 @@
<entry>Use a PagedResultsControl to page through large
results. This is not supported by all directory servers.</entry>
<entry>false</entry>
</row>
+ <row>
+ <entry>ExceptionOnSizeLimitExceeded</entry>
+ <entry>Set to true to throw an exception when a
SizeLimitExceededException is received and a LIMIT is not properly
enforced.</entry>
+ <entry>false</entry>
+ </row>
</tbody>
</tgroup>
</table>
Show replies by date