diff --git a/core/src/main/java/org/springframework/ldap/core/CollectingNameClassPairCallbackHandler.java b/core/src/main/java/org/springframework/ldap/core/CollectingNameClassPairCallbackHandler.java
index 83f5cac1..d2d637a6 100644
--- a/core/src/main/java/org/springframework/ldap/core/CollectingNameClassPairCallbackHandler.java
+++ b/core/src/main/java/org/springframework/ldap/core/CollectingNameClassPairCallbackHandler.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2005-2010 the original author or authors.
+ * Copyright 2005-2013 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.
@@ -15,11 +15,11 @@
*/
package org.springframework.ldap.core;
+import javax.naming.NameClassPair;
+import javax.naming.NamingException;
import java.util.LinkedList;
import java.util.List;
-import javax.naming.NameClassPair;
-
/**
* A NameClassPairCallbackHandler to collect all results in an internal List.
*
@@ -46,7 +46,7 @@ public abstract class CollectingNameClassPairCallbackHandler implements
* {@link #getObjectFromNameClassPair(NameClassPair)} and add the result to
* the internal list.
*/
- public void handleNameClassPair(NameClassPair nameClassPair) {
+ public final void handleNameClassPair(NameClassPair nameClassPair) throws NamingException {
list.add(getObjectFromNameClassPair(nameClassPair));
}
@@ -57,7 +57,8 @@ public abstract class CollectingNameClassPairCallbackHandler implements
* @param nameClassPair
* a NameClassPair from a search operation.
* @return an object constructed from the data in the NameClassPair.
+ * @throws NamingException if an error occurs.
*/
public abstract Object getObjectFromNameClassPair(
- NameClassPair nameClassPair);
+ NameClassPair nameClassPair) throws NamingException;
}
diff --git a/core/src/main/java/org/springframework/ldap/core/ContextMapper.java b/core/src/main/java/org/springframework/ldap/core/ContextMapper.java
index 636a12c0..3dfe018c 100644
--- a/core/src/main/java/org/springframework/ldap/core/ContextMapper.java
+++ b/core/src/main/java/org/springframework/ldap/core/ContextMapper.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2005-2010 the original author or authors.
+ * Copyright 2005-2013 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.
@@ -16,13 +16,14 @@
package org.springframework.ldap.core;
-import javax.naming.Binding;
-import javax.naming.Name;
-import javax.naming.directory.SearchResult;
-
import org.springframework.ldap.core.support.AbstractContextMapper;
import org.springframework.ldap.core.support.DefaultDirObjectFactory;
+import javax.naming.Binding;
+import javax.naming.Name;
+import javax.naming.NamingException;
+import javax.naming.directory.SearchResult;
+
/**
* An interface used by LdapTemplate to map LDAP Contexts to beans. When a
* DirObjectFactory is set on the ContextSource, the objects returned from
@@ -60,6 +61,7 @@ public interface ContextMapper {
* DirObjectFactory has been specified on the
* ContextSource.
* @return an object built from the data in the context.
+ * @throws NamingException if an error occurs.
*/
- Object mapFromContext(Object ctx);
+ Object mapFromContext(Object ctx) throws NamingException;
}
diff --git a/core/src/main/java/org/springframework/ldap/core/ContextMapperCallbackHandler.java b/core/src/main/java/org/springframework/ldap/core/ContextMapperCallbackHandler.java
index 0282d8ae..0ccd4ccc 100644
--- a/core/src/main/java/org/springframework/ldap/core/ContextMapperCallbackHandler.java
+++ b/core/src/main/java/org/springframework/ldap/core/ContextMapperCallbackHandler.java
@@ -19,6 +19,7 @@ import org.springframework.util.Assert;
import javax.naming.Binding;
import javax.naming.NameClassPair;
+import javax.naming.NamingException;
/**
* A CollectingNameClassPairCallbackHandler to wrap a ContextMapper. That is,
@@ -51,8 +52,10 @@ public class ContextMapperCallbackHandler extends
* @param nameClassPair
* a Binding instance.
* @return the Object returned from the mapper.
+ * @throws NamingException if an error occurs.
+ * @throws ObjectRetrievalException if the object of the nameClassPair is null.
*/
- public Object getObjectFromNameClassPair(NameClassPair nameClassPair) {
+ public Object getObjectFromNameClassPair(NameClassPair nameClassPair) throws NamingException {
if (!(nameClassPair instanceof Binding)) {
throw new IllegalArgumentException("Parameter must be an instance of Binding");
}
diff --git a/core/src/main/java/org/springframework/ldap/core/NameClassPairCallbackHandler.java b/core/src/main/java/org/springframework/ldap/core/NameClassPairCallbackHandler.java
index 611930a7..b64f4844 100644
--- a/core/src/main/java/org/springframework/ldap/core/NameClassPairCallbackHandler.java
+++ b/core/src/main/java/org/springframework/ldap/core/NameClassPairCallbackHandler.java
@@ -17,6 +17,7 @@
package org.springframework.ldap.core;
import javax.naming.NameClassPair;
+import javax.naming.NamingException;
/**
* Callback interface used by {@link LdapTemplate} search, list and listBindings
@@ -36,6 +37,8 @@ public interface NameClassPairCallbackHandler {
* @param nameClassPair
* the NameClassPair returned from the
* NamingEnumeration.
+ * @throws NamingException if an error occurs.
*/
- void handleNameClassPair(NameClassPair nameClassPair);
+ void handleNameClassPair(NameClassPair nameClassPair) throws NamingException;
+ ;
}
diff --git a/core/src/test/java/org/springframework/ldap/core/CollectingNameClassPairCallbackHandlerTest.java b/core/src/test/java/org/springframework/ldap/core/CollectingNameClassPairCallbackHandlerTest.java
index f9949efb..499d1068 100644
--- a/core/src/test/java/org/springframework/ldap/core/CollectingNameClassPairCallbackHandlerTest.java
+++ b/core/src/test/java/org/springframework/ldap/core/CollectingNameClassPairCallbackHandlerTest.java
@@ -20,6 +20,7 @@ import org.junit.Before;
import org.junit.Test;
import javax.naming.NameClassPair;
+import javax.naming.NamingException;
import java.util.List;
import static org.junit.Assert.assertEquals;
@@ -46,7 +47,7 @@ public class CollectingNameClassPairCallbackHandlerTest {
}
@Test
- public void testHandleNameClassPair() {
+ public void testHandleNameClassPair() throws NamingException {
tested.handleNameClassPair(expectedNameClassPair);
List result = tested.getList();
assertEquals(1, result.size());
diff --git a/core/src/test/java/org/springframework/ldap/core/ContextMapperCallbackHandlerTest.java b/core/src/test/java/org/springframework/ldap/core/ContextMapperCallbackHandlerTest.java
index 3d64ea14..31635acd 100644
--- a/core/src/test/java/org/springframework/ldap/core/ContextMapperCallbackHandlerTest.java
+++ b/core/src/test/java/org/springframework/ldap/core/ContextMapperCallbackHandlerTest.java
@@ -19,6 +19,7 @@ import org.junit.Before;
import org.junit.Test;
import javax.naming.Binding;
+import javax.naming.NamingException;
import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.mock;
@@ -42,7 +43,7 @@ public class ContextMapperCallbackHandlerTest {
}
@Test
- public void testGetObjectFromNameClassPair() {
+ public void testGetObjectFromNameClassPair() throws NamingException {
Object expectedObject = "object";
Object expectedResult = "result";
Binding expectedBinding = new Binding("some name", expectedObject);
@@ -54,7 +55,7 @@ public class ContextMapperCallbackHandlerTest {
}
@Test(expected = ObjectRetrievalException.class)
- public void testGetObjectFromNameClassPairObjectRetrievalException() {
+ public void testGetObjectFromNameClassPairObjectRetrievalException() throws NamingException {
Binding expectedBinding = new Binding("some name", null);
tested.getObjectFromNameClassPair(expectedBinding);
}