You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by el...@apache.org on 2011/03/20 21:17:29 UTC
svn commit: r1083558 - in /directory/shared/trunk/ldap/model/src:
main/antlr/ main/java/org/apache/directory/shared/ldap/model/exception/
main/java/org/apache/directory/shared/ldap/model/name/
test/java/org/apache/directory/shared/ldap/model/name/
Author: elecharny
Date: Sun Mar 20 20:17:29 2011
New Revision: 1083558
URL: http://svn.apache.org/viewvc?rev=1083558&view=rev
Log:
o Update some Javadoc
o Used the LdapInvalidAvaException
o Fixed the Ava.toString() method
Modified:
directory/shared/trunk/ldap/model/src/main/antlr/distinguishedName.g
directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/exception/LdapInvalidAvaException.java
directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/name/Ava.java
directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/name/AvaTest.java
directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/name/RdnTest.java
Modified: directory/shared/trunk/ldap/model/src/main/antlr/distinguishedName.g
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/main/antlr/distinguishedName.g?rev=1083558&r1=1083557&r2=1083558&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/main/antlr/distinguishedName.g (original)
+++ directory/shared/trunk/ldap/model/src/main/antlr/distinguishedName.g Sun Mar 20 20:17:29 2011
@@ -27,6 +27,7 @@ import java.util.List;
import java.util.Map;
import org.apache.directory.shared.ldap.model.exception.LdapInvalidDnException;
+import org.apache.directory.shared.ldap.model.exception.LdapInvalidAvaException;
import javax.naming.NameParser;
import org.apache.directory.shared.ldap.model.entry.StringValue;
import org.apache.directory.shared.ldap.model.entry.BinaryValue;
Modified: directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/exception/LdapInvalidAvaException.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/exception/LdapInvalidAvaException.java?rev=1083558&r1=1083557&r2=1083558&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/exception/LdapInvalidAvaException.java (original)
+++ directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/exception/LdapInvalidAvaException.java Sun Mar 20 20:17:29 2011
@@ -29,7 +29,7 @@ import org.apache.directory.shared.ldap.
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
-public class LdapInvalidAvaException extends LdapOperationException
+public class LdapInvalidAvaException extends LdapInvalidDnException
{
/** The serial version UUID */
static final long serialVersionUID = 1L;
@@ -67,7 +67,7 @@ public class LdapInvalidAvaException ext
*/
public LdapInvalidAvaException( ResultCodeEnum resultCode )
{
- super( null );
+ super( (String)null );
checkResultCode( resultCode );
this.resultCode = resultCode;
}
Modified: directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/name/Ava.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/name/Ava.java?rev=1083558&r1=1083557&r2=1083558&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/name/Ava.java (original)
+++ directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/name/Ava.java Sun Mar 20 20:17:29 2011
@@ -30,7 +30,7 @@ import org.apache.directory.shared.ldap.
import org.apache.directory.shared.ldap.model.entry.StringValue;
import org.apache.directory.shared.ldap.model.entry.Value;
import org.apache.directory.shared.ldap.model.exception.LdapException;
-import org.apache.directory.shared.ldap.model.exception.LdapInvalidDnException;
+import org.apache.directory.shared.ldap.model.exception.LdapInvalidAvaException;
import org.apache.directory.shared.ldap.model.message.ResultCodeEnum;
import org.apache.directory.shared.ldap.model.schema.AttributeType;
import org.apache.directory.shared.ldap.model.schema.MatchingRule;
@@ -122,15 +122,17 @@ public final class Ava implements Extern
*
* @param upType The User Provided type
* @param upValue The User Provided value
+ *
+ * @throws LdapInvalidAvaException If the given type or value are invalid
*/
- public Ava( String upType, byte[] upValue ) throws LdapInvalidDnException
+ public Ava( String upType, byte[] upValue ) throws LdapInvalidAvaException
{
this( null, upType, upValue );
}
/**
- * Construct aschma aware Ava containing a binary value. The AttributeType
+ * Construct a schema aware Ava containing a binary value. The AttributeType
* and value will be normalized accordingly to the given SchemaManager.
* <p>
* Note that the upValue should <b>not</b> be null or empty, or resolve
@@ -142,7 +144,7 @@ public final class Ava implements Extern
*
* @throws LdapInvalidAvaException If the given type or value are invalid
*/
- public Ava( SchemaManager schemaManager, String upType, byte[] upValue ) throws LdapInvalidDnException
+ public Ava( SchemaManager schemaManager, String upType, byte[] upValue ) throws LdapInvalidAvaException
{
if ( schemaManager != null )
{
@@ -154,7 +156,7 @@ public final class Ava implements Extern
{
String message = I18n.err( I18n.ERR_04188 );
LOG.error( message );
- throw new LdapInvalidDnException( ResultCodeEnum.INVALID_DN_SYNTAX, message );
+ throw new LdapInvalidAvaException( ResultCodeEnum.INVALID_DN_SYNTAX, message );
}
createAva( schemaManager, upType, new BinaryValue( attributeType, upValue ) );
@@ -167,38 +169,35 @@ public final class Ava implements Extern
/**
- * Construct an Ava. The type and value are normalized :
- * <li> the type is trimmed and lowercased </li>
- * <li> the value is trimmed </li>
+ * Construct an Ava with a String value.
* <p>
- * Note that the upValue should <b>not</b> be null or empty, or resolved
+ * Note that the upValue should <b>not</b> be null or empty, or resolve
* to an empty string after having trimmed it.
*
* @param upType The User Provided type
- * @param normType The normalized type
* @param upValue The User Provided value
- * @param normValue The normalized value
+ *
+ * @throws LdapInvalidAvaException If the given type or value are invalid
*/
- public Ava( String upType, String upValue ) throws LdapInvalidDnException
+ public Ava( String upType, String upValue ) throws LdapInvalidAvaException
{
this( null, upType, upValue );
}
/**
- * Construct an Ava. The type and value are normalized :
- * <li> the type is trimmed and lowercased </li>
- * <li> the value is trimmed </li>
+ * Construct a schema aware Ava with a String value.
* <p>
- * Note that the upValue should <b>not</b> be null or empty, or resolved
+ * Note that the upValue should <b>not</b> be null or empty, or resolve
* to an empty string after having trimmed it.
*
+ * @param schemaManager The SchemaManager instance
* @param upType The User Provided type
- * @param normType The normalized type
* @param upValue The User Provided value
- * @param normValue The normalized value
+ *
+ * @throws LdapInvalidAvaException If the given type or value are invalid
*/
- public Ava( SchemaManager schemaManager, String upType, String upValue ) throws LdapInvalidDnException
+ public Ava( SchemaManager schemaManager, String upType, String upValue ) throws LdapInvalidAvaException
{
if ( schemaManager != null )
{
@@ -210,7 +209,7 @@ public final class Ava implements Extern
{
String message = I18n.err( I18n.ERR_04188 );
LOG.error( message );
- throw new LdapInvalidDnException( ResultCodeEnum.INVALID_DN_SYNTAX, message );
+ throw new LdapInvalidAvaException( ResultCodeEnum.INVALID_DN_SYNTAX, message );
}
createAva( schemaManager, upType, new StringValue( attributeType, upValue ) );
@@ -223,19 +222,19 @@ public final class Ava implements Extern
/**
- * Construct an Ava. The type and value are normalized :
- * <li> the type is trimmed and lowercased </li>
- * <li> the value is trimmed </li>
+ * Construct a schema aware Ava. The AttributeType and value will be checked accordingly
+ * to the SchemaManager.
* <p>
- * Note that the upValue should <b>not</b> be null or empty, or resolved
+ * Note that the upValue should <b>not</b> be null or empty, or resolve
* to an empty string after having trimmed it.
*
+ * @param schemaManager The SchemaManager instance
* @param upType The User Provided type
- * @param normType The normalized type
* @param upValue The User Provided value
- * @param normValue The normalized value
+ *
+ * @throws LdapInvalidAvaException If the given type or value are invalid
*/
- private void createAva( SchemaManager schemaManager, String upType, Value<?> upValue ) throws LdapInvalidDnException
+ private void createAva( SchemaManager schemaManager, String upType, Value<?> upValue ) throws LdapInvalidAvaException
{
normType = attributeType.getOid();
this.upType = upType;
@@ -257,7 +256,7 @@ public final class Ava implements Extern
{
String message = I18n.err( I18n.ERR_04188 );
LOG.error( message );
- throw new LdapInvalidDnException( ResultCodeEnum.INVALID_DN_SYNTAX, message );
+ throw new LdapInvalidAvaException( ResultCodeEnum.INVALID_DN_SYNTAX, message );
}
this.upValue = upValue;
@@ -267,19 +266,21 @@ public final class Ava implements Extern
/**
- * Construct an Ava. The type and value are normalized :
- * <li> the type is trimmed and lowercased </li>
- * <li> the value is trimmed </li>
+ * Construct a schema aware Ava with a String value.
* <p>
* Note that the upValue should <b>not</b> be null or empty, or resolved
* to an empty string after having trimmed it.
*
+ * @param schemaManager The SchemaManager instance
* @param upType The User Provided type
* @param normType The normalized type
* @param upValue The User Provided value
* @param normValue The normalized value
+ *
+ * @throws LdapInvalidAvaException If the given type or value are invalid
*/
- /* No qualifier */ Ava( SchemaManager schemaManager, String upType, String normType, String upValue, String normValue ) throws LdapInvalidDnException
+ /* No qualifier */ Ava( SchemaManager schemaManager, String upType, String normType, String upValue, String normValue )
+ throws LdapInvalidAvaException
{
this( schemaManager, upType, normType, new StringValue( upValue ), new StringValue( normValue ) );
}
@@ -297,8 +298,11 @@ public final class Ava implements Extern
* @param normType The normalized type
* @param upValue The User Provided value
* @param normValue The normalized value
+ *
+ * @throws LdapInvalidAvaException If the given type or value are invalid
*/
- /* No qualifier */ Ava( SchemaManager schemaManager, String upType, String normType, byte[] upValue, byte[] normValue ) throws LdapInvalidDnException
+ /* No qualifier */ Ava( SchemaManager schemaManager, String upType, String normType, byte[] upValue, byte[] normValue )
+ throws LdapInvalidAvaException
{
this( schemaManager, upType, normType, new BinaryValue( upValue ), new BinaryValue( normValue ) );
}
@@ -316,8 +320,10 @@ public final class Ava implements Extern
* @param normType The normalized type
* @param upValue The User Provided value
* @param normValue The normalized value
+ *
+ * @throws LdapInvalidAvaException If the given type or value are invalid
*/
- private void createAva( String upType, Value<?> upValue ) throws LdapInvalidDnException
+ private void createAva( String upType, Value<?> upValue ) throws LdapInvalidAvaException
{
String upTypeTrimmed = Strings.trim(upType);
String normTypeTrimmed = Strings.trim(normType);
@@ -328,7 +334,7 @@ public final class Ava implements Extern
{
String message = I18n.err( I18n.ERR_04188 );
LOG.error( message );
- throw new LdapInvalidDnException( ResultCodeEnum.INVALID_DN_SYNTAX, message );
+ throw new LdapInvalidAvaException( ResultCodeEnum.INVALID_DN_SYNTAX, message );
}
else
{
@@ -369,19 +375,21 @@ public final class Ava implements Extern
* @param normType The normalized type
* @param upValue The User Provided value
* @param normValue The normalized value
+ *
+ * @throws LdapInvalidAvaException If the given type or value are invalid
*/
- /* No qualifier */ Ava( SchemaManager schemaManager, String upType, String normType, Value<?> upValue, Value<?> normValue ) throws LdapInvalidDnException
+ /* No qualifier */ Ava( SchemaManager schemaManager, String upType, String normType, Value<?> upValue, Value<?> normValue )
+ throws LdapInvalidAvaException
{
this.upType = upType;
this.normType = normType;
this.upValue = upValue;
this.normValue = normValue;
upName = this.upType + '=' + ( this.upValue == null ? "" : this.upValue.getString() );
- this.schemaManager = schemaManager;
if ( schemaManager != null )
{
- attributeType = schemaManager.getAttributeType( normType );
+ applySchemaManager( schemaManager );
}
}
@@ -399,9 +407,11 @@ public final class Ava implements Extern
* @param upValue The User Provided value
* @param normValue The normalized value
* @param upName The User Provided name (may be escaped)
+ *
+ * @throws LdapInvalidAvaException If the given type or value are invalid
*/
/* No qualifier */ Ava( String upType, String normType, Value<?> upValue, Value<?> normValue, String upName )
- throws LdapInvalidDnException
+ throws LdapInvalidAvaException
{
String upTypeTrimmed = Strings.trim(upType);
String normTypeTrimmed = Strings.trim(normType);
@@ -412,7 +422,7 @@ public final class Ava implements Extern
{
String message = I18n.err( I18n.ERR_04188 );
LOG.error( message );
- throw new LdapInvalidDnException( ResultCodeEnum.INVALID_DN_SYNTAX, message );
+ throw new LdapInvalidAvaException( ResultCodeEnum.INVALID_DN_SYNTAX, message );
}
else
{
@@ -436,7 +446,6 @@ public final class Ava implements Extern
this.normValue = normValue;
this.upValue = upValue;
-
this.upName = upName;
}
@@ -447,10 +456,12 @@ public final class Ava implements Extern
* used instead.
*
* @param schemaManager The SchemaManager instance to use
- * @throws LdapInvalidDnException If the Ava can't be normalized accordingly
+ * @throws LdapInvalidAvaException If the Ava can't be normalized accordingly
* to the given SchemaManager
+ *
+ * @throws LdapInvalidAvaException If the given type or value are invalid
*/
- public void applySchemaManager( SchemaManager schemaManager ) throws LdapInvalidDnException
+ public void applySchemaManager( SchemaManager schemaManager ) throws LdapInvalidAvaException
{
if ( schemaManager != null )
{
@@ -464,7 +475,7 @@ public final class Ava implements Extern
{
String message = I18n.err( I18n.ERR_04188 );
LOG.error( message );
- throw new LdapInvalidDnException( ResultCodeEnum.INVALID_DN_SYNTAX, message );
+ throw new LdapInvalidAvaException( ResultCodeEnum.INVALID_DN_SYNTAX, message );
}
normType = attributeType.getOid();
@@ -487,7 +498,7 @@ public final class Ava implements Extern
{
String message = I18n.err( I18n.ERR_04188 );
LOG.error( message );
- throw new LdapInvalidDnException( ResultCodeEnum.INVALID_DN_SYNTAX, message );
+ throw new LdapInvalidAvaException( ResultCodeEnum.INVALID_DN_SYNTAX, message );
}
}
}
@@ -828,6 +839,8 @@ public final class Ava implements Extern
* </ul>
*
* @see Externalizable#readExternal(ObjectInput)
+ *
+ * @throws IoException If the Ava can't be written in the stream
*/
public void writeExternal( ObjectOutput out ) throws IOException
{
@@ -911,6 +924,9 @@ public final class Ava implements Extern
* method
*
* @see Externalizable#readExternal(ObjectInput)
+ *
+ * @throws IOException If the Ava can't b written to the stream
+ * @throws ClassNotFoundException If we can't deserialize an Ava from the stream
*/
public void readExternal( ObjectInput in ) throws IOException, ClassNotFoundException
{
@@ -971,7 +987,7 @@ public final class Ava implements Extern
/**
- * Tells if the Ava is schema aware or not
+ * Tells if the Ava is schema aware or not.
*
* @return true if the Ava is schema aware
*/
@@ -982,26 +998,12 @@ public final class Ava implements Extern
/**
- * A String representation of a Ava.
+ * A String representation of an Ava, as provided by the user.
*
- * @return A string representing a Ava
+ * @return A string representing an Ava
*/
public String toString()
{
- StringBuffer sb = new StringBuffer();
-
- if ( Strings.isEmpty( normType) || Strings.isEmpty(normType.trim()) )
- {
- return "";
- }
-
- sb.append( upType ).append( "=" );
-
- if ( upValue != null )
- {
- sb.append( upValue.getString() );
- }
-
- return sb.toString();
+ return upName;
}
}
Modified: directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/name/AvaTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/name/AvaTest.java?rev=1083558&r1=1083557&r2=1083558&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/name/AvaTest.java (original)
+++ directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/name/AvaTest.java Sun Mar 20 20:17:29 2011
@@ -26,7 +26,7 @@ import static org.junit.Assert.assertTru
import static org.junit.Assert.fail;
import org.apache.directory.shared.ldap.model.exception.LdapException;
-import org.apache.directory.shared.ldap.model.exception.LdapInvalidDnException;
+import org.apache.directory.shared.ldap.model.exception.LdapInvalidAvaException;
import org.apache.directory.shared.ldap.model.schema.SchemaManager;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -116,7 +116,7 @@ public class AvaTest
atav = new Ava( schemaManager, null, (String)null );
fail();
}
- catch ( LdapInvalidDnException lide )
+ catch ( LdapInvalidAvaException lide )
{
assertTrue( true );
}
Modified: directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/name/RdnTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/name/RdnTest.java?rev=1083558&r1=1083557&r2=1083558&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/name/RdnTest.java (original)
+++ directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/name/RdnTest.java Sun Mar 20 20:17:29 2011
@@ -1217,7 +1217,7 @@ public class RdnTest
{
Rdn rdn = new Rdn( "cn=John + sn=Doe" );
- String[] expected = new String[]{ "cn=John", "sn=Doe" };
+ String[] expected = new String[]{ "cn=John ", " sn=Doe" };
int i = 0;
for ( Ava ava : rdn )