You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by ak...@apache.org on 2007/10/22 09:00:24 UTC

svn commit: r587014 - in /directory: apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/ apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/schema/ shared/branches/bigbang/ldap/src/main/...

Author: akarasulu
Date: Mon Oct 22 00:00:23 2007
New Revision: 587014

URL: http://svn.apache.org/viewvc?rev=587014&view=rev
Log:
experimenting with server entries: doco and tests to come

Added:
    directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/InvalidValueException.java
    directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/ServerAttribute.java
    directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/ServerBinaryValue.java
    directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/ServerEntry.java
    directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/ServerStringValue.java
    directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/ServerValue.java
    directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/schema/SchemaService.java
Removed:
    directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/server/
Modified:
    directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/EntryAttribute.java
    directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/StringValue.java

Added: directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/InvalidValueException.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/InvalidValueException.java?rev=587014&view=auto
==============================================================================
--- directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/InvalidValueException.java (added)
+++ directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/InvalidValueException.java Mon Oct 22 00:00:23 2007
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.directory.server.core.entry;
+
+
+/**
+ * Document me!
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class InvalidValueException extends Exception
+{
+}

Added: directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/ServerAttribute.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/ServerAttribute.java?rev=587014&view=auto
==============================================================================
--- directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/ServerAttribute.java (added)
+++ directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/ServerAttribute.java Mon Oct 22 00:00:23 2007
@@ -0,0 +1,172 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.directory.server.core.entry;
+
+
+import org.apache.directory.shared.ldap.NotImplementedException;
+import org.apache.directory.shared.ldap.entry.EntryAttribute;
+import org.apache.directory.shared.ldap.entry.Value;
+import org.apache.directory.shared.ldap.schema.AttributeType;
+
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+
+
+/**
+ * Document me!
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class ServerAttribute implements EntryAttribute
+{
+    private Set<Value<?>> values = new HashSet<Value<?>>();
+    private AttributeType attributeType;
+
+
+    public ServerAttribute( AttributeType attributeType )
+    {
+        this.attributeType = attributeType;
+    }
+
+
+    /**
+     * Gets the attribute type associated with this ServerAttribute.
+     *
+     * @return the attributeType associated with this entry attribute
+     */
+    public AttributeType getType()
+    {
+        return attributeType;
+    }
+
+
+    /**
+     * Checks to see if this attribute is valid along with the values it contains.
+     *
+     * @return true if the attribute and it's values are valid, false otherwise
+     */
+    boolean isValid()
+    {
+        throw new NotImplementedException();
+    }
+
+
+    public boolean add( Value<?> val )
+    {
+        return values.add( val );
+    }
+
+
+    public boolean add( String val )
+    {
+        return values.add( new ServerStringValue( attributeType, val ) );
+    }
+
+
+    public boolean add( byte[] val )
+    {
+        return values.add( new ServerBinaryValue( attributeType, val ) );
+    }
+
+
+    public void clear()
+    {
+        values.clear();
+    }
+
+
+    @SuppressWarnings ( { "CloneDoesntCallSuperClone" } )
+    public ServerAttribute clone() throws CloneNotSupportedException
+    {
+        Set<Value<?>> clonedValues = new HashSet<Value<?>>();
+        for ( Value value : values )
+        {
+            clonedValues.add( value.clone() );
+        }
+
+        ServerAttribute cloned = new ServerAttribute( attributeType );
+        cloned.values = clonedValues;
+        return cloned;
+    }
+
+
+    public boolean contains( Value<?> val )
+    {
+        return values.contains( val );
+    }
+
+
+    public boolean contains( String val )
+    {
+        ServerStringValue ssv = new ServerStringValue( attributeType, val );
+        return values.contains( ssv );
+    }
+
+
+    public boolean contains( byte[] val )
+    {
+        ServerBinaryValue sbv = new ServerBinaryValue( attributeType, val );
+        return values.contains( sbv );
+    }
+
+
+    public Value<?> get()
+    {
+        if ( values.isEmpty() )
+        {
+            return null;
+        }
+        
+        return values.iterator().next();
+    }
+
+
+    public Iterator<Value<?>> getAll()
+    {
+        return values.iterator();
+    }
+
+
+    public int size()
+    {
+        return values.size();
+    }
+
+
+    public boolean remove( Value<?> val )
+    {
+        return values.remove( val );
+    }
+
+
+    public boolean remove( byte[] val )
+    {
+        ServerBinaryValue sbv = new ServerBinaryValue( attributeType, val );
+        return values.remove( sbv );
+    }
+
+
+    public boolean remove( String val )
+    {
+        ServerStringValue ssv = new ServerStringValue( attributeType, val );
+        return values.remove( ssv );
+    }
+}

Added: directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/ServerBinaryValue.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/ServerBinaryValue.java?rev=587014&view=auto
==============================================================================
--- directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/ServerBinaryValue.java (added)
+++ directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/ServerBinaryValue.java Mon Oct 22 00:00:23 2007
@@ -0,0 +1,204 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.directory.server.core.entry;
+
+
+import org.apache.directory.shared.ldap.entry.BinaryValue;
+import org.apache.directory.shared.ldap.entry.Value;
+import org.apache.directory.shared.ldap.schema.AttributeType;
+import org.apache.directory.shared.ldap.schema.Normalizer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.naming.NamingException;
+import java.util.Arrays;
+
+
+/**
+ * A server side value which is also a StringValue.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class ServerBinaryValue extends BinaryValue implements Value<byte[]>
+{
+    private static final Logger LOG = LoggerFactory.getLogger( ServerBinaryValue.class );
+
+    @SuppressWarnings ( { "AnalyzingVariableNaming" } )
+    static final long serialVersionUID = 2L;
+
+    private byte[] normalizedValue;
+    private AttributeType attributeType;
+
+
+    public ServerBinaryValue( AttributeType attributeType ) throws NamingException
+    {
+        if ( attributeType.getSyntax().isHumanReadable() )
+        {
+            LOG.warn( "Treating a value of a human readible attribute {} as binary: ", attributeType.getName() );
+        }
+
+        this.attributeType = attributeType;
+    }
+
+
+    public ServerBinaryValue( AttributeType attributeType, byte[] wrapped )
+    {
+        this.attributeType = attributeType;
+        super.set( wrapped );
+    }
+
+
+    public byte[] getNormalizedValue() throws NamingException
+    {
+        if ( get() == null )
+        {
+            return null;
+        }
+
+        if ( normalizedValue == null )
+        {
+            // search for matchingRules with a normalizer we can use based on
+            // the parent attribute type this attribute value is intended for
+            Normalizer normalizer = attributeType.getEquality().getNormalizer();
+
+            if ( normalizer == null )
+            {
+                normalizer = attributeType.getOrdering().getNormalizer();
+            }
+
+            if ( normalizer == null )
+            {
+                normalizer = attributeType.getSubstr().getNormalizer();
+            }
+
+            // at this point if we still have no normalizer then presume as-is
+            // normalization - the value is the same as the normalized value
+            if ( normalizer == null )
+            {
+                normalizedValue = get();
+            }
+            else
+            {
+                normalizedValue = ( byte[] ) normalizer.normalize( get() );
+            }
+        }
+
+        return normalizedValue;
+    }
+
+
+    public final void set( byte[] wrapped )
+    {
+        normalizedValue = null;
+        super.set( wrapped );
+    }
+
+
+    public final boolean isValid() throws NamingException
+    {
+        return attributeType.getSyntax().getSyntaxChecker().isValidSyntax( get() );
+    }
+
+
+    @SuppressWarnings ( { "CloneDoesntCallSuperClone" } )
+    public final ServerBinaryValue clone() throws CloneNotSupportedException
+    {
+        ServerBinaryValue copy = new ServerBinaryValue( attributeType, get() );
+        copy.normalizedValue = normalizedValue;
+        return copy;
+    }
+
+
+    /**
+     * @see Object#hashCode()
+     */
+    public int hashCode()
+    {
+        // return zero if the value is null so only one null value can be
+        // stored in an attribute - the string version does the same
+        if ( get() == null )
+        {
+            return 0;
+        }
+
+        try
+        {
+            return getNormalizedValue().hashCode();
+        }
+        catch ( NamingException e )
+        {
+            LOG.warn( "Failed to get normalized value while trying to get hashCode: {}", toString() , e );
+
+            // recover by using non-normalized values
+            return get().hashCode();
+        }
+    }
+
+
+    /**
+     * @see Object#equals(Object)
+     */
+    public boolean equals( Object obj )
+    {
+        if ( this == obj )
+        {
+            return true;
+        }
+
+        if ( obj == null )
+        {
+            return false;
+        }
+
+        if ( ! ( obj instanceof ServerBinaryValue ) )
+        {
+            return false;
+        }
+
+        ServerBinaryValue other = ( ServerBinaryValue ) obj;
+        if ( get() == null && other.get() == null )
+        {
+            return true;
+        }
+
+        //noinspection SimplifiableIfStatement
+        if ( get() == null && other.get() != null ||
+             get() != null && other.get() == null )
+        {
+            return false;
+        }
+
+        // now unlike regular values we have to compare the normalized values
+        try
+        {
+            return Arrays.equals( getNormalizedValue(), other.getNormalizedValue() );
+        }
+        catch ( NamingException e )
+        {
+            // 1st this is a warning because we're recovering from it and secondly
+            // we build big string since waste is not an issue when exception handling
+            LOG.warn( "Failed to get normalized value while trying to compare StringValues: "
+                    + toString() + " and " + other.toString() , e );
+
+            // recover by comparing non-normalized values
+            return Arrays.equals( get(), other.get() );
+        }
+    }
+}
\ No newline at end of file

Added: directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/ServerEntry.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/ServerEntry.java?rev=587014&view=auto
==============================================================================
--- directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/ServerEntry.java (added)
+++ directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/ServerEntry.java Mon Oct 22 00:00:23 2007
@@ -0,0 +1,198 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.directory.server.core.entry;
+
+
+import org.apache.directory.shared.asn1.primitives.OID;
+import org.apache.directory.shared.ldap.entry.Entry;
+import org.apache.directory.shared.ldap.entry.Value;
+import org.apache.directory.shared.ldap.schema.AttributeType;
+import org.apache.directory.shared.ldap.schema.ObjectClass;
+
+import java.util.Set;
+
+
+/**
+ * Document me!
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public interface ServerEntry extends Entry
+{
+    // -----------------------------------------------------------------------
+    // Schema Related Methods
+    // -----------------------------------------------------------------------
+
+
+    /**
+     * Gets the first structural objectClass that it can find within the entry.
+     * If the entry is inconsistent and contains no objectClass attribute then
+     * null is returned.  If the entry is inconsistent and contains more than
+     * one structural objectClass which is illegal, then the first to be found
+     * will be returned.
+     *
+     * @return the first structural objectClass found in this entry
+     */
+    ObjectClass getStructuralObjectClass();
+
+
+    /**
+     * Gets all the auxiliary objectClasses that it can find within the entry.
+     * If the entry is inconsistent and contains no objectClass attribute then
+     * the empty set is returned.
+     *
+     * @return the set of auxiliary objectClasses found in this entry
+     */
+    Set<ObjectClass> getAuxiliaryObjectClasses();
+
+
+    /**
+     * Gets the objectClasses associated with this entry. If there is no
+     * objectClass attribute contained within this entry then an empty set
+     * is returned.
+     *
+     * @return the objectClasses which govern the structure of this entry
+     */
+    Set<ObjectClass> getObjectClasses();
+
+
+    /**
+     * Gets the combinded set of all required attributes for this entry across
+     * all objectClasses.
+     *
+     * @return the combinded set of all required attributes
+     */
+    Set<ServerAttribute> getMustList();
+
+
+    /**
+     * Gets the combined set of all optional attributes for this entry across
+     * all objectClasses.
+     *
+     * @return the combined set of all optional attributes
+     */
+    Set<ServerAttribute> getMayList();
+
+
+    /**
+     * Fail fast check performed to determine entry consistency according to schema
+     * characteristics.
+     *
+     * @return true if the entry, it's attributes and their values are consistent
+     * with the schema
+     */
+    boolean isValid();
+
+
+    // -----------------------------------------------------------------------
+    // Container (get/put/remove) Methods
+    // -----------------------------------------------------------------------
+
+
+    /**
+     * Returns the attribute with the specified OID. The return value
+     * is <code>null</code> if no match is found.
+     *
+     * @param attributeType the type of the attribute
+     * @return the attribute with the specified OID
+     */
+    ServerAttribute get( AttributeType attributeType );
+
+
+    /**
+     * Places a non-null attribute in the attribute collection. If there is
+     * already an attribute with the same OID as the new attribute, the old one
+     * is removed from the collection and is returned by this method. If there
+     * was no attribute with the same OID the return value is <code>null</code>.
+     *
+     * @param attribute the attribute to be put
+     * @return the old attribute with the same OID, if exists; otherwise
+     *         <code>null</code>
+     */
+    ServerAttribute put( ServerAttribute attribute );
+
+
+    /**
+     * Places a new attribute with the supplied OID and value into the attribute
+     * collection. If there is already an attribute with the same OID, the old
+     * one is removed from the collection and is returned by this method. If
+     * there was no attribute with the same OID the return value is
+     * <code>null</code>.
+     *
+     * This method provides a mechanism to put an attribute with a
+     * <code>null</code> value: the value of <code>obj</code> may be
+     * <code>null</code>.
+     *
+     * @param attributeType the type of the new attribute to be put
+     * @param val the value of the new attribute to be put
+     * @return the old attribute with the same OID, if exists; otherwise
+     *         <code>null</code>
+     */
+    ServerAttribute put( AttributeType attributeType, Value<?> val );
+
+
+    /**
+     * Places a new attribute with the supplied OID and value into the attribute
+     * collection. If there is already an attribute with the same OID, the old
+     * one is removed from the collection and is returned by this method. If
+     * there was no attribute with the same OID the return value is
+     * <code>null</code>.
+     *
+     * This method provides a mechanism to put an attribute with a
+     * <code>null</code> value: the value of <code>obj</code> may be
+     * <code>null</code>.
+     *
+     * @param attributeType the type of the new attribute to be put
+     * @param val the value of the new attribute to be put
+     * @return the old attribute with the same identifier, if exists; otherwise
+     *         <code>null</code>
+     */
+    ServerAttribute put( AttributeType attributeType, String val );
+
+
+    /**
+     * Places a new attribute with the supplied OID and value into the attribute
+     * collection. If there is already an attribute with the same OID, the old
+     * one is removed from the collection and is returned by this method. If
+     * there was no attribute with the same OID the return value is
+     * <code>null</code>.
+     *
+     * This method provides a mechanism to put an attribute with a
+     * <code>null</code> value: the value of <code>obj</code> may be
+     * <code>null</code>.
+     *
+     * @param attributeType the type of the new attribute to be put
+     * @param val the value of the new attribute to be put
+     * @return the old attribute with the same identifier, if exists; otherwise
+     *         <code>null</code>
+     */
+    ServerAttribute put( AttributeType attributeType, byte[] val );
+
+
+    /**
+     * Removes the attribute with the specified alias. The removed attribute is
+     * returned by this method. If there is no attribute with the specified OID,
+     * the return value is <code>null</code>.
+     *
+     * @param oid the numeric object identifier of the attribute to be removed
+     * @return the removed attribute, if exists; otherwise <code>null</code>
+     */
+    ServerAttribute remove( OID oid );
+}

Added: directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/ServerStringValue.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/ServerStringValue.java?rev=587014&view=auto
==============================================================================
--- directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/ServerStringValue.java (added)
+++ directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/ServerStringValue.java Mon Oct 22 00:00:23 2007
@@ -0,0 +1,206 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.directory.server.core.entry;
+
+
+import org.apache.directory.shared.ldap.entry.StringValue;
+import org.apache.directory.shared.ldap.entry.Value;
+import org.apache.directory.shared.ldap.schema.AttributeType;
+import org.apache.directory.shared.ldap.schema.Normalizer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.naming.NamingException;
+
+
+/**
+ * A server side value which is also a StringValue.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class ServerStringValue extends StringValue implements Value<String>
+{
+    private static final Logger LOG = LoggerFactory.getLogger( ServerStringValue.class );
+
+    @SuppressWarnings ( { "AnalyzingVariableNaming" } )
+    static final long serialVersionUID = 2L;
+
+    private String normalizedValue;
+
+    // use this to lookup the attributeType when deserializing
+    @SuppressWarnings ( { "UnusedDeclaration" } )
+    private final String oid;
+
+    // do not serialize the schema entity graph associated with the type
+    private transient AttributeType attributeType;
+
+
+    public ServerStringValue( AttributeType attributeType )
+    {
+        this.attributeType = attributeType;
+        this.oid = attributeType.getOid();
+    }
+
+
+    public ServerStringValue( AttributeType attributeType, String wrapped )
+    {
+        this.attributeType = attributeType;
+        this.oid = attributeType.getOid();
+        super.set( wrapped );
+    }
+
+
+    public String getNormalizedValue() throws NamingException
+    {
+        if ( get() == null )
+        {
+            return null;
+        }
+
+        if ( normalizedValue == null )
+        {
+            // search for matchingRules with a normalizer we can use based on
+            // the parent attribute type this attribute value is intended for
+            Normalizer normalizer = attributeType.getEquality().getNormalizer();
+
+            if ( normalizer == null )
+            {
+                normalizer = attributeType.getOrdering().getNormalizer();
+            }
+
+            if ( normalizer == null )
+            {
+                normalizer = attributeType.getSubstr().getNormalizer();
+            }
+
+            // at this point if we still have no normalizer then presume as-is
+            // normalization - the value is the same as the normalized value
+            if ( normalizer == null )
+            {
+                normalizedValue = get();
+            }
+            else
+            {
+                normalizedValue = ( String ) normalizer.normalize( get() );
+            }
+        }
+
+        return normalizedValue;
+    }
+
+
+    public final void set( String wrapped )
+    {
+        normalizedValue = null;
+        super.set( wrapped );
+    }
+
+
+    public final boolean isValid() throws NamingException
+    {
+        return attributeType.getSyntax().getSyntaxChecker().isValidSyntax( get() );
+    }
+
+
+    @SuppressWarnings ( { "CloneDoesntCallSuperClone" } )
+    public final ServerStringValue clone() throws CloneNotSupportedException
+    {
+        ServerStringValue copy = new ServerStringValue( attributeType, get() );
+        copy.normalizedValue = normalizedValue;
+        return copy;
+    }
+
+
+    /**
+     * @see Object#hashCode()
+     */
+    public int hashCode()
+    {
+        // return zero if the value is null so only one null value can be
+        // stored in an attribute - the binary version does the same 
+        if ( get() == null )
+        {
+            return 0;
+        }
+
+        try
+        {
+            return getNormalizedValue().hashCode();
+        }
+        catch ( NamingException e )
+        {
+            LOG.warn( "Failed to get normalized value while trying to get hashCode: {}", toString() , e );
+
+            // recover by using non-normalized values
+            return get().hashCode();
+        }
+    }
+
+
+    /**
+     * @see Object#equals(Object)
+     */
+    public boolean equals( Object obj )
+    {
+        if ( this == obj )
+        {
+            return true;
+        }
+
+        if ( obj == null )
+        {
+            return false;
+        }
+
+        if ( ! ( obj instanceof ServerStringValue ) )
+        {
+            return false;
+        }
+
+        ServerStringValue other = ( ServerStringValue ) obj;
+        if ( get() == null && other.get() == null )
+        {
+            return true;
+        }
+
+        //noinspection SimplifiableIfStatement
+        if ( get() == null && other.get() != null ||
+             get() != null && other.get() == null )
+        {
+            return false;
+        }
+
+        // now unlike regular values we have to compare the normalized values
+        try
+        {
+            return getNormalizedValue().equals( other.getNormalizedValue() );
+        }
+        catch ( NamingException e )
+        {
+            // 1st this is a warning because we're recovering from it and secondly
+            // we build big string since waste is not an issue when exception handling
+            LOG.warn( "Failed to get normalized value while trying to compare StringValues: "
+                    + toString() + " and " + other.toString() , e );
+
+            // recover by comparing non-normalized values
+            return get().equals( other.get() );
+        }
+    }
+}

Added: directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/ServerValue.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/ServerValue.java?rev=587014&view=auto
==============================================================================
--- directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/ServerValue.java (added)
+++ directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/ServerValue.java Mon Oct 22 00:00:23 2007
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.directory.server.core.entry;
+
+import org.apache.directory.shared.ldap.entry.Value;
+import org.apache.directory.server.core.entry.InvalidValueException;
+
+import javax.naming.NamingException;
+
+
+/**
+ * Document me!
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public interface ServerValue<T> extends Value
+{
+    /**
+     * Gets the normalized representation for the wrapped value of this ServerValue
+     * wrapper. Implementations
+     *
+     * @return the normalized wrapped value
+     * @throws InvalidValueException if the value is not valid
+     * @throws NamingException if resolution of needed schema entities fail
+     */
+    T getNormalizedValue() throws InvalidValueException, NamingException;
+
+    boolean isValid() throws NamingException;
+}

Added: directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/schema/SchemaService.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/schema/SchemaService.java?rev=587014&view=auto
==============================================================================
--- directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/schema/SchemaService.java (added)
+++ directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/schema/SchemaService.java Mon Oct 22 00:00:23 2007
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.directory.server.core.schema;
+
+
+import org.apache.directory.server.schema.registries.Registries;
+
+
+/**
+ * Document me!
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class SchemaService
+{
+    private Registries registries;
+
+
+    public Registries getRegistries()
+    {
+        return registries;
+    }
+}

Modified: directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/EntryAttribute.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/EntryAttribute.java?rev=587014&r1=587013&r2=587014&view=diff
==============================================================================
--- directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/EntryAttribute.java (original)
+++ directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/EntryAttribute.java Mon Oct 22 00:00:23 2007
@@ -90,7 +90,7 @@
      *
      * @return a deep clone of this attribute
      */
-    EntryAttribute clone();
+    EntryAttribute clone() throws CloneNotSupportedException;
 
 
     /**

Modified: directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/StringValue.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/StringValue.java?rev=587014&r1=587013&r2=587014&view=diff
==============================================================================
--- directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/StringValue.java (original)
+++ directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/StringValue.java Mon Oct 22 00:00:23 2007
@@ -68,7 +68,12 @@
      */
     public int hashCode()
     {
-        return wrapped.hashCode();
+        if ( wrapped != null )
+        {
+            return wrapped.hashCode();
+        }
+
+        return super.hashCode();
     }