Minor polishing.
This commit is contained in:
@@ -38,5 +38,5 @@ public interface ParameterizedContextMapper<T> extends ContextMapper {
|
||||
* @param ctx the context to map to an object.
|
||||
* @return an object built from the data in the context.
|
||||
*/
|
||||
public T mapFromContext(Object ctx);
|
||||
T mapFromContext(Object ctx);
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ public interface LdapDataEntry {
|
||||
* and one or several of the currently present attribute values is <strong>not</strong>
|
||||
* {@link Name} instances or Strings representing valid Distinguished Names.
|
||||
*/
|
||||
public void setAttributeValue(String name, Object value);
|
||||
void setAttributeValue(String name, Object value);
|
||||
|
||||
/**
|
||||
* Sets a multivalue attribute, disregarding the order of the values.
|
||||
|
||||
@@ -45,36 +45,44 @@ import static org.springframework.ldap.config.ParserUtils.getString;
|
||||
* @author Mattias Hellborg Arthursson
|
||||
*/
|
||||
public class ContextSourceParser implements BeanDefinitionParser {
|
||||
private final static String ATT_ANONYMOUS_READ_ONLY = "anonymous-read-only";
|
||||
private final static String ATT_AUTHENTICATION_SOURCE_REF = "authentication-source-ref";
|
||||
private final static String ATT_AUTHENTICATION_STRATEGY_REF = "authentication-strategy-ref";
|
||||
private final static String ATT_BASE = "base";
|
||||
private final static String ATT_PASSWORD = "password";
|
||||
private final static String ATT_NATIVE_POOLING = "native-pooling";
|
||||
private final static String ATT_REFERRAL = "referral";
|
||||
private final static String ATT_URL = "url";
|
||||
private final static String ATT_BASE_ENV_PROPS_REF = "base-env-props-ref";
|
||||
private static final String ATT_ANONYMOUS_READ_ONLY = "anonymous-read-only";
|
||||
private static final String ATT_AUTHENTICATION_SOURCE_REF = "authentication-source-ref";
|
||||
private static final String ATT_AUTHENTICATION_STRATEGY_REF = "authentication-strategy-ref";
|
||||
private static final String ATT_BASE = "base";
|
||||
private static final String ATT_PASSWORD = "password";
|
||||
private static final String ATT_NATIVE_POOLING = "native-pooling";
|
||||
private static final String ATT_REFERRAL = "referral";
|
||||
private static final String ATT_URL = "url";
|
||||
private static final String ATT_BASE_ENV_PROPS_REF = "base-env-props-ref";
|
||||
|
||||
// pooling attributes
|
||||
private final static String ATT_MAX_ACTIVE = "max-active";
|
||||
private final static String ATT_MAX_TOTAL = "max-total";
|
||||
private final static String ATT_MAX_IDLE = "max-idle";
|
||||
private final static String ATT_MIN_IDLE = "min-idle";
|
||||
private final static String ATT_MAX_WAIT = "max-wait";
|
||||
private final static String ATT_WHEN_EXHAUSTED = "when-exhausted";
|
||||
private final static String ATT_TEST_ON_BORROW = "test-on-borrow";
|
||||
private final static String ATT_TEST_ON_RETURN = "test-on-return";
|
||||
private final static String ATT_TEST_WHILE_IDLE = "test-while-idle";
|
||||
private final static String ATT_EVICTION_RUN_MILLIS = "eviction-run-interval-millis";
|
||||
private final static String ATT_TESTS_PER_EVICTION_RUN = "tests-per-eviction-run";
|
||||
private final static String ATT_EVICTABLE_TIME_MILLIS = "min-evictable-time-millis";
|
||||
private final static String ATT_VALIDATION_QUERY_BASE = "validation-query-base";
|
||||
private final static String ATT_VALIDATION_QUERY_FILTER = "validation-query-filter";
|
||||
private final static String ATT_VALIDATION_QUERY_SEARCH_CONTROLS_REF = "validation-query-search-controls-ref";
|
||||
private final static String ATT_NON_TRANSIENT_EXCEPTIONS = "non-transient-exceptions";
|
||||
private static final String ATT_MAX_ACTIVE = "max-active";
|
||||
private static final String ATT_MAX_TOTAL = "max-total";
|
||||
private static final String ATT_MAX_IDLE = "max-idle";
|
||||
private static final String ATT_MIN_IDLE = "min-idle";
|
||||
private static final String ATT_MAX_WAIT = "max-wait";
|
||||
private static final String ATT_WHEN_EXHAUSTED = "when-exhausted";
|
||||
private static final String ATT_TEST_ON_BORROW = "test-on-borrow";
|
||||
private static final String ATT_TEST_ON_RETURN = "test-on-return";
|
||||
private static final String ATT_TEST_WHILE_IDLE = "test-while-idle";
|
||||
private static final String ATT_EVICTION_RUN_MILLIS = "eviction-run-interval-millis";
|
||||
private static final String ATT_TESTS_PER_EVICTION_RUN = "tests-per-eviction-run";
|
||||
private static final String ATT_EVICTABLE_TIME_MILLIS = "min-evictable-time-millis";
|
||||
private static final String ATT_VALIDATION_QUERY_BASE = "validation-query-base";
|
||||
private static final String ATT_VALIDATION_QUERY_FILTER = "validation-query-filter";
|
||||
private static final String ATT_VALIDATION_QUERY_SEARCH_CONTROLS_REF = "validation-query-search-controls-ref";
|
||||
private static final String ATT_NON_TRANSIENT_EXCEPTIONS = "non-transient-exceptions";
|
||||
|
||||
private final static String ATT_USERNAME = "username";
|
||||
private static final String ATT_USERNAME = "username";
|
||||
static final String DEFAULT_ID = "contextSource";
|
||||
private static final int DEFAULT_MAX_ACTIVE = 8;
|
||||
private static final int DEFAULT_MAX_TOTAL = -1;
|
||||
private static final int DEFAULT_MAX_IDLE = 8;
|
||||
private static final int DEFAULT_MIN_IDLE = 0;
|
||||
private static final int DEFAULT_MAX_WAIT = -1;
|
||||
private static final int DEFAULT_EVICTION_RUN_MILLIS = -1;
|
||||
private static final int DEFAULT_TESTS_PER_EVICTION_RUN = 3;
|
||||
private static final int DEFAULT_EVICTABLE_MILLIS = 1000 * 60 * 30;
|
||||
|
||||
@Override
|
||||
public BeanDefinition parse(Element element, ParserContext parserContext) {
|
||||
@@ -150,11 +158,11 @@ public class ContextSourceParser implements BeanDefinitionParser {
|
||||
BeanDefinitionBuilder builder = BeanDefinitionBuilder.rootBeanDefinition(PoolingContextSource.class);
|
||||
builder.addPropertyValue("contextSource", targetContextSourceDefinition);
|
||||
|
||||
builder.addPropertyValue("maxActive", getInt(poolingElement, ATT_MAX_ACTIVE, 8));
|
||||
builder.addPropertyValue("maxTotal", getInt(poolingElement, ATT_MAX_TOTAL, -1));
|
||||
builder.addPropertyValue("maxIdle", getInt(poolingElement, ATT_MAX_IDLE, 8));
|
||||
builder.addPropertyValue("minIdle", getInt(poolingElement, ATT_MIN_IDLE, 0));
|
||||
builder.addPropertyValue("maxWait", getInt(poolingElement, ATT_MAX_WAIT, -1));
|
||||
builder.addPropertyValue("maxActive", getInt(poolingElement, ATT_MAX_ACTIVE, DEFAULT_MAX_ACTIVE));
|
||||
builder.addPropertyValue("maxTotal", getInt(poolingElement, ATT_MAX_TOTAL, DEFAULT_MAX_TOTAL));
|
||||
builder.addPropertyValue("maxIdle", getInt(poolingElement, ATT_MAX_IDLE, DEFAULT_MAX_IDLE));
|
||||
builder.addPropertyValue("minIdle", getInt(poolingElement, ATT_MIN_IDLE, DEFAULT_MIN_IDLE));
|
||||
builder.addPropertyValue("maxWait", getInt(poolingElement, ATT_MAX_WAIT, DEFAULT_MAX_WAIT));
|
||||
String whenExhausted = getString(poolingElement, ATT_WHEN_EXHAUSTED, PoolExhaustedAction.BLOCK.name());
|
||||
builder.addPropertyValue("whenExhaustedAction", PoolExhaustedAction.valueOf(whenExhausted).getValue());
|
||||
|
||||
@@ -186,9 +194,9 @@ public class ContextSourceParser implements BeanDefinitionParser {
|
||||
}
|
||||
builder.addPropertyValue("dirContextValidator", validatorBuilder.getBeanDefinition());
|
||||
|
||||
builder.addPropertyValue("timeBetweenEvictionRunsMillis", getInt(element, ATT_EVICTION_RUN_MILLIS, -1));
|
||||
builder.addPropertyValue("numTestsPerEvictionRun", getInt(element, ATT_TESTS_PER_EVICTION_RUN, 3));
|
||||
builder.addPropertyValue("minEvictableIdleTimeMillis", getInt(element, ATT_EVICTABLE_TIME_MILLIS, 1000 * 60 * 30));
|
||||
builder.addPropertyValue("timeBetweenEvictionRunsMillis", getInt(element, ATT_EVICTION_RUN_MILLIS, DEFAULT_EVICTION_RUN_MILLIS));
|
||||
builder.addPropertyValue("numTestsPerEvictionRun", getInt(element, ATT_TESTS_PER_EVICTION_RUN, DEFAULT_TESTS_PER_EVICTION_RUN));
|
||||
builder.addPropertyValue("minEvictableIdleTimeMillis", getInt(element, ATT_EVICTABLE_TIME_MILLIS, DEFAULT_EVICTABLE_MILLIS));
|
||||
|
||||
String nonTransientExceptions = getString(element, ATT_NON_TRANSIENT_EXCEPTIONS, CommunicationException.class.getName());
|
||||
String[] strings = StringUtils.commaDelimitedListToStringArray(nonTransientExceptions);
|
||||
|
||||
@@ -30,7 +30,7 @@ import static org.springframework.ldap.config.ParserUtils.getString;
|
||||
* @author Mattias Hellborg Arthursson
|
||||
*/
|
||||
public class DefaultRenamingStrategyParser implements BeanDefinitionParser {
|
||||
private final static String ATT_TEMP_SUFFIX = "temp-suffix";
|
||||
private static final String ATT_TEMP_SUFFIX = "temp-suffix";
|
||||
|
||||
@Override
|
||||
public BeanDefinition parse(Element element, ParserContext parserContext) {
|
||||
|
||||
@@ -35,15 +35,17 @@ import static org.springframework.ldap.config.ParserUtils.getString;
|
||||
* @author Mattias Hellborg Arthursson
|
||||
*/
|
||||
public class LdapTemplateParser implements BeanDefinitionParser {
|
||||
private final static String ATT_COUNT_LIMIT = "count-limit";
|
||||
private final static String ATT_TIME_LIMIT = "time-limit";
|
||||
private final static String ATT_SEARCH_SCOPE = "search-scope";
|
||||
private final static String ATT_IGNORE_PARTIAL_RESULT = "ignore-partial-result";
|
||||
private final static String ATT_IGNORE_NAME_NOT_FOUND = "ignore-name-not-found";
|
||||
private final static String ATT_ODM_REF = "odm-ref";
|
||||
private final static String ATT_CONTEXT_SOURCE_REF = "context-source-ref";
|
||||
private static final String ATT_COUNT_LIMIT = "count-limit";
|
||||
private static final String ATT_TIME_LIMIT = "time-limit";
|
||||
private static final String ATT_SEARCH_SCOPE = "search-scope";
|
||||
private static final String ATT_IGNORE_PARTIAL_RESULT = "ignore-partial-result";
|
||||
private static final String ATT_IGNORE_NAME_NOT_FOUND = "ignore-name-not-found";
|
||||
private static final String ATT_ODM_REF = "odm-ref";
|
||||
private static final String ATT_CONTEXT_SOURCE_REF = "context-source-ref";
|
||||
|
||||
private final static String DEFAULT_ID = "ldapTemplate";
|
||||
private static final String DEFAULT_ID = "ldapTemplate";
|
||||
private static final int DEFAULT_COUNT_LIMIT = 0;
|
||||
private static final int DEFAULT_TIME_LIMIT = 0;
|
||||
|
||||
@Override
|
||||
public BeanDefinition parse(Element element, ParserContext parserContext) {
|
||||
@@ -51,8 +53,8 @@ public class LdapTemplateParser implements BeanDefinitionParser {
|
||||
|
||||
String contextSourceRef = getString(element, ATT_CONTEXT_SOURCE_REF, ContextSourceParser.DEFAULT_ID);
|
||||
builder.addPropertyReference("contextSource", contextSourceRef);
|
||||
builder.addPropertyValue("defaultCountLimit", getInt(element, ATT_COUNT_LIMIT, 0));
|
||||
builder.addPropertyValue("defaultTimeLimit", getInt(element, ATT_TIME_LIMIT, 0));
|
||||
builder.addPropertyValue("defaultCountLimit", getInt(element, ATT_COUNT_LIMIT, DEFAULT_COUNT_LIMIT));
|
||||
builder.addPropertyValue("defaultTimeLimit", getInt(element, ATT_TIME_LIMIT, DEFAULT_TIME_LIMIT));
|
||||
|
||||
String searchScope = getString(element, ATT_SEARCH_SCOPE, SearchScope.SUBTREE.toString());
|
||||
builder.addPropertyValue("defaultSearchScope", SearchScope.valueOf(searchScope).getId());
|
||||
|
||||
@@ -38,14 +38,14 @@ import static org.springframework.ldap.config.ParserUtils.getString;
|
||||
* @author Mattias Hellborg Arthursson
|
||||
*/
|
||||
public class TransactionManagerParser implements BeanDefinitionParser {
|
||||
private final static String ATT_CONTEXT_SOURCE_REF = "context-source-ref";
|
||||
private final static String ATT_DATA_SOURCE_REF = "data-source-ref";
|
||||
private final static String ATT_SESSION_FACTORY_REF = "session-factory-ref";
|
||||
private static final String ATT_CONTEXT_SOURCE_REF = "context-source-ref";
|
||||
private static final String ATT_DATA_SOURCE_REF = "data-source-ref";
|
||||
private static final String ATT_SESSION_FACTORY_REF = "session-factory-ref";
|
||||
|
||||
private final static String ATT_TEMP_SUFFIX = "temp-suffix";
|
||||
private final static String ATT_SUBTREE_NODE = "subtree-node";
|
||||
private static final String ATT_TEMP_SUFFIX = "temp-suffix";
|
||||
private static final String ATT_SUBTREE_NODE = "subtree-node";
|
||||
|
||||
private final static String DEFAULT_ID = "transactionManager";
|
||||
private static final String DEFAULT_ID = "transactionManager";
|
||||
|
||||
@Override
|
||||
public BeanDefinition parse(Element element, ParserContext parserContext) {
|
||||
|
||||
@@ -102,8 +102,9 @@ public class DirContextAdapter implements DirContextOperations {
|
||||
private static final String EMPTY_STRING = "";
|
||||
|
||||
private static final boolean ORDER_DOESNT_MATTER = false;
|
||||
private static final String NOT_IMPLEMENTED = "Not implemented.";
|
||||
|
||||
private static Logger log = LoggerFactory.getLogger(DirContextAdapter.class);
|
||||
private static Logger log = LoggerFactory.getLogger(DirContextAdapter.class);
|
||||
|
||||
private final NameAwareAttributes originalAttrs;
|
||||
|
||||
@@ -839,7 +840,7 @@ public class DirContextAdapter implements DirContextOperations {
|
||||
*/
|
||||
public void modifyAttributes(Name name, int modOp, Attributes attrs)
|
||||
throws NamingException {
|
||||
throw new UnsupportedOperationException("Not implemented.");
|
||||
throw new UnsupportedOperationException(NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -848,7 +849,7 @@ public class DirContextAdapter implements DirContextOperations {
|
||||
*/
|
||||
public void modifyAttributes(String name, int modOp, Attributes attrs)
|
||||
throws NamingException {
|
||||
throw new UnsupportedOperationException("Not implemented.");
|
||||
throw new UnsupportedOperationException(NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -857,7 +858,7 @@ public class DirContextAdapter implements DirContextOperations {
|
||||
*/
|
||||
public void modifyAttributes(Name name, ModificationItem[] mods)
|
||||
throws NamingException {
|
||||
throw new UnsupportedOperationException("Not implemented.");
|
||||
throw new UnsupportedOperationException(NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -866,7 +867,7 @@ public class DirContextAdapter implements DirContextOperations {
|
||||
*/
|
||||
public void modifyAttributes(String name, ModificationItem[] mods)
|
||||
throws NamingException {
|
||||
throw new UnsupportedOperationException("Not implemented.");
|
||||
throw new UnsupportedOperationException(NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -874,7 +875,7 @@ public class DirContextAdapter implements DirContextOperations {
|
||||
*/
|
||||
public void bind(Name name, Object obj, Attributes attrs)
|
||||
throws NamingException {
|
||||
throw new UnsupportedOperationException("Not implemented.");
|
||||
throw new UnsupportedOperationException(NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -882,7 +883,7 @@ public class DirContextAdapter implements DirContextOperations {
|
||||
*/
|
||||
public void bind(String name, Object obj, Attributes attrs)
|
||||
throws NamingException {
|
||||
throw new UnsupportedOperationException("Not implemented.");
|
||||
throw new UnsupportedOperationException(NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -890,7 +891,7 @@ public class DirContextAdapter implements DirContextOperations {
|
||||
*/
|
||||
public void rebind(Name name, Object obj, Attributes attrs)
|
||||
throws NamingException {
|
||||
throw new UnsupportedOperationException("Not implemented.");
|
||||
throw new UnsupportedOperationException(NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -898,7 +899,7 @@ public class DirContextAdapter implements DirContextOperations {
|
||||
*/
|
||||
public void rebind(String name, Object obj, Attributes attrs)
|
||||
throws NamingException {
|
||||
throw new UnsupportedOperationException("Not implemented.");
|
||||
throw new UnsupportedOperationException(NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -906,7 +907,7 @@ public class DirContextAdapter implements DirContextOperations {
|
||||
*/
|
||||
public DirContext createSubcontext(Name name, Attributes attrs)
|
||||
throws NamingException {
|
||||
throw new UnsupportedOperationException("Not implemented.");
|
||||
throw new UnsupportedOperationException(NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -915,21 +916,21 @@ public class DirContextAdapter implements DirContextOperations {
|
||||
*/
|
||||
public DirContext createSubcontext(String name, Attributes attrs)
|
||||
throws NamingException {
|
||||
throw new UnsupportedOperationException("Not implemented.");
|
||||
throw new UnsupportedOperationException(NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see javax.naming.directory.DirContext#getSchema(Name)
|
||||
*/
|
||||
public DirContext getSchema(Name name) throws NamingException {
|
||||
throw new UnsupportedOperationException("Not implemented.");
|
||||
throw new UnsupportedOperationException(NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see javax.naming.directory.DirContext#getSchema(String)
|
||||
*/
|
||||
public DirContext getSchema(String name) throws NamingException {
|
||||
throw new UnsupportedOperationException("Not implemented.");
|
||||
throw new UnsupportedOperationException(NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -937,7 +938,7 @@ public class DirContextAdapter implements DirContextOperations {
|
||||
*/
|
||||
public DirContext getSchemaClassDefinition(Name name)
|
||||
throws NamingException {
|
||||
throw new UnsupportedOperationException("Not implemented.");
|
||||
throw new UnsupportedOperationException(NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -945,7 +946,7 @@ public class DirContextAdapter implements DirContextOperations {
|
||||
*/
|
||||
public DirContext getSchemaClassDefinition(String name)
|
||||
throws NamingException {
|
||||
throw new UnsupportedOperationException("Not implemented.");
|
||||
throw new UnsupportedOperationException(NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -953,7 +954,7 @@ public class DirContextAdapter implements DirContextOperations {
|
||||
*/
|
||||
public NamingEnumeration<SearchResult> search(Name name, Attributes matchingAttributes,
|
||||
String[] attributesToReturn) throws NamingException {
|
||||
throw new UnsupportedOperationException("Not implemented.");
|
||||
throw new UnsupportedOperationException(NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -962,7 +963,7 @@ public class DirContextAdapter implements DirContextOperations {
|
||||
*/
|
||||
public NamingEnumeration<SearchResult> search(String name, Attributes matchingAttributes,
|
||||
String[] attributesToReturn) throws NamingException {
|
||||
throw new UnsupportedOperationException("Not implemented.");
|
||||
throw new UnsupportedOperationException(NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -970,7 +971,7 @@ public class DirContextAdapter implements DirContextOperations {
|
||||
*/
|
||||
public NamingEnumeration<SearchResult> search(Name name, Attributes matchingAttributes)
|
||||
throws NamingException {
|
||||
throw new UnsupportedOperationException("Not implemented.");
|
||||
throw new UnsupportedOperationException(NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -978,7 +979,7 @@ public class DirContextAdapter implements DirContextOperations {
|
||||
*/
|
||||
public NamingEnumeration<SearchResult> search(String name, Attributes matchingAttributes)
|
||||
throws NamingException {
|
||||
throw new UnsupportedOperationException("Not implemented.");
|
||||
throw new UnsupportedOperationException(NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -987,7 +988,7 @@ public class DirContextAdapter implements DirContextOperations {
|
||||
*/
|
||||
public NamingEnumeration<SearchResult> search(Name name, String filter,
|
||||
SearchControls cons) throws NamingException {
|
||||
throw new UnsupportedOperationException("Not implemented.");
|
||||
throw new UnsupportedOperationException(NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -996,7 +997,7 @@ public class DirContextAdapter implements DirContextOperations {
|
||||
*/
|
||||
public NamingEnumeration<SearchResult> search(String name, String filter,
|
||||
SearchControls cons) throws NamingException {
|
||||
throw new UnsupportedOperationException("Not implemented.");
|
||||
throw new UnsupportedOperationException(NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1005,7 +1006,7 @@ public class DirContextAdapter implements DirContextOperations {
|
||||
*/
|
||||
public NamingEnumeration<SearchResult> search(Name name, String filterExpr,
|
||||
Object[] filterArgs, SearchControls cons) throws NamingException {
|
||||
throw new UnsupportedOperationException("Not implemented.");
|
||||
throw new UnsupportedOperationException(NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1014,168 +1015,168 @@ public class DirContextAdapter implements DirContextOperations {
|
||||
*/
|
||||
public NamingEnumeration<SearchResult> search(String name, String filterExpr,
|
||||
Object[] filterArgs, SearchControls cons) throws NamingException {
|
||||
throw new UnsupportedOperationException("Not implemented.");
|
||||
throw new UnsupportedOperationException(NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see javax.naming.Context#lookup(Name)
|
||||
*/
|
||||
public Object lookup(Name name) throws NamingException {
|
||||
throw new UnsupportedOperationException("Not implemented.");
|
||||
throw new UnsupportedOperationException(NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see javax.naming.Context#lookup(String)
|
||||
*/
|
||||
public Object lookup(String name) throws NamingException {
|
||||
throw new UnsupportedOperationException("Not implemented.");
|
||||
throw new UnsupportedOperationException(NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see javax.naming.Context#bind(Name, Object)
|
||||
*/
|
||||
public void bind(Name name, Object obj) throws NamingException {
|
||||
throw new UnsupportedOperationException("Not implemented.");
|
||||
throw new UnsupportedOperationException(NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see javax.naming.Context#bind(String, Object)
|
||||
*/
|
||||
public void bind(String name, Object obj) throws NamingException {
|
||||
throw new UnsupportedOperationException("Not implemented.");
|
||||
throw new UnsupportedOperationException(NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see javax.naming.Context#rebind(Name, Object)
|
||||
*/
|
||||
public void rebind(Name name, Object obj) throws NamingException {
|
||||
throw new UnsupportedOperationException("Not implemented.");
|
||||
throw new UnsupportedOperationException(NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see javax.naming.Context#rebind(String, Object)
|
||||
*/
|
||||
public void rebind(String name, Object obj) throws NamingException {
|
||||
throw new UnsupportedOperationException("Not implemented.");
|
||||
throw new UnsupportedOperationException(NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see javax.naming.Context#unbind(Name)
|
||||
*/
|
||||
public void unbind(Name name) throws NamingException {
|
||||
throw new UnsupportedOperationException("Not implemented.");
|
||||
throw new UnsupportedOperationException(NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see javax.naming.Context#unbind(String)
|
||||
*/
|
||||
public void unbind(String name) throws NamingException {
|
||||
throw new UnsupportedOperationException("Not implemented.");
|
||||
throw new UnsupportedOperationException(NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see javax.naming.Context#rename(Name, Name)
|
||||
*/
|
||||
public void rename(Name oldName, Name newName) throws NamingException {
|
||||
throw new UnsupportedOperationException("Not implemented.");
|
||||
throw new UnsupportedOperationException(NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see javax.naming.Context#rename(String, String)
|
||||
*/
|
||||
public void rename(String oldName, String newName) throws NamingException {
|
||||
throw new UnsupportedOperationException("Not implemented.");
|
||||
throw new UnsupportedOperationException(NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see javax.naming.Context#list(Name)
|
||||
*/
|
||||
public NamingEnumeration<NameClassPair> list(Name name) throws NamingException {
|
||||
throw new UnsupportedOperationException("Not implemented.");
|
||||
throw new UnsupportedOperationException(NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see javax.naming.Context#list(String)
|
||||
*/
|
||||
public NamingEnumeration<NameClassPair> list(String name) throws NamingException {
|
||||
throw new UnsupportedOperationException("Not implemented.");
|
||||
throw new UnsupportedOperationException(NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see javax.naming.Context#listBindings(Name)
|
||||
*/
|
||||
public NamingEnumeration<Binding> listBindings(Name name) throws NamingException {
|
||||
throw new UnsupportedOperationException("Not implemented.");
|
||||
throw new UnsupportedOperationException(NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see javax.naming.Context#listBindings(String)
|
||||
*/
|
||||
public NamingEnumeration<Binding> listBindings(String name) throws NamingException {
|
||||
throw new UnsupportedOperationException("Not implemented.");
|
||||
throw new UnsupportedOperationException(NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see javax.naming.Context#destroySubcontext(Name)
|
||||
*/
|
||||
public void destroySubcontext(Name name) throws NamingException {
|
||||
throw new UnsupportedOperationException("Not implemented.");
|
||||
throw new UnsupportedOperationException(NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see javax.naming.Context#destroySubcontext(String)
|
||||
*/
|
||||
public void destroySubcontext(String name) throws NamingException {
|
||||
throw new UnsupportedOperationException("Not implemented.");
|
||||
throw new UnsupportedOperationException(NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see javax.naming.Context#createSubcontext(Name)
|
||||
*/
|
||||
public Context createSubcontext(Name name) throws NamingException {
|
||||
throw new UnsupportedOperationException("Not implemented.");
|
||||
throw new UnsupportedOperationException(NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see javax.naming.Context#createSubcontext(String)
|
||||
*/
|
||||
public Context createSubcontext(String name) throws NamingException {
|
||||
throw new UnsupportedOperationException("Not implemented.");
|
||||
throw new UnsupportedOperationException(NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see javax.naming.Context#lookupLink(Name)
|
||||
*/
|
||||
public Object lookupLink(Name name) throws NamingException {
|
||||
throw new UnsupportedOperationException("Not implemented.");
|
||||
throw new UnsupportedOperationException(NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see javax.naming.Context#lookupLink(String)
|
||||
*/
|
||||
public Object lookupLink(String name) throws NamingException {
|
||||
throw new UnsupportedOperationException("Not implemented.");
|
||||
throw new UnsupportedOperationException(NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see javax.naming.Context#getNameParser(Name)
|
||||
*/
|
||||
public NameParser getNameParser(Name name) throws NamingException {
|
||||
throw new UnsupportedOperationException("Not implemented.");
|
||||
throw new UnsupportedOperationException(NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see javax.naming.Context#getNameParser(String)
|
||||
*/
|
||||
public NameParser getNameParser(String name) throws NamingException {
|
||||
throw new UnsupportedOperationException("Not implemented.");
|
||||
throw new UnsupportedOperationException(NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see javax.naming.Context#composeName(Name, Name)
|
||||
*/
|
||||
public Name composeName(Name name, Name prefix) throws NamingException {
|
||||
throw new UnsupportedOperationException("Not implemented.");
|
||||
throw new UnsupportedOperationException(NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1183,7 +1184,7 @@ public class DirContextAdapter implements DirContextOperations {
|
||||
*/
|
||||
public String composeName(String name, String prefix)
|
||||
throws NamingException {
|
||||
throw new UnsupportedOperationException("Not implemented.");
|
||||
throw new UnsupportedOperationException(NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1191,28 +1192,28 @@ public class DirContextAdapter implements DirContextOperations {
|
||||
*/
|
||||
public Object addToEnvironment(String propName, Object propVal)
|
||||
throws NamingException {
|
||||
throw new UnsupportedOperationException("Not implemented.");
|
||||
throw new UnsupportedOperationException(NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see javax.naming.Context#removeFromEnvironment(String)
|
||||
*/
|
||||
public Object removeFromEnvironment(String propName) throws NamingException {
|
||||
throw new UnsupportedOperationException("Not implemented.");
|
||||
throw new UnsupportedOperationException(NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see javax.naming.Context#getEnvironment()
|
||||
*/
|
||||
public Hashtable<?, ?> getEnvironment() throws NamingException {
|
||||
throw new UnsupportedOperationException("Not implemented.");
|
||||
throw new UnsupportedOperationException(NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see javax.naming.Context#close()
|
||||
*/
|
||||
public void close() throws NamingException {
|
||||
throw new UnsupportedOperationException("Not implemented.");
|
||||
throw new UnsupportedOperationException(NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -149,7 +149,7 @@ public class DistinguishedName implements Name {
|
||||
private static final String MANGLED_DOUBLE_QUOTES = "\\\\\"";
|
||||
private static final String PROPER_DOUBLE_QUOTES = "\\\"";
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(DistinguishedName.class);
|
||||
private static final Logger LOG = LoggerFactory.getLogger(DistinguishedName.class);
|
||||
|
||||
private static final boolean COMPACT = true;
|
||||
|
||||
@@ -161,8 +161,9 @@ public class DistinguishedName implements Name {
|
||||
* An empty, unmodifiable DistinguishedName.
|
||||
*/
|
||||
public static final DistinguishedName EMPTY_PATH = new DistinguishedName(Collections.EMPTY_LIST);
|
||||
private static final int DEFAULT_BUFFER_SIZE = 256;
|
||||
|
||||
private List names;
|
||||
private List names;
|
||||
|
||||
/**
|
||||
* Construct a new DistinguishedName with no components.
|
||||
@@ -358,10 +359,11 @@ public class DistinguishedName implements Name {
|
||||
|
||||
private String format(boolean compact) {
|
||||
// empty path
|
||||
if (names.size() == 0)
|
||||
if (names.size() == 0) {
|
||||
return "";
|
||||
}
|
||||
|
||||
StringBuffer buffer = new StringBuffer(256);
|
||||
StringBuffer buffer = new StringBuffer(DEFAULT_BUFFER_SIZE);
|
||||
|
||||
ListIterator i = names.listIterator(names.size());
|
||||
while (i.hasPrevious()) {
|
||||
@@ -390,7 +392,7 @@ public class DistinguishedName implements Name {
|
||||
* @return the LDAP path, for use in an url.
|
||||
*/
|
||||
public String toUrl() {
|
||||
StringBuffer buffer = new StringBuffer(256);
|
||||
StringBuffer buffer = new StringBuffer(DEFAULT_BUFFER_SIZE);
|
||||
|
||||
for (int i = names.size() - 1; i >= 0; i--) {
|
||||
LdapRdn n = (LdapRdn) names.get(i);
|
||||
@@ -415,12 +417,14 @@ public class DistinguishedName implements Name {
|
||||
List shortlist = path.getNames();
|
||||
|
||||
// this path must be at least as long
|
||||
if (getNames().size() < shortlist.size())
|
||||
return false;
|
||||
if (getNames().size() < shortlist.size()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// must have names
|
||||
if (shortlist.size() == 0)
|
||||
return false;
|
||||
if (shortlist.size() == 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Iterator longiter = getNames().iterator();
|
||||
Iterator shortiter = shortlist.iterator();
|
||||
@@ -434,10 +438,12 @@ public class DistinguishedName implements Name {
|
||||
}
|
||||
|
||||
// Done?
|
||||
if (!shortiter.hasNext() && longname.equals(shortname))
|
||||
return true;
|
||||
if (!longiter.hasNext())
|
||||
return false;
|
||||
if (!shortiter.hasNext() && longname.equals(shortname)) {
|
||||
return true;
|
||||
}
|
||||
if (!longiter.hasNext()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// compare
|
||||
while (longname.equals(shortname) && longiter.hasNext() && shortiter.hasNext()) {
|
||||
@@ -536,7 +542,7 @@ public class DistinguishedName implements Name {
|
||||
return result;
|
||||
}
|
||||
catch (CloneNotSupportedException e) {
|
||||
log.error("CloneNotSupported thrown from superclass - this should not happen");
|
||||
LOG.error("CloneNotSupported thrown from superclass - this should not happen");
|
||||
throw new UncategorizedLdapException("Fatal error in clone", e);
|
||||
}
|
||||
}
|
||||
@@ -702,12 +708,14 @@ public class DistinguishedName implements Name {
|
||||
List shortlist = path.getNames();
|
||||
|
||||
// this path must be at least as long
|
||||
if (getNames().size() < shortlist.size())
|
||||
return false;
|
||||
if (getNames().size() < shortlist.size()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// must have names
|
||||
if (shortlist.size() == 0)
|
||||
return false;
|
||||
if (shortlist.size() == 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
ListIterator longiter = getNames().listIterator(getNames().size());
|
||||
ListIterator shortiter = shortlist.listIterator(shortlist.size());
|
||||
|
||||
@@ -40,8 +40,9 @@ import java.util.Set;
|
||||
*/
|
||||
public class LdapRdn implements Serializable, Comparable {
|
||||
private static final long serialVersionUID = 5681397547245228750L;
|
||||
private static final int DEFAULT_BUFFER_SIZE = 100;
|
||||
|
||||
private Map<String, LdapRdnComponent> components = new LinkedHashMap<String, LdapRdnComponent>();
|
||||
private Map<String, LdapRdnComponent> components = new LinkedHashMap<String, LdapRdnComponent>();
|
||||
|
||||
/**
|
||||
* Default constructor. Create an empty, uninitialized LdapRdn.
|
||||
@@ -136,7 +137,7 @@ public class LdapRdn implements Serializable, Comparable {
|
||||
if (components.size() == 0) {
|
||||
throw new IndexOutOfBoundsException("No components in Rdn.");
|
||||
}
|
||||
StringBuffer sb = new StringBuffer(100);
|
||||
StringBuffer sb = new StringBuffer(DEFAULT_BUFFER_SIZE);
|
||||
for (Iterator iter = components.values().iterator(); iter.hasNext();) {
|
||||
LdapRdnComponent component = (LdapRdnComponent) iter.next();
|
||||
sb.append(component.encodeLdap());
|
||||
@@ -154,7 +155,7 @@ public class LdapRdn implements Serializable, Comparable {
|
||||
* @return a String representation of this LdapRdn for use in urls.
|
||||
*/
|
||||
public String encodeUrl() {
|
||||
StringBuffer sb = new StringBuffer(100);
|
||||
StringBuffer sb = new StringBuffer(DEFAULT_BUFFER_SIZE);
|
||||
for (Iterator iter = components.values().iterator(); iter.hasNext();) {
|
||||
LdapRdnComponent component = (LdapRdnComponent) iter.next();
|
||||
sb.append(component.encodeUrl());
|
||||
|
||||
@@ -36,7 +36,7 @@ import java.net.URISyntaxException;
|
||||
public class LdapRdnComponent implements Comparable, Serializable {
|
||||
private static final long serialVersionUID = -3296747972616243038L;
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(LdapRdnComponent.class);
|
||||
private static final Logger LOG = LoggerFactory.getLogger(LdapRdnComponent.class);
|
||||
|
||||
public static final boolean DONT_DECODE_VALUE = false;
|
||||
|
||||
@@ -80,11 +80,11 @@ public class LdapRdnComponent implements Comparable, Serializable {
|
||||
} else if (caseFold.equals(DistinguishedName.KEY_CASE_FOLD_NONE)) {
|
||||
this.key = key;
|
||||
} else {
|
||||
log
|
||||
LOG
|
||||
.warn("\"" + caseFold + "\" invalid property value for " + DistinguishedName.KEY_CASE_FOLD_PROPERTY
|
||||
+ "; expected \"" + DistinguishedName.KEY_CASE_FOLD_LOWER + "\", \""
|
||||
+ DistinguishedName.KEY_CASE_FOLD_UPPER + "\", or \""
|
||||
+ DistinguishedName.KEY_CASE_FOLD_NONE + "\"");
|
||||
+ "; expected \"" + DistinguishedName.KEY_CASE_FOLD_LOWER + "\", \""
|
||||
+ DistinguishedName.KEY_CASE_FOLD_UPPER + "\", or \""
|
||||
+ DistinguishedName.KEY_CASE_FOLD_NONE + "\"");
|
||||
this.key = key.toLowerCase();
|
||||
}
|
||||
if (decodeValue) {
|
||||
|
||||
@@ -68,7 +68,7 @@ import java.util.List;
|
||||
*/
|
||||
public class LdapTemplate implements LdapOperations, InitializingBean {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(LdapTemplate.class);
|
||||
private static final Logger LOG = LoggerFactory.getLogger(LdapTemplate.class);
|
||||
|
||||
private static final boolean DONT_RETURN_OBJ_FLAG = false;
|
||||
|
||||
@@ -380,7 +380,7 @@ public class LdapTemplate implements LdapOperations, InitializingBean {
|
||||
catch (NameNotFoundException e) {
|
||||
// It is possible to ignore errors caused by base not found
|
||||
if (ignoreNameNotFoundException) {
|
||||
log.warn("Base context not found, ignoring: " + e.getMessage());
|
||||
LOG.warn("Base context not found, ignoring: " + e.getMessage());
|
||||
}
|
||||
else {
|
||||
ex = LdapUtils.convertLdapException(e);
|
||||
@@ -389,7 +389,7 @@ public class LdapTemplate implements LdapOperations, InitializingBean {
|
||||
catch (PartialResultException e) {
|
||||
// Workaround for AD servers not handling referrals correctly.
|
||||
if (ignorePartialResultException) {
|
||||
log.debug("PartialResultException encountered and ignored", e);
|
||||
LOG.debug("PartialResultException encountered and ignored", e);
|
||||
}
|
||||
else {
|
||||
ex = LdapUtils.convertLdapException(e);
|
||||
@@ -397,7 +397,7 @@ public class LdapTemplate implements LdapOperations, InitializingBean {
|
||||
}
|
||||
catch(SizeLimitExceededException e) {
|
||||
if(ignoreSizeLimitExceededException) {
|
||||
log.debug("SizeLimitExceededException encountered and ignored", e);
|
||||
LOG.debug("SizeLimitExceededException encountered and ignored", e);
|
||||
}
|
||||
else {
|
||||
ex = LdapUtils.convertLdapException(e);
|
||||
@@ -417,7 +417,7 @@ public class LdapTemplate implements LdapOperations, InitializingBean {
|
||||
else {
|
||||
// We already had an exception from above and should ignore
|
||||
// this one.
|
||||
log.debug("Ignoring Exception from postProcess, " + "main exception thrown instead", e);
|
||||
LOG.debug("Ignoring Exception from postProcess, " + "main exception thrown instead", e);
|
||||
}
|
||||
}
|
||||
closeContextAndNamingEnumeration(ctx, results);
|
||||
@@ -1174,8 +1174,8 @@ public class LdapTemplate implements LdapOperations, InitializingBean {
|
||||
deleteRecursively(ctx, childName);
|
||||
}
|
||||
ctx.unbind(name);
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Entry " + name + " deleted");
|
||||
if (LOG.isDebugEnabled()) {
|
||||
LOG.debug("Entry " + name + " deleted");
|
||||
}
|
||||
}
|
||||
catch (javax.naming.NamingException e) {
|
||||
@@ -1318,8 +1318,8 @@ public class LdapTemplate implements LdapOperations, InitializingBean {
|
||||
private void assureReturnObjFlagSet(SearchControls controls) {
|
||||
Assert.notNull(controls, "controls must not be null");
|
||||
if (!controls.getReturningObjFlag()) {
|
||||
log.debug("The returnObjFlag of supplied SearchControls is not set"
|
||||
+ " but a ContextMapper is used - setting flag to true");
|
||||
LOG.debug("The returnObjFlag of supplied SearchControls is not set"
|
||||
+ " but a ContextMapper is used - setting flag to true");
|
||||
controls.setReturningObjFlag(true);
|
||||
}
|
||||
}
|
||||
@@ -1330,12 +1330,12 @@ public class LdapTemplate implements LdapOperations, InitializingBean {
|
||||
* @author Mattias Hellborg Arthursson
|
||||
* @since 2.0
|
||||
*/
|
||||
public final static class NullDirContextProcessor implements DirContextProcessor {
|
||||
public void postProcess(DirContext ctx) throws NamingException {
|
||||
public static final class NullDirContextProcessor implements DirContextProcessor {
|
||||
public void postProcess(DirContext ctx) {
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
public void preProcess(DirContext ctx) throws NamingException {
|
||||
public void preProcess(DirContext ctx) {
|
||||
// Do nothing
|
||||
}
|
||||
}
|
||||
@@ -1562,7 +1562,7 @@ public class LdapTemplate implements LdapOperations, InitializingBean {
|
||||
List<LdapEntryIdentification> result = search(base, filter, searchControls, new LdapEntryIdentificationContextMapper());
|
||||
if (result.size() == 0) {
|
||||
String msg = "No results found for search, base: '" + base + "'; filter: '" + filter + "'.";
|
||||
log.info(msg);
|
||||
LOG.info(msg);
|
||||
return false;
|
||||
} else if (result.size() > 1) {
|
||||
String msg = "base: '" + base + "'; filter: '" + filter + "'.";
|
||||
@@ -1582,7 +1582,7 @@ public class LdapTemplate implements LdapOperations, InitializingBean {
|
||||
return true;
|
||||
}
|
||||
catch (Exception e) {
|
||||
log.info("Authentication failed for entry with DN '" + entryIdentification.getAbsoluteName() + "'", e);
|
||||
LOG.info("Authentication failed for entry with DN '" + entryIdentification.getAbsoluteName() + "'", e);
|
||||
errorCallback.execute(e);
|
||||
return false;
|
||||
}
|
||||
@@ -1776,8 +1776,8 @@ public class LdapTemplate implements LdapOperations, InitializingBean {
|
||||
|
||||
@Override
|
||||
public <T> T findByDn(Name dn, final Class<T> clazz) {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug(String.format("Reading Entry at - %s$1", dn));
|
||||
if (LOG.isDebugEnabled()) {
|
||||
LOG.debug(String.format("Reading Entry at - %s$1", dn));
|
||||
}
|
||||
|
||||
// Make sure the class is OK before doing the lookup
|
||||
@@ -1793,8 +1793,8 @@ public class LdapTemplate implements LdapOperations, InitializingBean {
|
||||
if (result == null) {
|
||||
throw new OdmException(String.format("Entry %1$s does not have the required objectclasses ", dn));
|
||||
}
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug(String.format("Found entry - %s$1", result));
|
||||
if (LOG.isDebugEnabled()) {
|
||||
LOG.debug(String.format("Found entry - %s$1", result));
|
||||
}
|
||||
|
||||
return result;
|
||||
@@ -1804,8 +1804,8 @@ public class LdapTemplate implements LdapOperations, InitializingBean {
|
||||
public void create(Object entry) {
|
||||
Assert.notNull(entry, "Entry must not be null");
|
||||
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug(String.format("Creating entry - %s$1", entry));
|
||||
if (LOG.isDebugEnabled()) {
|
||||
LOG.debug(String.format("Creating entry - %s$1", entry));
|
||||
}
|
||||
|
||||
Name id = odm.getId(entry);
|
||||
@@ -1825,8 +1825,8 @@ public class LdapTemplate implements LdapOperations, InitializingBean {
|
||||
@Override
|
||||
public void update(Object entry) {
|
||||
Assert.notNull(entry, "Entry must not be null");
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug(String.format("Updating entry - %s$1", entry));
|
||||
if (LOG.isDebugEnabled()) {
|
||||
LOG.debug(String.format("Updating entry - %s$1", entry));
|
||||
}
|
||||
|
||||
Name originalId = odm.getId(entry);
|
||||
@@ -1835,8 +1835,8 @@ public class LdapTemplate implements LdapOperations, InitializingBean {
|
||||
if(originalId != null && calculatedId != null && !originalId.equals(calculatedId)) {
|
||||
// The DN has changed - remove the original entry and bind the new one
|
||||
// (because other data may have changed as well
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug(String.format("Calculated DN of %s; of entry %s differs from explicitly specified one; %s - moving",
|
||||
if (LOG.isDebugEnabled()) {
|
||||
LOG.debug(String.format("Calculated DN of %s; of entry %s differs from explicitly specified one; %s - moving",
|
||||
calculatedId, entry, originalId));
|
||||
}
|
||||
|
||||
@@ -1867,8 +1867,8 @@ public class LdapTemplate implements LdapOperations, InitializingBean {
|
||||
@Override
|
||||
public void delete(Object entry) {
|
||||
Assert.notNull(entry, "Entry must not be null");
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug(String.format("Deleting %s$1", entry));
|
||||
if (LOG.isDebugEnabled()) {
|
||||
LOG.debug(String.format("Deleting %s$1", entry));
|
||||
}
|
||||
|
||||
Name id = odm.getId(entry);
|
||||
@@ -1902,8 +1902,8 @@ public class LdapTemplate implements LdapOperations, InitializingBean {
|
||||
localBase = LdapUtils.emptyLdapName();
|
||||
}
|
||||
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug(String.format("Searching - base=%1$s, finalFilter=%2$s, scope=%3$s", base, finalFilter, searchControls));
|
||||
if (LOG.isDebugEnabled()) {
|
||||
LOG.debug(String.format("Searching - base=%1$s, finalFilter=%2$s, scope=%3$s", base, finalFilter, searchControls));
|
||||
}
|
||||
|
||||
List<T> result = search(localBase, finalFilter.encode(), searchControls, new ContextMapper<T>() {
|
||||
@@ -1914,8 +1914,8 @@ public class LdapTemplate implements LdapOperations, InitializingBean {
|
||||
});
|
||||
result.remove(null);
|
||||
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug(String.format("Found %1$s Entries - %2$s", result.size(), result));
|
||||
if (LOG.isDebugEnabled()) {
|
||||
LOG.debug(String.format("Found %1$s Entries - %2$s", result.size(), result));
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
@@ -80,6 +80,7 @@ public abstract class AbstractContextSource implements BaseLdapPathContextSource
|
||||
private static final Class<DefaultDirObjectFactory> DEFAULT_DIR_OBJECT_FACTORY = DefaultDirObjectFactory.class;
|
||||
private static final boolean DONT_DISABLE_POOLING = false;
|
||||
private static final boolean EXPLICITLY_DISABLE_POOLING = true;
|
||||
private static final int DEFAULT_BUFFER_SIZE = 1024;
|
||||
|
||||
private Class<?> dirObjectFactory = DEFAULT_DIR_OBJECT_FACTORY;
|
||||
|
||||
@@ -87,9 +88,9 @@ public abstract class AbstractContextSource implements BaseLdapPathContextSource
|
||||
|
||||
private LdapName base = LdapUtils.emptyLdapName();
|
||||
|
||||
protected String userDn = "";
|
||||
private String userDn = "";
|
||||
|
||||
protected String password = "";
|
||||
private String password = "";
|
||||
|
||||
private String[] urls;
|
||||
|
||||
@@ -107,7 +108,7 @@ public abstract class AbstractContextSource implements BaseLdapPathContextSource
|
||||
|
||||
private String referral = null;
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(AbstractContextSource.class);
|
||||
private static final Logger LOG = LoggerFactory.getLogger(AbstractContextSource.class);
|
||||
|
||||
public static final String SUN_LDAP_POOLING_FLAG = "com.sun.jndi.ldap.connect.pool";
|
||||
|
||||
@@ -200,7 +201,7 @@ public abstract class AbstractContextSource implements BaseLdapPathContextSource
|
||||
ctx.close();
|
||||
}
|
||||
catch (Exception e) {
|
||||
log.debug("Exception closing context", e);
|
||||
LOG.debug("Exception closing context", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -213,7 +214,7 @@ public abstract class AbstractContextSource implements BaseLdapPathContextSource
|
||||
* @return the full url String
|
||||
*/
|
||||
public String assembleProviderUrlString(String[] ldapUrls) {
|
||||
StringBuilder providerUrlBuffer = new StringBuilder(1024);
|
||||
StringBuilder providerUrlBuffer = new StringBuilder(DEFAULT_BUFFER_SIZE);
|
||||
for (String ldapUrl : ldapUrls) {
|
||||
providerUrlBuffer.append(ldapUrl);
|
||||
if (!base.isEmpty()) {
|
||||
@@ -333,10 +334,10 @@ public abstract class AbstractContextSource implements BaseLdapPathContextSource
|
||||
try {
|
||||
ctx = getDirContextInstance(environment);
|
||||
|
||||
if (log.isInfoEnabled()) {
|
||||
if (LOG.isInfoEnabled()) {
|
||||
Hashtable<?, ?> ctxEnv = ctx.getEnvironment();
|
||||
String ldapUrl = (String) ctxEnv.get(Context.PROVIDER_URL);
|
||||
log.debug("Got Ldap context on server '" + ldapUrl + "'");
|
||||
LOG.debug("Got Ldap context on server '" + ldapUrl + "'");
|
||||
}
|
||||
|
||||
return ctx;
|
||||
@@ -395,7 +396,7 @@ public abstract class AbstractContextSource implements BaseLdapPathContextSource
|
||||
* call this method explicitly after setting all desired properties if using
|
||||
* the class outside of a Spring Context.
|
||||
*/
|
||||
public void afterPropertiesSet() throws Exception {
|
||||
public void afterPropertiesSet() {
|
||||
if (ObjectUtils.isEmpty(urls)) {
|
||||
throw new IllegalArgumentException("At least one server url must be set");
|
||||
}
|
||||
@@ -405,12 +406,12 @@ public abstract class AbstractContextSource implements BaseLdapPathContextSource
|
||||
}
|
||||
|
||||
if (authenticationSource == null) {
|
||||
log.debug("AuthenticationSource not set - " + "using default implementation");
|
||||
LOG.debug("AuthenticationSource not set - " + "using default implementation");
|
||||
if (!StringUtils.hasText(userDn)) {
|
||||
log.info("Property 'userDn' not set - " + "anonymous context will be used for read-write operations");
|
||||
LOG.info("Property 'userDn' not set - " + "anonymous context will be used for read-write operations");
|
||||
}
|
||||
else if (!StringUtils.hasText(password)) {
|
||||
log.info("Property 'password' not set - " + "blank password will be used");
|
||||
LOG.info("Property 'password' not set - " + "blank password will be used");
|
||||
}
|
||||
authenticationSource = new SimpleAuthenticationSource();
|
||||
}
|
||||
@@ -423,11 +424,11 @@ public abstract class AbstractContextSource implements BaseLdapPathContextSource
|
||||
private Hashtable<String, Object> setupAnonymousEnv() {
|
||||
if (pooled) {
|
||||
baseEnv.put(SUN_LDAP_POOLING_FLAG, "true");
|
||||
log.debug("Using LDAP pooling.");
|
||||
LOG.debug("Using LDAP pooling.");
|
||||
}
|
||||
else {
|
||||
baseEnv.remove(SUN_LDAP_POOLING_FLAG);
|
||||
log.debug("Not using LDAP pooling");
|
||||
LOG.debug("Not using LDAP pooling");
|
||||
}
|
||||
|
||||
Hashtable<String, Object> env = new Hashtable<String, Object>(baseEnv);
|
||||
@@ -448,7 +449,7 @@ public abstract class AbstractContextSource implements BaseLdapPathContextSource
|
||||
env.put(DefaultDirObjectFactory.JNDI_ENV_BASE_PATH_KEY, base);
|
||||
}
|
||||
|
||||
log.debug("Trying provider Urls: " + assembleProviderUrlString(urls));
|
||||
LOG.debug("Trying provider Urls: " + assembleProviderUrlString(urls));
|
||||
|
||||
return env;
|
||||
}
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package org.springframework.ldap.core.support;
|
||||
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
|
||||
import org.springframework.beans.factory.config.BeanPostProcessor;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
@@ -63,7 +62,8 @@ public class BaseLdapPathBeanPostProcessor implements BeanPostProcessor, Applica
|
||||
|
||||
private int order = Ordered.LOWEST_PRECEDENCE;
|
||||
|
||||
public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
|
||||
@Override
|
||||
public Object postProcessBeforeInitialization(Object bean, String beanName) {
|
||||
if(bean instanceof BaseLdapNameAware) {
|
||||
BaseLdapNameAware baseLdapNameAware = (BaseLdapNameAware) bean;
|
||||
|
||||
@@ -126,18 +126,14 @@ public class BaseLdapPathBeanPostProcessor implements BeanPostProcessor, Applica
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.springframework.beans.factory.config.BeanPostProcessor#
|
||||
* postProcessAfterInitialization(java.lang.Object, java.lang.String)
|
||||
*/
|
||||
public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
|
||||
@Override
|
||||
public Object postProcessAfterInitialization(Object bean, String beanName) {
|
||||
// Do nothing for this implementation
|
||||
return bean;
|
||||
}
|
||||
|
||||
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
|
||||
@Override
|
||||
public void setApplicationContext(ApplicationContext applicationContext) {
|
||||
this.applicationContext = applicationContext;
|
||||
}
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ import java.util.Hashtable;
|
||||
* @author Mattias Hellborg Arthursson
|
||||
*/
|
||||
public class DefaultDirObjectFactory implements DirObjectFactory {
|
||||
private static final Logger log = LoggerFactory.getLogger(DefaultDirObjectFactory.class);
|
||||
private static final Logger LOG = LoggerFactory.getLogger(DefaultDirObjectFactory.class);
|
||||
|
||||
/**
|
||||
* Key to use in the ContextSource implementation to store the value of the
|
||||
@@ -54,14 +54,7 @@ public class DefaultDirObjectFactory implements DirObjectFactory {
|
||||
|
||||
private static final String LDAPS_PROTOCOL_PREFIX = "ldaps://";
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* javax.naming.spi.DirObjectFactory#getObjectInstance(java.lang.Object,
|
||||
* javax.naming.Name, javax.naming.Context, java.util.Hashtable,
|
||||
* javax.naming.directory.Attributes)
|
||||
*/
|
||||
@Override
|
||||
public final Object getObjectInstance(
|
||||
Object obj,
|
||||
Name name,
|
||||
@@ -130,16 +123,16 @@ public class DefaultDirObjectFactory implements DirObjectFactory {
|
||||
.convertCompositeNameToString((CompositeName) name);
|
||||
}
|
||||
else {
|
||||
log
|
||||
LOG
|
||||
.warn("Expecting a CompositeName as input to getObjectInstance but received a '"
|
||||
+ name.getClass().toString()
|
||||
+ "' - using toString and proceeding with undefined results");
|
||||
+ name.getClass().toString()
|
||||
+ "' - using toString and proceeding with undefined results");
|
||||
nameString = name.toString();
|
||||
}
|
||||
|
||||
if (nameString.startsWith(LDAP_PROTOCOL_PREFIX) || nameString.startsWith(LDAPS_PROTOCOL_PREFIX)) {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Received name '" + nameString + "' contains protocol delimiter; indicating a referral."
|
||||
if (LOG.isDebugEnabled()) {
|
||||
LOG.debug("Received name '" + nameString + "' contains protocol delimiter; indicating a referral."
|
||||
+ "Stripping protocol and address info to enable construction of a proper LdapName");
|
||||
}
|
||||
try {
|
||||
@@ -168,8 +161,8 @@ public class DefaultDirObjectFactory implements DirObjectFactory {
|
||||
e.getMessage());
|
||||
}
|
||||
}
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Resulting name after removal of referral information: '" + nameString + "'");
|
||||
if (LOG.isDebugEnabled()) {
|
||||
LOG.debug("Resulting name after removal of referral information: '" + nameString + "'");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -179,12 +172,7 @@ public class DefaultDirObjectFactory implements DirObjectFactory {
|
||||
return dirContextAdapter;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see javax.naming.spi.ObjectFactory#getObjectInstance(java.lang.Object,
|
||||
* javax.naming.Name, javax.naming.Context, java.util.Hashtable)
|
||||
*/
|
||||
@Override
|
||||
public Object getObjectInstance(Object obj, Name name, Context nameCtx, Hashtable<?, ?> environment) throws Exception {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -74,7 +74,7 @@ import java.util.Set;
|
||||
* @since 1.3.2
|
||||
*/
|
||||
public class DefaultIncrementalAttributesMapper implements IncrementalAttributesMapper<DefaultIncrementalAttributesMapper> {
|
||||
private final static Logger log = LoggerFactory.getLogger(DefaultIncrementalAttributesMapper.class);
|
||||
private final static Logger LOG = LoggerFactory.getLogger(DefaultIncrementalAttributesMapper.class);
|
||||
|
||||
private Map<String, IncrementalAttributeState> stateMap = new LinkedHashMap<String, IncrementalAttributeState>();
|
||||
private Set<String> rangedAttributesInNextIteration = new LinkedHashSet<String>();
|
||||
@@ -83,7 +83,7 @@ public class DefaultIncrementalAttributesMapper implements IncrementalAttributes
|
||||
* 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() {
|
||||
private static final IncrementalAttributeState NOT_FOUND_ATTRIBUTE_STATE = new IncrementalAttributeState() {
|
||||
@Override
|
||||
public String getRequestedAttributeName() {
|
||||
throw new UnsupportedOperationException("This method should never be called");
|
||||
@@ -203,7 +203,7 @@ public class DefaultIncrementalAttributesMapper implements IncrementalAttributes
|
||||
private IncrementalAttributeState getState(String attributeName) {
|
||||
Object mappedState = stateMap.get(attributeName);
|
||||
if (mappedState == null) {
|
||||
log.warn("Attribute '" + attributeName + "' is not handled by this instance");
|
||||
LOG.warn("Attribute '" + attributeName + "' is not handled by this instance");
|
||||
mappedState = NOT_FOUND_ATTRIBUTE_STATE;
|
||||
}
|
||||
|
||||
@@ -352,7 +352,7 @@ public class DefaultIncrementalAttributesMapper implements IncrementalAttributes
|
||||
* multi-value attributes using ranges. Holds the values collected thus far, the next applicable range,
|
||||
* and the actual (requested) attribute name.
|
||||
*/
|
||||
private final static class DefaultIncrementalAttributeState implements IncrementalAttributeState {
|
||||
private static final class DefaultIncrementalAttributeState implements IncrementalAttributeState {
|
||||
private final String actualAttributeName;
|
||||
private List<Object> values = null;
|
||||
private final int pageSize;
|
||||
@@ -427,7 +427,7 @@ public class DefaultIncrementalAttributesMapper implements IncrementalAttributes
|
||||
/**
|
||||
* @author Mattias Hellborg Arthursson
|
||||
*/
|
||||
private static interface IncrementalAttributeState {
|
||||
private interface IncrementalAttributeState {
|
||||
boolean hasMore();
|
||||
|
||||
void calculateNextRange(RangeOption responseRange);
|
||||
|
||||
@@ -56,7 +56,7 @@ public interface DirContextAuthenticationStrategy {
|
||||
* <code>DirContext</code> creation to be aborted and the exception to be
|
||||
* translated and rethrown.
|
||||
*/
|
||||
public void setupEnvironment(Hashtable<String, Object> env, String userDn, String password) throws NamingException;
|
||||
void setupEnvironment(Hashtable<String, Object> env, String userDn, String password) throws NamingException;
|
||||
|
||||
/**
|
||||
* This method is responsible for post-processing the
|
||||
@@ -79,7 +79,7 @@ public interface DirContextAuthenticationStrategy {
|
||||
* <code>DirContext</code> creation to be aborted and the exception to be
|
||||
* translated and rethrown.
|
||||
*/
|
||||
public DirContext processContextAfterCreation(DirContext ctx, String userDn, String password)
|
||||
DirContext processContextAfterCreation(DirContext ctx, String userDn, String password)
|
||||
throws NamingException;
|
||||
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@ package org.springframework.ldap.core.support;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.DisposableBean;
|
||||
import org.springframework.ldap.NamingException;
|
||||
import org.springframework.ldap.core.ContextSource;
|
||||
import org.springframework.ldap.core.DirContextProxy;
|
||||
import org.springframework.ldap.core.LdapTemplate;
|
||||
@@ -39,7 +38,7 @@ import java.lang.reflect.Proxy;
|
||||
*/
|
||||
public class SingleContextSource implements ContextSource, DisposableBean {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(SingleContextSource.class);
|
||||
private static final Logger LOG = LoggerFactory.getLogger(SingleContextSource.class);
|
||||
private static final boolean DONT_USE_READ_ONLY = false;
|
||||
private static final boolean DONT_IGNORE_PARTIAL_RESULT = false;
|
||||
private static final boolean DONT_IGNORE_NAME_NOT_FOUND = false;
|
||||
@@ -58,14 +57,14 @@ public class SingleContextSource implements ContextSource, DisposableBean {
|
||||
/*
|
||||
* @see org.springframework.ldap.ContextSource#getReadOnlyContext()
|
||||
*/
|
||||
public DirContext getReadOnlyContext() throws NamingException {
|
||||
public DirContext getReadOnlyContext() {
|
||||
return getNonClosingDirContextProxy(ctx);
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.springframework.ldap.ContextSource#getReadWriteContext()
|
||||
*/
|
||||
public DirContext getReadWriteContext() throws NamingException {
|
||||
public DirContext getReadWriteContext() {
|
||||
return getNonClosingDirContextProxy(ctx);
|
||||
}
|
||||
|
||||
@@ -79,8 +78,7 @@ public class SingleContextSource implements ContextSource, DisposableBean {
|
||||
|
||||
}
|
||||
|
||||
public DirContext getContext(String principal, String credentials)
|
||||
throws NamingException {
|
||||
public DirContext getContext(String principal, String credentials) {
|
||||
throw new UnsupportedOperationException(
|
||||
"Not a valid operation for this type of ContextSource");
|
||||
}
|
||||
@@ -94,7 +92,7 @@ public class SingleContextSource implements ContextSource, DisposableBean {
|
||||
ctx.close();
|
||||
}
|
||||
catch (javax.naming.NamingException e) {
|
||||
log.warn("Error when closing", e);
|
||||
LOG.warn("Error when closing", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -24,23 +24,16 @@ package org.springframework.ldap.filter;
|
||||
*/
|
||||
public abstract class AbstractFilter implements Filter {
|
||||
|
||||
/*
|
||||
* @see org.springframework.ldap.filter.Filter#encode(java.lang.StringBuffer)
|
||||
*/
|
||||
public abstract StringBuffer encode(StringBuffer buff);
|
||||
private static final int DEFAULT_BUFFER_SIZE = 256;
|
||||
|
||||
/*
|
||||
* @see org.springframework.ldap.filter.Filter#encode()
|
||||
*/
|
||||
@Override
|
||||
public String encode() {
|
||||
StringBuffer buf = new StringBuffer(256);
|
||||
StringBuffer buf = new StringBuffer(DEFAULT_BUFFER_SIZE);
|
||||
buf = encode(buf);
|
||||
return buf.toString();
|
||||
}
|
||||
|
||||
/*
|
||||
* @see java.lang.Object#toString()
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return encode();
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ import javax.naming.Name;
|
||||
*/
|
||||
public class ConversionServiceConverterManager implements ConverterManager {
|
||||
private GenericConversionService conversionService;
|
||||
private final static String DEFAULT_CONVERSION_SERVICE_CLASS =
|
||||
private static final String DEFAULT_CONVERSION_SERVICE_CLASS =
|
||||
"org.springframework.core.convert.support.DefaultConversionService";
|
||||
|
||||
public ConversionServiceConverterManager(GenericConversionService conversionService) {
|
||||
@@ -79,7 +79,7 @@ public class ConversionServiceConverterManager implements ConverterManager {
|
||||
}
|
||||
}
|
||||
|
||||
public final static class StringToNameConverter
|
||||
public static final class StringToNameConverter
|
||||
implements org.springframework.core.convert.converter.Converter<String, Name> {
|
||||
|
||||
@Override
|
||||
|
||||
@@ -96,7 +96,7 @@ public final class ConverterManagerFactoryBean implements FactoryBean {
|
||||
/**
|
||||
* Configuration information for a single Converter instance.
|
||||
*/
|
||||
public final static class ConverterConfig {
|
||||
public static final class ConverterConfig {
|
||||
// The set of classes the Converter will convert from.
|
||||
private Set<Class<?>> fromClasses = new HashSet<Class<?>>();
|
||||
|
||||
|
||||
@@ -78,7 +78,7 @@ class DirContextPoolableObjectFactory extends BaseKeyedPoolableObjectFactory {
|
||||
*/
|
||||
protected final Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
private final static Set<Class<? extends Throwable>> DEFAULT_NONTRANSIENT_EXCEPTIONS
|
||||
private static final Set<Class<? extends Throwable>> DEFAULT_NONTRANSIENT_EXCEPTIONS
|
||||
= new HashSet<Class<? extends Throwable>>(){{
|
||||
add(CommunicationException.class);
|
||||
}};
|
||||
|
||||
@@ -16,12 +16,11 @@
|
||||
|
||||
package org.springframework.ldap.pool.factory;
|
||||
|
||||
import org.apache.commons.pool.impl.GenericKeyedObjectPool;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.apache.commons.pool.impl.GenericKeyedObjectPool;
|
||||
import org.springframework.beans.factory.DisposableBean;
|
||||
import org.springframework.dao.DataAccessResourceFailureException;
|
||||
import org.springframework.ldap.NamingException;
|
||||
import org.springframework.ldap.core.ContextSource;
|
||||
import org.springframework.ldap.core.support.DelegatingBaseLdapPathContextSourceSupport;
|
||||
import org.springframework.ldap.pool.DelegatingDirContext;
|
||||
@@ -420,17 +419,13 @@ public class PoolingContextSource
|
||||
|
||||
// ***** ContextSource interface methods *****//
|
||||
|
||||
/*
|
||||
* @see ContextSource#getReadOnlyContext()
|
||||
*/
|
||||
public DirContext getReadOnlyContext() throws NamingException {
|
||||
@Override
|
||||
public DirContext getReadOnlyContext() {
|
||||
return this.getContext(DirContextType.READ_ONLY);
|
||||
}
|
||||
|
||||
/*
|
||||
* @see ContextSource#getReadWriteContext()
|
||||
*/
|
||||
public DirContext getReadWriteContext() throws NamingException {
|
||||
@Override
|
||||
public DirContext getReadWriteContext() {
|
||||
return this.getContext(DirContextType.READ_WRITE);
|
||||
}
|
||||
|
||||
@@ -458,7 +453,8 @@ public class PoolingContextSource
|
||||
return new DelegatingDirContext(this.keyedObjectPool, dirContext, dirContextType);
|
||||
}
|
||||
|
||||
public DirContext getContext(String principal, String credentials) throws NamingException {
|
||||
@Override
|
||||
public DirContext getContext(String principal, String credentials) {
|
||||
throw new UnsupportedOperationException("Not supported for this implementation");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,6 +75,7 @@ import javax.naming.directory.SearchResult;
|
||||
*/
|
||||
public class DefaultDirContextValidator implements DirContextValidator {
|
||||
public static final String DEFAULT_FILTER = "objectclass=*";
|
||||
private static final int DEFAULT_TIME_LIMIT = 500;
|
||||
|
||||
/**
|
||||
* Logger for this class and sub-classes
|
||||
@@ -105,7 +106,7 @@ public class DefaultDirContextValidator implements DirContextValidator {
|
||||
this.searchControls.setSearchScope(searchScope);
|
||||
this.searchControls.setCountLimit(1);
|
||||
this.searchControls.setReturningAttributes(new String[] { "objectclass" });
|
||||
this.searchControls.setTimeLimit(500);
|
||||
this.searchControls.setTimeLimit(DEFAULT_TIME_LIMIT);
|
||||
|
||||
this.base = "";
|
||||
|
||||
|
||||
@@ -183,7 +183,7 @@ public class SimpleLdapRepository<T> implements LdapRepository<T> {
|
||||
delete(findAll());
|
||||
}
|
||||
|
||||
private final static class TransformingIterable<F, T> implements Iterable<T> {
|
||||
private static final class TransformingIterable<F, T> implements Iterable<T> {
|
||||
private final Iterable<F> target;
|
||||
private final Function<F, T> function;
|
||||
|
||||
|
||||
@@ -26,9 +26,10 @@ import org.springframework.ldap.BadLdapGrammarException;
|
||||
*/
|
||||
public final class LdapEncoder {
|
||||
|
||||
private static String[] nameEscapeTable = new String[96];
|
||||
private static final int HEX = 16;
|
||||
private static String[] NAME_ESCAPE_TABLE = new String[96];
|
||||
|
||||
private static String[] filterEscapeTable = new String['\\' + 1];
|
||||
private static String[] FILTER_ESCAPE_TABLE = new String['\\' + 1];
|
||||
|
||||
static {
|
||||
|
||||
@@ -36,32 +37,32 @@ public final class LdapEncoder {
|
||||
|
||||
// all below 0x20 (control chars)
|
||||
for (char c = 0; c < ' '; c++) {
|
||||
nameEscapeTable[c] = "\\" + toTwoCharHex(c);
|
||||
NAME_ESCAPE_TABLE[c] = "\\" + toTwoCharHex(c);
|
||||
}
|
||||
|
||||
nameEscapeTable['#'] = "\\#";
|
||||
nameEscapeTable[','] = "\\,";
|
||||
nameEscapeTable[';'] = "\\;";
|
||||
nameEscapeTable['='] = "\\=";
|
||||
nameEscapeTable['+'] = "\\+";
|
||||
nameEscapeTable['<'] = "\\<";
|
||||
nameEscapeTable['>'] = "\\>";
|
||||
nameEscapeTable['\"'] = "\\\"";
|
||||
nameEscapeTable['\\'] = "\\\\";
|
||||
NAME_ESCAPE_TABLE['#'] = "\\#";
|
||||
NAME_ESCAPE_TABLE[','] = "\\,";
|
||||
NAME_ESCAPE_TABLE[';'] = "\\;";
|
||||
NAME_ESCAPE_TABLE['='] = "\\=";
|
||||
NAME_ESCAPE_TABLE['+'] = "\\+";
|
||||
NAME_ESCAPE_TABLE['<'] = "\\<";
|
||||
NAME_ESCAPE_TABLE['>'] = "\\>";
|
||||
NAME_ESCAPE_TABLE['\"'] = "\\\"";
|
||||
NAME_ESCAPE_TABLE['\\'] = "\\\\";
|
||||
|
||||
// Filter encoding table -------------------------------------
|
||||
|
||||
// fill with char itself
|
||||
for (char c = 0; c < filterEscapeTable.length; c++) {
|
||||
filterEscapeTable[c] = String.valueOf(c);
|
||||
for (char c = 0; c < FILTER_ESCAPE_TABLE.length; c++) {
|
||||
FILTER_ESCAPE_TABLE[c] = String.valueOf(c);
|
||||
}
|
||||
|
||||
// escapes (RFC2254)
|
||||
filterEscapeTable['*'] = "\\2a";
|
||||
filterEscapeTable['('] = "\\28";
|
||||
filterEscapeTable[')'] = "\\29";
|
||||
filterEscapeTable['\\'] = "\\5c";
|
||||
filterEscapeTable[0] = "\\00";
|
||||
FILTER_ESCAPE_TABLE['*'] = "\\2a";
|
||||
FILTER_ESCAPE_TABLE['('] = "\\28";
|
||||
FILTER_ESCAPE_TABLE[')'] = "\\29";
|
||||
FILTER_ESCAPE_TABLE['\\'] = "\\5c";
|
||||
FILTER_ESCAPE_TABLE[0] = "\\00";
|
||||
|
||||
}
|
||||
|
||||
@@ -103,8 +104,8 @@ public final class LdapEncoder {
|
||||
|
||||
char c = value.charAt(i);
|
||||
|
||||
if (c < filterEscapeTable.length) {
|
||||
encodedValue.append(filterEscapeTable[c]);
|
||||
if (c < FILTER_ESCAPE_TABLE.length) {
|
||||
encodedValue.append(FILTER_ESCAPE_TABLE[c]);
|
||||
} else {
|
||||
// default: add the char
|
||||
encodedValue.append(c);
|
||||
@@ -127,7 +128,7 @@ public final class LdapEncoder {
|
||||
* the value to escape.
|
||||
* @return The escaped value.
|
||||
*/
|
||||
static public String nameEncode(String value) {
|
||||
public static String nameEncode(String value) {
|
||||
|
||||
if (value == null)
|
||||
return null;
|
||||
@@ -148,9 +149,9 @@ public final class LdapEncoder {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (c < nameEscapeTable.length) {
|
||||
if (c < NAME_ESCAPE_TABLE.length) {
|
||||
// check in table for escapes
|
||||
String esc = nameEscapeTable[c];
|
||||
String esc = NAME_ESCAPE_TABLE[c];
|
||||
|
||||
if (esc != null) {
|
||||
encodedValue.append(esc);
|
||||
@@ -213,7 +214,7 @@ public final class LdapEncoder {
|
||||
String hexString = "" + nextChar
|
||||
+ value.charAt(i + 2);
|
||||
decoded.append((char) Integer.parseInt(hexString,
|
||||
16));
|
||||
HEX));
|
||||
i += 3;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,9 +48,10 @@ import java.util.NoSuchElementException;
|
||||
*/
|
||||
public final class LdapUtils {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(LdapUtils.class);
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(LdapUtils.class);
|
||||
private static final int HEX = 16;
|
||||
|
||||
/**
|
||||
/**
|
||||
* Not to be instantiated.
|
||||
*/
|
||||
private LdapUtils() {
|
||||
@@ -69,12 +70,12 @@ public final class LdapUtils {
|
||||
context.close();
|
||||
}
|
||||
catch (NamingException ex) {
|
||||
logger.debug("Could not close JNDI DirContext", ex);
|
||||
LOGGER.debug("Could not close JNDI DirContext", ex);
|
||||
}
|
||||
catch (Throwable ex) {
|
||||
// We don't trust the JNDI provider: It might throw
|
||||
// RuntimeException or Error.
|
||||
logger.debug("Unexpected exception on closing JNDI DirContext", ex);
|
||||
LOGGER.debug("Unexpected exception on closing JNDI DirContext", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -314,7 +315,7 @@ public final class LdapUtils {
|
||||
*
|
||||
* @author Mattias Hellborg Arthursson
|
||||
*/
|
||||
private final static class CollectingAttributeValueCallbackHandler<T> implements AttributeValueCallbackHandler {
|
||||
private static final class CollectingAttributeValueCallbackHandler<T> implements AttributeValueCallbackHandler {
|
||||
private final Collection<T> collection;
|
||||
private final Class<T> clazz;
|
||||
|
||||
@@ -326,7 +327,7 @@ public final class LdapUtils {
|
||||
this.clazz = clazz;
|
||||
}
|
||||
|
||||
public final void handleAttributeValue(String attributeName, Object attributeValue, int index) {
|
||||
public void handleAttributeValue(String attributeName, Object attributeValue, int index) {
|
||||
Assert.isTrue(attributeName == null || clazz.isAssignableFrom(attributeValue.getClass()));
|
||||
collection.add(clazz.cast(attributeValue));
|
||||
}
|
||||
@@ -551,7 +552,7 @@ public final class LdapUtils {
|
||||
LdapName ldapName = returnOrConstructLdapNameFromName(name);
|
||||
Rdn rdn = ldapName.getRdn(index);
|
||||
if(rdn.size() > 1) {
|
||||
logger.warn("Rdn at position " + index + " of dn '" + name +
|
||||
LOGGER.warn("Rdn at position " + index + " of dn '" + name +
|
||||
"' is multi-value - returned value is not to be trusted. " +
|
||||
"Consider using name-based getValue method instead");
|
||||
}
|
||||
@@ -646,7 +647,7 @@ public final class LdapUtils {
|
||||
String hexString = Integer.toHexString(sid[t] & 0xFF);
|
||||
sb.append(hexString);
|
||||
}
|
||||
sidAsString.append(Long.parseLong(sb.toString(), 16));
|
||||
sidAsString.append(Long.parseLong(sb.toString(), HEX));
|
||||
|
||||
// bytes[1] : the sub authorities count
|
||||
int count = sid[1];
|
||||
@@ -661,7 +662,7 @@ public final class LdapUtils {
|
||||
sb.append(toHexString((byte) (sid[9 + currSubAuthOffset] & 0xFF)));
|
||||
sb.append(toHexString((byte) (sid[8 + currSubAuthOffset] & 0xFF)));
|
||||
|
||||
sidAsString.append('-').append(Long.parseLong(sb.toString(), 16));
|
||||
sidAsString.append('-').append(Long.parseLong(sb.toString(), HEX));
|
||||
}
|
||||
|
||||
// That's it - we have the SID
|
||||
|
||||
@@ -59,7 +59,7 @@ public class ContextSourceAndDataSourceTransactionManager extends
|
||||
/*
|
||||
* @see org.springframework.jdbc.datasource.DataSourceTransactionManager#doGetTransaction()
|
||||
*/
|
||||
protected Object doGetTransaction() throws TransactionException {
|
||||
protected Object doGetTransaction() {
|
||||
Object dataSourceTransactionObject = super.doGetTransaction();
|
||||
Object contextSourceTransactionObject = ldapManagerDelegate
|
||||
.doGetTransaction();
|
||||
@@ -72,8 +72,7 @@ public class ContextSourceAndDataSourceTransactionManager extends
|
||||
* @see org.springframework.jdbc.datasource.DataSourceTransactionManager#doBegin(java.lang.Object,
|
||||
* org.springframework.transaction.TransactionDefinition)
|
||||
*/
|
||||
protected void doBegin(Object transaction, TransactionDefinition definition)
|
||||
throws TransactionException {
|
||||
protected void doBegin(Object transaction, TransactionDefinition definition) {
|
||||
ContextSourceAndDataSourceTransactionObject actualTransactionObject = (ContextSourceAndDataSourceTransactionObject) transaction;
|
||||
|
||||
super.doBegin(actualTransactionObject.getDataSourceTransactionObject(),
|
||||
@@ -103,8 +102,7 @@ public class ContextSourceAndDataSourceTransactionManager extends
|
||||
/*
|
||||
* @see org.springframework.jdbc.datasource.DataSourceTransactionManager#doCommit(org.springframework.transaction.support.DefaultTransactionStatus)
|
||||
*/
|
||||
protected void doCommit(DefaultTransactionStatus status)
|
||||
throws TransactionException {
|
||||
protected void doCommit(DefaultTransactionStatus status) {
|
||||
|
||||
ContextSourceAndDataSourceTransactionObject actualTransactionObject = (ContextSourceAndDataSourceTransactionObject) status
|
||||
.getTransaction();
|
||||
@@ -138,8 +136,7 @@ public class ContextSourceAndDataSourceTransactionManager extends
|
||||
/*
|
||||
* @see org.springframework.jdbc.datasource.DataSourceTransactionManager#doRollback(org.springframework.transaction.support.DefaultTransactionStatus)
|
||||
*/
|
||||
protected void doRollback(DefaultTransactionStatus status)
|
||||
throws TransactionException {
|
||||
protected void doRollback(DefaultTransactionStatus status) {
|
||||
ContextSourceAndDataSourceTransactionObject actualTransactionObject = (ContextSourceAndDataSourceTransactionObject) status
|
||||
.getTransaction();
|
||||
|
||||
@@ -190,7 +187,7 @@ public class ContextSourceAndDataSourceTransactionManager extends
|
||||
/*
|
||||
* @see org.springframework.jdbc.datasource.DataSourceTransactionManager#doSuspend(java.lang.Object)
|
||||
*/
|
||||
protected Object doSuspend(Object transaction) throws TransactionException {
|
||||
protected Object doSuspend(Object transaction) {
|
||||
throw new TransactionSuspensionNotSupportedException(
|
||||
"Transaction manager [" + getClass().getName()
|
||||
+ "] does not support transaction suspension");
|
||||
@@ -200,8 +197,7 @@ public class ContextSourceAndDataSourceTransactionManager extends
|
||||
* @see org.springframework.jdbc.datasource.DataSourceTransactionManager#doResume(java.lang.Object,
|
||||
* java.lang.Object)
|
||||
*/
|
||||
protected void doResume(Object transaction, Object suspendedResources)
|
||||
throws TransactionException {
|
||||
protected void doResume(Object transaction, Object suspendedResources) {
|
||||
throw new TransactionSuspensionNotSupportedException(
|
||||
"Transaction manager [" + getClass().getName()
|
||||
+ "] does not support transaction suspension");
|
||||
|
||||
@@ -58,7 +58,7 @@ public class ContextSourceAndHibernateTransactionManager extends HibernateTransa
|
||||
/*
|
||||
* @see org.springframework.orm.hibernate3.HibernateTransactionManager#doGetTransaction()
|
||||
*/
|
||||
protected Object doGetTransaction() throws TransactionException {
|
||||
protected Object doGetTransaction() {
|
||||
Object dataSourceTransactionObject = super.doGetTransaction();
|
||||
Object contextSourceTransactionObject = ldapManagerDelegate
|
||||
.doGetTransaction();
|
||||
@@ -71,8 +71,7 @@ public class ContextSourceAndHibernateTransactionManager extends HibernateTransa
|
||||
* @see org.springframework.orm.hibernate3.HibernateTransactionManager#doBegin(java.lang.Object,
|
||||
* org.springframework.transaction.TransactionDefinition)
|
||||
*/
|
||||
protected void doBegin(Object transaction, TransactionDefinition definition)
|
||||
throws TransactionException {
|
||||
protected void doBegin(Object transaction, TransactionDefinition definition) {
|
||||
ContextSourceAndHibernateTransactionObject actualTransactionObject = (ContextSourceAndHibernateTransactionObject) transaction;
|
||||
|
||||
super.doBegin(actualTransactionObject.getHibernateTransactionObject(),
|
||||
@@ -102,8 +101,7 @@ public class ContextSourceAndHibernateTransactionManager extends HibernateTransa
|
||||
/*
|
||||
* @see org.springframework.orm.hibernate3.HibernateTransactionManager#doCommit(org.springframework.transaction.support.DefaultTransactionStatus)
|
||||
*/
|
||||
protected void doCommit(DefaultTransactionStatus status)
|
||||
throws TransactionException {
|
||||
protected void doCommit(DefaultTransactionStatus status) {
|
||||
|
||||
ContextSourceAndHibernateTransactionObject actualTransactionObject = (ContextSourceAndHibernateTransactionObject) status
|
||||
.getTransaction();
|
||||
@@ -137,8 +135,7 @@ public class ContextSourceAndHibernateTransactionManager extends HibernateTransa
|
||||
/*
|
||||
* @see org.springframework.orm.hibernate3.HibernateTransactionManager#doRollback(org.springframework.transaction.support.DefaultTransactionStatus)
|
||||
*/
|
||||
protected void doRollback(DefaultTransactionStatus status)
|
||||
throws TransactionException {
|
||||
protected void doRollback(DefaultTransactionStatus status) {
|
||||
ContextSourceAndHibernateTransactionObject actualTransactionObject = (ContextSourceAndHibernateTransactionObject) status
|
||||
.getTransaction();
|
||||
|
||||
@@ -166,7 +163,7 @@ public class ContextSourceAndHibernateTransactionManager extends HibernateTransa
|
||||
ldapManagerDelegate.setRenamingStrategy(renamingStrategy);
|
||||
}
|
||||
|
||||
private final static class ContextSourceAndHibernateTransactionObject {
|
||||
private static final class ContextSourceAndHibernateTransactionObject {
|
||||
private Object ldapTransactionObject;
|
||||
|
||||
private Object hibernateTransactionObject;
|
||||
@@ -189,7 +186,7 @@ public class ContextSourceAndHibernateTransactionManager extends HibernateTransa
|
||||
/*
|
||||
* @see org.springframework.orm.hibernate3.HibernateTransactionManager#doSuspend(java.lang.Object)
|
||||
*/
|
||||
protected Object doSuspend(Object transaction) throws TransactionException {
|
||||
protected Object doSuspend(Object transaction) {
|
||||
throw new TransactionSuspensionNotSupportedException(
|
||||
"Transaction manager [" + getClass().getName()
|
||||
+ "] does not support transaction suspension");
|
||||
@@ -199,8 +196,7 @@ public class ContextSourceAndHibernateTransactionManager extends HibernateTransa
|
||||
* @see org.springframework.orm.hibernate3.HibernateTransactionManager#doResume(java.lang.Object,
|
||||
* java.lang.Object)
|
||||
*/
|
||||
protected void doResume(Object transaction, Object suspendedResources)
|
||||
throws TransactionException {
|
||||
protected void doResume(Object transaction, Object suspendedResources) {
|
||||
throw new TransactionSuspensionNotSupportedException(
|
||||
"Transaction manager [" + getClass().getName()
|
||||
+ "] does not support transaction suspension");
|
||||
|
||||
@@ -22,7 +22,6 @@ import org.springframework.ldap.transaction.compensating.TempEntryRenamingStrate
|
||||
import org.springframework.ldap.transaction.compensating.UnbindOperationExecutor;
|
||||
import org.springframework.ldap.transaction.compensating.support.DefaultTempEntryRenamingStrategy;
|
||||
import org.springframework.transaction.TransactionDefinition;
|
||||
import org.springframework.transaction.TransactionException;
|
||||
import org.springframework.transaction.compensating.CompensatingTransactionOperationExecutor;
|
||||
import org.springframework.transaction.compensating.CompensatingTransactionOperationRecorder;
|
||||
import org.springframework.transaction.compensating.support.DefaultCompensatingTransactionOperationManager;
|
||||
@@ -123,8 +122,7 @@ public class ContextSourceTransactionManager extends
|
||||
* @see org.springframework.transaction.support.AbstractPlatformTransactionManager#doBegin(java.lang.Object,
|
||||
* org.springframework.transaction.TransactionDefinition)
|
||||
*/
|
||||
protected void doBegin(Object transaction, TransactionDefinition definition)
|
||||
throws TransactionException {
|
||||
protected void doBegin(Object transaction, TransactionDefinition definition) {
|
||||
delegate.doBegin(transaction, definition);
|
||||
}
|
||||
|
||||
@@ -138,23 +136,21 @@ public class ContextSourceTransactionManager extends
|
||||
/*
|
||||
* @see org.springframework.transaction.support.AbstractPlatformTransactionManager#doCommit(org.springframework.transaction.support.DefaultTransactionStatus)
|
||||
*/
|
||||
protected void doCommit(DefaultTransactionStatus status)
|
||||
throws TransactionException {
|
||||
protected void doCommit(DefaultTransactionStatus status) {
|
||||
delegate.doCommit(status);
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.springframework.transaction.support.AbstractPlatformTransactionManager#doGetTransaction()
|
||||
*/
|
||||
protected Object doGetTransaction() throws TransactionException {
|
||||
protected Object doGetTransaction() {
|
||||
return delegate.doGetTransaction();
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.springframework.transaction.support.AbstractPlatformTransactionManager#doRollback(org.springframework.transaction.support.DefaultTransactionStatus)
|
||||
*/
|
||||
protected void doRollback(DefaultTransactionStatus status)
|
||||
throws TransactionException {
|
||||
protected void doRollback(DefaultTransactionStatus status) {
|
||||
delegate.doRollback(status);
|
||||
}
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ import javax.naming.directory.DirContext;
|
||||
public class ContextSourceTransactionManagerDelegate extends
|
||||
AbstractCompensatingTransactionManagerDelegate {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(ContextSourceTransactionManagerDelegate.class);
|
||||
private static final Logger LOG = LoggerFactory.getLogger(ContextSourceTransactionManagerDelegate.class);
|
||||
|
||||
private ContextSource contextSource;
|
||||
|
||||
@@ -109,10 +109,10 @@ public class ContextSourceTransactionManagerDelegate extends
|
||||
DirContext ctx = contextHolder.getCtx();
|
||||
|
||||
try {
|
||||
log.debug("Closing target context");
|
||||
LOG.debug("Closing target context");
|
||||
ctx.close();
|
||||
} catch (NamingException e) {
|
||||
log.warn("Failed to close target context", e);
|
||||
LOG.warn("Failed to close target context", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
*/
|
||||
package org.springframework.ldap.transaction.compensating.manager;
|
||||
|
||||
import org.springframework.ldap.NamingException;
|
||||
import org.springframework.ldap.core.ContextSource;
|
||||
import org.springframework.ldap.core.DirContextProxy;
|
||||
import org.springframework.ldap.core.support.DelegatingBaseLdapPathContextSourceSupport;
|
||||
@@ -57,10 +56,8 @@ public class TransactionAwareContextSourceProxy
|
||||
return target;
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.springframework.ldap.core.ContextSource#getReadOnlyContext()
|
||||
*/
|
||||
public DirContext getReadOnlyContext() throws NamingException {
|
||||
@Override
|
||||
public DirContext getReadOnlyContext() {
|
||||
return getReadWriteContext();
|
||||
}
|
||||
|
||||
@@ -77,10 +74,8 @@ public class TransactionAwareContextSourceProxy
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.springframework.ldap.core.ContextSource#getReadWriteContext()
|
||||
*/
|
||||
public DirContext getReadWriteContext() throws NamingException {
|
||||
@Override
|
||||
public DirContext getReadWriteContext() {
|
||||
DirContextHolder contextHolder = (DirContextHolder) TransactionSynchronizationManager
|
||||
.getResource(target);
|
||||
DirContext ctx = null;
|
||||
@@ -98,7 +93,8 @@ public class TransactionAwareContextSourceProxy
|
||||
return getTransactionAwareDirContextProxy(ctx, target);
|
||||
}
|
||||
|
||||
public DirContext getContext(String principal, String credentials) throws NamingException {
|
||||
@Override
|
||||
public DirContext getContext(String principal, String credentials) {
|
||||
return target.getContext(principal, credentials);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ public class DifferentSubtreeTempEntryRenamingStrategy implements
|
||||
|
||||
private Name subtreeNode;
|
||||
|
||||
private static final AtomicInteger nextSequenceNo = new AtomicInteger(1);
|
||||
private static final AtomicInteger NEXT_SEQUENCE_NO = new AtomicInteger(1);
|
||||
|
||||
public DifferentSubtreeTempEntryRenamingStrategy(Name subtreeNode) {
|
||||
this.subtreeNode = subtreeNode;
|
||||
@@ -68,14 +68,14 @@ public class DifferentSubtreeTempEntryRenamingStrategy implements
|
||||
}
|
||||
|
||||
int getNextSequenceNo() {
|
||||
return nextSequenceNo.get();
|
||||
return NEXT_SEQUENCE_NO.get();
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.springframework.ldap.support.transaction.TempEntryRenamingStrategy#getTemporaryName(javax.naming.Name)
|
||||
*/
|
||||
public Name getTemporaryName(Name originalName) {
|
||||
int thisSequenceNo = nextSequenceNo.getAndIncrement();
|
||||
int thisSequenceNo = NEXT_SEQUENCE_NO.getAndIncrement();
|
||||
|
||||
LdapName tempName = LdapUtils.newLdapName(originalName);
|
||||
try {
|
||||
|
||||
@@ -52,7 +52,7 @@ import org.springframework.util.ClassUtils;
|
||||
public class LdifReader extends AbstractItemCountingItemStreamItemReader<LdapAttributes>
|
||||
implements ResourceAwareItemReaderItemStream<LdapAttributes>, InitializingBean {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(LdifReader.class);
|
||||
private static final Logger LOG = LoggerFactory.getLogger(LdifReader.class);
|
||||
|
||||
private Resource resource;
|
||||
|
||||
@@ -119,7 +119,7 @@ public class LdifReader extends AbstractItemCountingItemStreamItemReader<LdapAtt
|
||||
if (strict) {
|
||||
throw new IllegalStateException("Input resource must exist (reader is in 'strict' mode): "+resource);
|
||||
} else {
|
||||
log.warn("Input resource does not exist " + resource.getDescription());
|
||||
LOG.warn("Input resource does not exist " + resource.getDescription());
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -149,8 +149,8 @@ public class LdifReader extends AbstractItemCountingItemStreamItemReader<LdapAtt
|
||||
return attributes;
|
||||
|
||||
} catch(Exception ex){
|
||||
log.error("Parsing error at record " + recordCount + " in resource=" +
|
||||
resource.getDescription() + ", input=[" + attributes + "]", ex);
|
||||
LOG.error("Parsing error at record " + recordCount + " in resource=" +
|
||||
resource.getDescription() + ", input=[" + attributes + "]", ex);
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ import org.springframework.util.ClassUtils;
|
||||
public class MappingLdifReader<T> extends AbstractItemCountingItemStreamItemReader<T>
|
||||
implements ResourceAwareItemReaderItemStream<T>, InitializingBean {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(MappingLdifReader.class);
|
||||
private static final Logger LOG = LoggerFactory.getLogger(MappingLdifReader.class);
|
||||
|
||||
private Resource resource;
|
||||
|
||||
@@ -129,7 +129,7 @@ public class MappingLdifReader<T> extends AbstractItemCountingItemStreamItemRead
|
||||
if (strict) {
|
||||
throw new IllegalStateException("Input resource must exist (reader is in 'strict' mode): "+resource);
|
||||
} else {
|
||||
log.warn("Input resource does not exist " + resource.getDescription());
|
||||
LOG.warn("Input resource does not exist " + resource.getDescription());
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -159,8 +159,8 @@ public class MappingLdifReader<T> extends AbstractItemCountingItemStreamItemRead
|
||||
|
||||
return null;
|
||||
} catch(Exception ex){
|
||||
log.error("Parsing error at record " + recordCount + " in resource=" +
|
||||
resource.getDescription() + ", input=[" + attributes + "]", ex);
|
||||
LOG.error("Parsing error at record " + recordCount + " in resource=" +
|
||||
resource.getDescription() + ", input=[" + attributes + "]", ex);
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -85,7 +85,7 @@ import java.util.NoSuchElementException;
|
||||
*/
|
||||
public class LdifParser implements Parser, InitializingBean {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(LdifParser.class);
|
||||
private static final Logger LOG = LoggerFactory.getLogger(LdifParser.class);
|
||||
|
||||
/**
|
||||
* The resource to parse.
|
||||
@@ -227,7 +227,7 @@ public class LdifParser implements Parser, InitializingBean {
|
||||
Assert.notNull(reader, "A reader must be obtained: parser not open.");
|
||||
|
||||
if (!reader.ready()) {
|
||||
log.debug("Reader not ready!");
|
||||
LOG.debug("Reader not ready!");
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -242,7 +242,7 @@ public class LdifParser implements Parser, InitializingBean {
|
||||
|
||||
switch(identifier) {
|
||||
case NewRecord:
|
||||
log.trace("Starting new record.");
|
||||
LOG.trace("Starting new record.");
|
||||
//Start new record.
|
||||
record = new LdapAttributes(caseInsensitive);
|
||||
builder = new StringBuilder(line);
|
||||
@@ -250,20 +250,20 @@ public class LdifParser implements Parser, InitializingBean {
|
||||
break;
|
||||
|
||||
case Control:
|
||||
log.trace("'control' encountered.");
|
||||
LOG.trace("'control' encountered.");
|
||||
|
||||
//Log WARN and discard record.
|
||||
log.warn("LDIF change records have no implementation: record will be ignored.");
|
||||
LOG.warn("LDIF change records have no implementation: record will be ignored.");
|
||||
builder = null;
|
||||
record = null;
|
||||
|
||||
break;
|
||||
|
||||
case ChangeType:
|
||||
log.trace("'changetype' encountered.");
|
||||
LOG.trace("'changetype' encountered.");
|
||||
|
||||
//Log WARN and discard record.
|
||||
log.warn("LDIF change records have no implementation: record will be ignored.");
|
||||
LOG.warn("LDIF change records have no implementation: record will be ignored.");
|
||||
builder = null;
|
||||
record = null;
|
||||
|
||||
@@ -273,21 +273,21 @@ public class LdifParser implements Parser, InitializingBean {
|
||||
//flush buffer.
|
||||
addAttributeToRecord(builder.toString(), record);
|
||||
|
||||
log.trace("Starting new attribute.");
|
||||
LOG.trace("Starting new attribute.");
|
||||
//Start new attribute.
|
||||
builder = new StringBuilder(line);
|
||||
|
||||
break;
|
||||
|
||||
case Continuation:
|
||||
log.trace("...appending line to buffer.");
|
||||
LOG.trace("...appending line to buffer.");
|
||||
//Append line to buffer.
|
||||
builder.append(line.replaceFirst(" ", ""));
|
||||
|
||||
break;
|
||||
|
||||
case EndOfRecord:
|
||||
log.trace("...done parsing record. (EndOfRecord)");
|
||||
LOG.trace("...done parsing record. (EndOfRecord)");
|
||||
|
||||
//Validate record and return.
|
||||
if (record == null) {
|
||||
@@ -298,14 +298,14 @@ public class LdifParser implements Parser, InitializingBean {
|
||||
addAttributeToRecord(builder.toString(), record);
|
||||
|
||||
if (specification.isSatisfiedBy(record)) {
|
||||
log.debug("record parsed:\n" + record);
|
||||
LOG.debug("record parsed:\n" + record);
|
||||
return record;
|
||||
|
||||
} else {
|
||||
throw new InvalidRecordFormatException("Record [dn: " + record.getDN() + "] does not conform to specification.");
|
||||
}
|
||||
} catch(NamingException e) {
|
||||
log.error("Error adding attribute to record", e);
|
||||
LOG.error("Error adding attribute to record", e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -330,7 +330,7 @@ public class LdifParser implements Parser, InitializingBean {
|
||||
Attribute attribute = attributePolicy.parse(buffer);
|
||||
|
||||
if (attribute.getID().equalsIgnoreCase("dn")) {
|
||||
log.trace("...adding DN to record.");
|
||||
LOG.trace("...adding DN to record.");
|
||||
|
||||
String dn;
|
||||
if (attribute.get() instanceof byte[]) {
|
||||
@@ -342,7 +342,7 @@ public class LdifParser implements Parser, InitializingBean {
|
||||
record.setName(LdapUtils.newLdapName(dn));
|
||||
|
||||
} else {
|
||||
log.trace("...adding attribute to record.");
|
||||
LOG.trace("...adding attribute to record.");
|
||||
Attribute attr = record.get(attribute.getID());
|
||||
|
||||
if (attr != null) {
|
||||
@@ -353,9 +353,9 @@ public class LdifParser implements Parser, InitializingBean {
|
||||
}
|
||||
}
|
||||
} catch (NamingException e) {
|
||||
log.error("Error adding attribute to record", e);
|
||||
LOG.error("Error adding attribute to record", e);
|
||||
} catch (NoSuchElementException e) {
|
||||
log.error("Error adding attribute to record", e);
|
||||
LOG.error("Error adding attribute to record", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -15,11 +15,10 @@
|
||||
*/
|
||||
package org.springframework.ldap.ldif.parser;
|
||||
|
||||
import java.io.IOException;
|
||||
import org.springframework.core.io.Resource;
|
||||
|
||||
import javax.naming.directory.Attributes;
|
||||
|
||||
import org.springframework.core.io.Resource;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* The Parser interface represents the required methods to be implemented by parser utilities.
|
||||
@@ -34,35 +33,35 @@ public interface Parser {
|
||||
*
|
||||
* @param resource The resource to parse.
|
||||
*/
|
||||
public void setResource(Resource resource);
|
||||
void setResource(Resource resource);
|
||||
|
||||
/**
|
||||
* Sets the control parameter for specifying case sensitivity on creation of the {@link Attributes} object.
|
||||
*
|
||||
* @param caseInsensitive The resource to parse.
|
||||
*/
|
||||
public void setCaseInsensitive(boolean caseInsensitive);
|
||||
void setCaseInsensitive(boolean caseInsensitive);
|
||||
|
||||
/**
|
||||
* Opens the resource: the resource must be opened prior to parsing.
|
||||
*
|
||||
* @throws IOException if a problem is encountered while trying to open the resource.
|
||||
*/
|
||||
public void open() throws IOException;
|
||||
void open() throws IOException;
|
||||
|
||||
/**
|
||||
* Closes the resource after parsing.
|
||||
*
|
||||
* @throws IOException if a problem is encountered while trying to close the resource.
|
||||
*/
|
||||
public void close() throws IOException;
|
||||
void close() throws IOException;
|
||||
|
||||
/**
|
||||
* Resets the line read parser.
|
||||
*
|
||||
* @throws Exception if a problem is encountered while trying to reset the resource.
|
||||
*/
|
||||
public void reset() throws IOException;
|
||||
void reset() throws IOException;
|
||||
|
||||
/**
|
||||
* True if the resource contains more records; false otherwise.
|
||||
@@ -70,7 +69,7 @@ public interface Parser {
|
||||
* @return boolean indicating whether or not the end of record has been reached.
|
||||
* @throws IOException if a problem is encountered while trying to validate the resource is ready.
|
||||
*/
|
||||
public boolean hasMoreRecords() throws IOException;
|
||||
boolean hasMoreRecords() throws IOException;
|
||||
|
||||
/**
|
||||
* Parses the next record from the resource.
|
||||
@@ -78,7 +77,7 @@ public interface Parser {
|
||||
* @return LdapAttributes object representing the record parsed.
|
||||
* @throws IOException if a problem is encountered while trying to read from the resource.
|
||||
*/
|
||||
public Attributes getRecord() throws IOException;
|
||||
Attributes getRecord() throws IOException;
|
||||
|
||||
/**
|
||||
* Indicates whether or not the parser is ready to to return results.
|
||||
@@ -86,5 +85,5 @@ public interface Parser {
|
||||
* @return boolean indicator
|
||||
* @throws IOException if there is a problem with the underlying resource.
|
||||
*/
|
||||
public boolean isReady() throws IOException;
|
||||
boolean isReady() throws IOException;
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ public class SeparatorPolicy {
|
||||
|
||||
private static final String COMMENT = "#";
|
||||
|
||||
private static final String NewRecord = "^dn:.*$";
|
||||
private static final String NEW_RECORD = "^dn:.*$";
|
||||
|
||||
private boolean record = false;
|
||||
|
||||
@@ -103,7 +103,7 @@ public class SeparatorPolicy {
|
||||
//Version Identifiers are ignored by parser.
|
||||
return LineIdentifier.VersionIdentifier;
|
||||
|
||||
} else if (StringUtils.hasLength(line) && line.matches(NewRecord)) {
|
||||
} else if (StringUtils.hasLength(line) && line.matches(NEW_RECORD)) {
|
||||
record = true;
|
||||
skip = false;
|
||||
return LineIdentifier.NewRecord;
|
||||
|
||||
@@ -102,7 +102,7 @@ public final class SchemaToJava {
|
||||
private static final String BINARY_FILE = "binary-attributes.txt";
|
||||
|
||||
// Class to use a base for loading resources
|
||||
private static final Class<?> loaderClass=SchemaToJava.class;
|
||||
private static final Class<?> DEFAULT_LOADER_CLASS =SchemaToJava.class;
|
||||
|
||||
// Default LDAP Url to bind with
|
||||
private static final String DEFAULT_URL="ldap://127.0.0.1:389";
|
||||
@@ -142,17 +142,17 @@ public final class SchemaToJava {
|
||||
}
|
||||
}
|
||||
|
||||
private static final Options options = new Options();
|
||||
private static final Options DEFAULT_OPTIONS = new Options();
|
||||
static {
|
||||
options.addOption(Flag.URL.getShort(), Flag.URL.getLong(), true, "Ldap url (defaults to "+DEFAULT_URL+")");
|
||||
options.addOption(Flag.USERNAME.getShort(), Flag.USERNAME.getLong(), true, "DN to bind with (defaults to \"\"");
|
||||
options.addOption(Flag.PASSWORD.getShort(), Flag.PASSWORD.getLong(), true, "Password to bind with (defaults to \"\"");
|
||||
options.addOption(Flag.OBJECTCLASS.getShort(), Flag.OBJECTCLASS.getLong(), true, "Comma separated list of object classes");
|
||||
options.addOption(Flag.CLASS.getShort(), Flag.CLASS.getLong(), true, "Name of the Java class to create");
|
||||
options.addOption(Flag.PACKAGE.getShort(), Flag.PACKAGE.getLong(), true, "Package to create the Java class in");
|
||||
options.addOption(Flag.SYNTAX_MAP.getShort(), Flag.SYNTAX_MAP.getLong(), true, "Syntax map file (optional)");
|
||||
options.addOption(Flag.OUTPUT_DIR.getShort(), Flag.OUTPUT_DIR.getLong(), true, "Base output directory (defaults to .)");
|
||||
options.addOption(Flag.HELP.getShort(), Flag.HELP.getLong(), false, "Print this help message");
|
||||
DEFAULT_OPTIONS.addOption(Flag.URL.getShort(), Flag.URL.getLong(), true, "Ldap url (defaults to " + DEFAULT_URL + ")");
|
||||
DEFAULT_OPTIONS.addOption(Flag.USERNAME.getShort(), Flag.USERNAME.getLong(), true, "DN to bind with (defaults to \"\"");
|
||||
DEFAULT_OPTIONS.addOption(Flag.PASSWORD.getShort(), Flag.PASSWORD.getLong(), true, "Password to bind with (defaults to \"\"");
|
||||
DEFAULT_OPTIONS.addOption(Flag.OBJECTCLASS.getShort(), Flag.OBJECTCLASS.getLong(), true, "Comma separated list of object classes");
|
||||
DEFAULT_OPTIONS.addOption(Flag.CLASS.getShort(), Flag.CLASS.getLong(), true, "Name of the Java class to create");
|
||||
DEFAULT_OPTIONS.addOption(Flag.PACKAGE.getShort(), Flag.PACKAGE.getLong(), true, "Package to create the Java class in");
|
||||
DEFAULT_OPTIONS.addOption(Flag.SYNTAX_MAP.getShort(), Flag.SYNTAX_MAP.getLong(), true, "Syntax map file (optional)");
|
||||
DEFAULT_OPTIONS.addOption(Flag.OUTPUT_DIR.getShort(), Flag.OUTPUT_DIR.getLong(), true, "Base output directory (defaults to .)");
|
||||
DEFAULT_OPTIONS.addOption(Flag.HELP.getShort(), Flag.HELP.getLong(), false, "Print this help message");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -265,7 +265,7 @@ public final class SchemaToJava {
|
||||
|
||||
Configuration freeMarkerConfiguration = new Configuration();
|
||||
|
||||
freeMarkerConfiguration.setClassForTemplateLoading(loaderClass, "");
|
||||
freeMarkerConfiguration.setClassForTemplateLoading(DEFAULT_LOADER_CLASS, "");
|
||||
freeMarkerConfiguration.setObjectWrapper(new DefaultObjectWrapper());
|
||||
|
||||
// Build the model for FreeMarker
|
||||
@@ -347,7 +347,7 @@ public final class SchemaToJava {
|
||||
|
||||
// Parse out the command line options
|
||||
try {
|
||||
cmd = parser.parse(options, argv);
|
||||
cmd = parser.parse(DEFAULT_OPTIONS, argv);
|
||||
} catch (ParseException e) {
|
||||
error(e.toString());
|
||||
}
|
||||
@@ -355,7 +355,7 @@ public final class SchemaToJava {
|
||||
// If the help flag is specified ignore other flags, print a usage message and exit
|
||||
if (cmd.hasOption(Flag.HELP.getShort())) {
|
||||
HelpFormatter formatter = new HelpFormatter();
|
||||
formatter.printHelp(120, SchemaToJava.class.getSimpleName(), null, options, null, true);
|
||||
formatter.printHelp(120, SchemaToJava.class.getSimpleName(), null, DEFAULT_OPTIONS, null, true);
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
@@ -414,7 +414,7 @@ public final class SchemaToJava {
|
||||
}
|
||||
|
||||
// Read binary mapping file
|
||||
URL binarySetUrl=loaderClass.getResource(BINARY_FILE);
|
||||
URL binarySetUrl= DEFAULT_LOADER_CLASS.getResource(BINARY_FILE);
|
||||
if (binarySetUrl==null) {
|
||||
error(String.format("Can't locatate binary mappings file %1$s", BINARY_FILE));
|
||||
}
|
||||
|
||||
@@ -95,19 +95,19 @@ public final class SchemaViewer {
|
||||
}
|
||||
}
|
||||
|
||||
private static final Options options = new Options();
|
||||
private static final Options DEFAULT_OPTIONS = new Options();
|
||||
static {
|
||||
options.addOption(Flag.URL.getShort(), Flag.URL.getLong(), true, "Ldap url (defaults to "+DEFAULT_URL+")");
|
||||
options.addOption(Flag.USERNAME.getShort(), Flag.USERNAME.getLong(), true, "DN to bind with (defaults to \"\")");
|
||||
options.addOption(Flag.PASSWORD.getShort(), Flag.PASSWORD.getLong(), true, "Password to bind with defaults to \"\")");
|
||||
options.addOption(Flag.OBJECTCLASS.getShort(), Flag.OBJECTCLASS.getLong(), true,
|
||||
DEFAULT_OPTIONS.addOption(Flag.URL.getShort(), Flag.URL.getLong(), true, "Ldap url (defaults to " + DEFAULT_URL + ")");
|
||||
DEFAULT_OPTIONS.addOption(Flag.USERNAME.getShort(), Flag.USERNAME.getLong(), true, "DN to bind with (defaults to \"\")");
|
||||
DEFAULT_OPTIONS.addOption(Flag.PASSWORD.getShort(), Flag.PASSWORD.getLong(), true, "Password to bind with defaults to \"\")");
|
||||
DEFAULT_OPTIONS.addOption(Flag.OBJECTCLASS.getShort(), Flag.OBJECTCLASS.getLong(), true,
|
||||
"Object class name or ? for all. Print object class schema");
|
||||
options.addOption(Flag.ATTRIBUTE.getShort(), Flag.ATTRIBUTE.getLong(), true,
|
||||
DEFAULT_OPTIONS.addOption(Flag.ATTRIBUTE.getShort(), Flag.ATTRIBUTE.getLong(), true,
|
||||
"Attribute name or ? for all. Print attribute schema");
|
||||
options.addOption(Flag.SYNTAX.getShort(), Flag.SYNTAX.getLong(), true,
|
||||
DEFAULT_OPTIONS.addOption(Flag.SYNTAX.getShort(), Flag.SYNTAX.getLong(), true,
|
||||
"Syntax OID or ? for all. Print attribute syntax");
|
||||
options.addOption(Flag.HELP.getShort(), Flag.HELP.getLong(), false, "Print this help message");
|
||||
options.addOption(Flag.ERROR.getShort(), Flag.ERROR.getLong(), false, "Send output to standard error");
|
||||
DEFAULT_OPTIONS.addOption(Flag.HELP.getShort(), Flag.HELP.getLong(), false, "Print this help message");
|
||||
DEFAULT_OPTIONS.addOption(Flag.ERROR.getShort(), Flag.ERROR.getLong(), false, "Send output to standard error");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -174,7 +174,7 @@ public final class SchemaViewer {
|
||||
CommandLine cmd = null;
|
||||
|
||||
try {
|
||||
cmd = parser.parse(options, argv);
|
||||
cmd = parser.parse(DEFAULT_OPTIONS, argv);
|
||||
} catch (ParseException e) {
|
||||
System.out.println(e.getMessage());
|
||||
System.exit(1);
|
||||
@@ -183,7 +183,7 @@ public final class SchemaViewer {
|
||||
if (cmd.hasOption(Flag.HELP.getShort())) {
|
||||
HelpFormatter formatter = new HelpFormatter();
|
||||
|
||||
formatter.printHelp(120, SchemaViewer.class.getSimpleName(), null, options, null, true);
|
||||
formatter.printHelp(120, SchemaViewer.class.getSimpleName(), null, DEFAULT_OPTIONS, null, true);
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ import java.util.Map.Entry;
|
||||
* @author Paul Harvey <paul.at.pauls-place.me.uk>
|
||||
*/
|
||||
/* package */ final class SyntaxToJavaClass {
|
||||
public final static class ClassInfo {
|
||||
public static final class ClassInfo {
|
||||
private final String className;
|
||||
|
||||
private final String packageName;
|
||||
|
||||
@@ -45,7 +45,7 @@ public abstract class AbstractEc2InstanceLaunchingFactoryBean extends AbstractFa
|
||||
|
||||
private static final long DEFAULT_PREPARATION_SLEEP_TIME = 30000;
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(AbstractEc2InstanceLaunchingFactoryBean.class);
|
||||
private static final Logger LOG = LoggerFactory.getLogger(AbstractEc2InstanceLaunchingFactoryBean.class);
|
||||
|
||||
private String imageName;
|
||||
|
||||
@@ -114,7 +114,7 @@ public abstract class AbstractEc2InstanceLaunchingFactoryBean extends AbstractFa
|
||||
Assert.hasLength(keypairName, "KeyName must be set");
|
||||
Assert.hasLength(groupName, "GroupName must be set");
|
||||
|
||||
log.info("Launching EC2 instance for image: " + imageName);
|
||||
LOG.info("Launching EC2 instance for image: " + imageName);
|
||||
|
||||
Jec2 jec2 = new Jec2(awsKey, awsSecretKey);
|
||||
LaunchConfiguration launchConfiguration = new LaunchConfiguration(imageName);
|
||||
@@ -124,18 +124,18 @@ public abstract class AbstractEc2InstanceLaunchingFactoryBean extends AbstractFa
|
||||
ReservationDescription reservationDescription = jec2.runInstances(launchConfiguration);
|
||||
instance = reservationDescription.getInstances().get(0);
|
||||
while (!instance.isRunning() && !instance.isTerminated()) {
|
||||
log.info("Instance still starting up; sleeping " + INSTANCE_START_SLEEP_TIME + "ms");
|
||||
LOG.info("Instance still starting up; sleeping " + INSTANCE_START_SLEEP_TIME + "ms");
|
||||
Thread.sleep(INSTANCE_START_SLEEP_TIME);
|
||||
reservationDescription = jec2.describeInstances(Collections.singletonList(instance.getInstanceId())).get(0);
|
||||
instance = reservationDescription.getInstances().get(0);
|
||||
}
|
||||
|
||||
if (instance.isRunning()) {
|
||||
log.info("EC2 instance is now running");
|
||||
LOG.info("EC2 instance is now running");
|
||||
if (preparationSleepTime > 0) {
|
||||
log.info("Sleeping " + preparationSleepTime + "ms allowing instance services to start up properly.");
|
||||
LOG.info("Sleeping " + preparationSleepTime + "ms allowing instance services to start up properly.");
|
||||
Thread.sleep(preparationSleepTime);
|
||||
log.info("Instance prepared - proceeding");
|
||||
LOG.info("Instance prepared - proceeding");
|
||||
}
|
||||
return doCreateInstance(instance.getDnsName());
|
||||
} else {
|
||||
@@ -156,7 +156,7 @@ public abstract class AbstractEc2InstanceLaunchingFactoryBean extends AbstractFa
|
||||
@Override
|
||||
protected void destroyInstance(Object ignored) throws Exception {
|
||||
if (this.instance != null) {
|
||||
log.info("Shutting down instance");
|
||||
LOG.info("Shutting down instance");
|
||||
Jec2 jec2 = new Jec2(awsKey, awsSecretKey);
|
||||
jec2.terminateInstances(Collections.singletonList(this.instance.getInstanceId()));
|
||||
}
|
||||
|
||||
@@ -49,10 +49,7 @@ import java.util.Set;
|
||||
* @author Mattias Hellborg Arthursson
|
||||
*/
|
||||
public final class LdapTestUtils {
|
||||
private final static Logger logger = LoggerFactory.getLogger(LdapTestUtils.class);
|
||||
|
||||
public static final String DEFAULT_PRINCIPAL = "uid=admin,ou=system";
|
||||
public static final String DEFAULT_PASSWORD = "secret";
|
||||
private final static Logger LOGGER = LoggerFactory.getLogger(LdapTestUtils.class);
|
||||
|
||||
private static EmbeddedLdapServer embeddedServer;
|
||||
|
||||
@@ -194,7 +191,7 @@ public final class LdapTestUtils {
|
||||
}
|
||||
}
|
||||
} catch (NamingException e) {
|
||||
logger.debug("Error cleaning sub-contexts", e);
|
||||
LOGGER.debug("Error cleaning sub-contexts", e);
|
||||
} finally {
|
||||
try {
|
||||
enumeration.close();
|
||||
|
||||
Reference in New Issue
Block a user