directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kayyag...@apache.org
Subject svn commit: r1538931 - in /directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap: LdapResourceProvider.java LdapUtil.java handlers/GroupsAttributeHandler.java handlers/LdapAttributeHandler.java handlers/MembersAttributeHandler.java
Date Tue, 05 Nov 2013 10:47:29 GMT
Author: kayyagari
Date: Tue Nov  5 10:47:28 2013
New Revision: 1538931

URL: http://svn.apache.org/r1538931
Log:
handling complex and multivalued attributes in searches

Modified:
    directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/LdapResourceProvider.java
    directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/LdapUtil.java
    directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/handlers/GroupsAttributeHandler.java
    directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/handlers/LdapAttributeHandler.java
    directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/handlers/MembersAttributeHandler.java

Modified: directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/LdapResourceProvider.java
URL: http://svn.apache.org/viewvc/directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/LdapResourceProvider.java?rev=1538931&r1=1538930&r2=1538931&view=diff
==============================================================================
--- directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/LdapResourceProvider.java
(original)
+++ directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/LdapResourceProvider.java
Tue Nov  5 10:47:28 2013
@@ -29,6 +29,7 @@ import java.io.InputStream;
 import java.net.URL;
 import java.util.ArrayList;
 import java.util.Collection;
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
@@ -232,7 +233,7 @@ public class LdapResourceProvider implem
     }
 
 
-    public AttributeType getLdapType( String scimAtName, ResourceSchema schema )
+    public List<AttributeType> getLdapTypes( String scimAtName, ResourceSchema schema
)
     {
         scimAtName = scimAtName.trim();
         int colonPos = scimAtName.lastIndexOf( ":" );
@@ -256,36 +257,57 @@ public class LdapResourceProvider implem
             
             if( Strings.isNotEmpty( st.getMappedTo() ) )
             {
-                return ldapSchema.getAttributeType( st.getMappedTo() );
+                return Collections.singletonList( ldapSchema.getAttributeType( st.getMappedTo()
) );
             }
             else if ( st.getAtHandlerName() != null )
             {
                 LdapAttributeHandler atHandler = ( LdapAttributeHandler ) schema.getHandler(
st.getAtHandlerName() );
-                return atHandler.getLdapAtType( st, "", schema, ldapSchema );
+                return atHandler.getLdapAtTypes( st, "", schema, ldapSchema );
             }
         }
-        else // a complex or multivalued attribute with a handler
+        else if ( bt != null )// a complex or multivalued attribute with a handler
         {
             int pos = scimAtName.indexOf( '.' );
             
-            if( pos <= 0 )
+            String remainingScimAttributePath = null;
+            if( pos > 0 )
             {
-                return null;
-            }
-            
-            bt = schema.getAttribute( scimAtName.substring( 0, pos ) );
-            
-            if( bt == null )
-            {
-                return null;
+                remainingScimAttributePath = scimAtName.substring( pos + 1 );
             }
             
             LdapAttributeHandler atHandler = ( LdapAttributeHandler ) schema.getHandler(
bt.getAtHandlerName() );
             
             if( atHandler != null )
             {
-                String remainingScimAttributePath = scimAtName.substring( pos + 1 );
-                return atHandler.getLdapAtType( bt, remainingScimAttributePath, schema, ldapSchema
);
+                return atHandler.getLdapAtTypes( bt, remainingScimAttributePath, schema,
ldapSchema );
+            }
+            else
+            {
+                SimpleTypeGroup stg = null;
+                
+                if( bt instanceof ComplexType )
+                {
+                    stg = ( ( ComplexType ) bt ).getAtGroup();
+                }
+                else if( bt instanceof MultiValType )
+                {
+                    stg = ( ( MultiValType ) bt ).getAtGroup();
+                }
+                
+                if( stg != null )
+                {
+                    List<AttributeType> atList = new ArrayList<AttributeType>();
+                    
+                    for( SimpleType st : stg.getSubTypes() )
+                    {
+                        if( Strings.isNotEmpty( st.getMappedTo() ) )
+                        {
+                            atList.add( ldapSchema.getAttributeType( st.getMappedTo() ) );
+                        }
+                    }
+                    
+                    return atList;
+                }
             }
         }
         
@@ -370,10 +392,13 @@ public class LdapResourceProvider implem
             String[] names = attributes.split( "," );
             for( String n : names )
             {
-                AttributeType at = getLdapType( n, scimSchema );
-                if( at != null )
+                List<AttributeType> atList = getLdapTypes( n, scimSchema );
+                if( atList != null )
                 {
-                    ldapAtNames.add( at.getName() );
+                    for( AttributeType at : atList )
+                    {
+                        ldapAtNames.add( at.getName() );
+                    }
                 }
             }
             

Modified: directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/LdapUtil.java
URL: http://svn.apache.org/viewvc/directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/LdapUtil.java?rev=1538931&r1=1538930&r2=1538931&view=diff
==============================================================================
--- directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/LdapUtil.java
(original)
+++ directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/LdapUtil.java
Tue Nov  5 10:47:28 2013
@@ -447,13 +447,16 @@ public class LdapUtil
         {
             TerminalNode tn = ( TerminalNode ) scimFilter;
 
-            AttributeType at = provider.getLdapType( tn.getAttribute(), scimSchema );
+            List<AttributeType> atList = provider.getLdapTypes( tn.getAttribute(),
scimSchema );
             
-            if( at == null )
+            // if there is none or more than one do not consider that scim attribute
+            if( ( atList == null ) || ( atList.size() > 1 ) )
             {
                 return null;
             }
             
+            AttributeType at = atList.get( 0 );
+            
             String value = tn.getValue();
             
             SyntaxChecker sc = at.getSyntax().getSyntaxChecker();

Modified: directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/handlers/GroupsAttributeHandler.java
URL: http://svn.apache.org/viewvc/directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/handlers/GroupsAttributeHandler.java?rev=1538931&r1=1538930&r2=1538931&view=diff
==============================================================================
--- directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/handlers/GroupsAttributeHandler.java
(original)
+++ directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/handlers/GroupsAttributeHandler.java
Tue Nov  5 10:47:28 2013
@@ -38,6 +38,8 @@ import org.apache.directory.api.ldap.mod
 import org.apache.directory.api.ldap.model.filter.FilterVisitor;
 import org.apache.directory.api.ldap.model.filter.SimpleNode;
 import org.apache.directory.api.ldap.model.message.SearchScope;
+import org.apache.directory.api.ldap.model.schema.AttributeType;
+import org.apache.directory.api.ldap.model.schema.SchemaManager;
 import org.apache.directory.api.util.Strings;
 import org.apache.directory.scim.MultiValAttribute;
 import org.apache.directory.scim.RequestContext;
@@ -45,6 +47,7 @@ import org.apache.directory.scim.SimpleA
 import org.apache.directory.scim.SimpleAttributeGroup;
 import org.apache.directory.scim.ldap.LdapResourceProvider;
 import org.apache.directory.scim.ldap.schema.MultiValType;
+import org.apache.directory.scim.ldap.schema.ResourceSchema;
 import org.apache.directory.scim.schema.BaseType;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -60,7 +63,21 @@ public class GroupsAttributeHandler exte
 
     private static final Logger LOG = LoggerFactory.getLogger( GroupsAttributeHandler.class
);
 
+    
+    @Override
+    public List<AttributeType> getLdapAtTypes( BaseType bt, String remainingScimAttributePath,
ResourceSchema schema,
+        SchemaManager ldapSchema )
+    {
+        List<AttributeType> atList = new ArrayList<AttributeType>();
+        
+        atList.add( ldapSchema.getAttributeType( SchemaConstants.UNIQUE_MEMBER_AT ) );
+        atList.add( ldapSchema.getAttributeType( SchemaConstants.MEMBER_AT ) );
+        atList.add( ldapSchema.getAttributeType( SchemaConstants.ENTRY_DN_AT ) );
+        
+        return atList;
+    }
 
+    
     @Override
     public void read( BaseType bt, Object srcResource, RequestContext ctx ) throws Exception
     {

Modified: directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/handlers/LdapAttributeHandler.java
URL: http://svn.apache.org/viewvc/directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/handlers/LdapAttributeHandler.java?rev=1538931&r1=1538930&r2=1538931&view=diff
==============================================================================
--- directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/handlers/LdapAttributeHandler.java
(original)
+++ directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/handlers/LdapAttributeHandler.java
Tue Nov  5 10:47:28 2013
@@ -19,6 +19,9 @@
  */
 package org.apache.directory.scim.ldap.handlers;
 
+import java.util.Collections;
+import java.util.List;
+
 import org.apache.directory.api.ldap.model.entry.Entry;
 import org.apache.directory.api.ldap.model.message.ModifyRequest;
 import org.apache.directory.api.ldap.model.schema.AttributeType;
@@ -74,13 +77,13 @@ public abstract class LdapAttributeHandl
     }
     
     
-    public AttributeType getLdapAtType( BaseType bt, String remainingScimAttributePath, ResourceSchema
schema, SchemaManager ldapSchema )
+    public List<AttributeType> getLdapAtTypes( BaseType bt, String remainingScimAttributePath,
ResourceSchema schema, SchemaManager ldapSchema )
     {
         if( !( bt instanceof SimpleType ) )
         {
             return null;
         }
         
-        return ldapSchema.getAttributeType( ( ( SimpleType ) bt ).getMappedTo() );
+        return Collections.singletonList( ldapSchema.getAttributeType( ( ( SimpleType ) bt
).getMappedTo() ) );
     }
 }

Modified: directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/handlers/MembersAttributeHandler.java
URL: http://svn.apache.org/viewvc/directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/handlers/MembersAttributeHandler.java?rev=1538931&r1=1538930&r2=1538931&view=diff
==============================================================================
--- directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/handlers/MembersAttributeHandler.java
(original)
+++ directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/handlers/MembersAttributeHandler.java
Tue Nov  5 10:47:28 2013
@@ -70,6 +70,19 @@ public class MembersAttributeHandler ext
 
 
     @Override
+    public List<AttributeType> getLdapAtTypes( BaseType bt, String remainingScimAttributePath,
ResourceSchema schema,
+        SchemaManager ldapSchema )
+    {
+        List<AttributeType> atList = new ArrayList<AttributeType>();
+        
+        atList.add( ldapSchema.getAttributeType( SchemaConstants.UNIQUE_MEMBER_AT ) );
+        atList.add( ldapSchema.getAttributeType( SchemaConstants.MEMBER_AT ) );
+        
+        return atList;
+    }
+
+
+    @Override
     public void read( BaseType bt, Object srcResource, RequestContext ctx ) throws Exception
     {
         checkHandler( bt, "members", this );



Mime
View raw message