diff --git a/spring-ldap/src/main/java/org/springframework/ldap/AttributeInUseException.java b/spring-ldap/src/main/java/org/springframework/ldap/AttributeInUseException.java new file mode 100644 index 00000000..e101e848 --- /dev/null +++ b/spring-ldap/src/main/java/org/springframework/ldap/AttributeInUseException.java @@ -0,0 +1,32 @@ +/* + * Copyright 2002-2006 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.ldap; + +/** + * Runtime exception mirroring the AttributeInUseException. + * + * @author Ulrik Sandberg + * @since 1.2 + * @see javax.naming.directory.AttributeInUseException + */ +public class AttributeInUseException extends NamingException { + + public AttributeInUseException( + javax.naming.directory.AttributeInUseException cause) { + super(cause); + } +} diff --git a/spring-ldap/src/main/java/org/springframework/ldap/AttributeModificationException.java b/spring-ldap/src/main/java/org/springframework/ldap/AttributeModificationException.java new file mode 100644 index 00000000..f93e07bc --- /dev/null +++ b/spring-ldap/src/main/java/org/springframework/ldap/AttributeModificationException.java @@ -0,0 +1,32 @@ +/* + * Copyright 2002-2006 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.ldap; + +/** + * Runtime exception mirroring the AttributeModificationException. + * + * @author Ulrik Sandberg + * @since 1.2 + * @see javax.naming.directory.AttributeModificationException + */ +public class AttributeModificationException extends NamingException { + + public AttributeModificationException( + javax.naming.directory.AttributeModificationException cause) { + super(cause); + } +} diff --git a/spring-ldap/src/main/java/org/springframework/ldap/AttributesIntegrityViolationException.java b/spring-ldap/src/main/java/org/springframework/ldap/AttributesIntegrityViolationException.java deleted file mode 100644 index 10089337..00000000 --- a/spring-ldap/src/main/java/org/springframework/ldap/AttributesIntegrityViolationException.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright 2002-2005 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.ldap; - -import org.springframework.dao.DataIntegrityViolationException; - -/** - * Exception that indicates that an invalid or missing Attribute has been - * supplied to an LDAP operation. - * - * @author Mattias Arthursson - * - */ -public class AttributesIntegrityViolationException extends - DataIntegrityViolationException { - - private static final long serialVersionUID = -6368616096960202571L; - - public AttributesIntegrityViolationException(String msg) { - super(msg); - } - - public AttributesIntegrityViolationException(String msg, Throwable t) { - super(msg, t); - } -} diff --git a/spring-ldap/src/main/java/org/springframework/ldap/AuthenticationException.java b/spring-ldap/src/main/java/org/springframework/ldap/AuthenticationException.java new file mode 100644 index 00000000..34c0612a --- /dev/null +++ b/spring-ldap/src/main/java/org/springframework/ldap/AuthenticationException.java @@ -0,0 +1,31 @@ +/* + * Copyright 2002-2006 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.ldap; + +/** + * Runtime exception mirroring the AuthenticationException. + * + * @author Ulrik Sandberg + * @since 1.2 + * @see javax.naming.AuthenticationException + */ +public class AuthenticationException extends NamingSecurityException { + + public AuthenticationException(javax.naming.AuthenticationException cause) { + super(cause); + } +} diff --git a/spring-ldap/src/main/java/org/springframework/ldap/AuthenticationNotSupportedException.java b/spring-ldap/src/main/java/org/springframework/ldap/AuthenticationNotSupportedException.java new file mode 100644 index 00000000..9478b110 --- /dev/null +++ b/spring-ldap/src/main/java/org/springframework/ldap/AuthenticationNotSupportedException.java @@ -0,0 +1,33 @@ +/* + * Copyright 2002-2006 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.ldap; + +/** + * Runtime exception mirroring the AuthenticationNotSupportedException. + * + * @author Ulrik Sandberg + * @since 1.2 + * @see javax.naming.AuthenticationNotSupportedException + */ +public class AuthenticationNotSupportedException extends + NamingSecurityException { + + public AuthenticationNotSupportedException( + javax.naming.AuthenticationNotSupportedException cause) { + super(cause); + } +} diff --git a/spring-ldap/src/main/java/org/springframework/ldap/BadLdapGrammarException.java b/spring-ldap/src/main/java/org/springframework/ldap/BadLdapGrammarException.java deleted file mode 100644 index a7d55dbd..00000000 --- a/spring-ldap/src/main/java/org/springframework/ldap/BadLdapGrammarException.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright 2002-2005 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.ldap; - -import org.springframework.dao.InvalidDataAccessResourceUsageException; - -/** - * Thrown to indicate that an invalid value has been supplied to an LDAP - * operation. This could be an invalid filter or dn. - * - * @author Mattias Arthursson - */ -public class BadLdapGrammarException extends - InvalidDataAccessResourceUsageException { - - private static final long serialVersionUID = 961612585331409470L; - - public BadLdapGrammarException(String message) { - super(message); - } - - public BadLdapGrammarException(String message, Throwable cause) { - super(message, cause); - } -} diff --git a/spring-ldap/src/main/java/org/springframework/ldap/CannotProceedException.java b/spring-ldap/src/main/java/org/springframework/ldap/CannotProceedException.java new file mode 100644 index 00000000..dcb01261 --- /dev/null +++ b/spring-ldap/src/main/java/org/springframework/ldap/CannotProceedException.java @@ -0,0 +1,31 @@ +/* + * Copyright 2002-2006 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.ldap; + +/** + * Runtime exception mirroring the CannotProceedException. + * + * @author Ulrik Sandberg + * @since 1.2 + * @see javax.naming.CannotProceedException + */ +public class CannotProceedException extends NamingException { + + public CannotProceedException(javax.naming.CannotProceedException cause) { + super(cause); + } +} diff --git a/spring-ldap/src/main/java/org/springframework/ldap/CommunicationException.java b/spring-ldap/src/main/java/org/springframework/ldap/CommunicationException.java new file mode 100644 index 00000000..1a768033 --- /dev/null +++ b/spring-ldap/src/main/java/org/springframework/ldap/CommunicationException.java @@ -0,0 +1,31 @@ +/* + * Copyright 2002-2006 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.ldap; + +/** + * Runtime exception mirroring the CommunicationException. + * + * @author Ulrik Sandberg + * @since 1.2 + * @see javax.naming.CommunicationException + */ +public class CommunicationException extends NamingException { + + public CommunicationException(javax.naming.CommunicationException cause) { + super(cause); + } +} diff --git a/spring-ldap/src/main/java/org/springframework/ldap/ConfigurationException.java b/spring-ldap/src/main/java/org/springframework/ldap/ConfigurationException.java new file mode 100644 index 00000000..7de12789 --- /dev/null +++ b/spring-ldap/src/main/java/org/springframework/ldap/ConfigurationException.java @@ -0,0 +1,31 @@ +/* + * Copyright 2002-2006 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.ldap; + +/** + * Runtime exception mirroring the ConfigurationException. + * + * @author Ulrik Sandberg + * @since 1.2 + * @see javax.naming.ConfigurationException + */ +public class ConfigurationException extends NamingException { + + public ConfigurationException(javax.naming.ConfigurationException cause) { + super(cause); + } +} diff --git a/spring-ldap/src/main/java/org/springframework/ldap/ContextNotEmptyException.java b/spring-ldap/src/main/java/org/springframework/ldap/ContextNotEmptyException.java new file mode 100644 index 00000000..7b214084 --- /dev/null +++ b/spring-ldap/src/main/java/org/springframework/ldap/ContextNotEmptyException.java @@ -0,0 +1,31 @@ +/* + * Copyright 2002-2006 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.ldap; + +/** + * Runtime exception mirroring the ContextNotEmptyException. + * + * @author Ulrik Sandberg + * @since 1.2 + * @see javax.naming.ContextNotEmptyException + */ +public class ContextNotEmptyException extends NamingException { + + public ContextNotEmptyException(javax.naming.ContextNotEmptyException cause) { + super(cause); + } +} diff --git a/spring-ldap/src/main/java/org/springframework/ldap/DefaultNamingExceptionTranslator.java b/spring-ldap/src/main/java/org/springframework/ldap/DefaultNamingExceptionTranslator.java deleted file mode 100644 index 6c27b5c7..00000000 --- a/spring-ldap/src/main/java/org/springframework/ldap/DefaultNamingExceptionTranslator.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright 2002-2005 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.ldap; - -import javax.naming.CommunicationException; -import javax.naming.ContextNotEmptyException; -import javax.naming.LimitExceededException; -import javax.naming.NameAlreadyBoundException; -import javax.naming.NameNotFoundException; -import javax.naming.NamingException; -import javax.naming.directory.InvalidAttributesException; -import javax.naming.directory.InvalidSearchControlsException; -import javax.naming.directory.InvalidSearchFilterException; - -import org.springframework.dao.DataAccessException; -import org.springframework.dao.DataIntegrityViolationException; -import org.springframework.dao.DataRetrievalFailureException; -import org.springframework.dao.InvalidDataAccessApiUsageException; - -/** - * The default implementation of NamingExceptionTranslator. - * - * @author Mattias Arthursson - */ -public class DefaultNamingExceptionTranslator implements - NamingExceptionTranslator { - - /* - * (non-Javadoc) - * - * @see org.springframework.ldap.NamingExceptionTranslator#translate(java.lang.String, - * java.lang.String, java.lang.String, javax.naming.NamingException) - */ - public DataAccessException translate(NamingException namingException) { - - if (namingException instanceof NameNotFoundException) { - return new EntryNotFoundException("Entry not found", - namingException); - } - - if (namingException instanceof InvalidSearchFilterException) { - return new BadLdapGrammarException("Invalid search filter", - namingException); - } - - if (namingException instanceof InvalidSearchControlsException) { - return new InvalidDataAccessApiUsageException( - "Invalid search controls supplied by internal API", - namingException); - } - - if (namingException instanceof NameAlreadyBoundException) { - return new DataIntegrityViolationException("Name already bound", - namingException); - } - - if (namingException instanceof ContextNotEmptyException) { - return new DataIntegrityViolationException( - "The context needs to be empty in order to be removed", - namingException); - } - - if (namingException instanceof InvalidAttributesException) { - return new AttributesIntegrityViolationException( - "Invalid attributes", namingException); - } - - if (namingException instanceof LimitExceededException) { - return new SearchLimitExceededException("Too many objects found", - namingException); - } - - if (namingException instanceof CommunicationException) { - throw new DataRetrievalFailureException( - "Unable to communicate with LDAP server", namingException); - } - - // Fallback - other type of NamingException encountered. - return new UncategorizedLdapException("Operation failed", - namingException); - } -} diff --git a/spring-ldap/src/main/java/org/springframework/ldap/EntryNotFoundException.java b/spring-ldap/src/main/java/org/springframework/ldap/InsufficientResourcesException.java similarity index 53% rename from spring-ldap/src/main/java/org/springframework/ldap/EntryNotFoundException.java rename to spring-ldap/src/main/java/org/springframework/ldap/InsufficientResourcesException.java index 9bd81eb9..b05236dd 100644 --- a/spring-ldap/src/main/java/org/springframework/ldap/EntryNotFoundException.java +++ b/spring-ldap/src/main/java/org/springframework/ldap/InsufficientResourcesException.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2005 the original author or authors. + * Copyright 2002-2006 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,22 +16,17 @@ package org.springframework.ldap; -import org.springframework.dao.DataRetrievalFailureException; - /** - * Represents that an entry could not be found. + * Runtime exception mirroring the InsufficientResourcesException. * - * @author Mattias Arthursson + * @author Ulrik Sandberg + * @since 1.2 + * @see javax.naming.InsufficientResourcesException */ -public class EntryNotFoundException extends DataRetrievalFailureException { +public class InsufficientResourcesException extends NamingException { - private static final long serialVersionUID = -1268390922996332424L; - - public EntryNotFoundException(String msg) { - super(msg); - } - - public EntryNotFoundException(String msg, Throwable cause) { - super(msg, cause); + public InsufficientResourcesException( + javax.naming.InsufficientResourcesException cause) { + super(cause); } } diff --git a/spring-ldap/src/main/java/org/springframework/ldap/InterruptedNamingException.java b/spring-ldap/src/main/java/org/springframework/ldap/InterruptedNamingException.java new file mode 100644 index 00000000..8389f689 --- /dev/null +++ b/spring-ldap/src/main/java/org/springframework/ldap/InterruptedNamingException.java @@ -0,0 +1,32 @@ +/* + * Copyright 2002-2006 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.ldap; + +/** + * Runtime exception mirroring the InterruptedNamingException. + * + * @author Ulrik Sandberg + * @since 1.2 + * @see javax.naming.InterruptedNamingException + */ +public class InterruptedNamingException extends NamingException { + + public InterruptedNamingException( + javax.naming.InterruptedNamingException cause) { + super(cause); + } +} diff --git a/spring-ldap/src/main/java/org/springframework/ldap/InvalidAttributeIdentifierException.java b/spring-ldap/src/main/java/org/springframework/ldap/InvalidAttributeIdentifierException.java new file mode 100644 index 00000000..c76d256d --- /dev/null +++ b/spring-ldap/src/main/java/org/springframework/ldap/InvalidAttributeIdentifierException.java @@ -0,0 +1,32 @@ +/* + * Copyright 2002-2006 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.ldap; + +/** + * Runtime exception mirroring the InvalidAttributeIdentifierException. + * + * @author Ulrik Sandberg + * @since 1.2 + * @see javax.naming.directory.InvalidAttributeIdentifierException + */ +public class InvalidAttributeIdentifierException extends NamingException { + + public InvalidAttributeIdentifierException( + javax.naming.directory.InvalidAttributeIdentifierException cause) { + super(cause); + } +} diff --git a/spring-ldap/src/main/java/org/springframework/ldap/InvalidAttributeValueException.java b/spring-ldap/src/main/java/org/springframework/ldap/InvalidAttributeValueException.java new file mode 100644 index 00000000..2308a6e2 --- /dev/null +++ b/spring-ldap/src/main/java/org/springframework/ldap/InvalidAttributeValueException.java @@ -0,0 +1,32 @@ +/* + * Copyright 2002-2006 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.ldap; + +/** + * Runtime exception mirroring the InvalidAttributeValueException. + * + * @author Ulrik Sandberg + * @since 1.2 + * @see javax.naming.directory.InvalidAttributeValueException + */ +public class InvalidAttributeValueException extends NamingException { + + public InvalidAttributeValueException( + javax.naming.directory.InvalidAttributeValueException cause) { + super(cause); + } +} diff --git a/spring-ldap/src/main/java/org/springframework/ldap/SearchLimitExceededException.java b/spring-ldap/src/main/java/org/springframework/ldap/InvalidAttributesException.java similarity index 52% rename from spring-ldap/src/main/java/org/springframework/ldap/SearchLimitExceededException.java rename to spring-ldap/src/main/java/org/springframework/ldap/InvalidAttributesException.java index 49806334..faf2f6af 100644 --- a/spring-ldap/src/main/java/org/springframework/ldap/SearchLimitExceededException.java +++ b/spring-ldap/src/main/java/org/springframework/ldap/InvalidAttributesException.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2005 the original author or authors. + * Copyright 2002-2006 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,22 +16,17 @@ package org.springframework.ldap; -import org.springframework.dao.DataRetrievalFailureException; - /** - * Indicates that the search limit was exceeded in a search. - * - * @author Mattias Arthursson + * Runtime exception mirroring the InvalidAttributesException. * + * @author Ulrik Sandberg + * @since 1.2 + * @see javax.naming.directory.InvalidAttributesException */ -public class SearchLimitExceededException extends DataRetrievalFailureException { - private static final long serialVersionUID = 6899885947075235580L; +public class InvalidAttributesException extends NamingException { - public SearchLimitExceededException(String msg) { - super(msg); - } - - public SearchLimitExceededException(String msg, Throwable cause) { - super(msg, cause); + public InvalidAttributesException( + javax.naming.directory.InvalidAttributesException cause) { + super(cause); } } diff --git a/spring-ldap/src/main/java/org/springframework/ldap/InvalidNameException.java b/spring-ldap/src/main/java/org/springframework/ldap/InvalidNameException.java new file mode 100644 index 00000000..fb7c447b --- /dev/null +++ b/spring-ldap/src/main/java/org/springframework/ldap/InvalidNameException.java @@ -0,0 +1,31 @@ +/* + * Copyright 2002-2006 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.ldap; + +/** + * Runtime exception mirroring the InvalidNameException. + * + * @author Ulrik Sandberg + * @since 1.2 + * @see javax.naming.InvalidNameException + */ +public class InvalidNameException extends NamingException { + + public InvalidNameException(javax.naming.InvalidNameException cause) { + super(cause); + } +} diff --git a/spring-ldap/src/main/java/org/springframework/ldap/InvalidSearchControlsException.java b/spring-ldap/src/main/java/org/springframework/ldap/InvalidSearchControlsException.java new file mode 100644 index 00000000..13e85753 --- /dev/null +++ b/spring-ldap/src/main/java/org/springframework/ldap/InvalidSearchControlsException.java @@ -0,0 +1,32 @@ +/* + * Copyright 2002-2006 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.ldap; + +/** + * Runtime exception mirroring the InvalidSearchControlsException. + * + * @author Ulrik Sandberg + * @since 1.2 + * @see javax.naming.directory.InvalidSearchControlsException + */ +public class InvalidSearchControlsException extends NamingException { + + public InvalidSearchControlsException( + javax.naming.directory.InvalidSearchControlsException cause) { + super(cause); + } +} diff --git a/spring-ldap/src/main/java/org/springframework/ldap/InvalidSearchFilterException.java b/spring-ldap/src/main/java/org/springframework/ldap/InvalidSearchFilterException.java new file mode 100644 index 00000000..4324ff4a --- /dev/null +++ b/spring-ldap/src/main/java/org/springframework/ldap/InvalidSearchFilterException.java @@ -0,0 +1,32 @@ +/* + * Copyright 2002-2006 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.ldap; + +/** + * Runtime exception mirroring the InvalidSearchFilterException. + * + * @author Ulrik Sandberg + * @since 1.2 + * @see javax.naming.directory.InvalidSearchFilterException + */ +public class InvalidSearchFilterException extends NamingException { + + public InvalidSearchFilterException( + javax.naming.directory.InvalidSearchFilterException cause) { + super(cause); + } +} diff --git a/spring-ldap/src/main/java/org/springframework/ldap/LdapReferralException.java b/spring-ldap/src/main/java/org/springframework/ldap/LdapReferralException.java new file mode 100644 index 00000000..f8eb2730 --- /dev/null +++ b/spring-ldap/src/main/java/org/springframework/ldap/LdapReferralException.java @@ -0,0 +1,31 @@ +/* + * Copyright 2002-2006 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.ldap; + +/** + * Runtime exception mirroring the LdapReferralException. + * + * @author Ulrik Sandberg + * @since 1.2 + * @see javax.naming.ldap.LdapReferralException + */ +public class LdapReferralException extends ReferralException { + + public LdapReferralException(javax.naming.ldap.LdapReferralException cause) { + super(cause); + } +} diff --git a/spring-ldap/src/main/java/org/springframework/ldap/LimitExceededException.java b/spring-ldap/src/main/java/org/springframework/ldap/LimitExceededException.java new file mode 100644 index 00000000..4ccb5971 --- /dev/null +++ b/spring-ldap/src/main/java/org/springframework/ldap/LimitExceededException.java @@ -0,0 +1,31 @@ +/* + * Copyright 2002-2006 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.ldap; + +/** + * Runtime exception mirroring the LimitExceededException. + * + * @author Ulrik Sandberg + * @since 1.2 + * @see javax.naming.LimitExceededException + */ +public class LimitExceededException extends NamingException { + + public LimitExceededException(javax.naming.LimitExceededException cause) { + super(cause); + } +} diff --git a/spring-ldap/src/main/java/org/springframework/ldap/LinkException.java b/spring-ldap/src/main/java/org/springframework/ldap/LinkException.java new file mode 100644 index 00000000..f0d842fc --- /dev/null +++ b/spring-ldap/src/main/java/org/springframework/ldap/LinkException.java @@ -0,0 +1,31 @@ +/* + * Copyright 2002-2006 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.ldap; + +/** + * Runtime exception mirroring the LinkException. + * + * @author Ulrik Sandberg + * @since 1.2 + * @see javax.naming.LinkException + */ +public class LinkException extends NamingException { + + public LinkException(javax.naming.LinkException cause) { + super(cause); + } +} diff --git a/spring-ldap/src/main/java/org/springframework/ldap/LinkLoopException.java b/spring-ldap/src/main/java/org/springframework/ldap/LinkLoopException.java new file mode 100644 index 00000000..4738a6b0 --- /dev/null +++ b/spring-ldap/src/main/java/org/springframework/ldap/LinkLoopException.java @@ -0,0 +1,31 @@ +/* + * Copyright 2002-2006 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.ldap; + +/** + * Runtime exception mirroring the LinkLoopException. + * + * @author Ulrik Sandberg + * @since 1.2 + * @see javax.naming.LinkLoopException + */ +public class LinkLoopException extends LinkException { + + public LinkLoopException(javax.naming.LinkLoopException cause) { + super(cause); + } +} diff --git a/spring-ldap/src/main/java/org/springframework/ldap/MalformedLinkException.java b/spring-ldap/src/main/java/org/springframework/ldap/MalformedLinkException.java new file mode 100644 index 00000000..7d714616 --- /dev/null +++ b/spring-ldap/src/main/java/org/springframework/ldap/MalformedLinkException.java @@ -0,0 +1,31 @@ +/* + * Copyright 2002-2006 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.ldap; + +/** + * Runtime exception mirroring the MalformedLinkException. + * + * @author Ulrik Sandberg + * @since 1.2 + * @see javax.naming.MalformedLinkException + */ +public class MalformedLinkException extends LinkException { + + public MalformedLinkException(javax.naming.MalformedLinkException cause) { + super(cause); + } +} diff --git a/spring-ldap/src/main/java/org/springframework/ldap/NameAlreadyBoundException.java b/spring-ldap/src/main/java/org/springframework/ldap/NameAlreadyBoundException.java new file mode 100644 index 00000000..07db5e71 --- /dev/null +++ b/spring-ldap/src/main/java/org/springframework/ldap/NameAlreadyBoundException.java @@ -0,0 +1,32 @@ +/* + * Copyright 2002-2006 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.ldap; + +/** + * Runtime exception mirroring the NameAlreadyBoundException. + * + * @author Ulrik Sandberg + * @since 1.2 + * @see javax.naming.NameAlreadyBoundException + */ +public class NameAlreadyBoundException extends NamingException { + + public NameAlreadyBoundException( + javax.naming.NameAlreadyBoundException cause) { + super(cause); + } +} diff --git a/spring-ldap/src/main/java/org/springframework/ldap/NameNotFoundException.java b/spring-ldap/src/main/java/org/springframework/ldap/NameNotFoundException.java new file mode 100644 index 00000000..38f8ddb5 --- /dev/null +++ b/spring-ldap/src/main/java/org/springframework/ldap/NameNotFoundException.java @@ -0,0 +1,31 @@ +/* + * Copyright 2002-2006 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.ldap; + +/** + * Runtime exception mirroring the NameNotFoundException. + * + * @author Ulrik Sandberg + * @since 1.2 + * @see javax.naming.NameNotFoundException + */ +public class NameNotFoundException extends NamingException { + + public NameNotFoundException(javax.naming.NameNotFoundException cause) { + super(cause); + } +} diff --git a/spring-ldap/src/main/java/org/springframework/ldap/NamingException.java b/spring-ldap/src/main/java/org/springframework/ldap/NamingException.java new file mode 100644 index 00000000..9380af60 --- /dev/null +++ b/spring-ldap/src/main/java/org/springframework/ldap/NamingException.java @@ -0,0 +1,136 @@ +/* + * Copyright 2002-2006 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.ldap; + +import javax.naming.Name; + +import org.springframework.core.NestedRuntimeException; + +/** + * Base class for exception thrown by the framework whenever it encounters a + * problem related to LDAP. + * + * @author Ulrik Sandberg + * @since 1.2 + */ +public abstract class NamingException extends NestedRuntimeException { + + /** + * Constructor that takes a message. + * + * @param msg + * the detail message + */ + public NamingException(String msg) { + super(msg); + } + + /** + * Constructor that allows a message and a root cause. + * + * @param msg + * the detail message + * @param cause + * the cause of the exception. This argument is generally + * expected to be a proper subclass of + * {@link javax.naming.NamingException}. + */ + public NamingException(String msg, Throwable cause) { + super(msg, cause); + } + + /** + * Constructor that allows a plain root cause, intended for subclasses + * mirroring corresponding javax.naming exceptions. + * + * @param cause + * the cause of the exception. This argument is generally + * expected to be a proper subclass of + * {@link javax.naming.NamingException}. + */ + public NamingException(Throwable cause) { + super(cause != null ? cause.getMessage() : null, cause); + } + + /** + * Convenience method to get the explanation associated with this exception, + * if the root cause was an instance of {@link javax.naming.NamingException}. + * + * @return a detail string explaining more about this exception if the root + * cause is an instance of javax.naming.NamingException, or + * null if there is no detail message for this + * exception + */ + public String getExplanation() { + if (getCause() instanceof javax.naming.NamingException) { + return ((javax.naming.NamingException) getCause()).getExplanation(); + } + return null; + } + + /** + * Convenience method to get the unresolved part of the name associated with + * this exception, if the root cause was an instance of + * {@link javax.naming.NamingException}. + * + * @return a composite name describing the part of the name that has not + * been resolved if the root cause is an instance of + * javax.naming.NamingException, or null if the + * remaining name field has not been set + */ + public Name getRemainingName() { + if (getCause() instanceof javax.naming.NamingException) { + return ((javax.naming.NamingException) getCause()) + .getRemainingName(); + } + return null; + } + + /** + * Convenience method to get the leading portion of the resolved name + * associated with this exception, if the root cause was an instance of + * {@link javax.naming.NamingException}. + * + * @return a composite name describing the the leading portion of the name + * that was resolved successfully if the root cause is an instance + * of javax.naming.NamingException, or null if the + * resolved name field has not been set + */ + public Name getResolvedName() { + if (getCause() instanceof javax.naming.NamingException) { + return ((javax.naming.NamingException) getCause()) + .getResolvedName(); + } + return null; + } + + /** + * Convenience method to get the resolved object associated with this + * exception, if the root cause was an instance of + * {@link javax.naming.NamingException}. + * + * @return the object that was resolved so far if the root cause is an + * instance of javax.naming.NamingException, or null + * if the resolved object field has not been set + */ + public Object getResolvedObj() { + if (getCause() instanceof javax.naming.NamingException) { + return ((javax.naming.NamingException) getCause()).getResolvedObj(); + } + return null; + } +} diff --git a/spring-ldap/src/main/java/org/springframework/ldap/NamingExceptionTranslator.java b/spring-ldap/src/main/java/org/springframework/ldap/NamingExceptionTranslator.java deleted file mode 100644 index cd6e7a4c..00000000 --- a/spring-ldap/src/main/java/org/springframework/ldap/NamingExceptionTranslator.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright 2002-2005 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.ldap; - -import javax.naming.NamingException; - -import org.springframework.dao.DataAccessException; - -/** - * Interface to be implemented by classes that can translate between - * NamingExceptions and DataAccessExceptions. - * - * @author Mattias Arthursson - * - */ -public interface NamingExceptionTranslator { - /** - * Translate the given NamingException into a generic data access exception. - * @param namingException - * the offending NamingException. - * - * @return the DataAccessException to throw. - */ - public DataAccessException translate(NamingException namingException); -} diff --git a/spring-ldap/src/main/java/org/springframework/ldap/NamingSecurityException.java b/spring-ldap/src/main/java/org/springframework/ldap/NamingSecurityException.java new file mode 100644 index 00000000..96d8e83a --- /dev/null +++ b/spring-ldap/src/main/java/org/springframework/ldap/NamingSecurityException.java @@ -0,0 +1,31 @@ +/* + * Copyright 2002-2006 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.ldap; + +/** + * Runtime exception mirroring the NamingSecurityException. + * + * @author Ulrik Sandberg + * @since 1.2 + * @see javax.naming.NamingSecurityException + */ +public abstract class NamingSecurityException extends NamingException { + + public NamingSecurityException(javax.naming.NamingSecurityException cause) { + super(cause); + } +} diff --git a/spring-ldap/src/main/java/org/springframework/ldap/NoInitialContextException.java b/spring-ldap/src/main/java/org/springframework/ldap/NoInitialContextException.java new file mode 100644 index 00000000..8ba0e09c --- /dev/null +++ b/spring-ldap/src/main/java/org/springframework/ldap/NoInitialContextException.java @@ -0,0 +1,32 @@ +/* + * Copyright 2002-2006 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.ldap; + +/** + * Runtime exception mirroring the NoInitialContextException. + * + * @author Ulrik Sandberg + * @since 1.2 + * @see javax.naming.NoInitialContextException + */ +public class NoInitialContextException extends NamingException { + + public NoInitialContextException( + javax.naming.NoInitialContextException cause) { + super(cause); + } +} diff --git a/spring-ldap/src/main/java/org/springframework/ldap/NoPermissionException.java b/spring-ldap/src/main/java/org/springframework/ldap/NoPermissionException.java new file mode 100644 index 00000000..aad6e416 --- /dev/null +++ b/spring-ldap/src/main/java/org/springframework/ldap/NoPermissionException.java @@ -0,0 +1,31 @@ +/* + * Copyright 2002-2006 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.ldap; + +/** + * Runtime exception mirroring the NoPermissionException. + * + * @author Ulrik Sandberg + * @since 1.2 + * @see javax.naming.NoPermissionException + */ +public class NoPermissionException extends NamingSecurityException { + + public NoPermissionException(javax.naming.NoPermissionException cause) { + super(cause); + } +} diff --git a/spring-ldap/src/main/java/org/springframework/ldap/NoSuchAttributeException.java b/spring-ldap/src/main/java/org/springframework/ldap/NoSuchAttributeException.java new file mode 100644 index 00000000..f235d6d7 --- /dev/null +++ b/spring-ldap/src/main/java/org/springframework/ldap/NoSuchAttributeException.java @@ -0,0 +1,32 @@ +/* + * Copyright 2002-2006 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.ldap; + +/** + * Runtime exception mirroring the NoSuchAttributeException. + * + * @author Ulrik Sandberg + * @since 1.2 + * @see javax.naming.directory.NoSuchAttributeException + */ +public class NoSuchAttributeException extends NamingException { + + public NoSuchAttributeException( + javax.naming.directory.NoSuchAttributeException cause) { + super(cause); + } +} diff --git a/spring-ldap/src/main/java/org/springframework/ldap/NotContextException.java b/spring-ldap/src/main/java/org/springframework/ldap/NotContextException.java new file mode 100644 index 00000000..d5fd5de3 --- /dev/null +++ b/spring-ldap/src/main/java/org/springframework/ldap/NotContextException.java @@ -0,0 +1,31 @@ +/* + * Copyright 2002-2006 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.ldap; + +/** + * Runtime exception mirroring the NotContextException. + * + * @author Ulrik Sandberg + * @since 1.2 + * @see javax.naming.NotContextException + */ +public class NotContextException extends NamingException { + + public NotContextException(javax.naming.NotContextException cause) { + super(cause); + } +} diff --git a/spring-ldap/src/main/java/org/springframework/ldap/OperationNotSupportedException.java b/spring-ldap/src/main/java/org/springframework/ldap/OperationNotSupportedException.java new file mode 100644 index 00000000..a08b17a4 --- /dev/null +++ b/spring-ldap/src/main/java/org/springframework/ldap/OperationNotSupportedException.java @@ -0,0 +1,32 @@ +/* + * Copyright 2002-2006 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.ldap; + +/** + * Runtime exception mirroring the OperationNotSupportedException. + * + * @author Ulrik Sandberg + * @since 1.2 + * @see javax.naming.OperationNotSupportedException + */ +public class OperationNotSupportedException extends NamingException { + + public OperationNotSupportedException( + javax.naming.OperationNotSupportedException cause) { + super(cause); + } +} diff --git a/spring-ldap/src/main/java/org/springframework/ldap/PartialResultException.java b/spring-ldap/src/main/java/org/springframework/ldap/PartialResultException.java new file mode 100644 index 00000000..e590a7e7 --- /dev/null +++ b/spring-ldap/src/main/java/org/springframework/ldap/PartialResultException.java @@ -0,0 +1,31 @@ +/* + * Copyright 2002-2006 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.ldap; + +/** + * Runtime exception mirroring the PartialResultException. + * + * @author Ulrik Sandberg + * @since 1.2 + * @see javax.naming.PartialResultException + */ +public class PartialResultException extends NamingException { + + public PartialResultException(javax.naming.PartialResultException cause) { + super(cause); + } +} diff --git a/spring-ldap/src/main/java/org/springframework/ldap/ReferralException.java b/spring-ldap/src/main/java/org/springframework/ldap/ReferralException.java new file mode 100644 index 00000000..c05d6335 --- /dev/null +++ b/spring-ldap/src/main/java/org/springframework/ldap/ReferralException.java @@ -0,0 +1,31 @@ +/* + * Copyright 2002-2006 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.ldap; + +/** + * Runtime exception mirroring the ReferralException. + * + * @author Ulrik Sandberg + * @since 1.2 + * @see javax.naming.ReferralException + */ +public abstract class ReferralException extends NamingException { + + public ReferralException(javax.naming.ReferralException cause) { + super(cause); + } +} diff --git a/spring-ldap/src/main/java/org/springframework/ldap/SchemaViolationException.java b/spring-ldap/src/main/java/org/springframework/ldap/SchemaViolationException.java new file mode 100644 index 00000000..733cd584 --- /dev/null +++ b/spring-ldap/src/main/java/org/springframework/ldap/SchemaViolationException.java @@ -0,0 +1,32 @@ +/* + * Copyright 2002-2006 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.ldap; + +/** + * Runtime exception mirroring the SchemaViolationException. + * + * @author Ulrik Sandberg + * @since 1.2 + * @see javax.naming.directory.SchemaViolationException + */ +public class SchemaViolationException extends NamingException { + + public SchemaViolationException( + javax.naming.directory.SchemaViolationException cause) { + super(cause); + } +} diff --git a/spring-ldap/src/main/java/org/springframework/ldap/ServiceUnavailableException.java b/spring-ldap/src/main/java/org/springframework/ldap/ServiceUnavailableException.java new file mode 100644 index 00000000..73a21641 --- /dev/null +++ b/spring-ldap/src/main/java/org/springframework/ldap/ServiceUnavailableException.java @@ -0,0 +1,32 @@ +/* + * Copyright 2002-2006 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.ldap; + +/** + * Runtime exception mirroring the ServiceUnavailableException. + * + * @author Ulrik Sandberg + * @since 1.2 + * @see javax.naming.ServiceUnavailableException + */ +public class ServiceUnavailableException extends NamingException { + + public ServiceUnavailableException( + javax.naming.ServiceUnavailableException cause) { + super(cause); + } +} diff --git a/spring-ldap/src/main/java/org/springframework/ldap/SizeLimitExceededException.java b/spring-ldap/src/main/java/org/springframework/ldap/SizeLimitExceededException.java new file mode 100644 index 00000000..f3f330f1 --- /dev/null +++ b/spring-ldap/src/main/java/org/springframework/ldap/SizeLimitExceededException.java @@ -0,0 +1,32 @@ +/* + * Copyright 2002-2006 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.ldap; + +/** + * Runtime exception mirroring the SizeLimitExceededException. + * + * @author Ulrik Sandberg + * @since 1.2 + * @see javax.naming.SizeLimitExceededException + */ +public class SizeLimitExceededException extends LimitExceededException { + + public SizeLimitExceededException( + javax.naming.SizeLimitExceededException cause) { + super(cause); + } +} diff --git a/spring-ldap/src/main/java/org/springframework/ldap/TimeLimitExceededException.java b/spring-ldap/src/main/java/org/springframework/ldap/TimeLimitExceededException.java new file mode 100644 index 00000000..0aebcc5f --- /dev/null +++ b/spring-ldap/src/main/java/org/springframework/ldap/TimeLimitExceededException.java @@ -0,0 +1,32 @@ +/* + * Copyright 2002-2006 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.ldap; + +/** + * Runtime exception mirroring the TimeLimitExceededException. + * + * @author Ulrik Sandberg + * @since 1.2 + * @see javax.naming.TimeLimitExceededException + */ +public class TimeLimitExceededException extends LimitExceededException { + + public TimeLimitExceededException( + javax.naming.TimeLimitExceededException cause) { + super(cause); + } +} diff --git a/spring-ldap/src/main/java/org/springframework/ldap/package.html b/spring-ldap/src/main/java/org/springframework/ldap/package.html index f160a4a2..74a2fbdd 100644 --- a/spring-ldap/src/main/java/org/springframework/ldap/package.html +++ b/spring-ldap/src/main/java/org/springframework/ldap/package.html @@ -1,3 +1,8 @@ + -The core package of the Spring-LDAP library. - \ No newline at end of file + +This package contains integration classes for JNDI/LDAP, +allowing for Spring-style LDAP access. + + + diff --git a/spring-ldap/src/main/java/org/springframework/ldap/support/AbstractContextSource.java b/spring-ldap/src/main/java/org/springframework/ldap/support/AbstractContextSource.java index 996a7188..1b700bc5 100644 --- a/spring-ldap/src/main/java/org/springframework/ldap/support/AbstractContextSource.java +++ b/spring-ldap/src/main/java/org/springframework/ldap/support/AbstractContextSource.java @@ -28,8 +28,6 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.springframework.beans.factory.InitializingBean; import org.springframework.core.JdkVersion; -import org.springframework.ldap.DefaultNamingExceptionTranslator; -import org.springframework.ldap.NamingExceptionTranslator; import org.springframework.ldap.core.AuthenticationSource; import org.springframework.ldap.core.ContextSource; diff --git a/spring-ldap/src/main/java/org/springframework/ldap/support/DirContextAdapter.java b/spring-ldap/src/main/java/org/springframework/ldap/support/DirContextAdapter.java index f4fcd6f7..689c70dc 100644 --- a/spring-ldap/src/main/java/org/springframework/ldap/support/DirContextAdapter.java +++ b/spring-ldap/src/main/java/org/springframework/ldap/support/DirContextAdapter.java @@ -46,8 +46,6 @@ import org.apache.commons.lang.builder.EqualsBuilder; import org.apache.commons.lang.builder.HashCodeBuilder; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.springframework.ldap.DefaultNamingExceptionTranslator; -import org.springframework.ldap.NamingExceptionTranslator; /** * Implements the interesting methods of the DirContext interface. In particular diff --git a/spring-ldap/src/main/java/org/springframework/ldap/support/DistinguishedName.java b/spring-ldap/src/main/java/org/springframework/ldap/support/DistinguishedName.java index 050ea203..7d4f5075 100644 --- a/spring-ldap/src/main/java/org/springframework/ldap/support/DistinguishedName.java +++ b/spring-ldap/src/main/java/org/springframework/ldap/support/DistinguishedName.java @@ -28,7 +28,6 @@ import javax.naming.InvalidNameException; import javax.naming.Name; import org.apache.commons.lang.StringUtils; -import org.springframework.ldap.BadLdapGrammarException; import org.springframework.ldap.util.ListComparator; /** diff --git a/spring-ldap/src/main/java/org/springframework/ldap/support/LdapEncoder.java b/spring-ldap/src/main/java/org/springframework/ldap/support/LdapEncoder.java index d6525bc2..0fb56752 100644 --- a/spring-ldap/src/main/java/org/springframework/ldap/support/LdapEncoder.java +++ b/spring-ldap/src/main/java/org/springframework/ldap/support/LdapEncoder.java @@ -21,7 +21,6 @@ import java.util.regex.Pattern; import org.apache.commons.lang.StringUtils; -import org.springframework.ldap.BadLdapGrammarException; /** * Helper class to encode and decode ldap names and values. diff --git a/spring-ldap/src/main/java/org/springframework/ldap/support/LdapRdn.java b/spring-ldap/src/main/java/org/springframework/ldap/support/LdapRdn.java index f5ccdd6d..c2d7e4d2 100644 --- a/spring-ldap/src/main/java/org/springframework/ldap/support/LdapRdn.java +++ b/spring-ldap/src/main/java/org/springframework/ldap/support/LdapRdn.java @@ -22,7 +22,6 @@ import java.util.Iterator; import java.util.LinkedList; import java.util.List; -import org.springframework.ldap.BadLdapGrammarException; import org.springframework.ldap.util.ListComparator; /** diff --git a/spring-ldap/src/main/java/org/springframework/ldap/support/LdapUtils.java b/spring-ldap/src/main/java/org/springframework/ldap/support/LdapUtils.java new file mode 100644 index 00000000..50e76bc7 --- /dev/null +++ b/spring-ldap/src/main/java/org/springframework/ldap/support/LdapUtils.java @@ -0,0 +1,210 @@ +/* + * Copyright 2002-2006 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.ldap.support; + +import javax.naming.directory.DirContext; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.springframework.ldap.NamingException; +import org.springframework.util.Assert; + +/** + * Generic utility methods for working with LDAP. Mainly for internal use within + * the framework, but also useful for custom code. + * + * @author Ulrik Sandberg + * @since 1.2 + */ +public abstract class LdapUtils { + + private static final Log logger = LogFactory.getLog(LdapUtils.class); + + /** + * Close the given JNDI Context and ignore any thrown exception. This is + * useful for typical finally blocks in JNDI code. + * + * @param context + * the JNDI Context to close (may be null) + */ + public static void closeContext(DirContext context) { + if (context != null) { + try { + context.close(); + } catch (NamingException 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); + } + } + } + + /** + * Convert the specified checked + * {@link javax.naming.NamingException NamingException} to a Spring LDAP + * runtime {@link org.springframework.ldap.NamingException NamingException} + * equivalent. + * + * @param ex + * the original checked NamingException to convert + * @return the Spring LDAP runtime NamingException wrapping the given + * exception + */ + public static NamingException convertLdapException( + javax.naming.NamingException ex) { + Assert.notNull(ex, "NamingException must not be null"); + + if (ex instanceof javax.naming.directory.AttributeInUseException) { + return new org.springframework.ldap.AttributeInUseException( + (javax.naming.directory.AttributeInUseException) ex); + } + if (ex instanceof javax.naming.directory.AttributeModificationException) { + return new org.springframework.ldap.AttributeModificationException( + (javax.naming.directory.AttributeModificationException) ex); + } + if (ex instanceof javax.naming.AuthenticationException) { + return new org.springframework.ldap.AuthenticationException( + (javax.naming.AuthenticationException) ex); + } + if (ex instanceof javax.naming.AuthenticationNotSupportedException) { + return new org.springframework.ldap.AuthenticationNotSupportedException( + (javax.naming.AuthenticationNotSupportedException) ex); + } + if (ex instanceof javax.naming.CannotProceedException) { + return new org.springframework.ldap.CannotProceedException( + (javax.naming.CannotProceedException) ex); + } + if (ex instanceof javax.naming.CommunicationException) { + return new org.springframework.ldap.CommunicationException( + (javax.naming.CommunicationException) ex); + } + if (ex instanceof javax.naming.ConfigurationException) { + return new org.springframework.ldap.ConfigurationException( + (javax.naming.ConfigurationException) ex); + } + if (ex instanceof javax.naming.ContextNotEmptyException) { + return new org.springframework.ldap.ContextNotEmptyException( + (javax.naming.ContextNotEmptyException) ex); + } + if (ex instanceof javax.naming.InsufficientResourcesException) { + return new org.springframework.ldap.InsufficientResourcesException( + (javax.naming.InsufficientResourcesException) ex); + } + if (ex instanceof javax.naming.InterruptedNamingException) { + return new org.springframework.ldap.InterruptedNamingException( + (javax.naming.InterruptedNamingException) ex); + } + if (ex instanceof javax.naming.directory.InvalidAttributeIdentifierException) { + return new org.springframework.ldap.InvalidAttributeIdentifierException( + (javax.naming.directory.InvalidAttributeIdentifierException) ex); + } + if (ex instanceof javax.naming.directory.InvalidAttributesException) { + return new org.springframework.ldap.InvalidAttributesException( + (javax.naming.directory.InvalidAttributesException) ex); + } + if (ex instanceof javax.naming.directory.InvalidAttributeValueException) { + return new org.springframework.ldap.InvalidAttributeValueException( + (javax.naming.directory.InvalidAttributeValueException) ex); + } + if (ex instanceof javax.naming.InvalidNameException) { + return new org.springframework.ldap.InvalidNameException( + (javax.naming.InvalidNameException) ex); + } + if (ex instanceof javax.naming.directory.InvalidSearchControlsException) { + return new org.springframework.ldap.InvalidSearchControlsException( + (javax.naming.directory.InvalidSearchControlsException) ex); + } + if (ex instanceof javax.naming.directory.InvalidSearchFilterException) { + return new org.springframework.ldap.InvalidSearchFilterException( + (javax.naming.directory.InvalidSearchFilterException) ex); + } + if (ex instanceof javax.naming.ldap.LdapReferralException) { + return new org.springframework.ldap.LdapReferralException( + (javax.naming.ldap.LdapReferralException) ex); + } + if (ex instanceof javax.naming.LimitExceededException) { + return new org.springframework.ldap.LimitExceededException( + (javax.naming.LimitExceededException) ex); + } + if (ex instanceof javax.naming.LinkException) { + return new org.springframework.ldap.LinkException( + (javax.naming.LinkException) ex); + } + if (ex instanceof javax.naming.LinkLoopException) { + return new org.springframework.ldap.LinkLoopException( + (javax.naming.LinkLoopException) ex); + } + if (ex instanceof javax.naming.MalformedLinkException) { + return new org.springframework.ldap.MalformedLinkException( + (javax.naming.MalformedLinkException) ex); + } + if (ex instanceof javax.naming.NameAlreadyBoundException) { + return new org.springframework.ldap.NameAlreadyBoundException( + (javax.naming.NameAlreadyBoundException) ex); + } + if (ex instanceof javax.naming.NameNotFoundException) { + return new org.springframework.ldap.NameNotFoundException( + (javax.naming.NameNotFoundException) ex); + } + if (ex instanceof javax.naming.NoInitialContextException) { + return new org.springframework.ldap.NoInitialContextException( + (javax.naming.NoInitialContextException) ex); + } + if (ex instanceof javax.naming.NoPermissionException) { + return new org.springframework.ldap.NoPermissionException( + (javax.naming.NoPermissionException) ex); + } + if (ex instanceof javax.naming.directory.NoSuchAttributeException) { + return new org.springframework.ldap.NoSuchAttributeException( + (javax.naming.directory.NoSuchAttributeException) ex); + } + if (ex instanceof javax.naming.NotContextException) { + return new org.springframework.ldap.NotContextException( + (javax.naming.NotContextException) ex); + } + if (ex instanceof javax.naming.OperationNotSupportedException) { + return new org.springframework.ldap.OperationNotSupportedException( + (javax.naming.OperationNotSupportedException) ex); + } + if (ex instanceof javax.naming.PartialResultException) { + return new org.springframework.ldap.PartialResultException( + (javax.naming.PartialResultException) ex); + } + if (ex instanceof javax.naming.directory.SchemaViolationException) { + return new org.springframework.ldap.SchemaViolationException( + (javax.naming.directory.SchemaViolationException) ex); + } + if (ex instanceof javax.naming.ServiceUnavailableException) { + return new org.springframework.ldap.ServiceUnavailableException( + (javax.naming.ServiceUnavailableException) ex); + } + if (ex instanceof javax.naming.SizeLimitExceededException) { + return new org.springframework.ldap.SizeLimitExceededException( + (javax.naming.SizeLimitExceededException) ex); + } + if (ex instanceof javax.naming.TimeLimitExceededException) { + return new org.springframework.ldap.TimeLimitExceededException( + (javax.naming.TimeLimitExceededException) ex); + } + + // fallback + return new org.springframework.ldap.UncategorizedLdapException(ex); + } +} diff --git a/spring-ldap/src/main/java/org/springframework/ldap/support/package.html b/spring-ldap/src/main/java/org/springframework/ldap/support/package.html index bf83afd5..5eabecc8 100644 --- a/spring-ldap/src/main/java/org/springframework/ldap/support/package.html +++ b/spring-ldap/src/main/java/org/springframework/ldap/support/package.html @@ -1,3 +1,7 @@ + + Support classes for Spring-LDAP. - \ No newline at end of file + + +