From ae603cebf39a6424edc24cf453ea26347479b54b Mon Sep 17 00:00:00 2001 From: Mattias Hellborg Arthursson Date: Fri, 30 Aug 2013 15:05:17 +0200 Subject: [PATCH] LDAP-258: Parameterized the core callback interfaces. --- .../ldap/core/AttributesMapper.java | 6 +- .../core/AttributesMapperCallbackHandler.java | 14 +- ...ollectingNameClassPairCallbackHandler.java | 8 +- .../ldap/core/ContextExecutor.java | 6 +- .../ldap/core/ContextMapper.java | 4 +- .../core/ContextMapperCallbackHandler.java | 10 +- .../ldap/core/DefaultDnParserFactory.java | 6 +- .../ldap/core/DefaultNameClassPairMapper.java | 7 +- .../ldap/core/DistinguishedNameEditor.java | 2 +- .../springframework/ldap/core/DnParser.java | 2 +- .../core/IncrementalAttributesMapper.java | 6 +- .../ldap/core/LdapEntryIdentification.java | 6 +- .../LdapEntryIdentificationContextMapper.java | 6 +- .../ldap/core/LdapOperations.java | 80 ++++----- .../springframework/ldap/core/LdapRdn.java | 2 +- .../ldap/core/LdapRdnComponent.java | 2 +- .../ldap/core/LdapTemplate.java | 166 +++++++++--------- .../core/NameClassPairCallbackHandler.java | 1 - .../ldap/core/NameClassPairMapper.java | 6 +- .../core/support/AbstractContextMapper.java | 8 +- .../core/support/AbstractContextSource.java | 2 +- .../ldap/core/support/BaseLdapPathAware.java | 2 +- .../BaseLdapPathBeanPostProcessor.java | 2 +- .../ldap/core/support/BaseLdapPathSource.java | 2 +- .../DefaultIncrementalAttributesMapper.java | 72 ++++---- .../support/LookupAttemptingCallback.java | 24 ++- .../ldap/core/support/RangeOption.java | 11 +- .../ldap/support/LdapUtils.java | 3 +- 28 files changed, 238 insertions(+), 228 deletions(-) diff --git a/core/src/main/java/org/springframework/ldap/core/AttributesMapper.java b/core/src/main/java/org/springframework/ldap/core/AttributesMapper.java index c2d445a4..24e168e2 100644 --- a/core/src/main/java/org/springframework/ldap/core/AttributesMapper.java +++ b/core/src/main/java/org/springframework/ldap/core/AttributesMapper.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. @@ -39,7 +39,7 @@ import javax.naming.directory.Attributes; * * @author Mattias Hellborg Arthursson */ -public interface AttributesMapper { +public interface AttributesMapper { /** * Map Attributes to an object. The supplied attributes are the attributes * from a single SearchResult. @@ -50,6 +50,6 @@ public interface AttributesMapper { * @throws NamingException * if any error occurs mapping the attributes */ - Object mapFromAttributes(Attributes attributes) + T mapFromAttributes(Attributes attributes) throws NamingException; } diff --git a/core/src/main/java/org/springframework/ldap/core/AttributesMapperCallbackHandler.java b/core/src/main/java/org/springframework/ldap/core/AttributesMapperCallbackHandler.java index 48667418..91004f67 100644 --- a/core/src/main/java/org/springframework/ldap/core/AttributesMapperCallbackHandler.java +++ b/core/src/main/java/org/springframework/ldap/core/AttributesMapperCallbackHandler.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,12 +16,12 @@ package org.springframework.ldap.core; +import org.springframework.ldap.support.LdapUtils; + import javax.naming.NameClassPair; import javax.naming.directory.Attributes; import javax.naming.directory.SearchResult; -import org.springframework.ldap.support.LdapUtils; - /** * A CollectingNameClassPairCallbackHandler to wrap an {@link AttributesMapper}. * That is, the found object is extracted from the {@link Attributes} of each @@ -32,15 +32,15 @@ import org.springframework.ldap.support.LdapUtils; * @author Ulrik Sandberg * @since 1.2 */ -public class AttributesMapperCallbackHandler extends CollectingNameClassPairCallbackHandler { - private AttributesMapper mapper; +public class AttributesMapperCallbackHandler extends CollectingNameClassPairCallbackHandler { + private AttributesMapper mapper; /** * Constructs a new instance around the specified {@link AttributesMapper}. * * @param mapper the target mapper. */ - public AttributesMapperCallbackHandler(AttributesMapper mapper) { + public AttributesMapperCallbackHandler(AttributesMapper mapper) { this.mapper = mapper; } @@ -51,7 +51,7 @@ public class AttributesMapperCallbackHandler extends CollectingNameClassPairCall * @param nameClassPair a SearchResult instance. * @return the Object returned from the mapper. */ - public Object getObjectFromNameClassPair(NameClassPair nameClassPair) { + public T getObjectFromNameClassPair(NameClassPair nameClassPair) { if (!(nameClassPair instanceof SearchResult)) { throw new IllegalArgumentException("Parameter must be an instance of SearchResult"); } 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 d2d637a6..e299ecfa 100644 --- a/core/src/main/java/org/springframework/ldap/core/CollectingNameClassPairCallbackHandler.java +++ b/core/src/main/java/org/springframework/ldap/core/CollectingNameClassPairCallbackHandler.java @@ -27,17 +27,17 @@ import java.util.List; * * @author Mattias Hellborg Arthursson */ -public abstract class CollectingNameClassPairCallbackHandler implements +public abstract class CollectingNameClassPairCallbackHandler implements NameClassPairCallbackHandler { - private List list = new LinkedList(); + private List list = new LinkedList(); /** * Get the assembled list. * * @return the list of all assembled objects. */ - public List getList() { + public List getList() { return list; } @@ -59,6 +59,6 @@ public abstract class CollectingNameClassPairCallbackHandler implements * @return an object constructed from the data in the NameClassPair. * @throws NamingException if an error occurs. */ - public abstract Object getObjectFromNameClassPair( + public abstract T getObjectFromNameClassPair( NameClassPair nameClassPair) throws NamingException; } diff --git a/core/src/main/java/org/springframework/ldap/core/ContextExecutor.java b/core/src/main/java/org/springframework/ldap/core/ContextExecutor.java index 5a0c1a6d..60c3615b 100644 --- a/core/src/main/java/org/springframework/ldap/core/ContextExecutor.java +++ b/core/src/main/java/org/springframework/ldap/core/ContextExecutor.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. @@ -36,7 +36,7 @@ import javax.naming.directory.DirContext; * * @author Mattias Hellborg Arthursson */ -public interface ContextExecutor { +public interface ContextExecutor { /** * Perform any operation on the context. * @@ -46,5 +46,5 @@ public interface ContextExecutor { * @throws NamingException * if the operation resulted in one. */ - Object executeWithContext(DirContext ctx) throws NamingException; + T executeWithContext(DirContext ctx) 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 3dfe018c..f9c6dabf 100644 --- a/core/src/main/java/org/springframework/ldap/core/ContextMapper.java +++ b/core/src/main/java/org/springframework/ldap/core/ContextMapper.java @@ -49,7 +49,7 @@ import javax.naming.directory.SearchResult; * * @author Mattias Hellborg Arthursson */ -public interface ContextMapper { +public interface ContextMapper { /** * Map a single LDAP Context to an object. The supplied Object * ctx is the object from a single {@link SearchResult}, @@ -63,5 +63,5 @@ public interface ContextMapper { * @return an object built from the data in the context. * @throws NamingException if an error occurs. */ - Object mapFromContext(Object ctx) throws NamingException; + T 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 0ccd4ccc..8beb007f 100644 --- a/core/src/main/java/org/springframework/ldap/core/ContextMapperCallbackHandler.java +++ b/core/src/main/java/org/springframework/ldap/core/ContextMapperCallbackHandler.java @@ -30,9 +30,9 @@ import javax.naming.NamingException; * @author Ulrik Sandberg * @since 1.2 */ -public class ContextMapperCallbackHandler extends - CollectingNameClassPairCallbackHandler { - private ContextMapper mapper; +public class ContextMapperCallbackHandler extends + CollectingNameClassPairCallbackHandler { + private ContextMapper mapper; /** * Constructs a new instance wrapping the supplied {@link ContextMapper}. @@ -40,7 +40,7 @@ public class ContextMapperCallbackHandler extends * @param mapper * the mapper to be called for each entry. */ - public ContextMapperCallbackHandler(ContextMapper mapper) { + public ContextMapperCallbackHandler(ContextMapper mapper) { Assert.notNull(mapper, "Mapper must not be empty"); this.mapper = mapper; } @@ -55,7 +55,7 @@ public class ContextMapperCallbackHandler extends * @throws NamingException if an error occurs. * @throws ObjectRetrievalException if the object of the nameClassPair is null. */ - public Object getObjectFromNameClassPair(NameClassPair nameClassPair) throws NamingException { + public T 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/DefaultDnParserFactory.java b/core/src/main/java/org/springframework/ldap/core/DefaultDnParserFactory.java index 286484ad..a45e82d6 100644 --- a/core/src/main/java/org/springframework/ldap/core/DefaultDnParserFactory.java +++ b/core/src/main/java/org/springframework/ldap/core/DefaultDnParserFactory.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. @@ -17,14 +17,12 @@ package org.springframework.ldap.core; import java.io.StringReader; -import org.springframework.ldap.core.DnParserImpl; - /** * A factory for creating DnParser instances. The actual implementation of * DnParser is generated using javacc and should not be constructed directly. * * @author Mattias Hellborg Arthursson - * + * @deprecated {@link DistinguishedName} and associated classes are deprecated as of 2.0. */ public class DefaultDnParserFactory { /** diff --git a/core/src/main/java/org/springframework/ldap/core/DefaultNameClassPairMapper.java b/core/src/main/java/org/springframework/ldap/core/DefaultNameClassPairMapper.java index 93718a3d..968e141a 100644 --- a/core/src/main/java/org/springframework/ldap/core/DefaultNameClassPairMapper.java +++ b/core/src/main/java/org/springframework/ldap/core/DefaultNameClassPairMapper.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. @@ -27,7 +27,7 @@ import javax.naming.NamingException; * @author Mattias Hellborg Arthursson * */ -public class DefaultNameClassPairMapper implements NameClassPairMapper { +public class DefaultNameClassPairMapper implements NameClassPairMapper { /** * Gets the Name from the supplied NameClassPair and returns it as the @@ -37,7 +37,8 @@ public class DefaultNameClassPairMapper implements NameClassPairMapper { * the NameClassPair to transform. * @return the Name string from the NameClassPair. */ - public Object mapFromNameClassPair(NameClassPair nameClassPair) + @Override + public String mapFromNameClassPair(NameClassPair nameClassPair) throws NamingException { return nameClassPair.getName(); diff --git a/core/src/main/java/org/springframework/ldap/core/DistinguishedNameEditor.java b/core/src/main/java/org/springframework/ldap/core/DistinguishedNameEditor.java index 1e0b1ca5..dfde2a57 100644 --- a/core/src/main/java/org/springframework/ldap/core/DistinguishedNameEditor.java +++ b/core/src/main/java/org/springframework/ldap/core/DistinguishedNameEditor.java @@ -24,7 +24,7 @@ import java.beans.PropertyEditorSupport; * * @author Mattias Hellborg Arthursson * @since 1.2 - * @deprecated {@link DistinguishedName and associated classes are deprecated as of 2.0}. + * @deprecated {@link DistinguishedName} and associated classes are deprecated as of 2.0. */ public class DistinguishedNameEditor extends PropertyEditorSupport { diff --git a/core/src/main/java/org/springframework/ldap/core/DnParser.java b/core/src/main/java/org/springframework/ldap/core/DnParser.java index 6e720557..427e811e 100644 --- a/core/src/main/java/org/springframework/ldap/core/DnParser.java +++ b/core/src/main/java/org/springframework/ldap/core/DnParser.java @@ -19,7 +19,7 @@ package org.springframework.ldap.core; * A parser for RFC2253-compliant Distinguished Names. * * @author Mattias Hellborg Arthursson - * @deprecated {@link DistinguishedName and associated classes are deprecated as of 2.0}. + * @deprecated {@link DistinguishedName} and associated classes are deprecated as of 2.0. */ public interface DnParser { /** diff --git a/core/src/main/java/org/springframework/ldap/core/IncrementalAttributesMapper.java b/core/src/main/java/org/springframework/ldap/core/IncrementalAttributesMapper.java index ab68ca77..0b141478 100644 --- a/core/src/main/java/org/springframework/ldap/core/IncrementalAttributesMapper.java +++ b/core/src/main/java/org/springframework/ldap/core/IncrementalAttributesMapper.java @@ -29,7 +29,7 @@ import java.util.List; * @see Incremental Retrieval of Multi-valued Properties * @see {@link org.springframework.ldap.core.support.DefaultIncrementalAttributesMapper} */ -public interface IncrementalAttributesMapper extends AttributesMapper { +public interface IncrementalAttributesMapper extends AttributesMapper { /** * Get all of the collected values for the specified attribute. * @@ -37,7 +37,7 @@ public interface IncrementalAttributesMapper extends AttributesMapper { * @return the collected values for the specified attribute. Will be null * if the requested attribute has not been returned by the server (attribute did not exist). */ - List getValues(String attributeName); + List getValues(String attributeName); /** * Get all collected values for all managed attributes as an Attributes instance. @@ -73,5 +73,5 @@ public interface IncrementalAttributesMapper extends AttributesMapper { * @return this instance. * @throws javax.naming.NamingException */ - Object mapFromAttributes(Attributes attributes) throws NamingException; + T mapFromAttributes(Attributes attributes) throws NamingException; } diff --git a/core/src/main/java/org/springframework/ldap/core/LdapEntryIdentification.java b/core/src/main/java/org/springframework/ldap/core/LdapEntryIdentification.java index 089aa665..d79d3ddc 100644 --- a/core/src/main/java/org/springframework/ldap/core/LdapEntryIdentification.java +++ b/core/src/main/java/org/springframework/ldap/core/LdapEntryIdentification.java @@ -48,7 +48,7 @@ public class LdapEntryIdentification { * returned by {@link DirContext#getNameInNamespace()}. * @param relativeDn the DN of the identified entry relative to the base * LDAP path, e.g. as returned by {@link DirContextOperations#getDn()}. - * @deprecated {@link DistinguishedName and associated classes and methods are deprecated as of 2.0}. + * @deprecated {@link DistinguishedName} and associated classes and methods are deprecated as of 2.0. * use {@link #LdapEntryIdentification(javax.naming.ldap.LdapName, javax.naming.ldap.LdapName)} instead. */ public LdapEntryIdentification(DistinguishedName absoluteDn, DistinguishedName relativeDn) { @@ -97,7 +97,7 @@ public class LdapEntryIdentification { * Get the DN of the identified entry relative to the base LDAP path, e.g. * as returned by {@link DirContextOperations#getDn()}. * @return the relative DN. - * @deprecated {@link DistinguishedName and associated classes and methods are deprecated as of 2.0}. + * @deprecated {@link DistinguishedName} and associated classes and methods are deprecated as of 2.0. * use {@link #getRelativeName()} instead. */ public DistinguishedName getRelativeDn() { @@ -108,7 +108,7 @@ public class LdapEntryIdentification { * Get the absolute DN of the identified entry, e.g. as returned by * {@link DirContext#getNameInNamespace()}. * @return the absolute DN. - * @deprecated {@link DistinguishedName and associated classes and methods are deprecated as of 2.0}. + * @deprecated {@link DistinguishedName} and associated classes and methods are deprecated as of 2.0. * use {@link #getAbsoluteName()} instead. */ public DistinguishedName getAbsoluteDn() { diff --git a/core/src/main/java/org/springframework/ldap/core/LdapEntryIdentificationContextMapper.java b/core/src/main/java/org/springframework/ldap/core/LdapEntryIdentificationContextMapper.java index 22d1072b..8e4f9ac5 100644 --- a/core/src/main/java/org/springframework/ldap/core/LdapEntryIdentificationContextMapper.java +++ b/core/src/main/java/org/springframework/ldap/core/LdapEntryIdentificationContextMapper.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. @@ -24,9 +24,9 @@ import org.springframework.ldap.support.LdapUtils; * @author Mattias Hellborg Arthursson * @since 1.3 */ -public class LdapEntryIdentificationContextMapper implements ContextMapper { +public class LdapEntryIdentificationContextMapper implements ContextMapper { - public Object mapFromContext(Object ctx) { + public LdapEntryIdentification mapFromContext(Object ctx) { DirContextOperations adapter = (DirContextOperations) ctx; return new LdapEntryIdentification( LdapUtils.newLdapName(adapter.getNameInNamespace()), diff --git a/core/src/main/java/org/springframework/ldap/core/LdapOperations.java b/core/src/main/java/org/springframework/ldap/core/LdapOperations.java index 69dd26c5..9cb724c8 100644 --- a/core/src/main/java/org/springframework/ldap/core/LdapOperations.java +++ b/core/src/main/java/org/springframework/ldap/core/LdapOperations.java @@ -106,7 +106,7 @@ public interface LdapOperations { * @see #search(Name, String, AttributesMapper) * @see #search(Name, String, ContextMapper) */ - Object executeReadOnly(ContextExecutor ce) throws NamingException; + T executeReadOnly(ContextExecutor ce) throws NamingException; /** * Perform an operation (or series of operations) on a read-write context. @@ -126,7 +126,7 @@ public interface LdapOperations { * @see #rename(Name, Name) * @see #modifyAttributes(Name, ModificationItem[]) */ - Object executeReadWrite(ContextExecutor ce) throws NamingException; + T executeReadWrite(ContextExecutor ce) throws NamingException; /** * Search for all objects matching the supplied filter. Each @@ -211,7 +211,7 @@ public interface LdapOperations { * NameNotFoundException will be ignored. Instead this is * interpreted that no entries were found. */ - List search(String base, String filter, SearchControls controls, AttributesMapper mapper, + List search(String base, String filter, SearchControls controls, AttributesMapper mapper, DirContextProcessor processor) throws NamingException; /** @@ -235,7 +235,7 @@ public interface LdapOperations { * NameNotFoundException will be ignored. Instead this is * interpreted that no entries were found. */ - List search(Name base, String filter, SearchControls controls, AttributesMapper mapper, + List search(Name base, String filter, SearchControls controls, AttributesMapper mapper, DirContextProcessor processor) throws NamingException; /** @@ -409,7 +409,7 @@ public interface LdapOperations { * NameNotFoundException will be ignored. Instead this is * interpreted that no entries were found. */ - List search(Name base, String filter, int searchScope, String[] attrs, AttributesMapper mapper) + List search(Name base, String filter, int searchScope, String[] attrs, AttributesMapper mapper) throws NamingException; /** @@ -432,7 +432,7 @@ public interface LdapOperations { * NameNotFoundException will be ignored. Instead this is * interpreted that no entries were found. */ - List search(String base, String filter, int searchScope, String[] attrs, AttributesMapper mapper) + List search(String base, String filter, int searchScope, String[] attrs, AttributesMapper mapper) throws NamingException; /** @@ -452,7 +452,7 @@ public interface LdapOperations { * NameNotFoundException will be ignored. Instead this is * interpreted that no entries were found. */ - List search(Name base, String filter, int searchScope, AttributesMapper mapper) throws NamingException; + List search(Name base, String filter, int searchScope, AttributesMapper mapper) throws NamingException; /** * Search for all objects matching the supplied filter. The Attributes in @@ -471,7 +471,7 @@ public interface LdapOperations { * NameNotFoundException will be ignored. Instead this is * interpreted that no entries were found. */ - List search(String base, String filter, int searchScope, AttributesMapper mapper) throws NamingException; + List search(String base, String filter, int searchScope, AttributesMapper mapper) throws NamingException; /** * Search for all objects matching the supplied filter. The Attributes in @@ -488,7 +488,7 @@ public interface LdapOperations { * NameNotFoundException will be ignored. Instead this is * interpreted that no entries were found. */ - List search(Name base, String filter, AttributesMapper mapper) throws NamingException; + List search(Name base, String filter, AttributesMapper mapper) throws NamingException; /** * Search for all objects matching the supplied filter. The Attributes in @@ -505,7 +505,7 @@ public interface LdapOperations { * NameNotFoundException will be ignored. Instead this is * interpreted that no entries were found. */ - List search(String base, String filter, AttributesMapper mapper) throws NamingException; + List search(String base, String filter, AttributesMapper mapper) throws NamingException; /** * Search for all objects matching the supplied filter. The @@ -527,7 +527,7 @@ public interface LdapOperations { * NameNotFoundException will be ignored. Instead this is * interpreted that no entries were found. */ - List search(Name base, String filter, int searchScope, String[] attrs, ContextMapper mapper) throws NamingException; + List search(Name base, String filter, int searchScope, String[] attrs, ContextMapper mapper) throws NamingException; /** * Search for all objects matching the supplied filter. The @@ -549,7 +549,7 @@ public interface LdapOperations { * NameNotFoundException will be ignored. Instead this is * interpreted that no entries were found. */ - List search(String base, String filter, int searchScope, String[] attrs, ContextMapper mapper) + List search(String base, String filter, int searchScope, String[] attrs, ContextMapper mapper) throws NamingException; /** @@ -569,7 +569,7 @@ public interface LdapOperations { * NameNotFoundException will be ignored. Instead this is * interpreted that no entries were found. */ - List search(Name base, String filter, int searchScope, ContextMapper mapper) throws NamingException; + List search(Name base, String filter, int searchScope, ContextMapper mapper) throws NamingException; /** * Search for all objects matching the supplied filter. The @@ -588,7 +588,7 @@ public interface LdapOperations { * NameNotFoundException will be ignored. Instead this is * interpreted that no entries were found. */ - List search(String base, String filter, int searchScope, ContextMapper mapper) throws NamingException; + List search(String base, String filter, int searchScope, ContextMapper mapper) throws NamingException; /** * Search for all objects matching the supplied filter. The @@ -606,7 +606,7 @@ public interface LdapOperations { * NameNotFoundException will be ignored. Instead this is * interpreted that no entries were found. */ - List search(Name base, String filter, ContextMapper mapper) throws NamingException; + List search(Name base, String filter, ContextMapper mapper) throws NamingException; /** * Search for all objects matching the supplied filter. The @@ -624,7 +624,7 @@ public interface LdapOperations { * NameNotFoundException will be ignored. Instead this is * interpreted that no entries were found. */ - List search(String base, String filter, ContextMapper mapper) throws NamingException; + List search(String base, String filter, ContextMapper mapper) throws NamingException; /** * Search for all objects matching the supplied filter. The @@ -642,7 +642,7 @@ public interface LdapOperations { * NameNotFoundException will be ignored. Instead this is * interpreted that no entries were found. */ - List search(String base, String filter, SearchControls controls, ContextMapper mapper) throws NamingException; + List search(String base, String filter, SearchControls controls, ContextMapper mapper) throws NamingException; /** * Search for all objects matching the supplied filter. The Object returned @@ -663,7 +663,7 @@ public interface LdapOperations { * NameNotFoundException will be ignored. Instead this is * interpreted that no entries were found. */ - List search(Name base, String filter, SearchControls controls, ContextMapper mapper) throws NamingException; + List search(Name base, String filter, SearchControls controls, ContextMapper mapper) throws NamingException; /** * Search for all objects matching the supplied filter. The Attributes @@ -681,7 +681,7 @@ public interface LdapOperations { * NameNotFoundException will be ignored. Instead this is * interpreted that no entries were found. */ - List search(String base, String filter, SearchControls controls, AttributesMapper mapper) throws NamingException; + List search(String base, String filter, SearchControls controls, AttributesMapper mapper) throws NamingException; /** * Search for all objects matching the supplied filter. The Attributes @@ -699,7 +699,7 @@ public interface LdapOperations { * NameNotFoundException will be ignored. Instead this is * interpreted that no entries were found. */ - List search(Name base, String filter, SearchControls controls, AttributesMapper mapper) throws NamingException; + List search(Name base, String filter, SearchControls controls, AttributesMapper mapper) throws NamingException; /** * Perform a non-recursive listing of the children of the given @@ -744,7 +744,7 @@ public interface LdapOperations { * NameNotFoundException will be ignored. Instead this is * interpreted that no entries were found. */ - List list(String base, NameClassPairMapper mapper) throws NamingException; + List list(String base, NameClassPairMapper mapper) throws NamingException; /** * Perform a non-recursive listing of the children of the given @@ -761,7 +761,7 @@ public interface LdapOperations { * NameNotFoundException will be ignored. Instead this is * interpreted that no entries were found. */ - List list(Name base, NameClassPairMapper mapper) throws NamingException; + List list(Name base, NameClassPairMapper mapper) throws NamingException; /** * Perform a non-recursive listing of the children of the given @@ -774,7 +774,7 @@ public interface LdapOperations { * NameNotFoundException will be ignored. Instead this is * interpreted that no entries were found. */ - List list(String base) throws NamingException; + List list(String base) throws NamingException; /** * Perform a non-recursive listing of the children of the given @@ -787,7 +787,7 @@ public interface LdapOperations { * NameNotFoundException will be ignored. Instead this is * interpreted that no entries were found. */ - List list(Name base) throws NamingException; + List list(Name base) throws NamingException; /** * Perform a non-recursive listing of the children of the given @@ -832,7 +832,7 @@ public interface LdapOperations { * NameNotFoundException will be ignored. Instead this is * interpreted that no entries were found. */ - List listBindings(String base, NameClassPairMapper mapper) throws NamingException; + List listBindings(String base, NameClassPairMapper mapper) throws NamingException; /** * Perform a non-recursive listing of the children of the given @@ -849,7 +849,7 @@ public interface LdapOperations { * NameNotFoundException will be ignored. Instead this is * interpreted that no entries were found. */ - List listBindings(Name base, NameClassPairMapper mapper) throws NamingException; + List listBindings(Name base, NameClassPairMapper mapper) throws NamingException; /** * Perform a non-recursive listing of children of the given @@ -862,7 +862,7 @@ public interface LdapOperations { * NameNotFoundException will be ignored. Instead this is * interpreted that no entries were found. */ - List listBindings(final String base) throws NamingException; + List listBindings(final String base) throws NamingException; /** * Perform a non-recursive listing of children of the given @@ -875,7 +875,7 @@ public interface LdapOperations { * NameNotFoundException will be ignored. Instead this is * interpreted that no entries were found. */ - List listBindings(final Name base) throws NamingException; + List listBindings(final Name base) throws NamingException; /** * Perform a non-recursive listing of the children of the given @@ -891,7 +891,7 @@ public interface LdapOperations { * NameNotFoundException will be ignored. Instead this is * interpreted that no entries were found. */ - List listBindings(String base, ContextMapper mapper) throws NamingException; + List listBindings(String base, ContextMapper mapper) throws NamingException; /** * Perform a non-recursive listing of the children of the given @@ -907,7 +907,7 @@ public interface LdapOperations { * NameNotFoundException will be ignored. Instead this is * interpreted that no entries were found. */ - List listBindings(Name base, ContextMapper mapper) throws NamingException; + List listBindings(Name base, ContextMapper mapper) throws NamingException; /** * Lookup the supplied DN and return the found object. This will typically @@ -945,7 +945,7 @@ public interface LdapOperations { * @return the object returned from the mapper. * @throws NamingException if any error occurs. */ - Object lookup(Name dn, AttributesMapper mapper) throws NamingException; + T lookup(Name dn, AttributesMapper mapper) throws NamingException; /** * Convenience method to get the attributes of a specified DN and @@ -957,7 +957,7 @@ public interface LdapOperations { * @return the object returned from the mapper. * @throws NamingException if any error occurs. */ - Object lookup(String dn, AttributesMapper mapper) throws NamingException; + T lookup(String dn, AttributesMapper mapper) throws NamingException; /** * Convenience method to lookup a specified DN and automatically pass the @@ -969,7 +969,7 @@ public interface LdapOperations { * @return the object returned from the mapper. * @throws NamingException if any error occurs. */ - Object lookup(Name dn, ContextMapper mapper) throws NamingException; + T lookup(Name dn, ContextMapper mapper) throws NamingException; /** * Convenience method to lookup a specified DN and automatically pass the @@ -981,7 +981,7 @@ public interface LdapOperations { * @return the object returned from the mapper. * @throws NamingException if any error occurs. */ - Object lookup(String dn, ContextMapper mapper) throws NamingException; + T lookup(String dn, ContextMapper mapper) throws NamingException; /** * Convenience method to get the specified attributes of a specified DN and @@ -994,7 +994,7 @@ public interface LdapOperations { * @return the object returned from the mapper. * @throws NamingException if any error occurs. */ - Object lookup(Name dn, String[] attributes, AttributesMapper mapper) throws NamingException; + T lookup(Name dn, String[] attributes, AttributesMapper mapper) throws NamingException; /** * Convenience method to get the specified attributes of a specified DN and @@ -1007,7 +1007,7 @@ public interface LdapOperations { * @return the object returned from the mapper. * @throws NamingException if any error occurs. */ - Object lookup(String dn, String[] attributes, AttributesMapper mapper) throws NamingException; + T lookup(String dn, String[] attributes, AttributesMapper mapper) throws NamingException; /** * Convenience method to get the specified attributes of a specified DN and @@ -1020,7 +1020,7 @@ public interface LdapOperations { * @return the object returned from the mapper. * @throws NamingException if any error occurs. */ - Object lookup(Name dn, String[] attributes, ContextMapper mapper) throws NamingException; + T lookup(Name dn, String[] attributes, ContextMapper mapper) throws NamingException; /** * Convenience method to get the specified attributes of a specified DN and @@ -1033,7 +1033,7 @@ public interface LdapOperations { * @return the object returned from the mapper. * @throws NamingException if any error occurs. */ - Object lookup(String dn, String[] attributes, ContextMapper mapper) throws NamingException; + T lookup(String dn, String[] attributes, ContextMapper mapper) throws NamingException; /** * Modify an entry in the LDAP tree using the supplied @@ -1501,7 +1501,7 @@ public interface LdapOperations { * @throws IncorrectResultSizeDataAccessException if the result is not one unique entry * @since 1.3 */ - Object searchForObject(Name base, String filter, ContextMapper mapper); + T searchForObject(Name base, String filter, ContextMapper mapper); /** * Perform a search for a unique entry matching the specified search @@ -1516,5 +1516,5 @@ public interface LdapOperations { * @throws IncorrectResultSizeDataAccessException if the result is not one unique entry * @since 1.3 */ - Object searchForObject(String base, String filter, ContextMapper mapper); + T searchForObject(String base, String filter, ContextMapper mapper); } diff --git a/core/src/main/java/org/springframework/ldap/core/LdapRdn.java b/core/src/main/java/org/springframework/ldap/core/LdapRdn.java index e83baadd..e630186a 100644 --- a/core/src/main/java/org/springframework/ldap/core/LdapRdn.java +++ b/core/src/main/java/org/springframework/ldap/core/LdapRdn.java @@ -36,7 +36,7 @@ import java.util.Set; * * @author Adam Skogman * @author Mattias Hellborg Arthursson - * @deprecated {@link DistinguishedName and associated classes are deprecated as of 2.0}. + * @deprecated {@link DistinguishedName} and associated classes are deprecated as of 2.0. */ public class LdapRdn implements Serializable, Comparable { private static final long serialVersionUID = 5681397547245228750L; diff --git a/core/src/main/java/org/springframework/ldap/core/LdapRdnComponent.java b/core/src/main/java/org/springframework/ldap/core/LdapRdnComponent.java index 2055cbcb..ba1cbad9 100644 --- a/core/src/main/java/org/springframework/ldap/core/LdapRdnComponent.java +++ b/core/src/main/java/org/springframework/ldap/core/LdapRdnComponent.java @@ -30,7 +30,7 @@ import java.net.URISyntaxException; * LdapRdnComponent represents one of these attributes. * * @author Mattias Hellborg Arthursson - * @deprecated {@link DistinguishedName and associated classes are deprecated as of 2.0}. + * @deprecated {@link DistinguishedName} and associated classes are deprecated as of 2.0. */ public class LdapRdnComponent implements Comparable, Serializable { private static final long serialVersionUID = -3296747972616243038L; diff --git a/core/src/main/java/org/springframework/ldap/core/LdapTemplate.java b/core/src/main/java/org/springframework/ldap/core/LdapTemplate.java index 559757c1..2351917b 100644 --- a/core/src/main/java/org/springframework/ldap/core/LdapTemplate.java +++ b/core/src/main/java/org/springframework/ldap/core/LdapTemplate.java @@ -397,7 +397,7 @@ public class LdapTemplate implements LdapOperations, InitializingBean { * java.lang.String, int, java.lang.String[], * org.springframework.ldap.core.AttributesMapper) */ - public List search(Name base, String filter, int searchScope, String[] attrs, AttributesMapper mapper) { + public List search(Name base, String filter, int searchScope, String[] attrs, AttributesMapper mapper) { return search(base, filter, getDefaultSearchControls(searchScope, DONT_RETURN_OBJ_FLAG, attrs), mapper); } @@ -407,7 +407,7 @@ public class LdapTemplate implements LdapOperations, InitializingBean { * java.lang.String, int, java.lang.String[], * org.springframework.ldap.core.AttributesMapper) */ - public List search(String base, String filter, int searchScope, String[] attrs, AttributesMapper mapper) { + public List search(String base, String filter, int searchScope, String[] attrs, AttributesMapper mapper) { return search(base, filter, getDefaultSearchControls(searchScope, DONT_RETURN_OBJ_FLAG, attrs), mapper); } @@ -416,7 +416,7 @@ public class LdapTemplate implements LdapOperations, InitializingBean { * org.springframework.ldap.core.LdapOperations#search(javax.naming.Name, * java.lang.String, int, org.springframework.ldap.core.AttributesMapper) */ - public List search(Name base, String filter, int searchScope, AttributesMapper mapper) { + public List search(Name base, String filter, int searchScope, AttributesMapper mapper) { return search(base, filter, searchScope, ALL_ATTRIBUTES, mapper); } @@ -426,7 +426,7 @@ public class LdapTemplate implements LdapOperations, InitializingBean { * org.springframework.ldap.core.LdapOperations#search(java.lang.String, * java.lang.String, int, org.springframework.ldap.core.AttributesMapper) */ - public List search(String base, String filter, int searchScope, AttributesMapper mapper) { + public List search(String base, String filter, int searchScope, AttributesMapper mapper) { return search(base, filter, searchScope, ALL_ATTRIBUTES, mapper); } @@ -436,7 +436,7 @@ public class LdapTemplate implements LdapOperations, InitializingBean { * 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) { + public List search(Name base, String filter, AttributesMapper mapper) { return search(base, filter, DEFAULT_SEARCH_SCOPE, mapper); } @@ -446,7 +446,7 @@ public class LdapTemplate implements LdapOperations, InitializingBean { * 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) { + public List search(String base, String filter, AttributesMapper mapper) { return search(base, filter, DEFAULT_SEARCH_SCOPE, mapper); } @@ -457,7 +457,7 @@ public class LdapTemplate implements LdapOperations, InitializingBean { * java.lang.String, int, java.lang.String[], * org.springframework.ldap.core.ContextMapper) */ - public List search(Name base, String filter, int searchScope, String[] attrs, ContextMapper mapper) { + public List search(Name base, String filter, int searchScope, String[] attrs, ContextMapper mapper) { return search(base, filter, getDefaultSearchControls(searchScope, RETURN_OBJ_FLAG, attrs), mapper); } @@ -468,7 +468,7 @@ public class LdapTemplate implements LdapOperations, InitializingBean { * java.lang.String, int, java.lang.String[], * org.springframework.ldap.core.ContextMapper) */ - public List search(String base, String filter, int searchScope, String[] attrs, ContextMapper mapper) { + public List search(String base, String filter, int searchScope, String[] attrs, ContextMapper mapper) { return search(base, filter, getDefaultSearchControls(searchScope, RETURN_OBJ_FLAG, attrs), mapper); } @@ -478,7 +478,7 @@ public class LdapTemplate implements LdapOperations, InitializingBean { * org.springframework.ldap.core.LdapOperations#search(javax.naming.Name, * java.lang.String, int, org.springframework.ldap.core.ContextMapper) */ - public List search(Name base, String filter, int searchScope, ContextMapper mapper) { + public List search(Name base, String filter, int searchScope, ContextMapper mapper) { return search(base, filter, searchScope, ALL_ATTRIBUTES, mapper); } @@ -488,7 +488,7 @@ public class LdapTemplate implements LdapOperations, InitializingBean { * org.springframework.ldap.core.LdapOperations#search(java.lang.String, * java.lang.String, int, org.springframework.ldap.core.ContextMapper) */ - public List search(String base, String filter, int searchScope, ContextMapper mapper) { + public List search(String base, String filter, int searchScope, ContextMapper mapper) { return search(base, filter, searchScope, ALL_ATTRIBUTES, mapper); } @@ -498,7 +498,7 @@ public class LdapTemplate implements LdapOperations, InitializingBean { * 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) { + public List search(Name base, String filter, ContextMapper mapper) { return search(base, filter, DEFAULT_SEARCH_SCOPE, mapper); } @@ -508,7 +508,7 @@ public class LdapTemplate implements LdapOperations, InitializingBean { * 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) { + public List search(String base, String filter, ContextMapper mapper) { return search(base, filter, DEFAULT_SEARCH_SCOPE, mapper); } @@ -519,7 +519,7 @@ public class LdapTemplate implements LdapOperations, InitializingBean { * java.lang.String, javax.naming.directory.SearchControls, * org.springframework.ldap.core.ContextMapper) */ - public List search(String base, String filter, SearchControls controls, ContextMapper mapper) { + public List search(String base, String filter, SearchControls controls, ContextMapper mapper) { return search(base, filter, controls, mapper, new NullDirContextProcessor()); } @@ -530,7 +530,7 @@ public class LdapTemplate implements LdapOperations, InitializingBean { * java.lang.String, javax.naming.directory.SearchControls, * org.springframework.ldap.core.ContextMapper) */ - public List search(Name base, String filter, SearchControls controls, ContextMapper mapper) { + public List search(Name base, String filter, SearchControls controls, ContextMapper mapper) { return search(base, filter, controls, mapper, new NullDirContextProcessor()); } @@ -541,7 +541,7 @@ public class LdapTemplate implements LdapOperations, InitializingBean { * java.lang.String, javax.naming.directory.SearchControls, * org.springframework.ldap.core.AttributesMapper) */ - public List search(Name base, String filter, SearchControls controls, AttributesMapper mapper) { + public List search(Name base, String filter, SearchControls controls, AttributesMapper mapper) { return search(base, filter, controls, mapper, new NullDirContextProcessor()); } @@ -552,7 +552,7 @@ public class LdapTemplate implements LdapOperations, InitializingBean { * java.lang.String, javax.naming.directory.SearchControls, * org.springframework.ldap.core.AttributesMapper) */ - public List search(String base, String filter, SearchControls controls, AttributesMapper mapper) { + public List search(String base, String filter, SearchControls controls, AttributesMapper mapper) { return search(base, filter, controls, mapper, new NullDirContextProcessor()); } @@ -565,9 +565,9 @@ public class LdapTemplate implements LdapOperations, InitializingBean { * org.springframework.ldap.core.AttributesMapper, * org.springframework.ldap.core.DirContextProcessor) */ - public List search(String base, String filter, SearchControls controls, AttributesMapper mapper, + public List search(String base, String filter, SearchControls controls, AttributesMapper mapper, DirContextProcessor processor) { - AttributesMapperCallbackHandler handler = new AttributesMapperCallbackHandler(mapper); + AttributesMapperCallbackHandler handler = new AttributesMapperCallbackHandler(mapper); search(base, filter, controls, handler, processor); return handler.getList(); @@ -582,9 +582,9 @@ public class LdapTemplate implements LdapOperations, InitializingBean { * org.springframework.ldap.core.AttributesMapper, * org.springframework.ldap.core.DirContextProcessor) */ - public List search(Name base, String filter, SearchControls controls, AttributesMapper mapper, + public List search(Name base, String filter, SearchControls controls, AttributesMapper mapper, DirContextProcessor processor) { - AttributesMapperCallbackHandler handler = new AttributesMapperCallbackHandler(mapper); + AttributesMapperCallbackHandler handler = new AttributesMapperCallbackHandler(mapper); search(base, filter, controls, handler, processor); return handler.getList(); @@ -658,8 +658,8 @@ public class LdapTemplate implements LdapOperations, InitializingBean { * @see org.springframework.ldap.core.LdapOperations#list(java.lang.String, * org.springframework.ldap.core.NameClassPairMapper) */ - public List list(String base, NameClassPairMapper mapper) { - CollectingNameClassPairCallbackHandler handler = new MappingCollectingNameClassPairCallbackHandler(mapper); + public List list(String base, NameClassPairMapper mapper) { + CollectingNameClassPairCallbackHandler handler = new MappingCollectingNameClassPairCallbackHandler(mapper); list(base, handler); return handler.getList(); } @@ -668,8 +668,8 @@ public class LdapTemplate implements LdapOperations, InitializingBean { * @see org.springframework.ldap.core.LdapOperations#list(javax.naming.Name, * org.springframework.ldap.core.NameClassPairMapper) */ - public List list(Name base, NameClassPairMapper mapper) { - CollectingNameClassPairCallbackHandler handler = new MappingCollectingNameClassPairCallbackHandler(mapper); + public List list(Name base, NameClassPairMapper mapper) { + CollectingNameClassPairCallbackHandler handler = new MappingCollectingNameClassPairCallbackHandler(mapper); list(base, handler); return handler.getList(); } @@ -677,14 +677,14 @@ public class LdapTemplate implements LdapOperations, InitializingBean { /* * @see org.springframework.ldap.core.LdapOperations#list(javax.naming.Name) */ - public List list(final Name base) { + public List list(final Name base) { return list(base, new DefaultNameClassPairMapper()); } /* * @see org.springframework.ldap.core.LdapOperations#list(java.lang.String) */ - public List list(final String base) { + public List list(final String base) { return list(base, new DefaultNameClassPairMapper()); } @@ -723,8 +723,8 @@ public class LdapTemplate implements LdapOperations, InitializingBean { * org.springframework.ldap.core.LdapOperations#listBindings(java.lang.String * , org.springframework.ldap.core.NameClassPairMapper) */ - public List listBindings(String base, NameClassPairMapper mapper) { - CollectingNameClassPairCallbackHandler handler = new MappingCollectingNameClassPairCallbackHandler(mapper); + public List listBindings(String base, NameClassPairMapper mapper) { + CollectingNameClassPairCallbackHandler handler = new MappingCollectingNameClassPairCallbackHandler(mapper); listBindings(base, handler); return handler.getList(); } @@ -734,8 +734,8 @@ public class LdapTemplate implements LdapOperations, InitializingBean { * org.springframework.ldap.core.LdapOperations#listBindings(javax.naming * .Name, org.springframework.ldap.core.NameClassPairMapper) */ - public List listBindings(Name base, NameClassPairMapper mapper) { - CollectingNameClassPairCallbackHandler handler = new MappingCollectingNameClassPairCallbackHandler(mapper); + public List listBindings(Name base, NameClassPairMapper mapper) { + CollectingNameClassPairCallbackHandler handler = new MappingCollectingNameClassPairCallbackHandler(mapper); listBindings(base, handler); return handler.getList(); } @@ -745,7 +745,7 @@ public class LdapTemplate implements LdapOperations, InitializingBean { * org.springframework.ldap.core.LdapOperations#listBindings(java.lang.String * ) */ - public List listBindings(final String base) { + public List listBindings(final String base) { return listBindings(base, new DefaultNameClassPairMapper()); } @@ -754,7 +754,7 @@ public class LdapTemplate implements LdapOperations, InitializingBean { * org.springframework.ldap.core.LdapOperations#listBindings(javax.naming * .Name) */ - public List listBindings(final Name base) { + public List listBindings(final Name base) { return listBindings(base, new DefaultNameClassPairMapper()); } @@ -763,9 +763,9 @@ public class LdapTemplate implements LdapOperations, InitializingBean { * org.springframework.ldap.core.LdapOperations#listBindings(java.lang.String * , org.springframework.ldap.core.ContextMapper) */ - public List listBindings(String base, ContextMapper mapper) { + public List listBindings(String base, ContextMapper mapper) { - ContextMapperCallbackHandler handler = new ContextMapperCallbackHandler(mapper); + ContextMapperCallbackHandler handler = new ContextMapperCallbackHandler(mapper); listBindings(base, handler); return handler.getList(); @@ -776,33 +776,27 @@ public class LdapTemplate implements LdapOperations, InitializingBean { * org.springframework.ldap.core.LdapOperations#listBindings(javax.naming * .Name, org.springframework.ldap.core.ContextMapper) */ - public List listBindings(Name base, ContextMapper mapper) { + public List listBindings(Name base, ContextMapper mapper) { - ContextMapperCallbackHandler handler = new ContextMapperCallbackHandler(mapper); + ContextMapperCallbackHandler handler = new ContextMapperCallbackHandler(mapper); listBindings(base, handler); return handler.getList(); } - /* - * @seeorg.springframework.ldap.core.LdapOperations#executeReadOnly(org. - * springframework.ldap.core.DirContextProcessor) - */ - public Object executeReadOnly(ContextExecutor ce) { + @Override + public T executeReadOnly(ContextExecutor ce) { DirContext ctx = contextSource.getReadOnlyContext(); return executeWithContext(ce, ctx); } - /* - * @seeorg.springframework.ldap.core.LdapOperations#executeReadWrite(org. - * springframework.ldap.core.DirContextProcessor) - */ - public Object executeReadWrite(ContextExecutor ce) { + @Override + public T executeReadWrite(ContextExecutor ce) { DirContext ctx = contextSource.getReadWriteContext(); return executeWithContext(ce, ctx); } - private Object executeWithContext(ContextExecutor ce, DirContext ctx) { + private T executeWithContext(ContextExecutor ce, DirContext ctx) { try { return ce.executeWithContext(ctx); } @@ -843,9 +837,9 @@ public class LdapTemplate implements LdapOperations, InitializingBean { * org.springframework.ldap.core.LdapOperations#lookup(javax.naming.Name, * org.springframework.ldap.core.AttributesMapper) */ - public Object lookup(final Name dn, final AttributesMapper mapper) { - return executeReadOnly(new ContextExecutor() { - public Object executeWithContext(DirContext ctx) throws javax.naming.NamingException { + public T lookup(final Name dn, final AttributesMapper mapper) { + return executeReadOnly(new ContextExecutor() { + public T executeWithContext(DirContext ctx) throws javax.naming.NamingException { Attributes attributes = ctx.getAttributes(dn); return mapper.mapFromAttributes(attributes); } @@ -857,10 +851,10 @@ public class LdapTemplate implements LdapOperations, InitializingBean { * org.springframework.ldap.core.LdapOperations#lookup(java.lang.String, * org.springframework.ldap.core.AttributesMapper) */ - public Object lookup(final String dn, final AttributesMapper mapper) { + public T lookup(final String dn, final AttributesMapper mapper) { - return executeReadOnly(new ContextExecutor() { - public Object executeWithContext(DirContext ctx) throws javax.naming.NamingException { + return executeReadOnly(new ContextExecutor() { + public T executeWithContext(DirContext ctx) throws javax.naming.NamingException { Attributes attributes = ctx.getAttributes(dn); return mapper.mapFromAttributes(attributes); } @@ -872,9 +866,9 @@ public class LdapTemplate implements LdapOperations, InitializingBean { * org.springframework.ldap.core.LdapOperations#lookup(javax.naming.Name, * org.springframework.ldap.core.ContextMapper) */ - public Object lookup(final Name dn, final ContextMapper mapper) { - return executeReadOnly(new ContextExecutor() { - public Object executeWithContext(DirContext ctx) throws javax.naming.NamingException { + public T lookup(final Name dn, final ContextMapper mapper) { + return executeReadOnly(new ContextExecutor() { + public T executeWithContext(DirContext ctx) throws javax.naming.NamingException { Object object = ctx.lookup(dn); return mapper.mapFromContext(object); } @@ -886,10 +880,10 @@ public class LdapTemplate implements LdapOperations, InitializingBean { * org.springframework.ldap.core.LdapOperations#lookup(java.lang.String, * org.springframework.ldap.core.ContextMapper) */ - public Object lookup(final String dn, final ContextMapper mapper) { + public T lookup(final String dn, final ContextMapper mapper) { - return executeReadOnly(new ContextExecutor() { - public Object executeWithContext(DirContext ctx) throws javax.naming.NamingException { + return executeReadOnly(new ContextExecutor() { + public T executeWithContext(DirContext ctx) throws javax.naming.NamingException { Object object = ctx.lookup(dn); return mapper.mapFromContext(object); } @@ -901,10 +895,10 @@ public class LdapTemplate implements LdapOperations, InitializingBean { * org.springframework.ldap.core.LdapOperations#lookup(javax.naming.Name, * java.lang.String[], org.springframework.ldap.core.AttributesMapper) */ - public Object lookup(final Name dn, final String[] attributes, final AttributesMapper mapper) { + public T lookup(final Name dn, final String[] attributes, final AttributesMapper mapper) { - return executeReadOnly(new ContextExecutor() { - public Object executeWithContext(DirContext ctx) throws javax.naming.NamingException { + return executeReadOnly(new ContextExecutor() { + public T executeWithContext(DirContext ctx) throws javax.naming.NamingException { Attributes filteredAttributes = ctx.getAttributes(dn, attributes); return mapper.mapFromAttributes(filteredAttributes); } @@ -916,9 +910,9 @@ public class LdapTemplate implements LdapOperations, InitializingBean { * org.springframework.ldap.core.LdapOperations#lookup(java.lang.String, * java.lang.String[], org.springframework.ldap.core.AttributesMapper) */ - public Object lookup(final String dn, final String[] attributes, final AttributesMapper mapper) { - return executeReadOnly(new ContextExecutor() { - public Object executeWithContext(DirContext ctx) throws javax.naming.NamingException { + public T lookup(final String dn, final String[] attributes, final AttributesMapper mapper) { + return executeReadOnly(new ContextExecutor() { + public T executeWithContext(DirContext ctx) throws javax.naming.NamingException { Attributes filteredAttributes = ctx.getAttributes(dn, attributes); return mapper.mapFromAttributes(filteredAttributes); } @@ -930,10 +924,10 @@ public class LdapTemplate implements LdapOperations, InitializingBean { * org.springframework.ldap.core.LdapOperations#lookup(javax.naming.Name, * java.lang.String[], org.springframework.ldap.core.ContextMapper) */ - public Object lookup(final Name dn, final String[] attributes, final ContextMapper mapper) { + public T lookup(final Name dn, final String[] attributes, final ContextMapper mapper) { - return executeReadOnly(new ContextExecutor() { - public Object executeWithContext(DirContext ctx) throws javax.naming.NamingException { + return executeReadOnly(new ContextExecutor() { + public T executeWithContext(DirContext ctx) throws javax.naming.NamingException { Attributes filteredAttributes = ctx.getAttributes(dn, attributes); DirContextAdapter contextAdapter = new DirContextAdapter(filteredAttributes, dn); return mapper.mapFromContext(contextAdapter); @@ -946,10 +940,10 @@ public class LdapTemplate implements LdapOperations, InitializingBean { * org.springframework.ldap.core.LdapOperations#lookup(java.lang.String, * java.lang.String[], org.springframework.ldap.core.ContextMapper) */ - public Object lookup(final String dn, final String[] attributes, final ContextMapper mapper) { + public T lookup(final String dn, final String[] attributes, final ContextMapper mapper) { - return executeReadOnly(new ContextExecutor() { - public Object executeWithContext(DirContext ctx) throws javax.naming.NamingException { + return executeReadOnly(new ContextExecutor() { + public T executeWithContext(DirContext ctx) throws javax.naming.NamingException { Attributes filteredAttributes = ctx.getAttributes(dn, attributes); LdapName name = LdapUtils.newLdapName(dn); DirContextAdapter contextAdapter = new DirContextAdapter(filteredAttributes, name); @@ -993,7 +987,7 @@ public class LdapTemplate implements LdapOperations, InitializingBean { */ public void bind(final Name dn, final Object obj, final Attributes attributes) { - executeReadWrite(new ContextExecutor() { + executeReadWrite(new ContextExecutor() { public Object executeWithContext(DirContext ctx) throws javax.naming.NamingException { ctx.bind(dn, obj, attributes); return null; @@ -1007,7 +1001,7 @@ public class LdapTemplate implements LdapOperations, InitializingBean { */ public void bind(final String dn, final Object obj, final Attributes attributes) { - executeReadWrite(new ContextExecutor() { + executeReadWrite(new ContextExecutor() { public Object executeWithContext(DirContext ctx) throws javax.naming.NamingException { ctx.bind(dn, obj, attributes); return null; @@ -1060,7 +1054,7 @@ public class LdapTemplate implements LdapOperations, InitializingBean { } private void doUnbind(final Name dn) { - executeReadWrite(new ContextExecutor() { + executeReadWrite(new ContextExecutor() { public Object executeWithContext(DirContext ctx) throws javax.naming.NamingException { ctx.unbind(dn); return null; @@ -1069,7 +1063,7 @@ public class LdapTemplate implements LdapOperations, InitializingBean { } private void doUnbind(final String dn) { - executeReadWrite(new ContextExecutor() { + executeReadWrite(new ContextExecutor() { public Object executeWithContext(DirContext ctx) throws javax.naming.NamingException { ctx.unbind(dn); return null; @@ -1078,7 +1072,7 @@ public class LdapTemplate implements LdapOperations, InitializingBean { } private void doUnbindRecursively(final Name dn) { - executeReadWrite(new ContextExecutor() { + executeReadWrite(new ContextExecutor() { public Object executeWithContext(DirContext ctx) { deleteRecursively(ctx, LdapUtils.newLdapName(dn)); return null; @@ -1087,7 +1081,7 @@ public class LdapTemplate implements LdapOperations, InitializingBean { } private void doUnbindRecursively(final String dn) { - executeReadWrite(new ContextExecutor() { + executeReadWrite(new ContextExecutor() { public Object executeWithContext(DirContext ctx) throws javax.naming.NamingException { deleteRecursively(ctx, LdapUtils.newLdapName(dn)); return null; @@ -1281,12 +1275,12 @@ public class LdapTemplate implements LdapOperations, InitializingBean { * * @author Mattias Hellborg Arthursson */ - public final static class MappingCollectingNameClassPairCallbackHandler extends - CollectingNameClassPairCallbackHandler { + public final static class MappingCollectingNameClassPairCallbackHandler extends + CollectingNameClassPairCallbackHandler { - private NameClassPairMapper mapper; + private NameClassPairMapper mapper; - public MappingCollectingNameClassPairCallbackHandler(NameClassPairMapper mapper) { + public MappingCollectingNameClassPairCallbackHandler(NameClassPairMapper mapper) { this.mapper = mapper; } @@ -1294,7 +1288,7 @@ public class LdapTemplate implements LdapOperations, InitializingBean { * @seeorg.springframework.ldap.CollectingNameClassPairCallbackHandler# * getObjectFromNameClassPair(javax.naming.NameClassPair) */ - public Object getObjectFromNameClassPair(NameClassPair nameClassPair) { + public T getObjectFromNameClassPair(NameClassPair nameClassPair) { try { return mapper.mapFromNameClassPair(nameClassPair); } @@ -1493,7 +1487,7 @@ public class LdapTemplate implements LdapOperations, InitializingBean { try { DirContext ctx = contextSource.getContext(entryIdentification.getAbsoluteDn().toString(), password); - executeWithContext(new ContextExecutor() { + executeWithContext(new ContextExecutor() { public Object executeWithContext(DirContext ctx) throws javax.naming.NamingException { callback.executeWithContext(ctx, entryIdentification); return null; @@ -1515,8 +1509,8 @@ public class LdapTemplate implements LdapOperations, InitializingBean { * org.springframework.ldap.core.LdapOperations#searchForObject(javax.naming * .Name, java.lang.String, org.springframework.ldap.core.ContextMapper) */ - public Object searchForObject(Name base, String filter, ContextMapper mapper) { - List result = search(base, filter, mapper); + public T searchForObject(Name base, String filter, ContextMapper mapper) { + List result = search(base, filter, mapper); if (result.size() == 0) { throw new EmptyResultDataAccessException(1); } @@ -1534,7 +1528,7 @@ public class LdapTemplate implements LdapOperations, InitializingBean { * org.springframework.ldap.core.LdapOperations#searchForObject(java.lang * .String, java.lang.String, org.springframework.ldap.core.ContextMapper) */ - public Object searchForObject(String base, String filter, ContextMapper mapper) { + public T searchForObject(String base, String filter, ContextMapper mapper) { return searchForObject(LdapUtils.newLdapName(base), filter, mapper); } 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 b64f4844..15ed3e15 100644 --- a/core/src/main/java/org/springframework/ldap/core/NameClassPairCallbackHandler.java +++ b/core/src/main/java/org/springframework/ldap/core/NameClassPairCallbackHandler.java @@ -40,5 +40,4 @@ public interface NameClassPairCallbackHandler { * @throws NamingException if an error occurs. */ void handleNameClassPair(NameClassPair nameClassPair) throws NamingException; - ; } diff --git a/core/src/main/java/org/springframework/ldap/core/NameClassPairMapper.java b/core/src/main/java/org/springframework/ldap/core/NameClassPairMapper.java index 3eb9df73..622ceaa5 100644 --- a/core/src/main/java/org/springframework/ldap/core/NameClassPairMapper.java +++ b/core/src/main/java/org/springframework/ldap/core/NameClassPairMapper.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. @@ -24,7 +24,7 @@ import javax.naming.NamingException; * * @author Mattias Hellborg Arthursson */ -public interface NameClassPairMapper { +public interface NameClassPairMapper { /** * Map NameClassPair to an Object. The supplied * NameClassPair is one of the results from a search @@ -39,6 +39,6 @@ public interface NameClassPairMapper { * @throws NamingException * if one is encountered in the operation. */ - Object mapFromNameClassPair(NameClassPair nameClassPair) + T mapFromNameClassPair(NameClassPair nameClassPair) throws NamingException; } diff --git a/core/src/main/java/org/springframework/ldap/core/support/AbstractContextMapper.java b/core/src/main/java/org/springframework/ldap/core/support/AbstractContextMapper.java index a5d0c6da..a787c05f 100644 --- a/core/src/main/java/org/springframework/ldap/core/support/AbstractContextMapper.java +++ b/core/src/main/java/org/springframework/ldap/core/support/AbstractContextMapper.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. @@ -29,7 +29,7 @@ import org.springframework.ldap.core.DirContextOperations; * @author Mattias Hellborg Arthursson * */ -public abstract class AbstractContextMapper implements ContextMapper { +public abstract class AbstractContextMapper implements ContextMapper { /** * {@inheritDoc} @@ -39,7 +39,7 @@ public abstract class AbstractContextMapper implements ContextMapper { * used, causing the objects passed in be anything else than * {@link DirContextOperations} instances. */ - public final Object mapFromContext(Object ctx) { + public final T mapFromContext(Object ctx) { return doMapFromContext((DirContextOperations) ctx); } @@ -53,6 +53,6 @@ public abstract class AbstractContextMapper implements ContextMapper { * the context to map to an object. * @return an object built from the data in the context. */ - protected abstract Object doMapFromContext(DirContextOperations ctx); + protected abstract T doMapFromContext(DirContextOperations ctx); } diff --git a/core/src/main/java/org/springframework/ldap/core/support/AbstractContextSource.java b/core/src/main/java/org/springframework/ldap/core/support/AbstractContextSource.java index 5b74b37f..3757cda8 100644 --- a/core/src/main/java/org/springframework/ldap/core/support/AbstractContextSource.java +++ b/core/src/main/java/org/springframework/ldap/core/support/AbstractContextSource.java @@ -301,7 +301,7 @@ public abstract class AbstractContextSource implements BaseLdapPathContextSource /** * @return - * @deprecated {@link DistinguishedName and associated classes and methods are deprecated as of 2.0}. + * @deprecated {@link DistinguishedName} and associated classes and methods are deprecated as of 2.0. */ @Override public DistinguishedName getBaseLdapPath() { diff --git a/core/src/main/java/org/springframework/ldap/core/support/BaseLdapPathAware.java b/core/src/main/java/org/springframework/ldap/core/support/BaseLdapPathAware.java index 4ab07747..271212a9 100644 --- a/core/src/main/java/org/springframework/ldap/core/support/BaseLdapPathAware.java +++ b/core/src/main/java/org/springframework/ldap/core/support/BaseLdapPathAware.java @@ -37,7 +37,7 @@ import org.springframework.ldap.core.DistinguishedName; * * @author Mattias Hellborg Arthursson * @since 1.2 - * @deprecated {@link DistinguishedName and associated classes and methods are deprecated as of 2.0}. + * @deprecated {@link DistinguishedName} and associated classes and methods are deprecated as of 2.0. * Use {@link BaseLdapNameAware} instead. */ public interface BaseLdapPathAware { diff --git a/core/src/main/java/org/springframework/ldap/core/support/BaseLdapPathBeanPostProcessor.java b/core/src/main/java/org/springframework/ldap/core/support/BaseLdapPathBeanPostProcessor.java index 1a97b920..09f34fbd 100644 --- a/core/src/main/java/org/springframework/ldap/core/support/BaseLdapPathBeanPostProcessor.java +++ b/core/src/main/java/org/springframework/ldap/core/support/BaseLdapPathBeanPostProcessor.java @@ -124,7 +124,7 @@ public class BaseLdapPathBeanPostProcessor implements BeanPostProcessor, Applica * ApplicationContext. * * @param basePath the base path. - * @deprecated {@link DistinguishedName and associated classes and methods are deprecated as of 2.0}. + * @deprecated {@link DistinguishedName} and associated classes and methods are deprecated as of 2.0. */ public void setBasePath(DistinguishedName basePath) { this.basePath = LdapUtils.newLdapName(basePath); diff --git a/core/src/main/java/org/springframework/ldap/core/support/BaseLdapPathSource.java b/core/src/main/java/org/springframework/ldap/core/support/BaseLdapPathSource.java index f3a23e4e..5b79cec4 100644 --- a/core/src/main/java/org/springframework/ldap/core/support/BaseLdapPathSource.java +++ b/core/src/main/java/org/springframework/ldap/core/support/BaseLdapPathSource.java @@ -35,7 +35,7 @@ public interface BaseLdapPathSource { * * @return the base LDAP path as a {@link DistinguishedName}. The path will * be empty if no base path is specified. - * @deprecated {@link DistinguishedName and associated classes and methods are deprecated as of 2.0}. + * @deprecated {@link DistinguishedName} and associated classes and methods are deprecated as of 2.0. * Use {@link #getBaseLdapName()} instead. */ DistinguishedName getBaseLdapPath(); diff --git a/core/src/main/java/org/springframework/ldap/core/support/DefaultIncrementalAttributesMapper.java b/core/src/main/java/org/springframework/ldap/core/support/DefaultIncrementalAttributesMapper.java index 09652313..3fb5066d 100644 --- a/core/src/main/java/org/springframework/ldap/core/support/DefaultIncrementalAttributesMapper.java +++ b/core/src/main/java/org/springframework/ldap/core/support/DefaultIncrementalAttributesMapper.java @@ -18,7 +18,6 @@ package org.springframework.ldap.core.support; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.springframework.ldap.core.AttributesMapper; import org.springframework.ldap.core.IncrementalAttributesMapper; import org.springframework.ldap.core.LdapOperations; import org.springframework.ldap.support.LdapUtils; @@ -33,7 +32,6 @@ import javax.naming.directory.BasicAttributes; import java.util.ArrayList; import java.util.Collections; import java.util.HashSet; -import java.util.Iterator; import java.util.LinkedHashMap; import java.util.LinkedHashSet; import java.util.LinkedList; @@ -75,38 +73,44 @@ import java.util.Set; * @see #lookupAttributeValues(org.springframework.ldap.core.LdapOperations, javax.naming.Name, String) * @since 1.3.2 */ -public class DefaultIncrementalAttributesMapper implements AttributesMapper, IncrementalAttributesMapper { +public class DefaultIncrementalAttributesMapper implements IncrementalAttributesMapper { private final static Log log = LogFactory.getLog(DefaultIncrementalAttributesMapper.class); - private Map stateMap = new LinkedHashMap(); - private Set rangedAttributesInNextIteration = new LinkedHashSet(); + private Map stateMap = new LinkedHashMap(); + private Set rangedAttributesInNextIteration = new LinkedHashSet(); /** * This guy will be used when an unmapped attribute is encountered. This really should never happen, * but this saves us a number of null checks. */ private final static IncrementalAttributeState NOT_FOUND_ATTRIBUTE_STATE = new IncrementalAttributeState() { + @Override public String getRequestedAttributeName() { throw new UnsupportedOperationException("This method should never be called"); } + @Override public boolean hasMore() { return false; } + @Override public void calculateNextRange(RangeOption responseRange) { // Nothing to do here } + @Override public String getAttributeNameForQuery() { throw new UnsupportedOperationException("This method should never be called"); } + @Override public void processValues(Attributes attributes, String attributeName) throws NamingException { // Nothing to do here } - public List getValues() { + @Override + public List getValues() { return null; } }; @@ -154,20 +158,20 @@ public class DefaultIncrementalAttributesMapper implements AttributesMapper, Inc * values are managed. */ public DefaultIncrementalAttributesMapper(int pageSize, String[] attributeNames) { - for (int i = 0; i < attributeNames.length; i++) { - String attributeName = attributeNames[i]; + for (String attributeName : attributeNames) { this.stateMap.put(attributeName, new DefaultIncrementalAttributeState(attributeName, pageSize)); this.rangedAttributesInNextIteration.add(attributeName); } } - public final Object mapFromAttributes(Attributes attributes) throws NamingException { + @Override + public final DefaultIncrementalAttributesMapper mapFromAttributes(Attributes attributes) throws NamingException { if (!hasMore()) { throw new IllegalStateException("No more attributes!"); } // Reset the affected attributes. - rangedAttributesInNextIteration = new HashSet(); + rangedAttributesInNextIteration = new HashSet(); NamingEnumeration attributeNameEnum = attributes.getIDs(); while (attributeNameEnum.hasMore()) { @@ -179,9 +183,7 @@ public class DefaultIncrementalAttributesMapper implements AttributesMapper, Inc // No range specification for this attribute state.processValues(attributes, attributeName); } else { - for (int i = 0; i < attributeNameSplit.length; i++) { - String option = attributeNameSplit[i]; - + for (String option : attributeNameSplit) { RangeOption responseRange = RangeOption.parse(option); if (responseRange != null) { @@ -208,22 +210,21 @@ public class DefaultIncrementalAttributesMapper implements AttributesMapper, Inc return (IncrementalAttributeState) mappedState; } - public final List getValues(String attributeName) { + @Override + public final List getValues(String attributeName) { return getState(attributeName).getValues(); } - public Attributes getCollectedAttributes() { + @Override + public final Attributes getCollectedAttributes() { BasicAttributes attributes = new BasicAttributes(); - Set attributeNames = stateMap.keySet(); - for (Iterator iterator = attributeNames.iterator(); iterator.hasNext(); ) { - String attributeName = (String) iterator.next(); - + Set attributeNames = stateMap.keySet(); + for (String attributeName : attributeNames) { BasicAttribute oneAttribute = new BasicAttribute(attributeName); List values = getValues(attributeName); if (values != null) { - for (Iterator valueIterator = values.iterator(); valueIterator.hasNext(); ) { - Object oneValue = valueIterator.next(); + for (Object oneValue : values) { oneAttribute.add(oneValue); } } @@ -234,16 +235,17 @@ public class DefaultIncrementalAttributesMapper implements AttributesMapper, Inc return attributes; } + @Override public final boolean hasMore() { return rangedAttributesInNextIteration.size() > 0; } + @Override public final String[] getAttributesForLookup() { String[] result = new String[rangedAttributesInNextIteration.size()]; int index = 0; - for (Iterator iterator = rangedAttributesInNextIteration.iterator(); iterator.hasNext(); ) { - String next = (String) iterator.next(); - IncrementalAttributeState state = (IncrementalAttributeState) stateMap.get(next); + for (String next : rangedAttributesInNextIteration) { + IncrementalAttributeState state = stateMap.get(next); result[index++] = state.getAttributeNameForQuery(); } @@ -315,7 +317,7 @@ public class DefaultIncrementalAttributesMapper implements AttributesMapper, Inc * @return a list with all attribute values found for the requested attribute. * Never null, an empty list indicates that the attribute was not set or empty. */ - public static List lookupAttributeValues(LdapOperations ldapOperations, String dn, String attribute) { + public static List lookupAttributeValues(LdapOperations ldapOperations, String dn, String attribute) { return lookupAttributeValues(ldapOperations, LdapUtils.newLdapName(dn), attribute); } @@ -328,8 +330,8 @@ public class DefaultIncrementalAttributesMapper implements AttributesMapper, Inc * @return a list with all attribute values found for the requested attribute. * Never null, an empty list indicates that the attribute was not set or empty. */ - public static List lookupAttributeValues(LdapOperations ldapOperations, Name dn, String attribute) { - List values = loopForAllAttributeValues(ldapOperations, dn, new String[]{attribute}).getValues(attribute); + public static List lookupAttributeValues(LdapOperations ldapOperations, Name dn, String attribute) { + List values = loopForAllAttributeValues(ldapOperations, dn, new String[]{attribute}).getValues(attribute); if(values == null) { values = Collections.emptyList(); } @@ -352,7 +354,7 @@ public class DefaultIncrementalAttributesMapper implements AttributesMapper, Inc */ private final static class DefaultIncrementalAttributeState implements IncrementalAttributeState { private final String actualAttributeName; - private List values = null; + private List values = null; private final int pageSize; boolean more = true; @@ -364,14 +366,17 @@ public class DefaultIncrementalAttributesMapper implements AttributesMapper, Inc this.requestRange = new RangeOption(0, pageSize); } + @Override public boolean hasMore() { return more; } + @Override public String getRequestedAttributeName() { return actualAttributeName; } + @Override public void calculateNextRange(RangeOption responseRange) { more = requestRange.compareTo(responseRange) > 0; @@ -380,6 +385,7 @@ public class DefaultIncrementalAttributesMapper implements AttributesMapper, Inc } } + @Override public String getAttributeNameForQuery() { StringBuilder attributeBuilder = new StringBuilder(actualAttributeName); @@ -391,6 +397,7 @@ public class DefaultIncrementalAttributesMapper implements AttributesMapper, Inc return attributeBuilder.toString(); } + @Override public void processValues(Attributes attributes, String attributeName) throws NamingException { Attribute attribute = attributes.get(attributeName); NamingEnumeration valueEnum = attribute.getAll(); @@ -403,13 +410,14 @@ public class DefaultIncrementalAttributesMapper implements AttributesMapper, Inc private void initValuesIfApplicable() { if (values == null) { - values = new LinkedList(); + values = new LinkedList(); } } - public List getValues() { + @Override + public List getValues() { if (values != null) { - return new ArrayList(values); + return new ArrayList(values); } else { return null; } @@ -430,6 +438,6 @@ public class DefaultIncrementalAttributesMapper implements AttributesMapper, Inc void processValues(Attributes attributes, String attributeName) throws NamingException; - List getValues(); + List getValues(); } } diff --git a/core/src/main/java/org/springframework/ldap/core/support/LookupAttemptingCallback.java b/core/src/main/java/org/springframework/ldap/core/support/LookupAttemptingCallback.java index abf25b00..5c764307 100644 --- a/core/src/main/java/org/springframework/ldap/core/support/LookupAttemptingCallback.java +++ b/core/src/main/java/org/springframework/ldap/core/support/LookupAttemptingCallback.java @@ -1,12 +1,28 @@ -package org.springframework.ldap.core.support; +/* + * 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. + * 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. + */ -import javax.naming.NamingException; -import javax.naming.directory.DirContext; +package org.springframework.ldap.core.support; import org.springframework.ldap.core.AuthenticatedLdapEntryContextCallback; import org.springframework.ldap.core.LdapEntryIdentification; import org.springframework.ldap.support.LdapUtils; +import javax.naming.NamingException; +import javax.naming.directory.DirContext; + /** * Attempts to perform an LDAP operation in the authenticated context, because * Active Directory might allow bind with incorrect password (specifically empty @@ -19,7 +35,7 @@ import org.springframework.ldap.support.LdapUtils; public class LookupAttemptingCallback implements AuthenticatedLdapEntryContextCallback { public void executeWithContext(DirContext ctx, LdapEntryIdentification ldapEntryIdentification) { try { - ctx.lookup(ldapEntryIdentification.getRelativeDn()); + ctx.lookup(ldapEntryIdentification.getRelativeName()); } catch (NamingException e) { // rethrow, because we aren't allowed to throw checked exceptions. diff --git a/core/src/main/java/org/springframework/ldap/core/support/RangeOption.java b/core/src/main/java/org/springframework/ldap/core/support/RangeOption.java index e38267cb..dc88e5f2 100644 --- a/core/src/main/java/org/springframework/ldap/core/support/RangeOption.java +++ b/core/src/main/java/org/springframework/ldap/core/support/RangeOption.java @@ -28,7 +28,7 @@ import java.util.regex.Matcher; * @see DefaultIncrementalAttributesMapper * @since 1.3.2 */ -class RangeOption implements Comparable { +class RangeOption implements Comparable { public static final int TERMINAL_END_OF_RANGE = -1; public static final int TERMINAL_MISSING = -2; @@ -124,14 +124,7 @@ class RangeOption implements Comparable { return new RangeOption(initial, terminal); } - public int compareTo(Object o) { - RangeOption that; - if (o instanceof RangeOption) { - that = (RangeOption) o; - } else { - throw new IllegalArgumentException("A RangeOption instance cannot be compared to " + o.getClass()); - } - + public int compareTo(RangeOption that) { if (this.getInitial() != that.getInitial()) throw new IllegalStateException("Ranges cannot be compared, range-initial not the same: " + this.toString() + " vs " + that.toString()); diff --git a/core/src/main/java/org/springframework/ldap/support/LdapUtils.java b/core/src/main/java/org/springframework/ldap/support/LdapUtils.java index 44c50f2a..b15a447e 100644 --- a/core/src/main/java/org/springframework/ldap/support/LdapUtils.java +++ b/core/src/main/java/org/springframework/ldap/support/LdapUtils.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. @@ -43,6 +43,7 @@ import java.util.NoSuchElementException; * the framework, but also useful for custom code. * * @author Ulrik Sandberg + * @author Mattias Hellborg Arthursson * @since 1.2 */ public final class LdapUtils {