directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r291028 - /directory/protocol-providers/ldap/trunk/src/main/java/org/apache/ldap/server/protocol/ModifyHandler.java
Date Thu, 22 Sep 2005 22:44:01 GMT
Author: akarasulu
Date: Thu Sep 22 15:43:59 2005
New Revision: 291028

URL: http://svn.apache.org/viewcvs?rev=291028&view=rev
Log:
moved schema checks into the schema checking interceptor

Modified:
    directory/protocol-providers/ldap/trunk/src/main/java/org/apache/ldap/server/protocol/ModifyHandler.java

Modified: directory/protocol-providers/ldap/trunk/src/main/java/org/apache/ldap/server/protocol/ModifyHandler.java
URL: http://svn.apache.org/viewcvs/directory/protocol-providers/ldap/trunk/src/main/java/org/apache/ldap/server/protocol/ModifyHandler.java?rev=291028&r1=291027&r2=291028&view=diff
==============================================================================
--- directory/protocol-providers/ldap/trunk/src/main/java/org/apache/ldap/server/protocol/ModifyHandler.java
(original)
+++ directory/protocol-providers/ldap/trunk/src/main/java/org/apache/ldap/server/protocol/ModifyHandler.java
Thu Sep 22 15:43:59 2005
@@ -19,9 +19,6 @@
 
 import javax.naming.NamingException;
 import javax.naming.directory.ModificationItem;
-import javax.naming.directory.DirContext;
-import javax.naming.directory.Attributes;
-import javax.naming.directory.Attribute;
 import javax.naming.ldap.LdapContext;
 
 import org.apache.ldap.common.exception.LdapException;
@@ -31,12 +28,6 @@
 import org.apache.ldap.common.message.ModifyResponseImpl;
 import org.apache.ldap.common.message.ResultCodeEnum;
 import org.apache.ldap.common.util.ExceptionUtils;
-import org.apache.ldap.common.schema.ObjectClass;
-import org.apache.ldap.common.schema.AttributeType;
-import org.apache.ldap.server.schema.AttributeTypeRegistry;
-import org.apache.ldap.server.schema.ObjectClassRegistry;
-import org.apache.ldap.server.schema.OidRegistry;
-import org.apache.ldap.server.jndi.ContextFactoryService;
 import org.apache.mina.protocol.ProtocolSession;
 import org.apache.mina.protocol.handler.MessageHandler;
 
@@ -56,31 +47,6 @@
     private static final ModificationItem[] EMPTY = new ModificationItem[0];
 
 
-    public boolean isRequired( String attrId, Attribute objectClass ) throws NamingException
-    {
-        OidRegistry oidRegistry = ContextFactoryService.getInstance().
-                getConfiguration().getGlobalRegistries().getOidRegistry();
-        ObjectClassRegistry registry = ContextFactoryService.getInstance().
-                getConfiguration().getGlobalRegistries().getObjectClassRegistry();
-
-        String attrOid = oidRegistry.getOid( attrId );
-        for ( int ii = 0; ii < objectClass.size(); ii++ )
-        {
-            ObjectClass ocSpec = registry.lookup( ( String ) objectClass.get( ii ) );
-            AttributeType[] mustList = ocSpec.getMustList();
-            for ( int jj = 0; jj < mustList.length; jj++ )
-            {
-                if ( mustList[jj].getOid().equals( attrOid ) )
-                {
-                    return true;
-                }
-            }
-        }
-
-        return false;
-    }
-
-
     public void messageReceived( ProtocolSession session, Object request )
     {
         ModifyRequest req = ( ModifyRequest ) request;
@@ -90,54 +56,7 @@
         try
         {
             LdapContext ctx = SessionRegistry.getSingleton().getLdapContext( session, null,
true );
-            Attributes entry = ctx.getAttributes( req.getName() );
             Object[] mods = req.getModificationItems().toArray( EMPTY );
-
-            /*
-             * Check first to see if the modification request is valid by looking
-             * at the attributes being modified. Some modification operations are
-             * invalid if the attributes they modify do not exist or are undefined
-             */
-            AttributeTypeRegistry registry = ContextFactoryService.getInstance().
-                    getConfiguration().getGlobalRegistries().getAttributeTypeRegistry();
-
-            // As I write this code I am begining to realize that this should really
-            // be located within the schema interceptor for schema checking however
-            // resolution of what kind of operation is being performed is often lost
-            // @todo figure out how to best integrate this code into the schema interceptor
-
-            for ( int ii = 0; ii < mods.length; ii++ )
-            {
-                ModificationItem item = ( ModificationItem ) mods[ii];
-                String id = item.getAttribute().getID();
-                Attribute attr = entry.get( id );
-
-                if ( ! registry.hasAttributeType( id ) )
-                {
-                    resp.getLdapResult().setResultCode( ResultCodeEnum.UNDEFINEDATTRIBUTETYPE
);
-                    resp.getLdapResult().setMatchedDn( req.getName() );
-                    session.write( resp );
-                    return;
-                }
-
-
-                if ( item.getModificationOp() == DirContext.REMOVE_ATTRIBUTE && attr
== null )
-                {
-                    resp.getLdapResult().setResultCode( ResultCodeEnum.NOSUCHATTRIBUTE );
-                    resp.getLdapResult().setMatchedDn( req.getName() );
-                    session.write( resp );
-                    return;
-                }
-
-                if ( item.getModificationOp() == DirContext.REMOVE_ATTRIBUTE && isRequired(
id, entry.get( "objectClass" ) ) )
-                {
-                    resp.getLdapResult().setResultCode( ResultCodeEnum.OBJECTCLASSVIOLATION
);
-                    resp.getLdapResult().setMatchedDn( req.getName() );
-                    session.write( resp );
-                    return;
-                }
-            }
-
             ctx.modifyAttributes( req.getName(), ( ModificationItem[] ) mods );
         }
         catch ( NamingException e )



Mime
View raw message