if ( change.size() == 0 ) {  throw new LdapInvalidAttributeValueException( "No value is not a valid value for an attribute.", ResultCodeEnum.INVALIDATTRIBUTESYNTAX ); }
    public void modify( NextInterceptor next, LdapDN name, int modOp, Attributes mods ) throws NamingException    {        // First, we get the entry from the backend. If it does not exist, then we throw an exception        Attributes entry = nexus.lookup( name );                if ( entry == null )        {            log.error( "No entry with this name :{}", name );            throw new LdapNameNotFoundException( "The entry which name is " + name + " is not found." );        }                Attribute objectClass = getResultantObjectClasses( modOp, mods.get( "objectClass" ), entry.get( "objectClass" ) );        ObjectClassRegistry ocRegistry = this.globalRegistries.getObjectClassRegistry();        AttributeTypeRegistry atRegistry = this.globalRegistries.getAttributeTypeRegistry();        NamingEnumeration changes = mods.getIDs();                Attributes tmpEntryForAdd = (Attributes)entry.clone();                while ( changes.hasMore() )        {            String id = ( String ) changes.next();            Attribute change = mods.get( id );            if ( !atRegistry.hasAttributeType( change.getID() ) && !objectClass.contains( "extensibleObject" ) )            {                throw new LdapInvalidAttributeIdentifierException( "unrecognized attributeID " + change.getID() );            }                        if ( modOp == DirContext.ADD_ATTRIBUTE )            {                tmpEntryForAdd.put( change );            }            if ( modOp == DirContext.REMOVE_ATTRIBUTE && entry.get( change.getID() ) == null )            {                throw new LdapNoSuchAttributeException();            }            // for required attributes we need to check if all values are removed            // if so then we have a schema violation that must be thrown            if ( modOp == DirContext.REMOVE_ATTRIBUTE && isRequired( change.getID(), objectClass )                && isCompleteRemoval( change, entry ) )            {                throw new LdapSchemaViolationException( ResultCodeEnum.OBJECTCLASSVIOLATION );            }        }        if ( modOp == DirContext.ADD_ATTRIBUTE )        {            assertNumberOfAttributeValuesValid( tmpEntryForAdd );        }                if ( modOp == DirContext.REMOVE_ATTRIBUTE )        {            SchemaChecker.preventRdnChangeOnModifyRemove( name, modOp, mods );            SchemaChecker.preventStructuralClassRemovalOnModifyRemove( ocRegistry, name, modOp, mods, objectClass );        }        if ( modOp == DirContext.REPLACE_ATTRIBUTE )        {            SchemaChecker.preventRdnChangeOnModifyReplace( name, modOp, mods );            SchemaChecker.preventStructuralClassRemovalOnModifyReplace( ocRegistry, name, modOp, mods );            assertNumberOfAttributeValuesValid( mods );        }        // let's figure out if we need to add or take away from mods to maintain         // the objectClass attribute with it's hierarchy of ancestors         if ( mods.get( "objectClass" ) != null )        {            Attribute alteredObjectClass = ( Attribute ) objectClass.clone();            alterObjectClasses( alteredObjectClass, ocRegistry );            if ( !alteredObjectClass.equals( objectClass ) )            {                Attribute ocMods = mods.get( "objectClass" );                switch ( modOp )                {                    case ( DirContext.ADD_ATTRIBUTE  ):                        if ( ocMods.contains( "top" ) )                        {                            ocMods.remove( "top" );                        }                        for ( int ii = 0; ii < alteredObjectClass.size(); ii++ )                        {                            if ( !objectClass.contains( alteredObjectClass.get( ii ) ) )                            {                                ocMods.add( alteredObjectClass.get( ii ) );                            }                        }                        break;                                            case ( DirContext.REMOVE_ATTRIBUTE  ):                        for ( int ii = 0; ii < alteredObjectClass.size(); ii++ )                        {                            if ( !objectClass.contains( alteredObjectClass.get( ii ) ) )                            {                                ocMods.remove( alteredObjectClass.get( ii ) );                            }                        }                        break;                                            case ( DirContext.REPLACE_ATTRIBUTE  ):                        for ( int ii = 0; ii < alteredObjectClass.size(); ii++ )                        {                            if ( !objectClass.contains( alteredObjectClass.get( ii ) ) )                            {                                ocMods.add( alteredObjectClass.get( ii ) );                            }                        }                        break;                                            default:                        break;                }            }        }        next.modify( name, modOp, mods );    }