IN PROGRESS - issue LDAP-4: Translate LDAP error codes
http://opensource.atlassian.com/projects/spring/browse/LDAP-4
This commit is contained in:
@@ -20,11 +20,9 @@ import javax.naming.directory.Attributes;
|
||||
import javax.naming.directory.BasicAttribute;
|
||||
import javax.naming.directory.BasicAttributes;
|
||||
|
||||
|
||||
import org.springframework.ldap.core.DirContextAdapter;
|
||||
import org.springframework.ldap.core.DistinguishedName;
|
||||
import org.springframework.ldap.core.LdapTemplate;
|
||||
import org.springframework.ldap.support.EntryNotFoundException;
|
||||
import org.springframework.test.AbstractDependencyInjectionSpringContextTests;
|
||||
|
||||
/**
|
||||
@@ -110,8 +108,8 @@ public class LdapTemplateBindUnbindITest extends
|
||||
private void verifyCleanup() {
|
||||
try {
|
||||
tested.lookup(DN);
|
||||
fail("EntryNotFoundException expected");
|
||||
} catch (EntryNotFoundException expected) {
|
||||
fail("NameNotFoundException expected");
|
||||
} catch (NameNotFoundException expected) {
|
||||
assertTrue(true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,19 +16,15 @@
|
||||
|
||||
package org.springframework.ldap;
|
||||
|
||||
import javax.naming.NamingException;
|
||||
import javax.naming.directory.Attributes;
|
||||
import javax.naming.directory.BasicAttribute;
|
||||
import javax.naming.directory.BasicAttributes;
|
||||
import javax.naming.directory.DirContext;
|
||||
import javax.naming.directory.ModificationItem;
|
||||
|
||||
|
||||
import org.springframework.dao.DataAccessException;
|
||||
import org.springframework.ldap.core.DirContextAdapter;
|
||||
import org.springframework.ldap.core.DistinguishedName;
|
||||
import org.springframework.ldap.core.LdapTemplate;
|
||||
import org.springframework.ldap.support.UncategorizedLdapException;
|
||||
import org.springframework.test.AbstractDependencyInjectionSpringContextTests;
|
||||
|
||||
/**
|
||||
@@ -49,6 +45,7 @@ public class LdapTemplateModifyITest extends
|
||||
private LdapTemplate tested;
|
||||
|
||||
private static String PERSON4_DN = "cn=Some Person4,ou=company1,c=Sweden";
|
||||
|
||||
private static String PERSON5_DN = "cn=Some Person5,ou=company1,c=Sweden";
|
||||
|
||||
protected String[] getConfigLocations() {
|
||||
@@ -70,10 +67,11 @@ public class LdapTemplateModifyITest extends
|
||||
"person" });
|
||||
adapter.setAttributeValue("cn", "Some Person5");
|
||||
adapter.setAttributeValue("sn", "Person5");
|
||||
adapter.setAttributeValues("description", new String[]{"qwe", "123", "rty", "uio"});
|
||||
adapter.setAttributeValues("description", new String[] { "qwe", "123",
|
||||
"rty", "uio" });
|
||||
|
||||
tested.bind(PERSON5_DN, adapter, null);
|
||||
|
||||
|
||||
}
|
||||
|
||||
protected void onTearDown() throws Exception {
|
||||
@@ -106,7 +104,8 @@ public class LdapTemplateModifyITest extends
|
||||
|
||||
tested.modifyAttributes(PERSON4_DN, mods);
|
||||
|
||||
DirContextAdapter result = (DirContextAdapter) tested.lookup(PERSON4_DN);
|
||||
DirContextAdapter result = (DirContextAdapter) tested
|
||||
.lookup(PERSON4_DN);
|
||||
String[] attributes = result.getStringAttributes("description");
|
||||
assertEquals(2, attributes.length);
|
||||
assertEquals("Some other description", attributes[0]);
|
||||
@@ -122,7 +121,8 @@ public class LdapTemplateModifyITest extends
|
||||
|
||||
tested.modifyAttributes(PERSON4_DN, mods);
|
||||
|
||||
DirContextAdapter result = (DirContextAdapter) tested.lookup(PERSON4_DN);
|
||||
DirContextAdapter result = (DirContextAdapter) tested
|
||||
.lookup(PERSON4_DN);
|
||||
String[] attributes = result.getStringAttributes("description");
|
||||
assertEquals(3, attributes.length);
|
||||
assertEquals("Some description", attributes[0]);
|
||||
@@ -138,8 +138,8 @@ public class LdapTemplateModifyITest extends
|
||||
|
||||
try {
|
||||
tested.modifyAttributes(PERSON4_DN, mods);
|
||||
fail("UncategorizedLdapException expected");
|
||||
} catch (UncategorizedLdapException expected) {
|
||||
fail("AttributeInUseException expected");
|
||||
} catch (AttributeInUseException expected) {
|
||||
// expected
|
||||
}
|
||||
}
|
||||
@@ -154,13 +154,14 @@ public class LdapTemplateModifyITest extends
|
||||
"Some other description", true); // ordered
|
||||
attr.add("Another description");
|
||||
// Commented out duplicate to make test work for Apache DS
|
||||
//attr.add("Some description");
|
||||
// attr.add("Some description");
|
||||
ModificationItem[] mods = new ModificationItem[1];
|
||||
mods[0] = new ModificationItem(DirContext.ADD_ATTRIBUTE, attr);
|
||||
|
||||
tested.modifyAttributes(PERSON4_DN, mods);
|
||||
|
||||
DirContextAdapter result = (DirContextAdapter) tested.lookup(PERSON4_DN);
|
||||
DirContextAdapter result = (DirContextAdapter) tested
|
||||
.lookup(PERSON4_DN);
|
||||
String[] attributes = result.getStringAttributes("description");
|
||||
assertEquals(3, attributes.length);
|
||||
assertEquals("Some description", attributes[0]);
|
||||
@@ -188,13 +189,15 @@ public class LdapTemplateModifyITest extends
|
||||
|
||||
verifyBoundCorrectData();
|
||||
}
|
||||
|
||||
public void testModifyAttributes_DirContextAdapter_MultiAttributes(){
|
||||
DirContextAdapter adapter = (DirContextAdapter) tested.lookup(PERSON5_DN);
|
||||
adapter.setAttributeValues("description", new String[]{"qwe", "123", "klytt", "kalle"});
|
||||
|
||||
|
||||
public void testModifyAttributes_DirContextAdapter_MultiAttributes() {
|
||||
DirContextAdapter adapter = (DirContextAdapter) tested
|
||||
.lookup(PERSON5_DN);
|
||||
adapter.setAttributeValues("description", new String[] { "qwe", "123",
|
||||
"klytt", "kalle" });
|
||||
|
||||
tested.modifyAttributes(PERSON5_DN, adapter.getModificationItems());
|
||||
|
||||
|
||||
// Verify
|
||||
adapter = (DirContextAdapter) tested.lookup(PERSON5_DN);
|
||||
String[] attributes = adapter.getStringAttributes("description");
|
||||
@@ -209,13 +212,10 @@ public class LdapTemplateModifyITest extends
|
||||
* Demonstrates how the DirContextAdapter can be used to automatically keep
|
||||
* track of changes of the attributes and deliver ModificationItems to use
|
||||
* in moifyAttributes().
|
||||
*
|
||||
* @throws NamingException
|
||||
* @throws DataAccessException
|
||||
*/
|
||||
public void testModifyAttributes_DirContextAdapter()
|
||||
throws DataAccessException, NamingException {
|
||||
DirContextAdapter adapter = (DirContextAdapter) tested.lookup(PERSON4_DN);
|
||||
public void testModifyAttributes_DirContextAdapter() throws Exception {
|
||||
DirContextAdapter adapter = (DirContextAdapter) tested
|
||||
.lookup(PERSON4_DN);
|
||||
|
||||
adapter.setAttributeValue("description", "Some other description");
|
||||
|
||||
@@ -238,7 +238,8 @@ public class LdapTemplateModifyITest extends
|
||||
}
|
||||
|
||||
private void verifyBoundCorrectData() {
|
||||
DirContextAdapter result = (DirContextAdapter) tested.lookup(PERSON4_DN);
|
||||
DirContextAdapter result = (DirContextAdapter) tested
|
||||
.lookup(PERSON4_DN);
|
||||
assertEquals("Some Person4", result.getStringAttribute("cn"));
|
||||
assertEquals("Person4", result.getStringAttribute("sn"));
|
||||
assertEquals("Some other description", result
|
||||
|
||||
@@ -19,7 +19,6 @@ package org.springframework.ldap;
|
||||
import org.springframework.ldap.core.DirContextAdapter;
|
||||
import org.springframework.ldap.core.LdapTemplate;
|
||||
import org.springframework.ldap.core.support.CountNameClassPairCallbackHandler;
|
||||
import org.springframework.ldap.support.EntryNotFoundException;
|
||||
import org.springframework.test.AbstractDependencyInjectionSpringContextTests;
|
||||
|
||||
/**
|
||||
@@ -88,8 +87,8 @@ public class LdapTemplateNoBaseSuffixITest extends
|
||||
try {
|
||||
tested
|
||||
.lookup("cn=Some Person4, ou=company1, c=Sweden, dc=jayway, dc=se");
|
||||
fail("EntryNotFoundException expected");
|
||||
} catch (EntryNotFoundException expected) {
|
||||
fail("NameNotFoundException expected");
|
||||
} catch (NameNotFoundException expected) {
|
||||
assertTrue(true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,7 +21,6 @@ import javax.naming.Name;
|
||||
import org.springframework.ldap.core.DirContextAdapter;
|
||||
import org.springframework.ldap.core.DistinguishedName;
|
||||
import org.springframework.ldap.core.LdapTemplate;
|
||||
import org.springframework.ldap.support.EntryNotFoundException;
|
||||
import org.springframework.test.AbstractDependencyInjectionSpringContextTests;
|
||||
|
||||
/**
|
||||
@@ -93,7 +92,7 @@ public class LdapTemplateRecursiveDeleteITest extends
|
||||
protected void onTearDown() throws Exception {
|
||||
try {
|
||||
tested.unbind(DN, true);
|
||||
} catch (EntryNotFoundException ignore) {
|
||||
} catch (NameNotFoundException ignore) {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
@@ -116,7 +115,7 @@ public class LdapTemplateRecursiveDeleteITest extends
|
||||
try {
|
||||
tested.lookup(dn);
|
||||
fail("Expected entry '" + dn + "' to be non-existent");
|
||||
} catch (EntryNotFoundException expected) {
|
||||
} catch (NameNotFoundException expected) {
|
||||
// expected
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,11 +18,9 @@ package org.springframework.ldap;
|
||||
|
||||
import javax.naming.Name;
|
||||
|
||||
|
||||
import org.springframework.ldap.core.DirContextAdapter;
|
||||
import org.springframework.ldap.core.DistinguishedName;
|
||||
import org.springframework.ldap.core.LdapTemplate;
|
||||
import org.springframework.ldap.support.EntryNotFoundException;
|
||||
import org.springframework.test.AbstractDependencyInjectionSpringContextTests;
|
||||
|
||||
/**
|
||||
@@ -82,7 +80,7 @@ public class LdapTemplateRenameITest extends
|
||||
try {
|
||||
tested.lookup(dn);
|
||||
fail("Expected entry '" + dn + "' to be non-existent");
|
||||
} catch (EntryNotFoundException expected) {
|
||||
} catch (NameNotFoundException expected) {
|
||||
// expected
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,16 +16,13 @@
|
||||
|
||||
package org.springframework.ldap;
|
||||
|
||||
import org.springframework.dao.InvalidDataAccessResourceUsageException;
|
||||
|
||||
/**
|
||||
* Thrown to indicate that an invalid value has been supplied to an LDAP
|
||||
* operation. This could be an invalid filter or dn.
|
||||
*
|
||||
* @author Mattias Arthursson
|
||||
*/
|
||||
public class BadLdapGrammarException extends
|
||||
InvalidDataAccessResourceUsageException {
|
||||
public class BadLdapGrammarException extends NamingException {
|
||||
|
||||
private static final long serialVersionUID = 961612585331409470L;
|
||||
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Copyright 2002-2006 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.ldap.control;
|
||||
|
||||
import org.springframework.ldap.NamingException;
|
||||
|
||||
/**
|
||||
* Thrown by an AbstractRequestControlDirContextProcessor when it cannot create
|
||||
* a request control.
|
||||
*
|
||||
* @author Ulrik Sandberg
|
||||
* @since 1.2
|
||||
*/
|
||||
public class CreateControlFailedException extends NamingException {
|
||||
|
||||
/**
|
||||
* Create a new CreateControlFailedException.
|
||||
*
|
||||
* @param msg
|
||||
* the detail message
|
||||
*/
|
||||
public CreateControlFailedException(String msg) {
|
||||
super(msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new CreateControlFailedException.
|
||||
*
|
||||
* @param msg
|
||||
* the detail message
|
||||
* @param cause
|
||||
* the root cause (if any)
|
||||
*/
|
||||
public CreateControlFailedException(String msg, Throwable cause) {
|
||||
super(msg, cause);
|
||||
}
|
||||
}
|
||||
@@ -25,7 +25,6 @@ import javax.naming.directory.DirContext;
|
||||
import javax.naming.ldap.Control;
|
||||
import javax.naming.ldap.LdapContext;
|
||||
|
||||
import org.springframework.ldap.support.UncategorizedLdapException;
|
||||
import org.springframework.util.ReflectionUtils;
|
||||
|
||||
import com.sun.jndi.ldap.ctl.PagedResultsControl;
|
||||
@@ -103,7 +102,7 @@ public class PagedResultsRequestControl extends
|
||||
return new PagedResultsControl(pageSize);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new UncategorizedLdapException(
|
||||
throw new CreateControlFailedException(
|
||||
"Error creating PagedResultsControl", e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,8 +46,7 @@ import org.apache.commons.lang.builder.EqualsBuilder;
|
||||
import org.apache.commons.lang.builder.HashCodeBuilder;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.ldap.support.DefaultNamingExceptionTranslator;
|
||||
import org.springframework.ldap.support.NamingExceptionTranslator;
|
||||
import org.springframework.ldap.support.LdapUtils;
|
||||
|
||||
/**
|
||||
* Implements the interesting methods of the DirContext interface. In particular
|
||||
@@ -80,8 +79,6 @@ public class DirContextAdapter implements DirContextOperations {
|
||||
|
||||
private Attributes updatedAttrs;
|
||||
|
||||
private NamingExceptionTranslator exceptionTranslator;
|
||||
|
||||
/**
|
||||
* Default constructor.
|
||||
*/
|
||||
@@ -195,7 +192,7 @@ public class DirContextAdapter implements DirContextOperations {
|
||||
tmpList.add(oneAttribute.getID());
|
||||
}
|
||||
} catch (NamingException e) {
|
||||
throw getExceptionTranslator().translate(e);
|
||||
throw LdapUtils.convertLdapException(e);
|
||||
} finally {
|
||||
closeNamingEnumeration(attributesEnumeration);
|
||||
}
|
||||
@@ -233,7 +230,7 @@ public class DirContextAdapter implements DirContextOperations {
|
||||
collectModifications(oneAttr, tmpList);
|
||||
}
|
||||
} catch (NamingException e) {
|
||||
throw getExceptionTranslator().translate(e);
|
||||
throw LdapUtils.convertLdapException(e);
|
||||
} finally {
|
||||
closeNamingEnumeration(attributesEnumeration);
|
||||
}
|
||||
@@ -573,7 +570,7 @@ public class DirContextAdapter implements DirContextOperations {
|
||||
try {
|
||||
return oneAttr.get();
|
||||
} catch (NamingException e) {
|
||||
throw getExceptionTranslator().translate(e);
|
||||
throw LdapUtils.convertLdapException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -651,7 +648,7 @@ public class DirContextAdapter implements DirContextOperations {
|
||||
}
|
||||
}
|
||||
} catch (NamingException e) {
|
||||
throw getExceptionTranslator().translate(e);
|
||||
throw LdapUtils.convertLdapException(e);
|
||||
} finally {
|
||||
closeNamingEnumeration(attributesEnumeration);
|
||||
}
|
||||
@@ -673,7 +670,7 @@ public class DirContextAdapter implements DirContextOperations {
|
||||
try {
|
||||
attributes[i] = (String) attribute.get(i);
|
||||
} catch (NamingException e) {
|
||||
throw getExceptionTranslator().translate(e);
|
||||
throw LdapUtils.convertLdapException(e);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -695,7 +692,7 @@ public class DirContextAdapter implements DirContextOperations {
|
||||
try {
|
||||
attrSet.add(attribute.get(i));
|
||||
} catch (NamingException e) {
|
||||
throw getExceptionTranslator().translate(e);
|
||||
throw LdapUtils.convertLdapException(e);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -1248,28 +1245,4 @@ public class DirContextAdapter implements DirContextOperations {
|
||||
return buf.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the NamingExceptionTranslator.
|
||||
*
|
||||
* @return the NamingExceptionTranslator to use; if none is specified,
|
||||
* {@link DefaultNamingExceptionTranslator} is used.
|
||||
*/
|
||||
public NamingExceptionTranslator getExceptionTranslator() {
|
||||
if (exceptionTranslator == null) {
|
||||
exceptionTranslator = new DefaultNamingExceptionTranslator();
|
||||
}
|
||||
return exceptionTranslator;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the NamingExceptionTranslator to use.
|
||||
*
|
||||
* @param exceptionTranslator
|
||||
* the NamingExceptionTranslator to use.
|
||||
*/
|
||||
public void setExceptionTranslator(
|
||||
NamingExceptionTranslator exceptionTranslator) {
|
||||
this.exceptionTranslator = exceptionTranslator;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -25,8 +25,8 @@ import javax.naming.directory.Attributes;
|
||||
import javax.naming.directory.ModificationItem;
|
||||
import javax.naming.directory.SearchControls;
|
||||
|
||||
import org.springframework.dao.DataAccessException;
|
||||
import org.springframework.dao.DataIntegrityViolationException;
|
||||
import org.springframework.ldap.ContextNotEmptyException;
|
||||
import org.springframework.ldap.NamingException;
|
||||
|
||||
/**
|
||||
* Interface that specifies a basic set of LDAP operations. Implemented by
|
||||
@@ -54,13 +54,13 @@ public interface LdapOperations {
|
||||
* will be passed.
|
||||
* @param processor
|
||||
* DirContextProcessor for custom pre- and post-processing.
|
||||
* @throws DataAccessException
|
||||
* @throws NamingException
|
||||
* if any error occurs. Note that a NameNotFoundException will
|
||||
* be ignored. Instead this is interpreted as no entries being
|
||||
* found.
|
||||
*/
|
||||
public void search(SearchExecutor se, NameClassPairCallbackHandler handler,
|
||||
DirContextProcessor processor) throws DataAccessException;
|
||||
DirContextProcessor processor) throws NamingException;
|
||||
|
||||
/**
|
||||
* Perform a search. Use this method only if especially needed - for the
|
||||
@@ -77,13 +77,13 @@ public interface LdapOperations {
|
||||
* @param handler
|
||||
* The NameClassPairCallbackHandler to which each found entry
|
||||
* will be passed.
|
||||
* @throws DataAccessException
|
||||
* @throws NamingException
|
||||
* if any error occurs. Note that a NameNotFoundException will
|
||||
* be ignored. Instead this is interpreted as no entries being
|
||||
* found.
|
||||
*/
|
||||
public void search(SearchExecutor se, NameClassPairCallbackHandler handler)
|
||||
throws DataAccessException;
|
||||
throws NamingException;
|
||||
|
||||
/**
|
||||
* Perform an operation (or series of operations) on a read-only context.
|
||||
@@ -97,11 +97,10 @@ public interface LdapOperations {
|
||||
* The ContextExecutor to which the actual operation on the
|
||||
* DirContext will be delegated.
|
||||
* @return the result from the ContextExecutor's operation.
|
||||
* @throws DataAccessException
|
||||
* @throws NamingException
|
||||
* if the operation resulted in a NamingException.
|
||||
*/
|
||||
public Object executeReadOnly(ContextExecutor ce)
|
||||
throws DataAccessException;
|
||||
public Object executeReadOnly(ContextExecutor ce) throws NamingException;
|
||||
|
||||
/**
|
||||
* Perform an operation (or series of operations) on a read-write context.
|
||||
@@ -112,11 +111,10 @@ public interface LdapOperations {
|
||||
* The ContextExecutor to which the actual operation on the
|
||||
* DirContext will be delegated.
|
||||
* @return the result from the ContextExecutor's operation.
|
||||
* @throws DataAccessException
|
||||
* @throws NamingException
|
||||
* if the operation resulted in a NamingException.
|
||||
*/
|
||||
public Object executeReadWrite(ContextExecutor ce)
|
||||
throws DataAccessException;
|
||||
public Object executeReadWrite(ContextExecutor ce) throws NamingException;
|
||||
|
||||
/**
|
||||
* Search for all objects matching the supplied filter. Each SearchResult is
|
||||
@@ -134,9 +132,13 @@ public interface LdapOperations {
|
||||
* @param handler
|
||||
* The NameClassPairCallbackHandler to supply the SearchResults
|
||||
* to.
|
||||
* @throws NamingException
|
||||
* if any error occurs. Note that a NameNotFoundException will
|
||||
* be ignored. Instead this is interpreted that no entries were
|
||||
* found.
|
||||
*/
|
||||
public void search(Name base, String filter, SearchControls controls,
|
||||
NameClassPairCallbackHandler handler);
|
||||
NameClassPairCallbackHandler handler) throws NamingException;
|
||||
|
||||
/**
|
||||
* Search for all objects matching the supplied filter. See
|
||||
@@ -152,9 +154,13 @@ public interface LdapOperations {
|
||||
* @param handler
|
||||
* The NameClassPairCallbackHandler to supply the SearchResults
|
||||
* to.
|
||||
* @throws NamingException
|
||||
* if any error occurs. Note that a NameNotFoundException will
|
||||
* be ignored. Instead this is interpreted that no entries were
|
||||
* found.
|
||||
*/
|
||||
public void search(String base, String filter, SearchControls controls,
|
||||
NameClassPairCallbackHandler handler);
|
||||
NameClassPairCallbackHandler handler) throws NamingException;
|
||||
|
||||
/**
|
||||
* Search for all objects matching the supplied filter. Each SearchResult is
|
||||
@@ -175,9 +181,14 @@ public interface LdapOperations {
|
||||
* to.
|
||||
* @param processor
|
||||
* The DirContextProcessor to use before and after the search.
|
||||
* @throws NamingException
|
||||
* if any error occurs. Note that a NameNotFoundException will
|
||||
* be ignored. Instead this is interpreted that no entries were
|
||||
* found.
|
||||
*/
|
||||
public void search(Name base, String filter, SearchControls controls,
|
||||
NameClassPairCallbackHandler handler, DirContextProcessor processor);
|
||||
NameClassPairCallbackHandler handler, DirContextProcessor processor)
|
||||
throws NamingException;
|
||||
|
||||
/**
|
||||
* Search for all objects matching the supplied filter. The Attributes in
|
||||
@@ -197,13 +208,14 @@ public interface LdapOperations {
|
||||
* @param processor
|
||||
* The DirContextProcessor to use before and after the search.
|
||||
* @return a List containing all entries received from the AttributesMapper.
|
||||
* @throws DataAccessException
|
||||
* @throws NamingException
|
||||
* if any error occurs. Note that a NameNotFoundException will
|
||||
* be ignored. Instead this is interpreted that no entries were
|
||||
* found.
|
||||
*/
|
||||
public List search(String base, String filter, SearchControls controls,
|
||||
AttributesMapper mapper, DirContextProcessor processor);
|
||||
AttributesMapper mapper, DirContextProcessor processor)
|
||||
throws NamingException;
|
||||
|
||||
/**
|
||||
* Search for all objects matching the supplied filter. The Attributes in
|
||||
@@ -223,13 +235,14 @@ public interface LdapOperations {
|
||||
* @param processor
|
||||
* The DirContextProcessor to use before and after the search.
|
||||
* @return a List containing all entries received from the AttributesMapper.
|
||||
* @throws DataAccessException
|
||||
* @throws NamingException
|
||||
* if any error occurs. Note that a NameNotFoundException will
|
||||
* be ignored. Instead this is interpreted that no entries were
|
||||
* found.
|
||||
*/
|
||||
public List search(Name base, String filter, SearchControls controls,
|
||||
AttributesMapper mapper, DirContextProcessor processor);
|
||||
AttributesMapper mapper, DirContextProcessor processor)
|
||||
throws NamingException;
|
||||
|
||||
/**
|
||||
* Search for all objects matching the supplied filter. The Object returned
|
||||
@@ -252,13 +265,14 @@ public interface LdapOperations {
|
||||
* @param processor
|
||||
* The DirContextProcessor to use before and after the search.
|
||||
* @return a List containing all entries received from the ContextMapper.
|
||||
* @throws DataAccessException
|
||||
* @throws NamingException
|
||||
* if any error occurs. Note that a NameNotFoundException will
|
||||
* be ignored. Instead this is interpreted that no entries were
|
||||
* found.
|
||||
*/
|
||||
public List search(String base, String filter, SearchControls controls,
|
||||
ContextMapper mapper, DirContextProcessor processor);
|
||||
ContextMapper mapper, DirContextProcessor processor)
|
||||
throws NamingException;
|
||||
|
||||
/**
|
||||
* Search for all objects matching the supplied filter. The Object returned
|
||||
@@ -281,13 +295,14 @@ public interface LdapOperations {
|
||||
* @param processor
|
||||
* The DirContextProcessor to use before and after the search.
|
||||
* @return a List containing all entries received from the ContextMapper.
|
||||
* @throws DataAccessException
|
||||
* @throws NamingException
|
||||
* if any error occurs. Note that a NameNotFoundException will
|
||||
* be ignored. Instead this is interpreted that no entries were
|
||||
* found.
|
||||
*/
|
||||
public List search(Name base, String filter, SearchControls controls,
|
||||
ContextMapper mapper, DirContextProcessor processor);
|
||||
ContextMapper mapper, DirContextProcessor processor)
|
||||
throws NamingException;
|
||||
|
||||
/**
|
||||
* Search for all objects matching the supplied filter. See
|
||||
@@ -305,9 +320,14 @@ public interface LdapOperations {
|
||||
* to.
|
||||
* @param processor
|
||||
* The DirContextProcessor to use before and after the search.
|
||||
* @throws NamingException
|
||||
* if any error occurs. Note that a NameNotFoundException will
|
||||
* be ignored. Instead this is interpreted that no entries were
|
||||
* found.
|
||||
*/
|
||||
public void search(String base, String filter, SearchControls controls,
|
||||
NameClassPairCallbackHandler handler, DirContextProcessor processor);
|
||||
NameClassPairCallbackHandler handler, DirContextProcessor processor)
|
||||
throws NamingException;
|
||||
|
||||
/**
|
||||
* Search for all objects matching the supplied filter. Each SearchResult is
|
||||
@@ -326,14 +346,14 @@ public interface LdapOperations {
|
||||
* @param handler
|
||||
* The NameClassPairCallbackHandler to supply the SearchResults
|
||||
* to.
|
||||
* @throws DataAccessException
|
||||
* @throws NamingException
|
||||
* if any error occurs. Note that a NameNotFoundException will
|
||||
* be ignored. Instead this is interpreted that no entries were
|
||||
* found.
|
||||
*/
|
||||
public void search(Name base, String filter, int searchScope,
|
||||
boolean returningObjFlag, NameClassPairCallbackHandler handler)
|
||||
throws DataAccessException;
|
||||
throws NamingException;
|
||||
|
||||
/**
|
||||
* Search for all objects matching the supplied filter. Each SearchResult is
|
||||
@@ -351,14 +371,14 @@ public interface LdapOperations {
|
||||
* @param handler
|
||||
* The NameClassPairCallbackHandler to supply the SearchResults
|
||||
* to.
|
||||
* @throws DataAccessException
|
||||
* @throws NamingException
|
||||
* if any error occurs. Note that a NameNotFoundException will
|
||||
* be ignored. Instead this is interpreted that no entries were
|
||||
* found.
|
||||
*/
|
||||
public void search(String base, String filter, int searchScope,
|
||||
boolean returningObjFlag, NameClassPairCallbackHandler handler)
|
||||
throws DataAccessException;
|
||||
throws NamingException;
|
||||
|
||||
/**
|
||||
* Search for all objects matching the supplied filter. Each SearchResult is
|
||||
@@ -373,13 +393,13 @@ public interface LdapOperations {
|
||||
* @param handler
|
||||
* The NameClassPairCallbackHandler to supply the SearchResults
|
||||
* to.
|
||||
* @throws DataAccessException
|
||||
* @throws NamingException
|
||||
* if any error occurs. Note that a NameNotFoundException will
|
||||
* be ignored. Instead this is interpreted that no entries were
|
||||
* found.
|
||||
*/
|
||||
public void search(Name base, String filter,
|
||||
NameClassPairCallbackHandler handler) throws DataAccessException;
|
||||
NameClassPairCallbackHandler handler) throws NamingException;
|
||||
|
||||
/**
|
||||
* Search for all objects matching the supplied filter. Each SearchResult is
|
||||
@@ -394,13 +414,13 @@ public interface LdapOperations {
|
||||
* @param handler
|
||||
* The NameClassPairCallbackHandler to supply the SearchResults
|
||||
* to.
|
||||
* @throws DataAccessException
|
||||
* @throws NamingException
|
||||
* if any error occurs. Note that a NameNotFoundException will
|
||||
* be ignored. Instead this is interpreted that no entries were
|
||||
* found.
|
||||
*/
|
||||
public void search(String base, String filter,
|
||||
NameClassPairCallbackHandler handler) throws DataAccessException;
|
||||
NameClassPairCallbackHandler handler) throws NamingException;
|
||||
|
||||
/**
|
||||
* Search for all objects matching the supplied filter. Only search for the
|
||||
@@ -418,13 +438,13 @@ public interface LdapOperations {
|
||||
* @param mapper
|
||||
* The AttributesMapper to use for translating each entry.
|
||||
* @return a List containing all entries received from the AttributesMapper.
|
||||
* @throws DataAccessException
|
||||
* @throws NamingException
|
||||
* if any error occurs. Note that a NameNotFoundException will
|
||||
* be ignored. Instead this is interpreted that no entries were
|
||||
* found.
|
||||
*/
|
||||
public List search(Name base, String filter, int searchScope,
|
||||
String[] attrs, AttributesMapper mapper) throws DataAccessException;
|
||||
String[] attrs, AttributesMapper mapper) throws NamingException;
|
||||
|
||||
/**
|
||||
* Search for all objects matching the supplied filter. Only search for the
|
||||
@@ -442,13 +462,13 @@ public interface LdapOperations {
|
||||
* @param mapper
|
||||
* The AttributesMapper to use for translating each entry.
|
||||
* @return a List containing all entries received from the AttributesMapper.
|
||||
* @throws DataAccessException
|
||||
* @throws NamingException
|
||||
* if any error occurs. Note that a NameNotFoundException will
|
||||
* be ignored. Instead this is interpreted that no entries were
|
||||
* found.
|
||||
*/
|
||||
public List search(String base, String filter, int searchScope,
|
||||
String[] attrs, AttributesMapper mapper) throws DataAccessException;
|
||||
String[] attrs, AttributesMapper mapper) throws NamingException;
|
||||
|
||||
/**
|
||||
* Search for all objects matching the supplied filter. The Attributes in
|
||||
@@ -463,13 +483,13 @@ public interface LdapOperations {
|
||||
* @param mapper
|
||||
* The AttributesMapper to use for translating each entry.
|
||||
* @return a List containing all entries received from the AttributesMapper.
|
||||
* @throws DataAccessException
|
||||
* @throws NamingException
|
||||
* if any error occurs. Note that a NameNotFoundException will
|
||||
* be ignored. Instead this is interpreted that no entries were
|
||||
* found.
|
||||
*/
|
||||
public List search(Name base, String filter, int searchScope,
|
||||
AttributesMapper mapper) throws DataAccessException;
|
||||
AttributesMapper mapper) throws NamingException;
|
||||
|
||||
/**
|
||||
* Search for all objects matching the supplied filter. The Attributes in
|
||||
@@ -484,13 +504,13 @@ public interface LdapOperations {
|
||||
* @param mapper
|
||||
* The AttributesMapper to use for translating each entry.
|
||||
* @return a List containing all entries received from the AttributesMapper.
|
||||
* @throws DataAccessException
|
||||
* @throws NamingException
|
||||
* if any error occurs. Note that a NameNotFoundException will
|
||||
* be ignored. Instead this is interpreted that no entries were
|
||||
* found.
|
||||
*/
|
||||
public List search(String base, String filter, int searchScope,
|
||||
AttributesMapper mapper) throws DataAccessException;
|
||||
AttributesMapper mapper) throws NamingException;
|
||||
|
||||
/**
|
||||
* Search for all objects matching the supplied filter. The Attributes in
|
||||
@@ -504,13 +524,13 @@ public interface LdapOperations {
|
||||
* @param mapper
|
||||
* The AttributesMapper to use for translating each entry.
|
||||
* @return a List containing all entries received from the AttributesMapper.
|
||||
* @throws DataAccessException
|
||||
* @throws NamingException
|
||||
* if any error occurs. Note that a NameNotFoundException will
|
||||
* be ignored. Instead this is interpreted that no entries were
|
||||
* found.
|
||||
*/
|
||||
public List search(Name base, String filter, AttributesMapper mapper)
|
||||
throws DataAccessException;
|
||||
throws NamingException;
|
||||
|
||||
/**
|
||||
* Search for all objects matching the supplied filter. The Attributes in
|
||||
@@ -524,13 +544,13 @@ public interface LdapOperations {
|
||||
* @param mapper
|
||||
* The AttributesMapper to use for translating each entry.
|
||||
* @return a List containing all entries received from the AttributesMapper.
|
||||
* @throws DataAccessException
|
||||
* @throws NamingException
|
||||
* if any error occurs. Note that a NameNotFoundException will
|
||||
* be ignored. Instead this is interpreted that no entries were
|
||||
* found.
|
||||
*/
|
||||
public List search(String base, String filter, AttributesMapper mapper)
|
||||
throws DataAccessException;
|
||||
throws NamingException;
|
||||
|
||||
/**
|
||||
* Search for all objects matching the supplied filter. The Object returned
|
||||
@@ -548,13 +568,13 @@ public interface LdapOperations {
|
||||
* @param mapper
|
||||
* The ContextMapper to use for translating each entry.
|
||||
* @return a List containing all entries received from the ContextMapper.
|
||||
* @throws DataAccessException
|
||||
* @throws NamingException
|
||||
* if any error occurs. Note that a NameNotFoundException will
|
||||
* be ignored. Instead this is interpreted that no entries were
|
||||
* found.
|
||||
*/
|
||||
public List search(Name base, String filter, int searchScope,
|
||||
String[] attrs, ContextMapper mapper) throws DataAccessException;
|
||||
String[] attrs, ContextMapper mapper) throws NamingException;
|
||||
|
||||
/**
|
||||
* Search for all objects matching the supplied filter. The Object returned
|
||||
@@ -572,13 +592,13 @@ public interface LdapOperations {
|
||||
* @param mapper
|
||||
* The ContextMapper to use for translating each entry.
|
||||
* @return a List containing all entries received from the ContextMapper.
|
||||
* @throws DataAccessException
|
||||
* @throws NamingException
|
||||
* if any error occurs. Note that a NameNotFoundException will
|
||||
* be ignored. Instead this is interpreted that no entries were
|
||||
* found.
|
||||
*/
|
||||
public List search(String base, String filter, int searchScope,
|
||||
String[] attrs, ContextMapper mapper) throws DataAccessException;
|
||||
String[] attrs, ContextMapper mapper) throws NamingException;
|
||||
|
||||
/**
|
||||
* Search for all objects matching the supplied filter. The Object returned
|
||||
@@ -593,13 +613,13 @@ public interface LdapOperations {
|
||||
* @param mapper
|
||||
* The ContextMapper to use for translating each entry.
|
||||
* @return a List containing all entries received from the ContextMapper.
|
||||
* @throws DataAccessException
|
||||
* @throws NamingException
|
||||
* if any error occurs. Note that a NameNotFoundException will
|
||||
* be ignored. Instead this is interpreted that no entries were
|
||||
* found.
|
||||
*/
|
||||
public List search(Name base, String filter, int searchScope,
|
||||
ContextMapper mapper) throws DataAccessException;
|
||||
ContextMapper mapper) throws NamingException;
|
||||
|
||||
/**
|
||||
* Search for all objects matching the supplied filter. The Object returned
|
||||
@@ -614,13 +634,13 @@ public interface LdapOperations {
|
||||
* @param mapper
|
||||
* The ContextMapper to use for translating each entry.
|
||||
* @return a List containing all entries received from the ContextMapper.
|
||||
* @throws DataAccessException
|
||||
* @throws NamingException
|
||||
* if any error occurs. Note that a NameNotFoundException will
|
||||
* be ignored. Instead this is interpreted that no entries were
|
||||
* found.
|
||||
*/
|
||||
public List search(String base, String filter, int searchScope,
|
||||
ContextMapper mapper) throws DataAccessException;
|
||||
ContextMapper mapper) throws NamingException;
|
||||
|
||||
/**
|
||||
* Search for all objects matching the supplied filter. The Object returned
|
||||
@@ -634,13 +654,13 @@ public interface LdapOperations {
|
||||
* @param mapper
|
||||
* The ContextMapper to use for translating each entry.
|
||||
* @return a List containing all entries received from the ContextMapper.
|
||||
* @throws DataAccessException
|
||||
* @throws NamingException
|
||||
* if any error occurs. Note that a NameNotFoundException will
|
||||
* be ignored. Instead this is interpreted that no entries were
|
||||
* found.
|
||||
*/
|
||||
public List search(Name base, String filter, ContextMapper mapper)
|
||||
throws DataAccessException;
|
||||
throws NamingException;
|
||||
|
||||
/**
|
||||
* Search for all objects matching the supplied filter. The Object returned
|
||||
@@ -654,13 +674,13 @@ public interface LdapOperations {
|
||||
* @param mapper
|
||||
* The ContextMapper to use for translating each entry.
|
||||
* @return a List containing all entries received from the ContextMapper.
|
||||
* @throws DataAccessException
|
||||
* @throws NamingException
|
||||
* if any error occurs. Note that a NameNotFoundException will
|
||||
* be ignored. Instead this is interpreted that no entries were
|
||||
* found.
|
||||
*/
|
||||
public List search(String base, String filter, ContextMapper mapper)
|
||||
throws DataAccessException;
|
||||
throws NamingException;
|
||||
|
||||
/**
|
||||
* Search for all objects matching the supplied filter. The Object returned
|
||||
@@ -678,13 +698,13 @@ public interface LdapOperations {
|
||||
* @param mapper
|
||||
* The ContextMapper to use for translating each entry.
|
||||
* @return a List containing all entries received from the ContextMapper.
|
||||
* @throws DataAccessException
|
||||
* @throws NamingException
|
||||
* if any error occurs. Note that a NameNotFoundException will
|
||||
* be ignored. Instead this is interpreted that no entries were
|
||||
* found.
|
||||
*/
|
||||
public List search(String base, String filter, SearchControls controls,
|
||||
ContextMapper mapper) throws DataAccessException;
|
||||
ContextMapper mapper) throws NamingException;
|
||||
|
||||
/**
|
||||
* Search for all objects matching the supplied filter. The Object returned
|
||||
@@ -702,13 +722,13 @@ public interface LdapOperations {
|
||||
* @param mapper
|
||||
* The ContextMapper to use for translating each entry.
|
||||
* @return a List containing all entries received from the ContextMapper.
|
||||
* @throws DataAccessException
|
||||
* @throws NamingException
|
||||
* if any error occurs. Note that a NameNotFoundException will
|
||||
* be ignored. Instead this is interpreted that no entries were
|
||||
* found.
|
||||
*/
|
||||
public List search(Name base, String filter, SearchControls controls,
|
||||
ContextMapper mapper) throws DataAccessException;
|
||||
ContextMapper mapper) throws NamingException;
|
||||
|
||||
/**
|
||||
* Search for all objects matching the supplied filter. The Object returned
|
||||
@@ -723,13 +743,13 @@ public interface LdapOperations {
|
||||
* @param mapper
|
||||
* The AttributesMapper to use for translating each entry.
|
||||
* @return a List containing all entries received from the ContextMapper.
|
||||
* @throws DataAccessException
|
||||
* @throws NamingException
|
||||
* if any error occurs. Note that a NameNotFoundException will
|
||||
* be ignored. Instead this is interpreted that no entries were
|
||||
* found.
|
||||
*/
|
||||
public List search(String base, String filter, SearchControls controls,
|
||||
AttributesMapper mapper) throws DataAccessException;
|
||||
AttributesMapper mapper) throws NamingException;
|
||||
|
||||
/**
|
||||
* Search for all objects matching the supplied filter. The Object returned
|
||||
@@ -744,13 +764,13 @@ public interface LdapOperations {
|
||||
* @param mapper
|
||||
* The AttributesMapper to use for translating each entry.
|
||||
* @return a List containing all entries received from the ContextMapper.
|
||||
* @throws DataAccessException
|
||||
* @throws NamingException
|
||||
* if any error occurs. Note that a NameNotFoundException will
|
||||
* be ignored. Instead this is interpreted that no entries were
|
||||
* found.
|
||||
*/
|
||||
public List search(Name base, String filter, SearchControls controls,
|
||||
AttributesMapper mapper) throws DataAccessException;
|
||||
AttributesMapper mapper) throws NamingException;
|
||||
|
||||
/**
|
||||
* Perform a non-recursive listing of the children of the given
|
||||
@@ -762,13 +782,13 @@ public interface LdapOperations {
|
||||
* @param handler
|
||||
* The NameClassPairCallbackHandler to supply each
|
||||
* {@link NameClassPair} to.
|
||||
* @throws DataAccessException
|
||||
* @throws NamingException
|
||||
* if any error occurs. Note that a NameNotFoundException will
|
||||
* be ignored. Instead this is interpreted that no entries were
|
||||
* found.
|
||||
*/
|
||||
public void list(String base, NameClassPairCallbackHandler handler)
|
||||
throws DataAccessException;
|
||||
throws NamingException;
|
||||
|
||||
/**
|
||||
* Perform a non-recursive listing of the children of the given
|
||||
@@ -780,13 +800,13 @@ public interface LdapOperations {
|
||||
* @param handler
|
||||
* The NameClassPairCallbackHandler to supply each
|
||||
* {@link NameClassPair} to.
|
||||
* @throws DataAccessException
|
||||
* @throws NamingException
|
||||
* if any error occurs. Note that a NameNotFoundException will
|
||||
* be ignored. Instead this is interpreted that no entries were
|
||||
* found.
|
||||
*/
|
||||
public void list(Name base, NameClassPairCallbackHandler handler)
|
||||
throws DataAccessException;
|
||||
throws NamingException;
|
||||
|
||||
/**
|
||||
* Perform a non-recursive listing of the children of the given
|
||||
@@ -800,13 +820,13 @@ public interface LdapOperations {
|
||||
* The NameClassPairMapper to supply each {@link NameClassPair}
|
||||
* to.
|
||||
* @return a List containing the Objects returned from the Mapper.
|
||||
* @throws DataAccessException
|
||||
* @throws NamingException
|
||||
* if any error occurs. Note that a NameNotFoundException will
|
||||
* be ignored. Instead this is interpreted that no entries were
|
||||
* found.
|
||||
*/
|
||||
public List list(String base, NameClassPairMapper mapper)
|
||||
throws DataAccessException;
|
||||
throws NamingException;
|
||||
|
||||
/**
|
||||
* Perform a non-recursive listing of the children of the given
|
||||
@@ -820,13 +840,13 @@ public interface LdapOperations {
|
||||
* The NameClassPairMapper to supply each {@link NameClassPair}
|
||||
* to.
|
||||
* @return a List containing the Objects returned from the Mapper.
|
||||
* @throws DataAccessException
|
||||
* @throws NamingException
|
||||
* if any error occurs. Note that a NameNotFoundException will
|
||||
* be ignored. Instead this is interpreted that no entries were
|
||||
* found.
|
||||
*/
|
||||
public List list(Name base, NameClassPairMapper mapper)
|
||||
throws DataAccessException;
|
||||
throws NamingException;
|
||||
|
||||
/**
|
||||
* Perform a non-recursive listing of the children of the given
|
||||
@@ -836,12 +856,12 @@ public interface LdapOperations {
|
||||
* The base DN where the list should be performed.
|
||||
* @return a List containing the names of all the contexts bound to
|
||||
* <code>base</code>.
|
||||
* @throws DataAccessException
|
||||
* @throws NamingException
|
||||
* if any error occurs. Note that a NameNotFoundException will
|
||||
* be ignored. Instead this is interpreted that no entries were
|
||||
* found.
|
||||
*/
|
||||
public List list(String base) throws DataAccessException;
|
||||
public List list(String base) throws NamingException;
|
||||
|
||||
/**
|
||||
* Perform a non-recursive listing of the contexts bound to the given
|
||||
@@ -851,12 +871,12 @@ public interface LdapOperations {
|
||||
* The base DN where the list should be performed.
|
||||
* @return a List containing the names of all the contexts bound to
|
||||
* <code>base</code>.
|
||||
* @throws DataAccessException
|
||||
* @throws NamingException
|
||||
* if any error occurs. Note that a NameNotFoundException will
|
||||
* be ignored. Instead this is interpreted that no entries were
|
||||
* found.
|
||||
*/
|
||||
public List list(Name base) throws DataAccessException;
|
||||
public List list(Name base) throws NamingException;
|
||||
|
||||
/**
|
||||
* Perform a non-recursive listing of the children of the given
|
||||
@@ -868,13 +888,13 @@ public interface LdapOperations {
|
||||
* @param handler
|
||||
* The NameClassPairCallbackHandler to supply each
|
||||
* {@link Binding} to.
|
||||
* @throws DataAccessException
|
||||
* @throws NamingException
|
||||
* if any error occurs. Note that a NameNotFoundException will
|
||||
* be ignored. Instead this is interpreted that no entries were
|
||||
* found.
|
||||
*/
|
||||
public void listBindings(final String base,
|
||||
NameClassPairCallbackHandler handler) throws DataAccessException;
|
||||
NameClassPairCallbackHandler handler) throws NamingException;
|
||||
|
||||
/**
|
||||
* Perform a non-recursive listing of the children of the given
|
||||
@@ -886,13 +906,13 @@ public interface LdapOperations {
|
||||
* @param handler
|
||||
* The NameClassPairCallbackHandler to supply each
|
||||
* {@link Binding} to.
|
||||
* @throws DataAccessException
|
||||
* @throws NamingException
|
||||
* if any error occurs. Note that a NameNotFoundException will
|
||||
* be ignored. Instead this is interpreted that no entries were
|
||||
* found.
|
||||
*/
|
||||
public void listBindings(final Name base,
|
||||
NameClassPairCallbackHandler handler) throws DataAccessException;
|
||||
NameClassPairCallbackHandler handler) throws NamingException;
|
||||
|
||||
/**
|
||||
* Perform a non-recursive listing of the children of the given
|
||||
@@ -904,13 +924,13 @@ public interface LdapOperations {
|
||||
* @param mapper
|
||||
* The NameClassPairMapper to supply each {@link Binding} to.
|
||||
* @return a List containing the Objects returned from the Mapper.
|
||||
* @throws DataAccessException
|
||||
* @throws NamingException
|
||||
* if any error occurs. Note that a NameNotFoundException will
|
||||
* be ignored. Instead this is interpreted that no entries were
|
||||
* found.
|
||||
*/
|
||||
public List listBindings(String base, NameClassPairMapper mapper)
|
||||
throws DataAccessException;
|
||||
throws NamingException;
|
||||
|
||||
/**
|
||||
* Perform a non-recursive listing of the children of the given
|
||||
@@ -922,13 +942,13 @@ public interface LdapOperations {
|
||||
* @param mapper
|
||||
* The NameClassPairMapper to supply each {@link Binding} to.
|
||||
* @return a List containing the Objects returned from the Mapper.
|
||||
* @throws DataAccessException
|
||||
* @throws NamingException
|
||||
* if any error occurs. Note that a NameNotFoundException will
|
||||
* be ignored. Instead this is interpreted that no entries were
|
||||
* found.
|
||||
*/
|
||||
public List listBindings(Name base, NameClassPairMapper mapper)
|
||||
throws DataAccessException;
|
||||
throws NamingException;
|
||||
|
||||
/**
|
||||
* Perform a non-recursive listing of children of the given
|
||||
@@ -938,12 +958,12 @@ public interface LdapOperations {
|
||||
* The base DN where the list should be performed.
|
||||
* @return a List containing the names of all the contexts bound to
|
||||
* <code>base</code>.
|
||||
* @throws DataAccessException
|
||||
* @throws NamingException
|
||||
* if any error occurs. Note that a NameNotFoundException will
|
||||
* be ignored. Instead this is interpreted that no entries were
|
||||
* found.
|
||||
*/
|
||||
public List listBindings(final String base) throws DataAccessException;
|
||||
public List listBindings(final String base) throws NamingException;
|
||||
|
||||
/**
|
||||
* Perform a non-recursive listing of the children of the given
|
||||
@@ -953,12 +973,12 @@ public interface LdapOperations {
|
||||
* The base DN where the list should be performed.
|
||||
* @return a List containing the names of all the contexts bound to
|
||||
* <code>base</code>.
|
||||
* @throws DataAccessException
|
||||
* @throws NamingException
|
||||
* if any error occurs. Note that a NameNotFoundException will
|
||||
* be ignored. Instead this is interpreted that no entries were
|
||||
* found.
|
||||
*/
|
||||
public List listBindings(final Name base) throws DataAccessException;
|
||||
public List listBindings(final Name base) throws NamingException;
|
||||
|
||||
/**
|
||||
* Perform a non-recursive listing of the children of the given
|
||||
@@ -970,13 +990,13 @@ public interface LdapOperations {
|
||||
* @param mapper
|
||||
* The ContextMapper to use for mapping the found object.
|
||||
* @return a List containing all entries received from the ContextMapper.
|
||||
* @throws DataAccessException
|
||||
* @throws NamingException
|
||||
* if any error occurs. Note that a NameNotFoundException will
|
||||
* be ignored. Instead this is interpreted that no entries were
|
||||
* found.
|
||||
*/
|
||||
public List listBindings(String base, ContextMapper mapper)
|
||||
throws DataAccessException;
|
||||
throws NamingException;
|
||||
|
||||
/**
|
||||
* Perform a non-recursive listing of the children of the given
|
||||
@@ -988,13 +1008,13 @@ public interface LdapOperations {
|
||||
* @param mapper
|
||||
* The ContextMapper to use for mapping the found object.
|
||||
* @return a List containing all entries received from the ContextMapper.
|
||||
* @throws DataAccessException
|
||||
* @throws NamingException
|
||||
* if any error occurs. Note that a NameNotFoundException will
|
||||
* be ignored. Instead this is interpreted that no entries were
|
||||
* found.
|
||||
*/
|
||||
public List listBindings(Name base, ContextMapper mapper)
|
||||
throws DataAccessException;
|
||||
throws NamingException;
|
||||
|
||||
/**
|
||||
* Lookup the supplied DN and return the found object. <b>WARNING</b>: This
|
||||
@@ -1007,10 +1027,10 @@ public interface LdapOperations {
|
||||
* @param dn
|
||||
* The distinguished name of the object to find.
|
||||
* @return the found object.
|
||||
* @throws DataAccessException
|
||||
* @throws NamingException
|
||||
* if any error occurs.
|
||||
*/
|
||||
public Object lookup(Name dn) throws DataAccessException;
|
||||
public Object lookup(Name dn) throws NamingException;
|
||||
|
||||
/**
|
||||
* Lookup the supplied DN and return the found object. <b>WARNING</b>: This
|
||||
@@ -1023,10 +1043,10 @@ public interface LdapOperations {
|
||||
* @param dn
|
||||
* The distinguished name of the object to find.
|
||||
* @return the found object.
|
||||
* @throws DataAccessException
|
||||
* @throws NamingException
|
||||
* if any error occurs.
|
||||
*/
|
||||
public Object lookup(String dn) throws DataAccessException;
|
||||
public Object lookup(String dn) throws NamingException;
|
||||
|
||||
/**
|
||||
* Convenience method to get the attributes of a specified DN and
|
||||
@@ -1037,11 +1057,11 @@ public interface LdapOperations {
|
||||
* @param mapper
|
||||
* The AttributesMapper to use for mapping the found object.
|
||||
* @return the object returned from the mapper.
|
||||
* @throws DataAccessException
|
||||
* @throws NamingException
|
||||
* if any error occurs.
|
||||
*/
|
||||
public Object lookup(Name dn, AttributesMapper mapper)
|
||||
throws DataAccessException;
|
||||
throws NamingException;
|
||||
|
||||
/**
|
||||
* Convenience method to get the attributes of a specified DN and
|
||||
@@ -1052,11 +1072,11 @@ public interface LdapOperations {
|
||||
* @param mapper
|
||||
* The AttributesMapper to use for mapping the found object.
|
||||
* @return the object returned from the mapper.
|
||||
* @throws DataAccessException
|
||||
* @throws NamingException
|
||||
* if any error occurs.
|
||||
*/
|
||||
public Object lookup(String dn, AttributesMapper mapper)
|
||||
throws DataAccessException;
|
||||
throws NamingException;
|
||||
|
||||
/**
|
||||
* Convenience method to lookup a specified DN and automatically pass the
|
||||
@@ -1067,11 +1087,10 @@ public interface LdapOperations {
|
||||
* @param mapper
|
||||
* The ContextMapper to use for mapping the found object.
|
||||
* @return the object returned from the mapper.
|
||||
* @throws DataAccessException
|
||||
* @throws NamingException
|
||||
* if any error occurs.
|
||||
*/
|
||||
public Object lookup(Name dn, ContextMapper mapper)
|
||||
throws DataAccessException;
|
||||
public Object lookup(Name dn, ContextMapper mapper) throws NamingException;
|
||||
|
||||
/**
|
||||
* Convenience method to lookup a specified DN and automatically pass the
|
||||
@@ -1082,11 +1101,11 @@ public interface LdapOperations {
|
||||
* @param mapper
|
||||
* The ContextMapper to use for mapping the found object.
|
||||
* @return the object returned from the mapper.
|
||||
* @throws DataAccessException
|
||||
* @throws NamingException
|
||||
* if any error occurs.
|
||||
*/
|
||||
public Object lookup(String dn, ContextMapper mapper)
|
||||
throws DataAccessException;
|
||||
throws NamingException;
|
||||
|
||||
/**
|
||||
* Convenience method to get the specified attributes of a specified DN and
|
||||
@@ -1099,11 +1118,11 @@ public interface LdapOperations {
|
||||
* @param mapper
|
||||
* The AttributesMapper to use for mapping the found object.
|
||||
* @return the object returned from the mapper.
|
||||
* @throws DataAccessException
|
||||
* @throws NamingException
|
||||
* if any error occurs.
|
||||
*/
|
||||
public Object lookup(Name dn, String[] attributes, AttributesMapper mapper)
|
||||
throws DataAccessException;
|
||||
throws NamingException;
|
||||
|
||||
/**
|
||||
* Convenience method to get the specified attributes of a specified DN and
|
||||
@@ -1116,11 +1135,11 @@ public interface LdapOperations {
|
||||
* @param mapper
|
||||
* The AttributesMapper to use for mapping the found object.
|
||||
* @return the object returned from the mapper.
|
||||
* @throws DataAccessException
|
||||
* @throws NamingException
|
||||
* if any error occurs.
|
||||
*/
|
||||
public Object lookup(String dn, String[] attributes, AttributesMapper mapper)
|
||||
throws DataAccessException;
|
||||
throws NamingException;
|
||||
|
||||
/**
|
||||
* Convenience method to get the specified attributes of a specified DN and
|
||||
@@ -1133,11 +1152,11 @@ public interface LdapOperations {
|
||||
* @param mapper
|
||||
* The ContextMapper to use for mapping the found object.
|
||||
* @return the object returned from the mapper.
|
||||
* @throws DataAccessException
|
||||
* @throws NamingException
|
||||
* if any error occurs.
|
||||
*/
|
||||
public Object lookup(Name dn, String[] attributes, ContextMapper mapper)
|
||||
throws DataAccessException;
|
||||
throws NamingException;
|
||||
|
||||
/**
|
||||
* Convenience method to get the specified attributes of a specified DN and
|
||||
@@ -1150,11 +1169,11 @@ public interface LdapOperations {
|
||||
* @param mapper
|
||||
* The ContextMapper to use for mapping the found object.
|
||||
* @return the object returned from the mapper.
|
||||
* @throws DataAccessException
|
||||
* @throws NamingException
|
||||
* if any error occurs.
|
||||
*/
|
||||
public Object lookup(String dn, String[] attributes, ContextMapper mapper)
|
||||
throws DataAccessException;
|
||||
throws NamingException;
|
||||
|
||||
/**
|
||||
* Modify an entry in the LDAP tree using the supplied ModificationItems.
|
||||
@@ -1163,11 +1182,11 @@ public interface LdapOperations {
|
||||
* The distinguished name of the node to modify.
|
||||
* @param mods
|
||||
* The modifications to perform.
|
||||
* @throws DataAccessException
|
||||
* @throws NamingException
|
||||
* if any error occurs.
|
||||
*/
|
||||
public void modifyAttributes(Name dn, ModificationItem[] mods)
|
||||
throws DataAccessException;
|
||||
throws NamingException;
|
||||
|
||||
/**
|
||||
* Modify an entry in the LDAP tree using the supplied ModificationItems.
|
||||
@@ -1176,11 +1195,11 @@ public interface LdapOperations {
|
||||
* The distinguished name of the node to modify.
|
||||
* @param mods
|
||||
* The modifications to perform.
|
||||
* @throws DataAccessException
|
||||
* @throws NamingException
|
||||
* if any error occurs.
|
||||
*/
|
||||
public void modifyAttributes(String dn, ModificationItem[] mods)
|
||||
throws DataAccessException;
|
||||
throws NamingException;
|
||||
|
||||
/**
|
||||
* Create an entry in the LDAP tree. The attributes used to create the entry
|
||||
@@ -1195,11 +1214,11 @@ public interface LdapOperations {
|
||||
* implementation.
|
||||
* @param attributes
|
||||
* The attributes to bind, may be null.
|
||||
* @throws DataAccessException
|
||||
* @throws NamingException
|
||||
* if any error occurs.
|
||||
*/
|
||||
public void bind(Name dn, Object obj, Attributes attributes)
|
||||
throws DataAccessException;
|
||||
throws NamingException;
|
||||
|
||||
/**
|
||||
* Create an entry in the LDAP tree. The attributes used to create the entry
|
||||
@@ -1214,11 +1233,11 @@ public interface LdapOperations {
|
||||
* implementation.
|
||||
* @param attributes
|
||||
* The attributes to bind, may be null.
|
||||
* @throws DataAccessException
|
||||
* @throws NamingException
|
||||
* if any error occurs.
|
||||
*/
|
||||
public void bind(String dn, Object obj, Attributes attributes)
|
||||
throws DataAccessException;
|
||||
throws NamingException;
|
||||
|
||||
/**
|
||||
* Remove an entry from the LDAP tree. The entry must not have any children -
|
||||
@@ -1227,10 +1246,10 @@ public interface LdapOperations {
|
||||
*
|
||||
* @param dn
|
||||
* The distinguished name of the entry to remove.
|
||||
* @throws DataAccessException
|
||||
* @throws NamingException
|
||||
* if any error occurs.
|
||||
*/
|
||||
public void unbind(Name dn) throws DataAccessException;
|
||||
public void unbind(Name dn) throws NamingException;
|
||||
|
||||
/**
|
||||
* Remove an entry from the LDAP tree. The entry must not have any children -
|
||||
@@ -1239,10 +1258,10 @@ public interface LdapOperations {
|
||||
*
|
||||
* @param dn
|
||||
* The distinguished name to unbind.
|
||||
* @throws DataAccessException
|
||||
* @throws NamingException
|
||||
* if any error occurs.
|
||||
*/
|
||||
public void unbind(String dn) throws DataAccessException;
|
||||
public void unbind(String dn) throws NamingException;
|
||||
|
||||
/**
|
||||
* Remove an entry from the LDAP tree, optionally removing all descendants
|
||||
@@ -1254,10 +1273,10 @@ public interface LdapOperations {
|
||||
* Whether to unbind all subcontexts as well. If this parameter
|
||||
* is <code>false</code> and the entry has children, the
|
||||
* operation will fail.
|
||||
* @throws DataAccessException
|
||||
* @throws NamingException
|
||||
* if any error occurs.
|
||||
*/
|
||||
public void unbind(Name dn, boolean recursive) throws DataAccessException;
|
||||
public void unbind(Name dn, boolean recursive) throws NamingException;
|
||||
|
||||
/**
|
||||
* Remove an entry from the LDAP tree, optionally removing all descendants
|
||||
@@ -1269,10 +1288,10 @@ public interface LdapOperations {
|
||||
* Whether to unbind all subcontexts as well. If this parameter
|
||||
* is <code>false</code> and the entry has children, the
|
||||
* operation will fail.
|
||||
* @throws DataAccessException
|
||||
* @throws NamingException
|
||||
* if any error occurs.
|
||||
*/
|
||||
public void unbind(String dn, boolean recursive) throws DataAccessException;
|
||||
public void unbind(String dn, boolean recursive) throws NamingException;
|
||||
|
||||
/**
|
||||
* Remove an entry and replace it with a new one. The attributes used to
|
||||
@@ -1288,11 +1307,11 @@ public interface LdapOperations {
|
||||
* DirContext implementation.
|
||||
* @param attributes
|
||||
* The attributes to bind, may be null.
|
||||
* @throws DataAccessException
|
||||
* @throws NamingException
|
||||
* if any error occurs.
|
||||
*/
|
||||
public void rebind(Name dn, Object obj, Attributes attributes)
|
||||
throws DataAccessException;
|
||||
throws NamingException;
|
||||
|
||||
/**
|
||||
* Remove an entry and replace it with a new one. The attributes used to
|
||||
@@ -1308,11 +1327,11 @@ public interface LdapOperations {
|
||||
* DirContext implementation.
|
||||
* @param attributes
|
||||
* The attributes to bind, may be null.
|
||||
* @throws DataAccessException
|
||||
* @throws NamingException
|
||||
* if any error occurs.
|
||||
*/
|
||||
public void rebind(String dn, Object obj, Attributes attributes)
|
||||
throws DataAccessException;
|
||||
throws NamingException;
|
||||
|
||||
/**
|
||||
* Move an entry in the LDAP tree to a new location.
|
||||
@@ -1323,13 +1342,13 @@ public interface LdapOperations {
|
||||
* @param newDn
|
||||
* The distinguished name where the entry should be moved; may
|
||||
* not be null or empty.
|
||||
* @throws DataIntegrityViolationException
|
||||
* @throws ContextNotEmptyException
|
||||
* if newDn is already bound
|
||||
* @throws DataAccessException
|
||||
* @throws NamingException
|
||||
* if any other error occurs.
|
||||
*/
|
||||
public void rename(final Name oldDn, final Name newDn)
|
||||
throws DataAccessException;
|
||||
throws NamingException;
|
||||
|
||||
/**
|
||||
* Move an entry in the LDAP tree to a new location.
|
||||
@@ -1340,11 +1359,11 @@ public interface LdapOperations {
|
||||
* @param newDn
|
||||
* The distinguished name where the entry should be moved; may
|
||||
* not be null or empty.
|
||||
* @throws DataIntegrityViolationException
|
||||
* @throws ContextNotEmptyException
|
||||
* if newDn is already bound
|
||||
* @throws DataAccessException
|
||||
* @throws NamingException
|
||||
* if any other error occurs.
|
||||
*/
|
||||
public void rename(final String oldDn, final String newDn)
|
||||
throws DataAccessException;
|
||||
throws NamingException;
|
||||
}
|
||||
|
||||
@@ -22,7 +22,6 @@ import javax.naming.Name;
|
||||
import javax.naming.NameClassPair;
|
||||
import javax.naming.NameNotFoundException;
|
||||
import javax.naming.NamingEnumeration;
|
||||
import javax.naming.NamingException;
|
||||
import javax.naming.PartialResultException;
|
||||
import javax.naming.directory.Attributes;
|
||||
import javax.naming.directory.DirContext;
|
||||
@@ -34,10 +33,8 @@ import org.apache.commons.lang.Validate;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.dao.DataAccessException;
|
||||
import org.springframework.ldap.support.DefaultNamingExceptionTranslator;
|
||||
import org.springframework.ldap.support.EntryNotFoundException;
|
||||
import org.springframework.ldap.support.NamingExceptionTranslator;
|
||||
import org.springframework.ldap.NamingException;
|
||||
import org.springframework.ldap.support.LdapUtils;
|
||||
|
||||
/**
|
||||
* Executes core LDAP functionality and helps to avoid common errors, relieving
|
||||
@@ -75,8 +72,6 @@ public class LdapTemplate implements LdapOperations, InitializingBean {
|
||||
|
||||
private ContextSource contextSource;
|
||||
|
||||
private NamingExceptionTranslator exceptionTranslator = new DefaultNamingExceptionTranslator();
|
||||
|
||||
private boolean ignorePartialResultException = false;
|
||||
|
||||
/**
|
||||
@@ -145,8 +140,7 @@ public class LdapTemplate implements LdapOperations, InitializingBean {
|
||||
* org.springframework.ldap.core.NameClassPairCallbackHandler)
|
||||
*/
|
||||
public void search(String base, String filter, int searchScope,
|
||||
boolean returningObjFlag, NameClassPairCallbackHandler handler)
|
||||
throws DataAccessException {
|
||||
boolean returningObjFlag, NameClassPairCallbackHandler handler) {
|
||||
|
||||
search(base, filter, getDefaultSearchControls(searchScope,
|
||||
returningObjFlag, ALL_ATTRIBUTES), handler);
|
||||
@@ -163,7 +157,7 @@ public class LdapTemplate implements LdapOperations, InitializingBean {
|
||||
// Create a SearchExecutor to perform the search.
|
||||
SearchExecutor se = new SearchExecutor() {
|
||||
public NamingEnumeration executeSearch(DirContext ctx)
|
||||
throws NamingException {
|
||||
throws javax.naming.NamingException {
|
||||
return ctx.search(base, filter, controls);
|
||||
}
|
||||
};
|
||||
@@ -182,7 +176,7 @@ public class LdapTemplate implements LdapOperations, InitializingBean {
|
||||
// Create a SearchExecutor to perform the search.
|
||||
SearchExecutor se = new SearchExecutor() {
|
||||
public NamingEnumeration executeSearch(DirContext ctx)
|
||||
throws NamingException {
|
||||
throws javax.naming.NamingException {
|
||||
return ctx.search(base, filter, controls);
|
||||
}
|
||||
};
|
||||
@@ -203,7 +197,7 @@ public class LdapTemplate implements LdapOperations, InitializingBean {
|
||||
// Create a SearchExecutor to perform the search.
|
||||
SearchExecutor se = new SearchExecutor() {
|
||||
public NamingEnumeration executeSearch(DirContext ctx)
|
||||
throws NamingException {
|
||||
throws javax.naming.NamingException {
|
||||
return ctx.search(base, filter, controls);
|
||||
}
|
||||
};
|
||||
@@ -224,7 +218,7 @@ public class LdapTemplate implements LdapOperations, InitializingBean {
|
||||
// Create a SearchExecutor to perform the search.
|
||||
SearchExecutor se = new SearchExecutor() {
|
||||
public NamingEnumeration executeSearch(DirContext ctx)
|
||||
throws NamingException {
|
||||
throws javax.naming.NamingException {
|
||||
return ctx.search(base, filter, controls);
|
||||
}
|
||||
};
|
||||
@@ -254,7 +248,7 @@ public class LdapTemplate implements LdapOperations, InitializingBean {
|
||||
* DirContextProcessor for custom pre- and post-processing. May
|
||||
* be <code>null</code> if no custom processing should take
|
||||
* place.
|
||||
* @throws DataAccessException
|
||||
* @throws NamingException
|
||||
* if any error occurs. Note that a NameNotFoundException will
|
||||
* be ignored. Instead this is interpreted that no entries were
|
||||
* found.
|
||||
@@ -287,16 +281,16 @@ public class LdapTemplate implements LdapOperations, InitializingBean {
|
||||
if (ignorePartialResultException) {
|
||||
log.debug("PartialResultException encountered and ignored", e);
|
||||
} else {
|
||||
ex = getExceptionTranslator().translate(e);
|
||||
ex = LdapUtils.convertLdapException(e);
|
||||
}
|
||||
} catch (NamingException e) {
|
||||
ex = getExceptionTranslator().translate(e);
|
||||
} catch (javax.naming.NamingException e) {
|
||||
ex = LdapUtils.convertLdapException(e);
|
||||
} finally {
|
||||
try {
|
||||
processor.postProcess(ctx);
|
||||
} catch (NamingException e) {
|
||||
} catch (javax.naming.NamingException e) {
|
||||
if (ex == null) {
|
||||
ex = getExceptionTranslator().translate(e);
|
||||
ex = LdapUtils.convertLdapException(e);
|
||||
} else {
|
||||
// We already had an exception from above and should ignore
|
||||
// this one.
|
||||
@@ -327,7 +321,7 @@ public class LdapTemplate implements LdapOperations, InitializingBean {
|
||||
* @param handler
|
||||
* the NameClassPairCallbackHandler to which each found entry
|
||||
* will be passed.
|
||||
* @throws DataAccessException
|
||||
* @throws NamingException
|
||||
* if any error occurs. Note that a NameNotFoundException will
|
||||
* be ignored. Instead this is interpreted that no entries were
|
||||
* found.
|
||||
@@ -342,7 +336,7 @@ public class LdapTemplate implements LdapOperations, InitializingBean {
|
||||
* org.springframework.ldap.core.NameClassPairCallbackHandler)
|
||||
*/
|
||||
public void search(Name base, String filter,
|
||||
NameClassPairCallbackHandler handler) throws DataAccessException {
|
||||
NameClassPairCallbackHandler handler) {
|
||||
|
||||
search(base, filter, getDefaultSearchControls(DEFAULT_SEARCH_SCOPE,
|
||||
DONT_RETURN_OBJ_FLAG, ALL_ATTRIBUTES), handler);
|
||||
@@ -354,7 +348,7 @@ public class LdapTemplate implements LdapOperations, InitializingBean {
|
||||
* org.springframework.ldap.core.NameClassPairCallbackHandler)
|
||||
*/
|
||||
public void search(String base, String filter,
|
||||
NameClassPairCallbackHandler handler) throws DataAccessException {
|
||||
NameClassPairCallbackHandler handler) {
|
||||
|
||||
search(base, filter, getDefaultSearchControls(DEFAULT_SEARCH_SCOPE,
|
||||
DONT_RETURN_OBJ_FLAG, ALL_ATTRIBUTES), handler);
|
||||
@@ -366,7 +360,7 @@ public class LdapTemplate implements LdapOperations, InitializingBean {
|
||||
* org.springframework.ldap.core.AttributesMapper)
|
||||
*/
|
||||
public List search(Name base, String filter, int searchScope,
|
||||
String[] attrs, AttributesMapper mapper) throws DataAccessException {
|
||||
String[] attrs, AttributesMapper mapper) {
|
||||
return search(base, filter, getDefaultSearchControls(searchScope,
|
||||
DONT_RETURN_OBJ_FLAG, attrs), mapper);
|
||||
}
|
||||
@@ -377,7 +371,7 @@ public class LdapTemplate implements LdapOperations, InitializingBean {
|
||||
* org.springframework.ldap.core.AttributesMapper)
|
||||
*/
|
||||
public List search(String base, String filter, int searchScope,
|
||||
String[] attrs, AttributesMapper mapper) throws DataAccessException {
|
||||
String[] attrs, AttributesMapper mapper) {
|
||||
return search(base, filter, getDefaultSearchControls(searchScope,
|
||||
DONT_RETURN_OBJ_FLAG, attrs), mapper);
|
||||
}
|
||||
@@ -399,7 +393,7 @@ public class LdapTemplate implements LdapOperations, InitializingBean {
|
||||
* org.springframework.ldap.core.AttributesMapper)
|
||||
*/
|
||||
public List search(String base, String filter, int searchScope,
|
||||
AttributesMapper mapper) throws DataAccessException {
|
||||
AttributesMapper mapper) {
|
||||
|
||||
return search(base, filter, searchScope, ALL_ATTRIBUTES, mapper);
|
||||
}
|
||||
@@ -408,8 +402,7 @@ public class LdapTemplate implements LdapOperations, InitializingBean {
|
||||
* @see org.springframework.ldap.core.LdapOperations#search(javax.naming.Name,
|
||||
* java.lang.String, org.springframework.ldap.core.AttributesMapper)
|
||||
*/
|
||||
public List search(Name base, String filter, AttributesMapper mapper)
|
||||
throws DataAccessException {
|
||||
public List search(Name base, String filter, AttributesMapper mapper) {
|
||||
|
||||
return search(base, filter, DEFAULT_SEARCH_SCOPE, mapper);
|
||||
}
|
||||
@@ -418,8 +411,7 @@ public class LdapTemplate implements LdapOperations, InitializingBean {
|
||||
* @see org.springframework.ldap.core.LdapOperations#search(java.lang.String,
|
||||
* java.lang.String, org.springframework.ldap.core.AttributesMapper)
|
||||
*/
|
||||
public List search(String base, String filter, AttributesMapper mapper)
|
||||
throws DataAccessException {
|
||||
public List search(String base, String filter, AttributesMapper mapper) {
|
||||
|
||||
return search(base, filter, DEFAULT_SEARCH_SCOPE, mapper);
|
||||
}
|
||||
@@ -430,7 +422,7 @@ public class LdapTemplate implements LdapOperations, InitializingBean {
|
||||
* org.springframework.ldap.core.ContextMapper)
|
||||
*/
|
||||
public List search(Name base, String filter, int searchScope,
|
||||
String[] attrs, ContextMapper mapper) throws DataAccessException {
|
||||
String[] attrs, ContextMapper mapper) {
|
||||
|
||||
return search(base, filter, getDefaultSearchControls(searchScope,
|
||||
RETURN_OBJ_FLAG, attrs), mapper);
|
||||
@@ -442,7 +434,7 @@ public class LdapTemplate implements LdapOperations, InitializingBean {
|
||||
* org.springframework.ldap.core.ContextMapper)
|
||||
*/
|
||||
public List search(String base, String filter, int searchScope,
|
||||
String[] attrs, ContextMapper mapper) throws DataAccessException {
|
||||
String[] attrs, ContextMapper mapper) {
|
||||
|
||||
return search(base, filter, getDefaultSearchControls(searchScope,
|
||||
RETURN_OBJ_FLAG, attrs), mapper);
|
||||
@@ -463,7 +455,7 @@ public class LdapTemplate implements LdapOperations, InitializingBean {
|
||||
* java.lang.String, int, org.springframework.ldap.core.ContextMapper)
|
||||
*/
|
||||
public List search(String base, String filter, int searchScope,
|
||||
ContextMapper mapper) throws DataAccessException {
|
||||
ContextMapper mapper) {
|
||||
|
||||
return search(base, filter, searchScope, ALL_ATTRIBUTES, mapper);
|
||||
}
|
||||
@@ -472,8 +464,7 @@ public class LdapTemplate implements LdapOperations, InitializingBean {
|
||||
* @see org.springframework.ldap.core.LdapOperations#search(javax.naming.Name,
|
||||
* java.lang.String, org.springframework.ldap.core.ContextMapper)
|
||||
*/
|
||||
public List search(Name base, String filter, ContextMapper mapper)
|
||||
throws DataAccessException {
|
||||
public List search(Name base, String filter, ContextMapper mapper) {
|
||||
|
||||
return search(base, filter, DEFAULT_SEARCH_SCOPE, mapper);
|
||||
}
|
||||
@@ -482,8 +473,7 @@ public class LdapTemplate implements LdapOperations, InitializingBean {
|
||||
* @see org.springframework.ldap.core.LdapOperations#search(java.lang.String,
|
||||
* java.lang.String, org.springframework.ldap.core.ContextMapper)
|
||||
*/
|
||||
public List search(String base, String filter, ContextMapper mapper)
|
||||
throws DataAccessException {
|
||||
public List search(String base, String filter, ContextMapper mapper) {
|
||||
|
||||
return search(base, filter, DEFAULT_SEARCH_SCOPE, mapper);
|
||||
}
|
||||
@@ -612,7 +602,7 @@ public class LdapTemplate implements LdapOperations, InitializingBean {
|
||||
public void list(final String base, NameClassPairCallbackHandler handler) {
|
||||
SearchExecutor searchExecutor = new SearchExecutor() {
|
||||
public NamingEnumeration executeSearch(DirContext ctx)
|
||||
throws NamingException {
|
||||
throws javax.naming.NamingException {
|
||||
return ctx.list(base);
|
||||
}
|
||||
};
|
||||
@@ -627,7 +617,7 @@ public class LdapTemplate implements LdapOperations, InitializingBean {
|
||||
public void list(final Name base, NameClassPairCallbackHandler handler) {
|
||||
SearchExecutor searchExecutor = new SearchExecutor() {
|
||||
public NamingEnumeration executeSearch(DirContext ctx)
|
||||
throws NamingException {
|
||||
throws javax.naming.NamingException {
|
||||
return ctx.list(base);
|
||||
}
|
||||
};
|
||||
@@ -679,7 +669,7 @@ public class LdapTemplate implements LdapOperations, InitializingBean {
|
||||
NameClassPairCallbackHandler handler) {
|
||||
SearchExecutor searchExecutor = new SearchExecutor() {
|
||||
public NamingEnumeration executeSearch(DirContext ctx)
|
||||
throws NamingException {
|
||||
throws javax.naming.NamingException {
|
||||
return ctx.listBindings(base);
|
||||
}
|
||||
};
|
||||
@@ -695,7 +685,7 @@ public class LdapTemplate implements LdapOperations, InitializingBean {
|
||||
NameClassPairCallbackHandler handler) {
|
||||
SearchExecutor searchExecutor = new SearchExecutor() {
|
||||
public NamingEnumeration executeSearch(DirContext ctx)
|
||||
throws NamingException {
|
||||
throws javax.naming.NamingException {
|
||||
return ctx.listBindings(base);
|
||||
}
|
||||
};
|
||||
@@ -784,8 +774,8 @@ public class LdapTemplate implements LdapOperations, InitializingBean {
|
||||
private Object executeWithContext(ContextExecutor ce, DirContext ctx) {
|
||||
try {
|
||||
return ce.executeWithContext(ctx);
|
||||
} catch (NamingException e) {
|
||||
throw getExceptionTranslator().translate(e);
|
||||
} catch (javax.naming.NamingException e) {
|
||||
throw LdapUtils.convertLdapException(e);
|
||||
} finally {
|
||||
closeContext(ctx);
|
||||
}
|
||||
@@ -797,7 +787,7 @@ public class LdapTemplate implements LdapOperations, InitializingBean {
|
||||
public Object lookup(final Name dn) {
|
||||
return executeReadOnly(new ContextExecutor() {
|
||||
public Object executeWithContext(DirContext ctx)
|
||||
throws NamingException {
|
||||
throws javax.naming.NamingException {
|
||||
return ctx.lookup(dn);
|
||||
}
|
||||
});
|
||||
@@ -806,10 +796,10 @@ public class LdapTemplate implements LdapOperations, InitializingBean {
|
||||
/*
|
||||
* @see org.springframework.ldap.core.LdapOperations#lookup(java.lang.String)
|
||||
*/
|
||||
public Object lookup(final String dn) throws DataAccessException {
|
||||
public Object lookup(final String dn) {
|
||||
return executeReadOnly(new ContextExecutor() {
|
||||
public Object executeWithContext(DirContext ctx)
|
||||
throws NamingException {
|
||||
throws javax.naming.NamingException {
|
||||
return ctx.lookup(dn);
|
||||
}
|
||||
});
|
||||
@@ -822,7 +812,7 @@ public class LdapTemplate implements LdapOperations, InitializingBean {
|
||||
public Object lookup(final Name dn, final AttributesMapper mapper) {
|
||||
return executeReadOnly(new ContextExecutor() {
|
||||
public Object executeWithContext(DirContext ctx)
|
||||
throws NamingException {
|
||||
throws javax.naming.NamingException {
|
||||
Attributes attributes = ctx.getAttributes(dn);
|
||||
return mapper.mapFromAttributes(attributes);
|
||||
}
|
||||
@@ -833,12 +823,11 @@ public class LdapTemplate implements LdapOperations, InitializingBean {
|
||||
* @see org.springframework.ldap.core.LdapOperations#lookup(java.lang.String,
|
||||
* org.springframework.ldap.core.AttributesMapper)
|
||||
*/
|
||||
public Object lookup(final String dn, final AttributesMapper mapper)
|
||||
throws DataAccessException {
|
||||
public Object lookup(final String dn, final AttributesMapper mapper) {
|
||||
|
||||
return executeReadOnly(new ContextExecutor() {
|
||||
public Object executeWithContext(DirContext ctx)
|
||||
throws NamingException {
|
||||
throws javax.naming.NamingException {
|
||||
Attributes attributes = ctx.getAttributes(dn);
|
||||
return mapper.mapFromAttributes(attributes);
|
||||
}
|
||||
@@ -852,7 +841,7 @@ public class LdapTemplate implements LdapOperations, InitializingBean {
|
||||
public Object lookup(final Name dn, final ContextMapper mapper) {
|
||||
return executeReadOnly(new ContextExecutor() {
|
||||
public Object executeWithContext(DirContext ctx)
|
||||
throws NamingException {
|
||||
throws javax.naming.NamingException {
|
||||
Object object = ctx.lookup(dn);
|
||||
return mapper.mapFromContext(object);
|
||||
}
|
||||
@@ -863,12 +852,11 @@ public class LdapTemplate implements LdapOperations, InitializingBean {
|
||||
* @see org.springframework.ldap.core.LdapOperations#lookup(java.lang.String,
|
||||
* org.springframework.ldap.core.ContextMapper)
|
||||
*/
|
||||
public Object lookup(final String dn, final ContextMapper mapper)
|
||||
throws DataAccessException {
|
||||
public Object lookup(final String dn, final ContextMapper mapper) {
|
||||
|
||||
return executeReadOnly(new ContextExecutor() {
|
||||
public Object executeWithContext(DirContext ctx)
|
||||
throws NamingException {
|
||||
throws javax.naming.NamingException {
|
||||
Object object = ctx.lookup(dn);
|
||||
return mapper.mapFromContext(object);
|
||||
}
|
||||
@@ -880,11 +868,11 @@ public class LdapTemplate implements LdapOperations, InitializingBean {
|
||||
* java.lang.String[], org.springframework.ldap.core.AttributesMapper)
|
||||
*/
|
||||
public Object lookup(final Name dn, final String[] attributes,
|
||||
final AttributesMapper mapper) throws DataAccessException {
|
||||
final AttributesMapper mapper) {
|
||||
|
||||
return executeReadOnly(new ContextExecutor() {
|
||||
public Object executeWithContext(DirContext ctx)
|
||||
throws NamingException {
|
||||
throws javax.naming.NamingException {
|
||||
Attributes filteredAttributes = ctx.getAttributes(dn,
|
||||
attributes);
|
||||
return mapper.mapFromAttributes(filteredAttributes);
|
||||
@@ -897,10 +885,10 @@ public class LdapTemplate implements LdapOperations, InitializingBean {
|
||||
* java.lang.String[], org.springframework.ldap.core.AttributesMapper)
|
||||
*/
|
||||
public Object lookup(final String dn, final String[] attributes,
|
||||
final AttributesMapper mapper) throws DataAccessException {
|
||||
final AttributesMapper mapper) {
|
||||
return executeReadOnly(new ContextExecutor() {
|
||||
public Object executeWithContext(DirContext ctx)
|
||||
throws NamingException {
|
||||
throws javax.naming.NamingException {
|
||||
Attributes filteredAttributes = ctx.getAttributes(dn,
|
||||
attributes);
|
||||
return mapper.mapFromAttributes(filteredAttributes);
|
||||
@@ -913,11 +901,11 @@ public class LdapTemplate implements LdapOperations, InitializingBean {
|
||||
* java.lang.String[], org.springframework.ldap.core.ContextMapper)
|
||||
*/
|
||||
public Object lookup(final Name dn, final String[] attributes,
|
||||
final ContextMapper mapper) throws DataAccessException {
|
||||
final ContextMapper mapper) {
|
||||
|
||||
return executeReadOnly(new ContextExecutor() {
|
||||
public Object executeWithContext(DirContext ctx)
|
||||
throws NamingException {
|
||||
throws javax.naming.NamingException {
|
||||
Attributes filteredAttributes = ctx.getAttributes(dn,
|
||||
attributes);
|
||||
DirContextAdapter contextAdapter = new DirContextAdapter(
|
||||
@@ -932,11 +920,11 @@ public class LdapTemplate implements LdapOperations, InitializingBean {
|
||||
* java.lang.String[], org.springframework.ldap.core.ContextMapper)
|
||||
*/
|
||||
public Object lookup(final String dn, final String[] attributes,
|
||||
final ContextMapper mapper) throws DataAccessException {
|
||||
final ContextMapper mapper) {
|
||||
|
||||
return executeReadOnly(new ContextExecutor() {
|
||||
public Object executeWithContext(DirContext ctx)
|
||||
throws NamingException {
|
||||
throws javax.naming.NamingException {
|
||||
Attributes filteredAttributes = ctx.getAttributes(dn,
|
||||
attributes);
|
||||
DistinguishedName name = new DistinguishedName(dn);
|
||||
@@ -954,7 +942,7 @@ public class LdapTemplate implements LdapOperations, InitializingBean {
|
||||
public void modifyAttributes(final Name dn, final ModificationItem[] mods) {
|
||||
executeReadWrite(new ContextExecutor() {
|
||||
public Object executeWithContext(DirContext ctx)
|
||||
throws NamingException {
|
||||
throws javax.naming.NamingException {
|
||||
ctx.modifyAttributes(dn, mods);
|
||||
return null;
|
||||
}
|
||||
@@ -965,12 +953,11 @@ public class LdapTemplate implements LdapOperations, InitializingBean {
|
||||
* @see org.springframework.ldap.core.LdapOperations#modifyAttributes(java.lang.String,
|
||||
* javax.naming.directory.ModificationItem[])
|
||||
*/
|
||||
public void modifyAttributes(final String dn, final ModificationItem[] mods)
|
||||
throws DataAccessException {
|
||||
public void modifyAttributes(final String dn, final ModificationItem[] mods) {
|
||||
|
||||
executeReadWrite(new ContextExecutor() {
|
||||
public Object executeWithContext(DirContext ctx)
|
||||
throws NamingException {
|
||||
throws javax.naming.NamingException {
|
||||
ctx.modifyAttributes(dn, mods);
|
||||
return null;
|
||||
}
|
||||
@@ -986,7 +973,7 @@ public class LdapTemplate implements LdapOperations, InitializingBean {
|
||||
|
||||
executeReadWrite(new ContextExecutor() {
|
||||
public Object executeWithContext(DirContext ctx)
|
||||
throws NamingException {
|
||||
throws javax.naming.NamingException {
|
||||
ctx.bind(dn, obj, attributes);
|
||||
return null;
|
||||
}
|
||||
@@ -998,11 +985,11 @@ public class LdapTemplate implements LdapOperations, InitializingBean {
|
||||
* java.lang.Object, javax.naming.directory.Attributes)
|
||||
*/
|
||||
public void bind(final String dn, final Object obj,
|
||||
final Attributes attributes) throws DataAccessException {
|
||||
final Attributes attributes) {
|
||||
|
||||
executeReadWrite(new ContextExecutor() {
|
||||
public Object executeWithContext(DirContext ctx)
|
||||
throws NamingException {
|
||||
throws javax.naming.NamingException {
|
||||
ctx.bind(dn, obj, attributes);
|
||||
return null;
|
||||
}
|
||||
@@ -1019,7 +1006,7 @@ public class LdapTemplate implements LdapOperations, InitializingBean {
|
||||
/*
|
||||
* @see org.springframework.ldap.core.LdapOperations#unbind(java.lang.String)
|
||||
*/
|
||||
public void unbind(final String dn) throws DataAccessException {
|
||||
public void unbind(final String dn) {
|
||||
doUnbind(dn);
|
||||
}
|
||||
|
||||
@@ -1027,8 +1014,7 @@ public class LdapTemplate implements LdapOperations, InitializingBean {
|
||||
* @see org.springframework.ldap.core.LdapOperations#unbind(javax.naming.Name,
|
||||
* boolean)
|
||||
*/
|
||||
public void unbind(final Name dn, boolean recursive)
|
||||
throws DataAccessException {
|
||||
public void unbind(final Name dn, boolean recursive) {
|
||||
if (!recursive) {
|
||||
doUnbind(dn);
|
||||
} else {
|
||||
@@ -1040,8 +1026,7 @@ public class LdapTemplate implements LdapOperations, InitializingBean {
|
||||
* @see org.springframework.ldap.core.LdapOperations#unbind(java.lang.String,
|
||||
* boolean)
|
||||
*/
|
||||
public void unbind(final String dn, boolean recursive)
|
||||
throws DataAccessException {
|
||||
public void unbind(final String dn, boolean recursive) {
|
||||
if (!recursive) {
|
||||
doUnbind(dn);
|
||||
} else {
|
||||
@@ -1049,41 +1034,39 @@ public class LdapTemplate implements LdapOperations, InitializingBean {
|
||||
}
|
||||
}
|
||||
|
||||
private void doUnbind(final Name dn) throws DataAccessException {
|
||||
private void doUnbind(final Name dn) {
|
||||
executeReadWrite(new ContextExecutor() {
|
||||
public Object executeWithContext(DirContext ctx)
|
||||
throws NamingException {
|
||||
throws javax.naming.NamingException {
|
||||
ctx.unbind(dn);
|
||||
return null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void doUnbind(final String dn) throws DataAccessException {
|
||||
private void doUnbind(final String dn) {
|
||||
executeReadWrite(new ContextExecutor() {
|
||||
public Object executeWithContext(DirContext ctx)
|
||||
throws NamingException {
|
||||
throws javax.naming.NamingException {
|
||||
ctx.unbind(dn);
|
||||
return null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void doUnbindRecursively(final Name dn) throws DataAccessException {
|
||||
private void doUnbindRecursively(final Name dn) {
|
||||
executeReadWrite(new ContextExecutor() {
|
||||
public Object executeWithContext(DirContext ctx)
|
||||
throws NamingException {
|
||||
public Object executeWithContext(DirContext ctx) {
|
||||
deleteRecursively(ctx, new DistinguishedName(dn));
|
||||
return null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void doUnbindRecursively(final String dn)
|
||||
throws DataAccessException {
|
||||
private void doUnbindRecursively(final String dn) {
|
||||
executeReadWrite(new ContextExecutor() {
|
||||
public Object executeWithContext(DirContext ctx)
|
||||
throws NamingException {
|
||||
throws javax.naming.NamingException {
|
||||
deleteRecursively(ctx, new DistinguishedName(dn));
|
||||
return null;
|
||||
}
|
||||
@@ -1097,11 +1080,10 @@ public class LdapTemplate implements LdapOperations, InitializingBean {
|
||||
* The context to use for deleting.
|
||||
* @param name
|
||||
* The starting point to delete recursively.
|
||||
* @throws DataAccessException
|
||||
* @throws NamingException
|
||||
* if any error occurs
|
||||
*/
|
||||
protected void deleteRecursively(DirContext ctx, DistinguishedName name)
|
||||
throws DataAccessException {
|
||||
protected void deleteRecursively(DirContext ctx, DistinguishedName name) {
|
||||
|
||||
NamingEnumeration enumeration = null;
|
||||
try {
|
||||
@@ -1117,8 +1099,8 @@ public class LdapTemplate implements LdapOperations, InitializingBean {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Entry " + name + " deleted");
|
||||
}
|
||||
} catch (NamingException e) {
|
||||
throw getExceptionTranslator().translate(e);
|
||||
} catch (javax.naming.NamingException e) {
|
||||
throw LdapUtils.convertLdapException(e);
|
||||
} finally {
|
||||
try {
|
||||
enumeration.close();
|
||||
@@ -1133,11 +1115,11 @@ public class LdapTemplate implements LdapOperations, InitializingBean {
|
||||
* java.lang.Object, javax.naming.directory.Attributes)
|
||||
*/
|
||||
public void rebind(final Name dn, final Object obj,
|
||||
final Attributes attributes) throws DataAccessException {
|
||||
final Attributes attributes) {
|
||||
|
||||
executeReadWrite(new ContextExecutor() {
|
||||
public Object executeWithContext(DirContext ctx)
|
||||
throws NamingException {
|
||||
throws javax.naming.NamingException {
|
||||
ctx.rebind(dn, obj, attributes);
|
||||
return null;
|
||||
}
|
||||
@@ -1149,11 +1131,11 @@ public class LdapTemplate implements LdapOperations, InitializingBean {
|
||||
* java.lang.Object, javax.naming.directory.Attributes)
|
||||
*/
|
||||
public void rebind(final String dn, final Object obj,
|
||||
final Attributes attributes) throws DataAccessException {
|
||||
final Attributes attributes) {
|
||||
|
||||
executeReadWrite(new ContextExecutor() {
|
||||
public Object executeWithContext(DirContext ctx)
|
||||
throws NamingException {
|
||||
throws javax.naming.NamingException {
|
||||
ctx.rebind(dn, obj, attributes);
|
||||
return null;
|
||||
}
|
||||
@@ -1164,12 +1146,11 @@ public class LdapTemplate implements LdapOperations, InitializingBean {
|
||||
* @see org.springframework.ldap.core.LdapOperations#rename(javax.naming.Name,
|
||||
* javax.naming.Name)
|
||||
*/
|
||||
public void rename(final Name oldDn, final Name newDn)
|
||||
throws DataAccessException {
|
||||
public void rename(final Name oldDn, final Name newDn) {
|
||||
|
||||
executeReadWrite(new ContextExecutor() {
|
||||
public Object executeWithContext(DirContext ctx)
|
||||
throws NamingException {
|
||||
throws javax.naming.NamingException {
|
||||
ctx.rename(oldDn, newDn);
|
||||
return null;
|
||||
}
|
||||
@@ -1180,12 +1161,11 @@ public class LdapTemplate implements LdapOperations, InitializingBean {
|
||||
* @see org.springframework.ldap.core.LdapOperations#rename(java.lang.String,
|
||||
* java.lang.String)
|
||||
*/
|
||||
public void rename(final String oldDn, final String newDn)
|
||||
throws DataAccessException {
|
||||
public void rename(final String oldDn, final String newDn) {
|
||||
|
||||
executeReadWrite(new ContextExecutor() {
|
||||
public Object executeWithContext(DirContext ctx)
|
||||
throws NamingException {
|
||||
throws javax.naming.NamingException {
|
||||
ctx.rename(oldDn, newDn);
|
||||
return null;
|
||||
}
|
||||
@@ -1243,28 +1223,6 @@ public class LdapTemplate implements LdapOperations, InitializingBean {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the NamingExceptionTranslator that will be used by this instance. If
|
||||
* no exceptionTranslator has been set, a default instance will be created.
|
||||
*
|
||||
* @return the NamingExceptionTranslator to be used by this instance.
|
||||
*/
|
||||
public NamingExceptionTranslator getExceptionTranslator() {
|
||||
return exceptionTranslator;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the NamingExceptionTranslator to be used by this instance.
|
||||
*
|
||||
* @param exceptionTranslator
|
||||
* the NamingExceptionTranslator to use.
|
||||
*/
|
||||
public void setExceptionTranslator(
|
||||
NamingExceptionTranslator exceptionTranslator) {
|
||||
|
||||
this.exceptionTranslator = exceptionTranslator;
|
||||
}
|
||||
|
||||
private SearchControls getDefaultSearchControls(int searchScope,
|
||||
boolean returningObjFlag, String[] attrs) {
|
||||
|
||||
@@ -1323,8 +1281,8 @@ public class LdapTemplate implements LdapOperations, InitializingBean {
|
||||
public Object getObjectFromNameClassPair(NameClassPair nameClassPair) {
|
||||
try {
|
||||
return mapper.mapFromNameClassPair(nameClassPair);
|
||||
} catch (NamingException e) {
|
||||
throw getExceptionTranslator().translate(e);
|
||||
} catch (javax.naming.NamingException e) {
|
||||
throw LdapUtils.convertLdapException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1360,8 +1318,8 @@ public class LdapTemplate implements LdapOperations, InitializingBean {
|
||||
Attributes attributes = searchResult.getAttributes();
|
||||
try {
|
||||
return mapper.mapFromAttributes(attributes);
|
||||
} catch (NamingException e) {
|
||||
throw getExceptionTranslator().translate(e);
|
||||
} catch (javax.naming.NamingException e) {
|
||||
throw LdapUtils.convertLdapException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1394,7 +1352,7 @@ public class LdapTemplate implements LdapOperations, InitializingBean {
|
||||
Binding binding = (Binding) nameClassPair;
|
||||
Object object = binding.getObject();
|
||||
if (object == null) {
|
||||
throw new EntryNotFoundException(
|
||||
throw new ObjectRetrievalException(
|
||||
"SearchResult did not contain any object.");
|
||||
}
|
||||
return mapper.mapFromContext(object);
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Copyright 2002-2006 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.ldap.core;
|
||||
|
||||
import org.springframework.ldap.NamingException;
|
||||
|
||||
/**
|
||||
* Thrown by a ContextMapperCallbackHandler when it cannot retrieve an object
|
||||
* from the given Binding.
|
||||
*
|
||||
* @author Ulrik Sandberg
|
||||
* @since 1.2
|
||||
*/
|
||||
public class ObjectRetrievalException extends NamingException {
|
||||
|
||||
/**
|
||||
* Create a new ObjectRetrievalException.
|
||||
*
|
||||
* @param msg
|
||||
* the detail message
|
||||
*
|
||||
*/
|
||||
public ObjectRetrievalException(String msg) {
|
||||
super(msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new ObjectRetrievalException.
|
||||
*
|
||||
* @param msg
|
||||
* the detail message
|
||||
* @param cause
|
||||
* the root cause (if any)
|
||||
*/
|
||||
public ObjectRetrievalException(String msg, Throwable cause) {
|
||||
super(msg, cause);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -32,8 +32,7 @@ import org.springframework.ldap.core.AuthenticationSource;
|
||||
import org.springframework.ldap.core.ContextSource;
|
||||
import org.springframework.ldap.core.DefaultDirObjectFactory;
|
||||
import org.springframework.ldap.core.DistinguishedName;
|
||||
import org.springframework.ldap.support.DefaultNamingExceptionTranslator;
|
||||
import org.springframework.ldap.support.NamingExceptionTranslator;
|
||||
import org.springframework.ldap.support.LdapUtils;
|
||||
|
||||
/**
|
||||
* Abstract implementation of the ContextSource interface. By default, returns
|
||||
@@ -93,8 +92,6 @@ public abstract class AbstractContextSource implements ContextSource,
|
||||
|
||||
private boolean anonymousReadOnly = false;
|
||||
|
||||
private NamingExceptionTranslator exceptionTranslator = new DefaultNamingExceptionTranslator();
|
||||
|
||||
private static final Log log = LogFactory.getLog(LdapContextSource.class);
|
||||
|
||||
public static final String SUN_LDAP_POOLING_FLAG = "com.sun.jndi.ldap.connect.pool";
|
||||
@@ -203,7 +200,7 @@ public abstract class AbstractContextSource implements ContextSource,
|
||||
return ctx;
|
||||
} catch (NamingException e) {
|
||||
closeContext(ctx);
|
||||
throw getExceptionTranslator().translate(e);
|
||||
throw LdapUtils.convertLdapException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -420,27 +417,6 @@ public abstract class AbstractContextSource implements ContextSource,
|
||||
this.anonymousReadOnly = anonymousReadOnly;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the NamingExceptionTranslator to be used by this instance. By
|
||||
* default, a {@link DefaultNamingExceptionTranslator} will be used.
|
||||
*
|
||||
* @param exceptionTranslator
|
||||
* the NamingExceptionTranslator to use.
|
||||
*/
|
||||
public void setExceptionTranslator(
|
||||
NamingExceptionTranslator exceptionTranslator) {
|
||||
this.exceptionTranslator = exceptionTranslator;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the NamingExceptionTranslator used by this instance.
|
||||
*
|
||||
* @return the NamingExceptionTranslator.
|
||||
*/
|
||||
public NamingExceptionTranslator getExceptionTranslator() {
|
||||
return exceptionTranslator;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implement in subclass to create a DirContext of the desired type (e.g.
|
||||
* InitialDirContext or InitialLdapContext).
|
||||
|
||||
@@ -1,40 +0,0 @@
|
||||
/*
|
||||
* Copyright 2002-2005 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.ldap.support;
|
||||
|
||||
import org.springframework.dao.DataIntegrityViolationException;
|
||||
|
||||
/**
|
||||
* Exception that indicates that an invalid or missing Attribute has been
|
||||
* supplied to an LDAP operation.
|
||||
*
|
||||
* @author Mattias Arthursson
|
||||
* @deprecated Should be replaced with the matching mirrored NamingException
|
||||
*/
|
||||
public class AttributesIntegrityViolationException extends
|
||||
DataIntegrityViolationException {
|
||||
|
||||
private static final long serialVersionUID = -6368616096960202571L;
|
||||
|
||||
public AttributesIntegrityViolationException(String msg) {
|
||||
super(msg);
|
||||
}
|
||||
|
||||
public AttributesIntegrityViolationException(String msg, Throwable t) {
|
||||
super(msg, t);
|
||||
}
|
||||
}
|
||||
@@ -30,6 +30,7 @@ import org.springframework.dao.DataAccessException;
|
||||
import org.springframework.dao.DataIntegrityViolationException;
|
||||
import org.springframework.dao.DataRetrievalFailureException;
|
||||
import org.springframework.dao.InvalidDataAccessApiUsageException;
|
||||
import org.springframework.dao.UncategorizedDataAccessException;
|
||||
import org.springframework.ldap.BadLdapGrammarException;
|
||||
|
||||
/**
|
||||
@@ -53,11 +54,6 @@ public class DefaultNamingExceptionTranslator implements
|
||||
namingException);
|
||||
}
|
||||
|
||||
if (namingException instanceof InvalidSearchFilterException) {
|
||||
return new BadLdapGrammarException("Invalid search filter",
|
||||
namingException);
|
||||
}
|
||||
|
||||
if (namingException instanceof InvalidSearchControlsException) {
|
||||
return new InvalidDataAccessApiUsageException(
|
||||
"Invalid search controls supplied by internal API",
|
||||
@@ -75,23 +71,13 @@ public class DefaultNamingExceptionTranslator implements
|
||||
namingException);
|
||||
}
|
||||
|
||||
if (namingException instanceof InvalidAttributesException) {
|
||||
return new AttributesIntegrityViolationException(
|
||||
"Invalid attributes", namingException);
|
||||
}
|
||||
|
||||
if (namingException instanceof LimitExceededException) {
|
||||
return new SearchLimitExceededException("Too many objects found",
|
||||
namingException);
|
||||
}
|
||||
|
||||
if (namingException instanceof CommunicationException) {
|
||||
throw new DataRetrievalFailureException(
|
||||
"Unable to communicate with LDAP server", namingException);
|
||||
}
|
||||
|
||||
// Fallback - other type of NamingException encountered.
|
||||
return new UncategorizedLdapException("Operation failed",
|
||||
namingException);
|
||||
return new UncategorizedDataAccessException("Operation failed",
|
||||
namingException) {};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,11 +25,13 @@ import org.springframework.dao.DataAccessException;
|
||||
* NamingExceptions and DataAccessExceptions.
|
||||
*
|
||||
* @author Mattias Arthursson
|
||||
*
|
||||
* @deprecated Use {@link LdapUtils#convertLdapException(NamingException)}
|
||||
* instead.
|
||||
*/
|
||||
public interface NamingExceptionTranslator {
|
||||
/**
|
||||
* Translate the given NamingException into a generic data access exception.
|
||||
*
|
||||
* @param namingException
|
||||
* the offending NamingException.
|
||||
*
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
/*
|
||||
* Copyright 2002-2005 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.ldap.support;
|
||||
|
||||
import org.springframework.dao.DataRetrievalFailureException;
|
||||
|
||||
/**
|
||||
* Indicates that the search limit was exceeded in a search.
|
||||
*
|
||||
* @author Mattias Arthursson
|
||||
* @deprecated Should be replaced with the matching mirrored NamingException
|
||||
*/
|
||||
public class SearchLimitExceededException extends DataRetrievalFailureException {
|
||||
private static final long serialVersionUID = 6899885947075235580L;
|
||||
|
||||
public SearchLimitExceededException(String msg) {
|
||||
super(msg);
|
||||
}
|
||||
|
||||
public SearchLimitExceededException(String msg, Throwable cause) {
|
||||
super(msg, cause);
|
||||
}
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
/*
|
||||
* Copyright 2002-2005 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.ldap.support;
|
||||
|
||||
import org.springframework.dao.UncategorizedDataAccessException;
|
||||
|
||||
/**
|
||||
* Indicates that an unknown NamingException has occurred.
|
||||
*
|
||||
* @author Mattias Arthursson
|
||||
* @deprecated Should be replaced with {@link org.springframework.ldap.support.UncategorizedLdapException}
|
||||
*/
|
||||
public class UncategorizedLdapException extends
|
||||
UncategorizedDataAccessException {
|
||||
|
||||
private static final long serialVersionUID = -3319936235493869823L;
|
||||
|
||||
public UncategorizedLdapException(String msg, Throwable cause) {
|
||||
super(msg, cause);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -23,7 +23,6 @@ import javax.naming.Name;
|
||||
import javax.naming.NameClassPair;
|
||||
import javax.naming.NamingEnumeration;
|
||||
import javax.naming.NamingException;
|
||||
import javax.naming.PartialResultException;
|
||||
import javax.naming.directory.DirContext;
|
||||
import javax.naming.ldap.LdapContext;
|
||||
|
||||
@@ -34,8 +33,6 @@ import org.springframework.ldap.core.ContextMapper;
|
||||
import org.springframework.ldap.core.ContextSource;
|
||||
import org.springframework.ldap.core.LdapTemplate;
|
||||
import org.springframework.ldap.core.NameClassPairCallbackHandler;
|
||||
import org.springframework.ldap.support.EntryNotFoundException;
|
||||
import org.springframework.ldap.support.NamingExceptionTranslator;
|
||||
|
||||
/**
|
||||
* Unit tests for the <code>list</code> operations in {@link LdapTemplate}.
|
||||
@@ -72,10 +69,6 @@ public class LdapTemplateListTest extends TestCase {
|
||||
|
||||
private ContextMapper contextMapperMock;
|
||||
|
||||
private MockControl exceptionTranslatorControl;
|
||||
|
||||
private NamingExceptionTranslator exceptionTranslatorMock;
|
||||
|
||||
private LdapTemplate tested;
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
@@ -107,13 +100,7 @@ public class LdapTemplateListTest extends TestCase {
|
||||
contextMapperControl = MockControl.createControl(ContextMapper.class);
|
||||
contextMapperMock = (ContextMapper) contextMapperControl.getMock();
|
||||
|
||||
exceptionTranslatorControl = MockControl
|
||||
.createControl(NamingExceptionTranslator.class);
|
||||
exceptionTranslatorMock = (NamingExceptionTranslator) exceptionTranslatorControl
|
||||
.getMock();
|
||||
|
||||
tested = new LdapTemplate(contextSourceMock);
|
||||
tested.setExceptionTranslator(exceptionTranslatorMock);
|
||||
}
|
||||
|
||||
protected void tearDown() throws Exception {
|
||||
@@ -136,9 +123,6 @@ public class LdapTemplateListTest extends TestCase {
|
||||
|
||||
contextMapperControl = null;
|
||||
contextMapperMock = null;
|
||||
|
||||
exceptionTranslatorControl = null;
|
||||
exceptionTranslatorMock = null;
|
||||
}
|
||||
|
||||
protected void replay() {
|
||||
@@ -148,7 +132,6 @@ public class LdapTemplateListTest extends TestCase {
|
||||
nameControl.replay();
|
||||
handlerControl.replay();
|
||||
contextMapperControl.replay();
|
||||
exceptionTranslatorControl.replay();
|
||||
}
|
||||
|
||||
protected void verify() {
|
||||
@@ -158,7 +141,6 @@ public class LdapTemplateListTest extends TestCase {
|
||||
nameControl.verify();
|
||||
handlerControl.verify();
|
||||
contextMapperControl.verify();
|
||||
exceptionTranslatorControl.verify();
|
||||
}
|
||||
|
||||
private void expectGetReadOnlyContext() {
|
||||
@@ -182,8 +164,8 @@ public class LdapTemplateListTest extends TestCase {
|
||||
setupNamingEnumeration(listResult);
|
||||
}
|
||||
|
||||
private void setupStringListBindingsAndNamingEnumeration(NameClassPair listResult)
|
||||
throws NamingException {
|
||||
private void setupStringListBindingsAndNamingEnumeration(
|
||||
NameClassPair listResult) throws NamingException {
|
||||
dirContextControl.expectAndReturn(dirContextMock.listBindings(NAME),
|
||||
namingEnumerationMock);
|
||||
|
||||
@@ -192,8 +174,8 @@ public class LdapTemplateListTest extends TestCase {
|
||||
|
||||
private void setupListBindingsAndNamingEnumeration(NameClassPair listResult)
|
||||
throws NamingException {
|
||||
dirContextControl.expectAndReturn(dirContextMock.listBindings(nameMock),
|
||||
namingEnumerationMock);
|
||||
dirContextControl.expectAndReturn(
|
||||
dirContextMock.listBindings(nameMock), namingEnumerationMock);
|
||||
|
||||
setupNamingEnumeration(listResult);
|
||||
}
|
||||
@@ -288,20 +270,17 @@ public class LdapTemplateListTest extends TestCase {
|
||||
public void testList_PartialResultException() throws NamingException {
|
||||
expectGetReadOnlyContext();
|
||||
|
||||
PartialResultException pre = new PartialResultException();
|
||||
javax.naming.PartialResultException pre = new javax.naming.PartialResultException();
|
||||
dirContextControl.expectAndThrow(dirContextMock.list(NAME), pre);
|
||||
|
||||
dirContextMock.close();
|
||||
|
||||
exceptionTranslatorControl.expectAndReturn(exceptionTranslatorMock
|
||||
.translate(pre), new EntryNotFoundException("dummy"));
|
||||
|
||||
replay();
|
||||
|
||||
try {
|
||||
tested.list(NAME);
|
||||
fail("EntryNotFoundException expected");
|
||||
} catch (EntryNotFoundException expected) {
|
||||
fail("PartialResultException expected");
|
||||
} catch (PartialResultException expected) {
|
||||
assertTrue(true);
|
||||
}
|
||||
|
||||
@@ -311,7 +290,7 @@ public class LdapTemplateListTest extends TestCase {
|
||||
public void testList_PartialResultException_Ignore() throws NamingException {
|
||||
expectGetReadOnlyContext();
|
||||
|
||||
PartialResultException pre = new PartialResultException();
|
||||
javax.naming.PartialResultException pre = new javax.naming.PartialResultException();
|
||||
dirContextControl.expectAndThrow(dirContextMock.list(NAME), pre);
|
||||
|
||||
dirContextMock.close();
|
||||
@@ -331,20 +310,17 @@ public class LdapTemplateListTest extends TestCase {
|
||||
public void testList_NamingException() throws NamingException {
|
||||
expectGetReadOnlyContext();
|
||||
|
||||
NamingException ne = new NamingException();
|
||||
javax.naming.LimitExceededException ne = new javax.naming.LimitExceededException();
|
||||
dirContextControl.expectAndThrow(dirContextMock.list(NAME), ne);
|
||||
|
||||
dirContextMock.close();
|
||||
|
||||
exceptionTranslatorControl.expectAndReturn(exceptionTranslatorMock
|
||||
.translate(ne), new EntryNotFoundException("dummy"));
|
||||
|
||||
replay();
|
||||
|
||||
try {
|
||||
tested.list(NAME);
|
||||
fail("EntryNotFoundException expected");
|
||||
} catch (EntryNotFoundException expected) {
|
||||
fail("LimitExceededException expected");
|
||||
} catch (LimitExceededException expected) {
|
||||
assertTrue(true);
|
||||
}
|
||||
|
||||
|
||||
@@ -17,8 +17,6 @@
|
||||
package org.springframework.ldap;
|
||||
|
||||
import javax.naming.Name;
|
||||
import javax.naming.NameNotFoundException;
|
||||
import javax.naming.NamingException;
|
||||
import javax.naming.directory.BasicAttributes;
|
||||
import javax.naming.directory.DirContext;
|
||||
import javax.naming.ldap.LdapContext;
|
||||
@@ -32,8 +30,6 @@ import org.springframework.ldap.core.ContextSource;
|
||||
import org.springframework.ldap.core.DirContextAdapter;
|
||||
import org.springframework.ldap.core.DistinguishedName;
|
||||
import org.springframework.ldap.core.LdapTemplate;
|
||||
import org.springframework.ldap.support.EntryNotFoundException;
|
||||
import org.springframework.ldap.support.NamingExceptionTranslator;
|
||||
|
||||
public class LdapTemplateLookupTest extends TestCase {
|
||||
|
||||
@@ -59,10 +55,6 @@ public class LdapTemplateLookupTest extends TestCase {
|
||||
|
||||
private ContextMapper contextMapperMock;
|
||||
|
||||
private MockControl exceptionTranslatorControl;
|
||||
|
||||
private NamingExceptionTranslator exceptionTranslatorMock;
|
||||
|
||||
private LdapTemplate tested;
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
@@ -88,13 +80,7 @@ public class LdapTemplateLookupTest extends TestCase {
|
||||
attributesMapperMock = (AttributesMapper) attributesMapperControl
|
||||
.getMock();
|
||||
|
||||
exceptionTranslatorControl = MockControl
|
||||
.createControl(NamingExceptionTranslator.class);
|
||||
exceptionTranslatorMock = (NamingExceptionTranslator) exceptionTranslatorControl
|
||||
.getMock();
|
||||
|
||||
tested = new LdapTemplate(contextSourceMock);
|
||||
tested.setExceptionTranslator(exceptionTranslatorMock);
|
||||
}
|
||||
|
||||
protected void tearDown() throws Exception {
|
||||
@@ -114,9 +100,6 @@ public class LdapTemplateLookupTest extends TestCase {
|
||||
|
||||
attributesMapperControl = null;
|
||||
attributesMapperMock = null;
|
||||
|
||||
exceptionTranslatorControl = null;
|
||||
exceptionTranslatorMock = null;
|
||||
}
|
||||
|
||||
protected void replay() {
|
||||
@@ -125,7 +108,6 @@ public class LdapTemplateLookupTest extends TestCase {
|
||||
nameControl.replay();
|
||||
contextMapperControl.replay();
|
||||
attributesMapperControl.replay();
|
||||
exceptionTranslatorControl.replay();
|
||||
}
|
||||
|
||||
protected void verify() {
|
||||
@@ -134,7 +116,6 @@ public class LdapTemplateLookupTest extends TestCase {
|
||||
nameControl.verify();
|
||||
contextMapperControl.verify();
|
||||
attributesMapperControl.verify();
|
||||
exceptionTranslatorControl.verify();
|
||||
}
|
||||
|
||||
private void expectGetReadOnlyContext() {
|
||||
@@ -144,7 +125,7 @@ public class LdapTemplateLookupTest extends TestCase {
|
||||
|
||||
// Tests for lookup(name)
|
||||
|
||||
public void testLookup() throws NamingException {
|
||||
public void testLookup() throws Exception {
|
||||
expectGetReadOnlyContext();
|
||||
|
||||
Object expected = new Object();
|
||||
@@ -162,7 +143,7 @@ public class LdapTemplateLookupTest extends TestCase {
|
||||
assertSame(expected, actual);
|
||||
}
|
||||
|
||||
public void testLookup_String() throws NamingException {
|
||||
public void testLookup_String() throws Exception {
|
||||
expectGetReadOnlyContext();
|
||||
|
||||
Object expected = new Object();
|
||||
@@ -180,23 +161,20 @@ public class LdapTemplateLookupTest extends TestCase {
|
||||
assertSame(expected, actual);
|
||||
}
|
||||
|
||||
public void testLookup_NamingException() throws NamingException {
|
||||
public void testLookup_NamingException() throws Exception {
|
||||
expectGetReadOnlyContext();
|
||||
|
||||
NamingException ne = new NamingException();
|
||||
javax.naming.NameNotFoundException ne = new javax.naming.NameNotFoundException();
|
||||
dirContextControl.expectAndThrow(dirContextMock.lookup(nameMock), ne);
|
||||
|
||||
dirContextMock.close();
|
||||
|
||||
exceptionTranslatorControl.expectAndReturn(exceptionTranslatorMock
|
||||
.translate(ne), new EntryNotFoundException("dummy"));
|
||||
|
||||
replay();
|
||||
|
||||
try {
|
||||
tested.lookup(nameMock);
|
||||
fail("EntryNotFoundException expected");
|
||||
} catch (EntryNotFoundException expected) {
|
||||
fail("NameNotFoundException expected");
|
||||
} catch (NameNotFoundException expected) {
|
||||
assertTrue(true);
|
||||
}
|
||||
|
||||
@@ -251,20 +229,17 @@ public class LdapTemplateLookupTest extends TestCase {
|
||||
public void testLookup_AttributesMapper_NamingException() throws Exception {
|
||||
expectGetReadOnlyContext();
|
||||
|
||||
NamingException ne = new NamingException();
|
||||
javax.naming.NameNotFoundException ne = new javax.naming.NameNotFoundException();
|
||||
dirContextControl.expectAndThrow(
|
||||
dirContextMock.getAttributes(nameMock), ne);
|
||||
dirContextMock.close();
|
||||
|
||||
exceptionTranslatorControl.expectAndReturn(exceptionTranslatorMock
|
||||
.translate(ne), new EntryNotFoundException("dummy"));
|
||||
|
||||
replay();
|
||||
|
||||
try {
|
||||
tested.lookup(nameMock, attributesMapperMock);
|
||||
fail("EntryNotFoundException expected");
|
||||
} catch (EntryNotFoundException expected) {
|
||||
fail("NameNotFoundException expected");
|
||||
} catch (NameNotFoundException expected) {
|
||||
assertTrue(true);
|
||||
}
|
||||
|
||||
@@ -320,20 +295,17 @@ public class LdapTemplateLookupTest extends TestCase {
|
||||
public void testLookup_ContextMapper_NamingException() throws Exception {
|
||||
expectGetReadOnlyContext();
|
||||
|
||||
NameNotFoundException ne = new NameNotFoundException();
|
||||
javax.naming.NameNotFoundException ne = new javax.naming.NameNotFoundException();
|
||||
dirContextControl.expectAndThrow(dirContextMock.lookup(nameMock), ne);
|
||||
|
||||
dirContextMock.close();
|
||||
|
||||
exceptionTranslatorControl.expectAndReturn(exceptionTranslatorMock
|
||||
.translate(ne), new EntryNotFoundException("dummy"));
|
||||
|
||||
replay();
|
||||
|
||||
try {
|
||||
tested.lookup(nameMock, contextMapperMock);
|
||||
fail("EntryNotFoundException expected");
|
||||
} catch (EntryNotFoundException expected) {
|
||||
fail("NameNotFoundException expected");
|
||||
} catch (NameNotFoundException expected) {
|
||||
assertTrue(true);
|
||||
}
|
||||
|
||||
|
||||
@@ -17,20 +17,14 @@
|
||||
package org.springframework.ldap;
|
||||
|
||||
import javax.naming.Name;
|
||||
import javax.naming.NameAlreadyBoundException;
|
||||
import javax.naming.NamingException;
|
||||
import javax.naming.directory.DirContext;
|
||||
import javax.naming.ldap.LdapContext;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
|
||||
import org.easymock.MockControl;
|
||||
import org.springframework.dao.DataIntegrityViolationException;
|
||||
import org.springframework.ldap.core.ContextSource;
|
||||
import org.springframework.ldap.core.LdapTemplate;
|
||||
import org.springframework.ldap.support.NamingExceptionTranslator;
|
||||
import org.springframework.ldap.support.UncategorizedLdapException;
|
||||
|
||||
/**
|
||||
* Unit tests for the rename operations in the LdapTemplate class.
|
||||
@@ -55,10 +49,6 @@ public class LdapTemplateRenameTest extends TestCase {
|
||||
|
||||
private Name newNameMock;
|
||||
|
||||
private MockControl exceptionTranslatorControl;
|
||||
|
||||
private NamingExceptionTranslator exceptionTranslatorMock;
|
||||
|
||||
private LdapTemplate tested;
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
@@ -80,13 +70,7 @@ public class LdapTemplateRenameTest extends TestCase {
|
||||
newNameControl = MockControl.createControl(Name.class);
|
||||
newNameMock = (Name) newNameControl.getMock();
|
||||
|
||||
exceptionTranslatorControl = MockControl
|
||||
.createControl(NamingExceptionTranslator.class);
|
||||
exceptionTranslatorMock = (NamingExceptionTranslator) exceptionTranslatorControl
|
||||
.getMock();
|
||||
|
||||
tested = new LdapTemplate(contextSourceMock);
|
||||
tested.setExceptionTranslator(exceptionTranslatorMock);
|
||||
}
|
||||
|
||||
protected void tearDown() throws Exception {
|
||||
@@ -100,23 +84,18 @@ public class LdapTemplateRenameTest extends TestCase {
|
||||
|
||||
oldNameControl = null;
|
||||
newNameMock = null;
|
||||
|
||||
exceptionTranslatorControl = null;
|
||||
exceptionTranslatorMock = null;
|
||||
}
|
||||
|
||||
protected void replay() {
|
||||
contextSourceControl.replay();
|
||||
dirContextControl.replay();
|
||||
oldNameControl.replay();
|
||||
exceptionTranslatorControl.replay();
|
||||
}
|
||||
|
||||
protected void verify() {
|
||||
contextSourceControl.verify();
|
||||
dirContextControl.verify();
|
||||
oldNameControl.verify();
|
||||
exceptionTranslatorControl.verify();
|
||||
}
|
||||
|
||||
private void expectGetReadWriteContext() {
|
||||
@@ -124,7 +103,7 @@ public class LdapTemplateRenameTest extends TestCase {
|
||||
.getReadWriteContext(), dirContextMock);
|
||||
}
|
||||
|
||||
public void testRename() throws NamingException {
|
||||
public void testRename() throws Exception {
|
||||
expectGetReadWriteContext();
|
||||
|
||||
dirContextMock.rename(oldNameMock, newNameMock);
|
||||
@@ -141,19 +120,16 @@ public class LdapTemplateRenameTest extends TestCase {
|
||||
expectGetReadWriteContext();
|
||||
|
||||
dirContextMock.rename(oldNameMock, newNameMock);
|
||||
NameAlreadyBoundException ne = new NameAlreadyBoundException();
|
||||
javax.naming.NameAlreadyBoundException ne = new javax.naming.NameAlreadyBoundException();
|
||||
dirContextControl.setThrowable(ne);
|
||||
dirContextMock.close();
|
||||
|
||||
exceptionTranslatorControl.expectAndReturn(exceptionTranslatorMock
|
||||
.translate(ne), new DataIntegrityViolationException("dummy"));
|
||||
|
||||
replay();
|
||||
|
||||
try {
|
||||
tested.rename(oldNameMock, newNameMock);
|
||||
fail("DataIntegrityViolationException expected");
|
||||
} catch (DataIntegrityViolationException expected) {
|
||||
fail("NameAlreadyBoundException expected");
|
||||
} catch (NameAlreadyBoundException expected) {
|
||||
assertTrue(true);
|
||||
}
|
||||
|
||||
@@ -164,13 +140,10 @@ public class LdapTemplateRenameTest extends TestCase {
|
||||
expectGetReadWriteContext();
|
||||
|
||||
dirContextMock.rename(oldNameMock, newNameMock);
|
||||
NamingException ne = new NamingException();
|
||||
javax.naming.NamingException ne = new javax.naming.NamingException();
|
||||
dirContextControl.setThrowable(ne);
|
||||
dirContextMock.close();
|
||||
|
||||
exceptionTranslatorControl.expectAndReturn(exceptionTranslatorMock
|
||||
.translate(ne), new UncategorizedLdapException("dummy", ne));
|
||||
|
||||
replay();
|
||||
|
||||
try {
|
||||
@@ -183,7 +156,7 @@ public class LdapTemplateRenameTest extends TestCase {
|
||||
verify();
|
||||
}
|
||||
|
||||
public void testRename_String() throws NamingException {
|
||||
public void testRename_String() throws Exception {
|
||||
expectGetReadWriteContext();
|
||||
|
||||
dirContextMock.rename("o=example.com", "o=somethingelse.com");
|
||||
|
||||
@@ -20,10 +20,7 @@ import java.util.List;
|
||||
|
||||
import javax.naming.Binding;
|
||||
import javax.naming.Name;
|
||||
import javax.naming.NameNotFoundException;
|
||||
import javax.naming.NamingEnumeration;
|
||||
import javax.naming.NamingException;
|
||||
import javax.naming.PartialResultException;
|
||||
import javax.naming.directory.BasicAttributes;
|
||||
import javax.naming.directory.DirContext;
|
||||
import javax.naming.directory.ModificationItem;
|
||||
@@ -44,8 +41,6 @@ import org.springframework.ldap.core.DistinguishedName;
|
||||
import org.springframework.ldap.core.LdapTemplate;
|
||||
import org.springframework.ldap.core.NameClassPairCallbackHandler;
|
||||
import org.springframework.ldap.core.SearchExecutor;
|
||||
import org.springframework.ldap.support.EntryNotFoundException;
|
||||
import org.springframework.ldap.support.NamingExceptionTranslator;
|
||||
|
||||
public class LdapTemplateTest extends TestCase {
|
||||
|
||||
@@ -79,10 +74,6 @@ public class LdapTemplateTest extends TestCase {
|
||||
|
||||
private ContextMapper contextMapperMock;
|
||||
|
||||
private MockControl exceptionTranslatorControl;
|
||||
|
||||
private NamingExceptionTranslator exceptionTranslatorMock;
|
||||
|
||||
private MockControl contextExecutorControl;
|
||||
|
||||
private ContextExecutor contextExecutorMock;
|
||||
@@ -131,11 +122,6 @@ public class LdapTemplateTest extends TestCase {
|
||||
attributesMapperMock = (AttributesMapper) attributesMapperControl
|
||||
.getMock();
|
||||
|
||||
exceptionTranslatorControl = MockControl
|
||||
.createControl(NamingExceptionTranslator.class);
|
||||
exceptionTranslatorMock = (NamingExceptionTranslator) exceptionTranslatorControl
|
||||
.getMock();
|
||||
|
||||
contextExecutorControl = MockControl
|
||||
.createControl(ContextExecutor.class);
|
||||
contextExecutorMock = (ContextExecutor) contextExecutorControl
|
||||
@@ -150,7 +136,6 @@ public class LdapTemplateTest extends TestCase {
|
||||
.getMock();
|
||||
|
||||
tested = new LdapTemplate(contextSourceMock);
|
||||
tested.setExceptionTranslator(exceptionTranslatorMock);
|
||||
}
|
||||
|
||||
protected void tearDown() throws Exception {
|
||||
@@ -177,9 +162,6 @@ public class LdapTemplateTest extends TestCase {
|
||||
attributesMapperControl = null;
|
||||
attributesMapperMock = null;
|
||||
|
||||
exceptionTranslatorControl = null;
|
||||
exceptionTranslatorMock = null;
|
||||
|
||||
contextExecutorControl = null;
|
||||
contextExecutorMock = null;
|
||||
|
||||
@@ -198,7 +180,6 @@ public class LdapTemplateTest extends TestCase {
|
||||
handlerControl.replay();
|
||||
contextMapperControl.replay();
|
||||
attributesMapperControl.replay();
|
||||
exceptionTranslatorControl.replay();
|
||||
contextExecutorControl.replay();
|
||||
searchExecutorControl.replay();
|
||||
dirContextProcessorControl.replay();
|
||||
@@ -212,7 +193,6 @@ public class LdapTemplateTest extends TestCase {
|
||||
handlerControl.verify();
|
||||
contextMapperControl.verify();
|
||||
attributesMapperControl.verify();
|
||||
exceptionTranslatorControl.verify();
|
||||
contextExecutorControl.verify();
|
||||
searchExecutorControl.verify();
|
||||
dirContextProcessorControl.verify();
|
||||
@@ -228,7 +208,7 @@ public class LdapTemplateTest extends TestCase {
|
||||
.getReadOnlyContext(), dirContextMock);
|
||||
}
|
||||
|
||||
public void testSearch_CallbackHandler() throws NamingException {
|
||||
public void testSearch_CallbackHandler() throws Exception {
|
||||
expectGetReadOnlyContext();
|
||||
|
||||
SearchControls controls = new SearchControls();
|
||||
@@ -251,7 +231,7 @@ public class LdapTemplateTest extends TestCase {
|
||||
verify();
|
||||
}
|
||||
|
||||
public void testSearch_StringBase_CallbackHandler() throws NamingException {
|
||||
public void testSearch_StringBase_CallbackHandler() throws Exception {
|
||||
expectGetReadOnlyContext();
|
||||
|
||||
SearchControls controls = new SearchControls();
|
||||
@@ -276,7 +256,7 @@ public class LdapTemplateTest extends TestCase {
|
||||
}
|
||||
|
||||
private void setupStringSearchAndNamingEnumeration(SearchControls controls,
|
||||
SearchResult searchResult) throws NamingException {
|
||||
SearchResult searchResult) throws Exception {
|
||||
dirContextControl.setDefaultMatcher(new SearchControlsMatcher());
|
||||
dirContextControl.expectAndReturn(dirContextMock.search(
|
||||
DEFAULT_BASE_STRING, "(ou=somevalue)", controls),
|
||||
@@ -291,7 +271,7 @@ public class LdapTemplateTest extends TestCase {
|
||||
namingEnumerationMock.close();
|
||||
}
|
||||
|
||||
public void testSearch_CallbackHandler_Defaults() throws NamingException {
|
||||
public void testSearch_CallbackHandler_Defaults() throws Exception {
|
||||
expectGetReadOnlyContext();
|
||||
|
||||
SearchControls controls = new SearchControls();
|
||||
@@ -314,8 +294,7 @@ public class LdapTemplateTest extends TestCase {
|
||||
verify();
|
||||
}
|
||||
|
||||
public void testSearch_String_CallbackHandler_Defaults()
|
||||
throws NamingException {
|
||||
public void testSearch_String_CallbackHandler_Defaults() throws Exception {
|
||||
expectGetReadOnlyContext();
|
||||
|
||||
SearchControls controls = new SearchControls();
|
||||
@@ -339,7 +318,7 @@ public class LdapTemplateTest extends TestCase {
|
||||
}
|
||||
|
||||
private void setupSearchAndNamingEnumeration(SearchControls controls,
|
||||
SearchResult searchResult) throws NamingException {
|
||||
SearchResult searchResult) throws Exception {
|
||||
dirContextControl.setDefaultMatcher(new SearchControlsMatcher());
|
||||
dirContextControl.expectAndReturn(dirContextMock.search(nameMock,
|
||||
"(ou=somevalue)", controls), namingEnumerationMock);
|
||||
@@ -353,7 +332,7 @@ public class LdapTemplateTest extends TestCase {
|
||||
namingEnumerationMock.close();
|
||||
}
|
||||
|
||||
public void testSearch_NameNotFoundException() throws NamingException {
|
||||
public void testSearch_NameNotFoundException() throws Exception {
|
||||
expectGetReadOnlyContext();
|
||||
|
||||
SearchControls controls = new SearchControls();
|
||||
@@ -361,8 +340,9 @@ public class LdapTemplateTest extends TestCase {
|
||||
controls.setReturningObjFlag(false);
|
||||
|
||||
dirContextControl.setDefaultMatcher(new SearchControlsMatcher());
|
||||
javax.naming.NameNotFoundException ne = new javax.naming.NameNotFoundException();
|
||||
dirContextControl.expectAndThrow(dirContextMock.search(nameMock,
|
||||
"(ou=somevalue)", controls), new NameNotFoundException());
|
||||
"(ou=somevalue)", controls), ne);
|
||||
|
||||
dirContextMock.close();
|
||||
|
||||
@@ -373,7 +353,7 @@ public class LdapTemplateTest extends TestCase {
|
||||
verify();
|
||||
}
|
||||
|
||||
public void testSearch_NamingException() throws NamingException {
|
||||
public void testSearch_NamingException() throws Exception {
|
||||
expectGetReadOnlyContext();
|
||||
|
||||
SearchControls controls = new SearchControls();
|
||||
@@ -381,31 +361,26 @@ public class LdapTemplateTest extends TestCase {
|
||||
controls.setReturningObjFlag(false);
|
||||
|
||||
dirContextControl.setDefaultMatcher(new SearchControlsMatcher());
|
||||
NamingException ne = new NamingException();
|
||||
javax.naming.LimitExceededException ne = new javax.naming.LimitExceededException();
|
||||
dirContextControl.expectAndThrow(dirContextMock.search(nameMock,
|
||||
"(ou=somevalue)", controls), ne);
|
||||
|
||||
dirContextMock.close();
|
||||
|
||||
EntryNotFoundException expectedException = new EntryNotFoundException(
|
||||
"dummy");
|
||||
exceptionTranslatorControl.expectAndReturn(exceptionTranslatorMock
|
||||
.translate(ne), expectedException);
|
||||
|
||||
replay();
|
||||
|
||||
try {
|
||||
tested.search(nameMock, "(ou=somevalue)", handlerMock);
|
||||
fail("EntryNotFoundException expected");
|
||||
} catch (EntryNotFoundException expected) {
|
||||
assertSame(expectedException, expected);
|
||||
fail("LimitExceededException expected");
|
||||
} catch (LimitExceededException expected) {
|
||||
// expected
|
||||
}
|
||||
|
||||
verify();
|
||||
}
|
||||
|
||||
public void testSearch_CallbackHandler_DirContextProcessor()
|
||||
throws NamingException {
|
||||
throws Exception {
|
||||
expectGetReadOnlyContext();
|
||||
|
||||
SearchControls controls = new SearchControls();
|
||||
@@ -434,7 +409,7 @@ public class LdapTemplateTest extends TestCase {
|
||||
}
|
||||
|
||||
public void testSearch_String_CallbackHandler_DirContextProcessor()
|
||||
throws NamingException {
|
||||
throws Exception {
|
||||
expectGetReadOnlyContext();
|
||||
|
||||
SearchControls controls = new SearchControls();
|
||||
@@ -463,7 +438,7 @@ public class LdapTemplateTest extends TestCase {
|
||||
}
|
||||
|
||||
public void testSearch_String_AttributesMapper_DirContextProcessor()
|
||||
throws NamingException {
|
||||
throws Exception {
|
||||
expectGetReadOnlyContext();
|
||||
|
||||
SearchControls controls = new SearchControls();
|
||||
@@ -497,7 +472,7 @@ public class LdapTemplateTest extends TestCase {
|
||||
}
|
||||
|
||||
public void testSearch_Name_AttributesMapper_DirContextProcessor()
|
||||
throws NamingException {
|
||||
throws Exception {
|
||||
expectGetReadOnlyContext();
|
||||
|
||||
SearchControls controls = new SearchControls();
|
||||
@@ -598,8 +573,7 @@ public class LdapTemplateTest extends TestCase {
|
||||
assertSame(expectedResult, list.get(0));
|
||||
}
|
||||
|
||||
public void testSearch_AttributesMapper_ReturningAttrs()
|
||||
throws NamingException {
|
||||
public void testSearch_AttributesMapper_ReturningAttrs() throws Exception {
|
||||
expectGetReadOnlyContext();
|
||||
|
||||
String[] attrs = new String[0];
|
||||
@@ -633,7 +607,7 @@ public class LdapTemplateTest extends TestCase {
|
||||
}
|
||||
|
||||
public void testSearch_String_AttributesMapper_ReturningAttrs()
|
||||
throws NamingException {
|
||||
throws Exception {
|
||||
expectGetReadOnlyContext();
|
||||
|
||||
String[] attrs = new String[0];
|
||||
@@ -666,7 +640,7 @@ public class LdapTemplateTest extends TestCase {
|
||||
assertSame(expectedResult, list.get(0));
|
||||
}
|
||||
|
||||
public void testSearch_AttributesMapper() throws NamingException {
|
||||
public void testSearch_AttributesMapper() throws Exception {
|
||||
expectGetReadOnlyContext();
|
||||
|
||||
SearchControls controls = new SearchControls();
|
||||
@@ -697,7 +671,7 @@ public class LdapTemplateTest extends TestCase {
|
||||
assertSame(expectedResult, list.get(0));
|
||||
}
|
||||
|
||||
public void testSearch_String_AttributesMapper() throws NamingException {
|
||||
public void testSearch_String_AttributesMapper() throws Exception {
|
||||
expectGetReadOnlyContext();
|
||||
|
||||
SearchControls controls = new SearchControls();
|
||||
@@ -728,7 +702,7 @@ public class LdapTemplateTest extends TestCase {
|
||||
assertSame(expectedResult, list.get(0));
|
||||
}
|
||||
|
||||
public void testSearch_AttributesMapper_Default() throws NamingException {
|
||||
public void testSearch_AttributesMapper_Default() throws Exception {
|
||||
expectGetReadOnlyContext();
|
||||
|
||||
SearchControls controls = new SearchControls();
|
||||
@@ -759,8 +733,7 @@ public class LdapTemplateTest extends TestCase {
|
||||
assertSame(expectedResult, list.get(0));
|
||||
}
|
||||
|
||||
public void testSearch_String_AttributesMapper_Default()
|
||||
throws NamingException {
|
||||
public void testSearch_String_AttributesMapper_Default() throws Exception {
|
||||
expectGetReadOnlyContext();
|
||||
|
||||
SearchControls controls = new SearchControls();
|
||||
@@ -791,7 +764,7 @@ public class LdapTemplateTest extends TestCase {
|
||||
assertSame(expectedResult, list.get(0));
|
||||
}
|
||||
|
||||
public void testSearch_ContextMapper() throws NamingException {
|
||||
public void testSearch_ContextMapper() throws Exception {
|
||||
expectGetReadOnlyContext();
|
||||
|
||||
SearchControls controls = new SearchControls();
|
||||
@@ -822,8 +795,7 @@ public class LdapTemplateTest extends TestCase {
|
||||
assertSame(expectedResult, list.get(0));
|
||||
}
|
||||
|
||||
public void testSearch_ContextMapper_ReturningAttrs()
|
||||
throws NamingException {
|
||||
public void testSearch_ContextMapper_ReturningAttrs() throws Exception {
|
||||
expectGetReadOnlyContext();
|
||||
|
||||
String[] attrs = new String[0];
|
||||
@@ -858,7 +830,7 @@ public class LdapTemplateTest extends TestCase {
|
||||
}
|
||||
|
||||
public void testSearch_String_ContextMapper_ReturningAttrs()
|
||||
throws NamingException {
|
||||
throws Exception {
|
||||
expectGetReadOnlyContext();
|
||||
|
||||
String[] attrs = new String[0];
|
||||
@@ -892,7 +864,7 @@ public class LdapTemplateTest extends TestCase {
|
||||
assertSame(expectedResult, list.get(0));
|
||||
}
|
||||
|
||||
public void testSearch_String_ContextMapper() throws NamingException {
|
||||
public void testSearch_String_ContextMapper() throws Exception {
|
||||
expectGetReadOnlyContext();
|
||||
|
||||
SearchControls controls = new SearchControls();
|
||||
@@ -923,7 +895,7 @@ public class LdapTemplateTest extends TestCase {
|
||||
assertSame(expectedResult, list.get(0));
|
||||
}
|
||||
|
||||
public void testSearch_ContextMapper_Default() throws NamingException {
|
||||
public void testSearch_ContextMapper_Default() throws Exception {
|
||||
expectGetReadOnlyContext();
|
||||
|
||||
SearchControls controls = new SearchControls();
|
||||
@@ -954,8 +926,7 @@ public class LdapTemplateTest extends TestCase {
|
||||
assertSame(expectedResult, list.get(0));
|
||||
}
|
||||
|
||||
public void testSearch_String_ContextMapper_Default()
|
||||
throws NamingException {
|
||||
public void testSearch_String_ContextMapper_Default() throws Exception {
|
||||
expectGetReadOnlyContext();
|
||||
|
||||
SearchControls controls = new SearchControls();
|
||||
@@ -1085,7 +1056,7 @@ public class LdapTemplateTest extends TestCase {
|
||||
}
|
||||
|
||||
public void testSearch_String_SearchControls_AttributesMapper()
|
||||
throws NamingException {
|
||||
throws Exception {
|
||||
expectGetReadOnlyContext();
|
||||
|
||||
SearchControls controls = new SearchControls();
|
||||
@@ -1117,7 +1088,7 @@ public class LdapTemplateTest extends TestCase {
|
||||
}
|
||||
|
||||
public void testSearch_Name_SearchControls_AttributesMapper()
|
||||
throws NamingException {
|
||||
throws Exception {
|
||||
expectGetReadOnlyContext();
|
||||
|
||||
SearchControls controls = new SearchControls();
|
||||
@@ -1183,20 +1154,17 @@ public class LdapTemplateTest extends TestCase {
|
||||
|
||||
ModificationItem[] mods = new ModificationItem[0];
|
||||
dirContextMock.modifyAttributes(nameMock, mods);
|
||||
NamingException ne = new NamingException();
|
||||
javax.naming.LimitExceededException ne = new javax.naming.LimitExceededException();
|
||||
dirContextControl.setThrowable(ne);
|
||||
|
||||
exceptionTranslatorControl.expectAndReturn(exceptionTranslatorMock
|
||||
.translate(ne), new EntryNotFoundException("dummy"));
|
||||
|
||||
dirContextMock.close();
|
||||
|
||||
replay();
|
||||
|
||||
try {
|
||||
tested.modifyAttributes(nameMock, mods);
|
||||
fail("EntryNotFoundException expected");
|
||||
} catch (EntryNotFoundException expected) {
|
||||
fail("LimitExceededException expected");
|
||||
} catch (LimitExceededException expected) {
|
||||
assertTrue(true);
|
||||
}
|
||||
|
||||
@@ -1242,19 +1210,16 @@ public class LdapTemplateTest extends TestCase {
|
||||
Object expectedObject = new Object();
|
||||
BasicAttributes expectedAttributes = new BasicAttributes();
|
||||
dirContextMock.bind(nameMock, expectedObject, expectedAttributes);
|
||||
NamingException ne = new NamingException();
|
||||
javax.naming.NameNotFoundException ne = new javax.naming.NameNotFoundException();
|
||||
dirContextControl.setThrowable(ne);
|
||||
dirContextMock.close();
|
||||
|
||||
exceptionTranslatorControl.expectAndReturn(exceptionTranslatorMock
|
||||
.translate(ne), new EntryNotFoundException("dummy"));
|
||||
|
||||
replay();
|
||||
|
||||
try {
|
||||
tested.bind(nameMock, expectedObject, expectedAttributes);
|
||||
fail("EntryNotFoundException expected");
|
||||
} catch (EntryNotFoundException expected) {
|
||||
fail("NameNotFoundException expected");
|
||||
} catch (NameNotFoundException expected) {
|
||||
assertTrue(true);
|
||||
}
|
||||
|
||||
@@ -1359,7 +1324,7 @@ public class LdapTemplateTest extends TestCase {
|
||||
verify();
|
||||
}
|
||||
|
||||
public void testRebind() throws NamingException {
|
||||
public void testRebind() throws Exception {
|
||||
expectGetReadWriteContext();
|
||||
|
||||
Object expectedObject = new Object();
|
||||
@@ -1375,7 +1340,7 @@ public class LdapTemplateTest extends TestCase {
|
||||
verify();
|
||||
}
|
||||
|
||||
public void testRebind_String() throws NamingException {
|
||||
public void testRebind_String() throws Exception {
|
||||
expectGetReadWriteContext();
|
||||
|
||||
Object expectedObject = new Object();
|
||||
@@ -1396,19 +1361,16 @@ public class LdapTemplateTest extends TestCase {
|
||||
expectGetReadWriteContext();
|
||||
|
||||
dirContextMock.unbind(nameMock);
|
||||
NamingException ne = new NamingException();
|
||||
javax.naming.NameNotFoundException ne = new javax.naming.NameNotFoundException();
|
||||
dirContextControl.setThrowable(ne);
|
||||
dirContextMock.close();
|
||||
|
||||
exceptionTranslatorControl.expectAndReturn(exceptionTranslatorMock
|
||||
.translate(ne), new EntryNotFoundException("dummy"));
|
||||
|
||||
replay();
|
||||
|
||||
try {
|
||||
tested.unbind(nameMock);
|
||||
fail("EntryNotFoundException expected");
|
||||
} catch (EntryNotFoundException expected) {
|
||||
fail("NameNotFoundException expected");
|
||||
} catch (NameNotFoundException expected) {
|
||||
assertTrue(true);
|
||||
}
|
||||
|
||||
@@ -1436,21 +1398,18 @@ public class LdapTemplateTest extends TestCase {
|
||||
public void testExecuteReadOnly_NamingException() throws Exception {
|
||||
expectGetReadOnlyContext();
|
||||
|
||||
NamingException ne = new NamingException();
|
||||
javax.naming.NameNotFoundException ne = new javax.naming.NameNotFoundException();
|
||||
contextExecutorControl.expectAndThrow(contextExecutorMock
|
||||
.executeWithContext(dirContextMock), ne);
|
||||
|
||||
dirContextMock.close();
|
||||
|
||||
exceptionTranslatorControl.expectAndReturn(exceptionTranslatorMock
|
||||
.translate(ne), new EntryNotFoundException("dummy"));
|
||||
|
||||
replay();
|
||||
|
||||
try {
|
||||
tested.executeReadOnly(contextExecutorMock);
|
||||
fail("EntryNotFoundException expected");
|
||||
} catch (EntryNotFoundException expected) {
|
||||
fail("NameNotFoundException expected");
|
||||
} catch (NameNotFoundException expected) {
|
||||
assertTrue(true);
|
||||
}
|
||||
|
||||
@@ -1478,21 +1437,18 @@ public class LdapTemplateTest extends TestCase {
|
||||
public void testExecuteReadWrite_NamingException() throws Exception {
|
||||
expectGetReadWriteContext();
|
||||
|
||||
NamingException ne = new NamingException();
|
||||
javax.naming.NameNotFoundException ne = new javax.naming.NameNotFoundException();
|
||||
contextExecutorControl.expectAndThrow(contextExecutorMock
|
||||
.executeWithContext(dirContextMock), ne);
|
||||
|
||||
dirContextMock.close();
|
||||
|
||||
exceptionTranslatorControl.expectAndReturn(exceptionTranslatorMock
|
||||
.translate(ne), new EntryNotFoundException("dummy"));
|
||||
|
||||
replay();
|
||||
|
||||
try {
|
||||
tested.executeReadWrite(contextExecutorMock);
|
||||
fail("EntryNotFoundException expected");
|
||||
} catch (EntryNotFoundException expected) {
|
||||
fail("NameNotFoundException expected");
|
||||
} catch (NameNotFoundException expected) {
|
||||
assertTrue(true);
|
||||
}
|
||||
|
||||
@@ -1536,23 +1492,20 @@ public class LdapTemplateTest extends TestCase {
|
||||
|
||||
dirContextProcessorMock.preProcess(dirContextMock);
|
||||
|
||||
NamingException ne = new NamingException();
|
||||
javax.naming.LimitExceededException ne = new javax.naming.LimitExceededException();
|
||||
searchExecutorControl.expectAndThrow(searchExecutorMock
|
||||
.executeSearch(dirContextMock), ne);
|
||||
|
||||
dirContextProcessorMock.postProcess(dirContextMock);
|
||||
dirContextMock.close();
|
||||
|
||||
exceptionTranslatorControl.expectAndReturn(exceptionTranslatorMock
|
||||
.translate(ne), new EntryNotFoundException("dummy"));
|
||||
|
||||
replay();
|
||||
|
||||
try {
|
||||
tested.search(searchExecutorMock, handlerMock,
|
||||
dirContextProcessorMock);
|
||||
fail("EntryNotFoundException expected");
|
||||
} catch (EntryNotFoundException expected) {
|
||||
fail("LimitExceededException expected");
|
||||
} catch (LimitExceededException expected) {
|
||||
assertTrue(true);
|
||||
}
|
||||
|
||||
@@ -1589,21 +1542,18 @@ public class LdapTemplateTest extends TestCase {
|
||||
public void testDoSearch_NamingException() throws Exception {
|
||||
expectGetReadOnlyContext();
|
||||
|
||||
NamingException ne = new NamingException();
|
||||
javax.naming.LimitExceededException ne = new javax.naming.LimitExceededException();
|
||||
searchExecutorControl.expectAndThrow(searchExecutorMock
|
||||
.executeSearch(dirContextMock), ne);
|
||||
|
||||
dirContextMock.close();
|
||||
|
||||
exceptionTranslatorControl.expectAndReturn(exceptionTranslatorMock
|
||||
.translate(ne), new EntryNotFoundException("dummy"));
|
||||
|
||||
replay();
|
||||
|
||||
try {
|
||||
tested.search(searchExecutorMock, handlerMock);
|
||||
fail("EntryNotFoundException expected");
|
||||
} catch (EntryNotFoundException expected) {
|
||||
fail("LimitExceededException expected");
|
||||
} catch (LimitExceededException expected) {
|
||||
assertTrue(true);
|
||||
}
|
||||
|
||||
@@ -1617,22 +1567,19 @@ public class LdapTemplateTest extends TestCase {
|
||||
searchExecutorControl.expectAndReturn(searchExecutorMock
|
||||
.executeSearch(dirContextMock), namingEnumerationMock);
|
||||
|
||||
NamingException ne = new NamingException();
|
||||
javax.naming.LimitExceededException ne = new javax.naming.LimitExceededException();
|
||||
namingEnumerationControl.expectAndThrow(
|
||||
namingEnumerationMock.hasMore(), ne);
|
||||
namingEnumerationMock.close();
|
||||
|
||||
dirContextMock.close();
|
||||
|
||||
exceptionTranslatorControl.expectAndReturn(exceptionTranslatorMock
|
||||
.translate(ne), new EntryNotFoundException("dummy"));
|
||||
|
||||
replay();
|
||||
|
||||
try {
|
||||
tested.search(searchExecutorMock, handlerMock);
|
||||
fail("EntryNotFoundException expected");
|
||||
} catch (EntryNotFoundException expected) {
|
||||
fail("LimitExceededException expected");
|
||||
} catch (LimitExceededException expected) {
|
||||
assertTrue(true);
|
||||
}
|
||||
|
||||
@@ -1643,7 +1590,7 @@ public class LdapTemplateTest extends TestCase {
|
||||
expectGetReadOnlyContext();
|
||||
|
||||
searchExecutorControl.expectAndThrow(searchExecutorMock
|
||||
.executeSearch(dirContextMock), new NameNotFoundException());
|
||||
.executeSearch(dirContextMock), new javax.naming.NameNotFoundException());
|
||||
dirContextMock.close();
|
||||
|
||||
replay();
|
||||
@@ -1653,34 +1600,31 @@ public class LdapTemplateTest extends TestCase {
|
||||
verify();
|
||||
}
|
||||
|
||||
public void testSearch_PartialResult_IgnoreNotSet() throws NamingException {
|
||||
public void testSearch_PartialResult_IgnoreNotSet() throws Exception {
|
||||
expectGetReadOnlyContext();
|
||||
|
||||
dirContextProcessorMock.preProcess(dirContextMock);
|
||||
|
||||
PartialResultException ex = new PartialResultException();
|
||||
javax.naming.PartialResultException ex = new javax.naming.PartialResultException();
|
||||
searchExecutorControl.expectAndThrow(searchExecutorMock
|
||||
.executeSearch(dirContextMock), ex);
|
||||
dirContextProcessorMock.postProcess(dirContextMock);
|
||||
dirContextMock.close();
|
||||
|
||||
exceptionTranslatorControl.expectAndReturn(exceptionTranslatorMock
|
||||
.translate(ex), new EntryNotFoundException("dummy"));
|
||||
|
||||
replay();
|
||||
|
||||
try {
|
||||
tested.search(searchExecutorMock, handlerMock,
|
||||
dirContextProcessorMock);
|
||||
fail("EntryNotFoundException expected");
|
||||
} catch (EntryNotFoundException expected) {
|
||||
fail("PartialResultException expected");
|
||||
} catch (PartialResultException expected) {
|
||||
assertTrue(true);
|
||||
}
|
||||
|
||||
verify();
|
||||
}
|
||||
|
||||
public void testSearch_PartialResult_IgnoreSet() throws NamingException {
|
||||
public void testSearch_PartialResult_IgnoreSet() throws Exception {
|
||||
tested.setIgnorePartialResultException(true);
|
||||
|
||||
expectGetReadOnlyContext();
|
||||
@@ -1688,7 +1632,8 @@ public class LdapTemplateTest extends TestCase {
|
||||
dirContextProcessorMock.preProcess(dirContextMock);
|
||||
|
||||
searchExecutorControl.expectAndThrow(searchExecutorMock
|
||||
.executeSearch(dirContextMock), new PartialResultException());
|
||||
.executeSearch(dirContextMock),
|
||||
new javax.naming.PartialResultException());
|
||||
|
||||
dirContextProcessorMock.postProcess(dirContextMock);
|
||||
dirContextMock.close();
|
||||
|
||||
Reference in New Issue
Block a user