directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r267438 - in /directory/shared/ldap/branches/new-codec-integration/common/src/java/org/apache/ldap/common/exception: LdapInvalidAttributeValueException.java LdapNoSuchAttributeException.java
Date Sat, 03 Sep 2005 08:46:36 GMT
Author: elecharny
Date: Sat Sep  3 01:46:31 2005
New Revision: 267438

URL: http://svn.apache.org/viewcvs?rev=267438&view=rev
Log:
Backporting trunk modifications to the branch

Added:
    directory/shared/ldap/branches/new-codec-integration/common/src/java/org/apache/ldap/common/exception/LdapInvalidAttributeValueException.java
    directory/shared/ldap/branches/new-codec-integration/common/src/java/org/apache/ldap/common/exception/LdapNoSuchAttributeException.java

Added: directory/shared/ldap/branches/new-codec-integration/common/src/java/org/apache/ldap/common/exception/LdapInvalidAttributeValueException.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/branches/new-codec-integration/common/src/java/org/apache/ldap/common/exception/LdapInvalidAttributeValueException.java?rev=267438&view=auto
==============================================================================
--- directory/shared/ldap/branches/new-codec-integration/common/src/java/org/apache/ldap/common/exception/LdapInvalidAttributeValueException.java
(added)
+++ directory/shared/ldap/branches/new-codec-integration/common/src/java/org/apache/ldap/common/exception/LdapInvalidAttributeValueException.java
Sat Sep  3 01:46:31 2005
@@ -0,0 +1,91 @@
+/*
+ *   Copyright 2004 The Apache Software Foundation
+ *
+ *   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.apache.ldap.common.exception;
+
+
+import javax.naming.directory.SchemaViolationException;
+import javax.naming.directory.InvalidAttributeValueException;
+
+import org.apache.ldap.common.message.ResultCodeEnum;
+
+
+/**
+ * Makes a InvalidAttributeValueException unambiguous with respect to the result code it
corresponds to
+ * by associating an LDAP specific result code with it.
+ *
+ * @see <a href="http://java.sun.com/j2se/1.4.2/docs/guide/jndi/jndi-ldap-gl.html#EXCEPT">
+ * LDAP ResultCode to JNDI Exception Mappings</a>
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$
+ */
+public class LdapInvalidAttributeValueException extends InvalidAttributeValueException implements
LdapException
+{
+    static final long serialVersionUID = 5763624876999168014L;
+    /** the LDAP resultCode this exception is associated with */
+    private final ResultCodeEnum resultCode;
+
+
+    /**
+     * Creates an Ldap InvalidAttributeValueException using a result code.
+     *
+     * @param resultCode the LDAP resultCode this exception is associated with
+     * @throws IllegalArgumentException if the resultCode argument is not ResultCodeEnum.CONSTRAINTVIOLATION,
or
+     * ResultCodeEnum.INVALIDATTRIBUTESYNTAX
+     */
+    public LdapInvalidAttributeValueException( ResultCodeEnum resultCode )
+    {
+        super();
+
+        switch( resultCode.getValue() )
+        {
+            case( ResultCodeEnum.CONSTRAINTVIOLATION_VAL ):
+                break;
+            case( ResultCodeEnum.INVALIDATTRIBUTESYNTAX_VAL ):
+                break;
+            default:
+
+                throw new IllegalArgumentException( resultCode.getName() + " is not an acceptable
result code." );
+        }
+
+        this.resultCode = resultCode;
+    }
+
+
+    /**
+     * Creates an Ldap InvalidAttributeValueException using a result code and a specific
message.
+     *
+     * @param explanation an explanation for the failure
+     * @param resultCode the LDAP resultCode this exception is associated with
+     */
+    public LdapInvalidAttributeValueException( String explanation, ResultCodeEnum resultCode
)
+    {
+        super( explanation );
+
+        this.resultCode = resultCode;
+    }
+
+
+    /**
+     * Gets the LDAP resultCode this exception is associated with.
+     *
+     * @return the LDAP resultCode this exception is associated with
+     */
+    public ResultCodeEnum getResultCode()
+    {
+        return this.resultCode;
+    }
+}

Added: directory/shared/ldap/branches/new-codec-integration/common/src/java/org/apache/ldap/common/exception/LdapNoSuchAttributeException.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/branches/new-codec-integration/common/src/java/org/apache/ldap/common/exception/LdapNoSuchAttributeException.java?rev=267438&view=auto
==============================================================================
--- directory/shared/ldap/branches/new-codec-integration/common/src/java/org/apache/ldap/common/exception/LdapNoSuchAttributeException.java
(added)
+++ directory/shared/ldap/branches/new-codec-integration/common/src/java/org/apache/ldap/common/exception/LdapNoSuchAttributeException.java
Sat Sep  3 01:46:31 2005
@@ -0,0 +1,64 @@
+/*
+ *   Copyright 2004 The Apache Software Foundation
+ *
+ *   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.apache.ldap.common.exception;
+
+
+import javax.naming.directory.NoSuchAttributeException;
+
+import org.apache.ldap.common.message.ResultCodeEnum;
+
+
+/**
+ * A subclass of NoSuchAttributeException which holds the LDAP resultCode
+ * associated with the exception.
+ *
+ * @see <a href="http://java.sun.com/j2se/1.4.2/docs/guide/jndi/jndi-ldap-gl.html#EXCEPT">
+ * LDAP ResultCode to JNDI Exception Mappings</a>
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$
+ */
+public class LdapNoSuchAttributeException extends NoSuchAttributeException implements LdapException
+{
+    static final long serialVersionUID = 886120483680893537L;
+
+
+    /**
+     * @see javax.naming.directory.NoSuchAttributeException#NoSuchAttributeException()
+     */
+    public LdapNoSuchAttributeException()
+    {
+        super();
+    }
+
+
+    /**
+     * @see javax.naming.directory.NoSuchAttributeException#NoSuchAttributeException(String)
+     */
+    public LdapNoSuchAttributeException( String explanation )
+    {
+        super( explanation );
+    }
+
+
+    /**
+     * @see LdapException#getResultCode()
+     */
+    public ResultCodeEnum getResultCode()
+    {
+        return ResultCodeEnum.NOSUCHATTRIBUTE;
+    }
+}



Mime
View raw message