directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kayyag...@apache.org
Subject svn commit: r1507826 - in /directory/escimo/trunk/ldap/src/main: java/org/apache/directory/scim/ java/org/apache/directory/scim/ldap/ java/org/apache/directory/scim/ldap/schema/ resources/
Date Sun, 28 Jul 2013 18:20:42 GMT
Author: kayyagari
Date: Sun Jul 28 18:20:42 2013
New Revision: 1507826

URL: http://svn.apache.org/r1507826
Log:
creating user resource from LDAP entry

Added:
    directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/MultiValAttribute.java
    directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/SimpleAttributeGroup.java
    directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/schema/MultiValType.java
Modified:
    directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ComplexAttribute.java
    directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/SimpleAttribute.java
    directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/User.java
    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/LdapSchemaMapper.java
    directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/schema/ComplexType.java
    directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/schema/SimpleTypeGroup.java
    directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/schema/TypedType.java
    directory/escimo/trunk/ldap/src/main/resources/escimo-ldap-mapping.xml

Modified: directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ComplexAttribute.java
URL: http://svn.apache.org/viewvc/directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ComplexAttribute.java?rev=1507826&r1=1507825&r2=1507826&view=diff
==============================================================================
--- directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ComplexAttribute.java
(original)
+++ directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ComplexAttribute.java
Sun Jul 28 18:20:42 2013
@@ -28,12 +28,14 @@ import java.util.List;
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public class ComplexAttribute extends ScimAttribute
+public class ComplexAttribute extends AbstractAttribute
 {
-    public ComplexAttribute( String name )
+    private List<SimpleAttribute> atList;
+
+    public ComplexAttribute( String name, List<SimpleAttribute> atList )
     {
         super( name );
+        this.atList = atList;
     }
 
-    private List<SimpleAttribute> atList;
 }

Added: directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/MultiValAttribute.java
URL: http://svn.apache.org/viewvc/directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/MultiValAttribute.java?rev=1507826&view=auto
==============================================================================
--- directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/MultiValAttribute.java
(added)
+++ directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/MultiValAttribute.java
Sun Jul 28 18:20:42 2013
@@ -0,0 +1,61 @@
+/*
+ *   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.scim;
+
+
+import java.util.ArrayList;
+import java.util.List;
+
+
+/**
+ * TODO SimpleAttribute.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class MultiValAttribute extends AbstractAttribute
+{
+    private List<SimpleAttributeGroup> atGroupList;
+
+    public MultiValAttribute( String name, List<SimpleAttributeGroup> atGroupList )
+    {
+        super( name );
+        this.atGroupList = atGroupList;
+    }
+
+    public MultiValAttribute( String name )
+    {
+        super( name );
+    }
+
+    public List<SimpleAttributeGroup> getAtGroupList()
+    {
+        return atGroupList;
+    }
+
+    public void addAtGroup( SimpleAttributeGroup atGroup )
+    {
+        if( atGroupList == null )
+        {
+            atGroupList = new ArrayList<SimpleAttributeGroup>();
+        }
+        
+        atGroupList.add( atGroup );
+    }
+}

Modified: directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/SimpleAttribute.java
URL: http://svn.apache.org/viewvc/directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/SimpleAttribute.java?rev=1507826&r1=1507825&r2=1507826&view=diff
==============================================================================
--- directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/SimpleAttribute.java
(original)
+++ directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/SimpleAttribute.java
Sun Jul 28 18:20:42 2013
@@ -25,9 +25,9 @@ package org.apache.directory.scim;
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public class SimpleAttribute extends ScimAttribute
+public class SimpleAttribute extends AbstractAttribute
 {
-    private String value;
+    private Object value;
 
 
     public SimpleAttribute( String name )
@@ -36,20 +36,20 @@ public class SimpleAttribute extends Sci
     }
 
 
-    public SimpleAttribute( String name, String value )
+    public SimpleAttribute( String name, Object value )
     {
         super( name );
         this.value = value;
     }
 
 
-    public String getValue()
+    public Object getValue()
     {
         return value;
     }
 
 
-    public void setValue( String value )
+    public void setValue( Object value )
     {
         this.value = value;
     }

Added: directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/SimpleAttributeGroup.java
URL: http://svn.apache.org/viewvc/directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/SimpleAttributeGroup.java?rev=1507826&view=auto
==============================================================================
--- directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/SimpleAttributeGroup.java
(added)
+++ directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/SimpleAttributeGroup.java
Sun Jul 28 18:20:42 2013
@@ -0,0 +1,61 @@
+/*
+ *   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.scim;
+
+
+import java.util.List;
+
+
+/**
+ * TODO SimpleAttribute.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class SimpleAttributeGroup
+{
+    private List<SimpleAttribute> atList;
+
+
+    public SimpleAttributeGroup()
+    {
+    }
+
+
+    public SimpleAttributeGroup( List<SimpleAttribute> atList )
+    {
+        this.atList = atList;
+    }
+
+
+    public void addAttribute( SimpleAttribute at )
+    {
+        if ( atList == null )
+        {
+            atList.add( at );
+        }
+    }
+
+
+    public List<SimpleAttribute> getAtList()
+    {
+        return atList;
+    }
+
+}

Modified: directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/User.java
URL: http://svn.apache.org/viewvc/directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/User.java?rev=1507826&r1=1507825&r2=1507826&view=diff
==============================================================================
--- directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/User.java (original)
+++ directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/User.java Sun Jul
28 18:20:42 2013
@@ -35,15 +35,15 @@ public class User
     
     private List<ComplexAttribute> complexList;
     
-    private Map<String,List<ScimAttribute>> uriAtMap = new HashMap<String,
List<ScimAttribute>>();
+    private Map<String,List<AbstractAttribute>> uriAtMap = new HashMap<String,
List<AbstractAttribute>>();
     
-    public void addAttribute( String uri, ScimAttribute at )
+    public void addAttribute( String uri, AbstractAttribute at )
     {
-        List<ScimAttribute> atList = uriAtMap.get( uri );
+        List<AbstractAttribute> atList = uriAtMap.get( uri );
         
         if( atList == null )
         {
-            atList = new ArrayList<ScimAttribute>();
+            atList = new ArrayList<AbstractAttribute>();
             uriAtMap.put( uri, atList );
         }
         

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=1507826&r1=1507825&r2=1507826&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
Sun Jul 28 18:20:42 2013
@@ -23,15 +23,21 @@ package org.apache.directory.scim.ldap;
 import static org.apache.directory.api.ldap.model.constants.SchemaConstants.ALL_ATTRIBUTES_ARRAY;
 import static org.apache.directory.api.ldap.model.message.SearchScope.SUBTREE;
 
+import java.io.IOException;
+import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Iterator;
 import java.util.List;
 
 import org.apache.directory.api.ldap.codec.standalone.StandaloneLdapApiService;
+import org.apache.directory.api.ldap.model.constants.SchemaConstants;
+import org.apache.directory.api.ldap.model.cursor.CursorException;
 import org.apache.directory.api.ldap.model.cursor.EntryCursor;
 import org.apache.directory.api.ldap.model.cursor.SearchCursor;
 import org.apache.directory.api.ldap.model.entry.Attribute;
 import org.apache.directory.api.ldap.model.entry.Entry;
+import org.apache.directory.api.ldap.model.entry.Value;
+import org.apache.directory.api.ldap.model.exception.LdapException;
 import org.apache.directory.api.ldap.model.message.Response;
 import org.apache.directory.api.ldap.model.message.SearchRequest;
 import org.apache.directory.api.ldap.model.message.SearchRequestImpl;
@@ -41,14 +47,26 @@ import org.apache.directory.api.ldap.mod
 import org.apache.directory.api.ldap.model.message.controls.PersistentSearch;
 import org.apache.directory.api.ldap.model.message.controls.PersistentSearchImpl;
 import org.apache.directory.api.ldap.model.name.Dn;
+import org.apache.directory.api.ldap.model.schema.LdapSyntax;
+import org.apache.directory.api.ldap.model.schema.SyntaxChecker;
+import org.apache.directory.api.ldap.model.schema.syntaxCheckers.IntegerSyntaxChecker;
+import org.apache.directory.api.ldap.model.schema.syntaxCheckers.JavaByteSyntaxChecker;
+import org.apache.directory.api.ldap.model.schema.syntaxCheckers.JavaIntegerSyntaxChecker;
+import org.apache.directory.api.ldap.model.schema.syntaxCheckers.JavaLongSyntaxChecker;
+import org.apache.directory.api.ldap.model.schema.syntaxCheckers.JavaShortSyntaxChecker;
 import org.apache.directory.api.util.Base64;
+import org.apache.directory.api.util.Strings;
 import org.apache.directory.ldap.client.api.LdapConnection;
 import org.apache.directory.ldap.client.api.LdapNetworkConnection;
+import org.apache.directory.scim.ComplexAttribute;
+import org.apache.directory.scim.MultiValAttribute;
 import org.apache.directory.scim.ResourceNotFoundException;
 import org.apache.directory.scim.SimpleAttribute;
+import org.apache.directory.scim.SimpleAttributeGroup;
 import org.apache.directory.scim.User;
 import org.apache.directory.scim.ldap.schema.BaseType;
 import org.apache.directory.scim.ldap.schema.ComplexType;
+import org.apache.directory.scim.ldap.schema.MultiValType;
 import org.apache.directory.scim.ldap.schema.SimpleType;
 import org.apache.directory.scim.ldap.schema.SimpleTypeGroup;
 import org.apache.directory.scim.ldap.schema.TypedType;
@@ -108,7 +126,14 @@ public class LdapResourceProvider
             throw new ResourceNotFoundException( "No User resource found with the ID " +
id );
         }
 
-        return toUser( entry );
+        try
+        {
+            return toUser( entry );
+        }
+        catch ( Exception e )
+        {
+            throw new ResourceNotFoundException( e );
+        }
     }
 
 
@@ -123,49 +148,282 @@ public class LdapResourceProvider
             if ( bt instanceof SimpleType )
             {
                 SimpleType st = ( SimpleType ) bt;
-                
-                if(!st.isShow()) 
+
+                if ( !st.isShow() )
                 {
                     continue;
                 }
-                
-                String name = st.getName();
-                Attribute at = entry.get( st.getMappedTo() );
+
+                SimpleAttribute at = getValueInto( st, entry );
                 if ( at != null )
                 {
-                    String value = null;
-                    if( at.isHumanReadable() )
+                    user.addAttribute( bt.getUri(), at );
+                }
+            }
+            else if ( bt instanceof ComplexType )
+            {
+                ComplexType ct = ( ComplexType ) bt;
+
+                if ( !ct.isShow() )
+                {
+                    continue;
+                }
+
+                List<SimpleAttribute> lstAts = getValuesInto( ct.getAtGroup(), entry
);
+
+                if ( !lstAts.isEmpty() )
+                {
+                    ComplexAttribute cAt = new ComplexAttribute( ct.getName(), lstAts );
+                    user.addAttribute( bt.getUri(), cAt );
+                }
+            }
+            else if ( bt instanceof MultiValType )
+            {
+                MultiValType mt = ( MultiValType ) bt;
+
+                if ( !mt.isShow() )
+                {
+                    continue;
+                }
+
+                List<TypedType> typedList = mt.getTypedList();
+                SimpleTypeGroup stg = mt.getStGroup();
+
+                if ( typedList != null )
+                {
+                    MultiValAttribute mv = new MultiValAttribute( mt.getName() );
+
+                    for ( TypedType tt : typedList )
+                    {
+                        SimpleTypeGroup typeStg = tt.getAtGroup();
+                        List<SimpleAttribute> lstAts = getValuesInto( typeStg, entry
);
+                        lstAts.add( new SimpleAttribute( "type", tt.getName() ) );
+                        if ( tt.isPrimary() )
+                        {
+                            lstAts.add( new SimpleAttribute( "primary", true ) );
+                        }
+
+                        if ( !lstAts.isEmpty() )
+                        {
+                            mv.addAtGroup( new SimpleAttributeGroup( lstAts ) );
+                        }
+                    }
+
+                    if ( mv.getAtGroupList() != null )
+                    {
+                        user.addAttribute( bt.getUri(), mv );
+                    }
+                }
+                else if ( stg != null )
+                {
+                    List<SimpleAttributeGroup> atGroupList = null;
+
+                    if ( !Strings.isEmpty( mt.getFilter() ) )
                     {
-                        value = at.getString();
+                        atGroupList = getDynamicMultiValAtFrom( stg, mt.getFilter(), mt.getBaseDn(),
entry );
                     }
                     else
                     {
-                        value = new String( Base64.encode( at.getBytes() ) );
+                        atGroupList = getValuesFor( stg, entry );
                     }
-                    
-                    user.addAttribute( bt.getUri(), new SimpleAttribute( name, value ) );
+
+                    MultiValAttribute mv = new MultiValAttribute( mt.getName(), atGroupList
);
+
                 }
             }
-            else if ( bt instanceof ComplexType )
+        }
+
+        return user;
+    }
+
+
+    private List<SimpleAttributeGroup> getDynamicMultiValAtFrom( SimpleTypeGroup stg,
String filter, String baseDn,
+        Entry entry )
+        throws LdapException, IOException, CursorException
+    {
+        if ( Strings.isEmpty( baseDn ) )
+        {
+            baseDn = ""; // RootDSE
+        }
+
+        /* if( filter.contains( "$" ))
+         {
+             StringBuilder sb = new StringBuilder();
+             int len = filter.length();
+             int pos = 0;
+             while( pos < len-1 )
+             {
+                 int equalPos = filter.indexOf( "=", pos );
+                 sb.append( filter.subSequence( pos, equalPos+1 ) );
+                 
+                 int dollarPos = filter.indexOf( "$", equalPos );
+                 if( dollarPos != -1 )
+                 {
+                     int rightParenPos = filter.indexOf( ")", dollarPos );
+                     while( filter.charAt( rightParenPos - 1 ) == '\\' )
+                     {
+                         rightParenPos = filter.indexOf( ")", rightParenPos );
+                     }
+                     
+                 }
+                 
+             }
+         }*/
+
+        List<SimpleAttributeGroup> lst = new ArrayList<SimpleAttributeGroup>();
+
+        EntryCursor cursor = connection.search( baseDn, filter, SearchScope.SUBTREE,
+            SchemaConstants.ALL_ATTRIBUTES_ARRAY );
+        while ( cursor.next() )
+        {
+            Entry mvEntry = cursor.get();
+            List<SimpleAttributeGroup> tmp = getValuesFor( stg, mvEntry );
+            if ( tmp != null )
             {
-                ComplexType ct = ( ComplexType ) bt;
-                
-                if(!ct.isShow()) 
+                lst.add( tmp.get( 0 ) );
+            }
+        }
+
+        cursor.close();
+
+        if ( lst.isEmpty() )
+        {
+            return null;
+        }
+
+        return lst;
+    }
+
+
+    private List<SimpleAttributeGroup> getValuesFor( SimpleTypeGroup stg, Entry entry
) throws LdapException
+    {
+        if ( stg == null )
+        {
+            return null;
+        }
+
+        SimpleType valType = stg.getValueType();
+
+        if ( valType == null )
+        {
+            return null;
+        }
+
+        List<SimpleType> types = new ArrayList<SimpleType>( stg.getLstSTypes()
);
+        types.remove( valType );
+
+        Attribute ldapAt = entry.get( valType.getMappedTo() );
+
+        if ( ldapAt == null )
+        {
+            return null;
+        }
+
+        List<SimpleAttributeGroup> lst = new ArrayList<SimpleAttributeGroup>();
+
+        Iterator<Value<?>> itr = ldapAt.iterator();
+
+        while ( itr.hasNext() )
+        {
+            Value<?> val = itr.next();
+
+            Object scimVal = getScimValFrom( val );
+            SimpleAttributeGroup sg = new SimpleAttributeGroup();
+            sg.addAttribute( new SimpleAttribute( valType.getName(), scimVal ) );
+
+            for ( SimpleType type : types )
+            {
+                SimpleAttribute st = getValueInto( type, entry );
+
+                if ( st != null )
                 {
-                    continue;
+                    sg.addAttribute( st );
                 }
-                
-                SimpleTypeGroup stg = ct.getStGroup();
-                List<SimpleType> lstTyps = stg.getLstSTypes();
-                
             }
+
+            lst.add( sg );
+        }
+
+        if ( lst.isEmpty() )
+        {
+            return null;
+        }
+
+        return lst;
+    }
+
+
+    public SimpleAttribute getValueInto( SimpleType st, Entry entry ) throws LdapException
+    {
+        String name = st.getName();
+        Attribute at = entry.get( st.getMappedTo() );
+        if ( at != null )
+        {
+
+            Object value = getScimValFrom( at );
+            return new SimpleAttribute( name, value );
         }
 
-        Iterator<Attribute> itr = entry.iterator();
         return null;
     }
 
 
+    private Object getScimValFrom( Attribute at ) throws LdapException
+    {
+        return getScimValFrom( at.get() );
+    }
+
+
+    private Object getScimValFrom( Value<?> ldapValue ) throws LdapException
+    {
+        if ( !ldapValue.isHumanReadable() )
+        {
+            return new String( Base64.encode( ldapValue.getBytes() ) );
+        }
+
+        LdapSyntax syntax = ldapValue.getAttributeType().getSyntax();
+        if ( syntax != null )
+        {
+            SyntaxChecker sc = syntax.getSyntaxChecker();
+            if ( sc instanceof IntegerSyntaxChecker ||
+                sc instanceof JavaByteSyntaxChecker ||
+                sc instanceof JavaIntegerSyntaxChecker ||
+                sc instanceof JavaLongSyntaxChecker ||
+                sc instanceof JavaShortSyntaxChecker )
+            {
+                return Long.parseLong( ldapValue.getString() );
+            }
+        }
+
+        return ldapValue.getString();
+
+    }
+
+
+    //    public List<SimpleAttribute> getValuesInto( List<SimpleType> lstTyps,
Entry entry ) throws LdapException
+    //    {
+    //    }
+
+    public List<SimpleAttribute> getValuesInto( SimpleTypeGroup stg, Entry entry )
throws LdapException
+    {
+        List<SimpleAttribute> lstAts = new ArrayList<SimpleAttribute>();
+
+        for ( SimpleType st : stg.getLstSTypes() )
+        {
+            SimpleAttribute at = getValueInto( st, entry );
+            if ( at != null )
+            {
+                lstAts.add( at );
+            }
+
+            //TODO handle the format
+        }
+
+        return lstAts;
+
+    }
+
+
     public static void main( String[] args ) throws Exception
     {
         System.setProperty( StandaloneLdapApiService.DEFAULT_CONTROLS_LIST,

Modified: directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/LdapSchemaMapper.java
URL: http://svn.apache.org/viewvc/directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/LdapSchemaMapper.java?rev=1507826&r1=1507825&r2=1507826&view=diff
==============================================================================
--- directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/LdapSchemaMapper.java
(original)
+++ directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/LdapSchemaMapper.java
Sun Jul 28 18:20:42 2013
@@ -36,6 +36,7 @@ import org.apache.directory.ldap.client.
 import org.apache.directory.scim.SchemaMapper;
 import org.apache.directory.scim.ldap.schema.BaseType;
 import org.apache.directory.scim.ldap.schema.ComplexType;
+import org.apache.directory.scim.ldap.schema.MultiValType;
 import org.apache.directory.scim.ldap.schema.ResourceSchema;
 import org.apache.directory.scim.ldap.schema.SimpleType;
 import org.apache.directory.scim.ldap.schema.SimpleTypeGroup;
@@ -221,6 +222,32 @@ public class LdapSchemaMapper implements
                     + elmComplex.asXML() );
             }
 
+
+            List<SimpleType> stList = new ArrayList<SimpleType>();
+            
+            Element atGrpElm = elmComplex.element( "at-group" );
+            SimpleTypeGroup stg = parseAtGroup( atGrpElm, uri );
+            if( stg != null )
+            {
+                ComplexType ct = new ComplexType( name, uri, stg );
+                resourceSchema.addAttributeType( name, ct );
+            }
+
+        }
+        
+        // load multival-attributes
+        List<Element> multivalAtElmList = schemaRoot.elements( "multival-attribute"
);
+
+        for ( Element elmComplex : multivalAtElmList )
+        {
+            String name = elmComplex.attributeValue( "name" );
+
+            if ( Strings.isEmpty( name ) )
+            {
+                throw new IllegalStateException( "name is missing in the multival-attribute
configuration element "
+                    + elmComplex.asXML() );
+            }
+
             String baseDn = elmComplex.attributeValue( "baseDn" );
             String filter = elmComplex.attributeValue( "filter" );
             
@@ -230,7 +257,7 @@ public class LdapSchemaMapper implements
                 SimpleTypeGroup stg = parseAtGroup( elmAtGroup, uri );
                 if ( stg != null )
                 {
-                    ComplexType ct = new ComplexType( name, uri, stg, baseDn, filter );
+                    MultiValType ct = new MultiValType( name, uri, stg, baseDn, filter );
                     resourceSchema.addAttributeType( name, ct );
                 }
 
@@ -271,7 +298,7 @@ public class LdapSchemaMapper implements
                     lstTypes.add( tt );
                 }
 
-                ComplexType ct = new ComplexType( name, uri, lstTypes, baseDn, filter );
+                MultiValType ct = new MultiValType( name, uri, lstTypes, baseDn, filter );
                 resourceSchema.addAttributeType( name, ct );
             }
         }

Modified: directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/schema/ComplexType.java
URL: http://svn.apache.org/viewvc/directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/schema/ComplexType.java?rev=1507826&r1=1507825&r2=1507826&view=diff
==============================================================================
--- directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/schema/ComplexType.java
(original)
+++ directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/schema/ComplexType.java
Sun Jul 28 18:20:42 2013
@@ -32,57 +32,18 @@ public class ComplexType extends BaseTyp
 {
     private String name;
 
-    private SimpleTypeGroup stGroup;
-
-    private List<TypedType> typedList;
+    private SimpleTypeGroup atGroup;
 
     private boolean show = true;
 
-    private String baseDn;
-    
-    private String filter;
-
-    /** used for setting the value of "formatted" attribute */
-    private String format;
-
-    public ComplexType( String name, String uri, SimpleTypeGroup stGroup, String baseDn,
String filter )
-    {
-        super(uri);
-        this.name = name;
-        this.stGroup = stGroup;
-        this.baseDn = baseDn;
-        this.filter = filter;
-    }
-
-
-    public ComplexType( String name, String uri, List<TypedType> typedList, String
baseDn, String filter )
+    public ComplexType( String name, String uri, SimpleTypeGroup atGroup )
     {
         super(uri);
         this.name = name;
-        this.typedList = typedList;
-        this.baseDn = baseDn;
-        this.filter = filter;
+        this.atGroup = atGroup;
     }
 
     /**
-     * @return the typedList
-     */
-    public List<TypedType> getTypedList()
-    {
-        return typedList;
-    }
-
-
-    /**
-     * @return the stGroup
-     */
-    public SimpleTypeGroup getStGroup()
-    {
-        return stGroup;
-    }
-
-
-    /**
      * @return the show
      */
     public boolean isShow()
@@ -92,33 +53,6 @@ public class ComplexType extends BaseTyp
 
 
     /**
-     * @return the baseDn
-     */
-    public String getBaseDn()
-    {
-        return baseDn;
-    }
-
-
-    /**
-     * @return the filter
-     */
-    public String getFilter()
-    {
-        return filter;
-    }
-
-
-    /**
-     * @return the format
-     */
-    public String getFormat()
-    {
-        return format;
-    }
-
-
-    /**
      * @return the name
      */
     public String getName()
@@ -127,21 +61,15 @@ public class ComplexType extends BaseTyp
     }
 
 
-    @Override
-    public boolean isComplex()
+    public SimpleTypeGroup getAtGroup()
     {
-        return true;
+        return atGroup;
     }
 
-
-    /* (non-Javadoc)
-     * @see java.lang.Object#toString()
-     */
     @Override
-    public String toString()
+    public boolean isComplex()
     {
-        return "ComplexType [name=" + name + ", stGroup=" + stGroup + ", typedList="
-            + typedList + ", show=" + show + ", format=" + format + "]";
+        return true;
     }
 
 }

Added: directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/schema/MultiValType.java
URL: http://svn.apache.org/viewvc/directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/schema/MultiValType.java?rev=1507826&view=auto
==============================================================================
--- directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/schema/MultiValType.java
(added)
+++ directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/schema/MultiValType.java
Sun Jul 28 18:20:42 2013
@@ -0,0 +1,147 @@
+/*
+ *   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.scim.ldap.schema;
+
+
+import java.util.List;
+
+
+/**
+ * TODO SimpleType.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class MultiValType extends BaseType
+{
+    private String name;
+
+    private SimpleTypeGroup stGroup;
+
+    private List<TypedType> typedList;
+
+    private boolean show = true;
+
+    private String baseDn;
+    
+    private String filter;
+
+    /** used for setting the value of "formatted" attribute */
+    private String format;
+
+    public MultiValType( String name, String uri, SimpleTypeGroup stGroup, String baseDn,
String filter )
+    {
+        super(uri);
+        this.name = name;
+        this.stGroup = stGroup;
+        this.baseDn = baseDn;
+        this.filter = filter;
+    }
+
+
+    public MultiValType( String name, String uri, List<TypedType> typedList, String
baseDn, String filter )
+    {
+        super(uri);
+        this.name = name;
+        this.typedList = typedList;
+        this.baseDn = baseDn;
+        this.filter = filter;
+    }
+
+    /**
+     * @return the typedList
+     */
+    public List<TypedType> getTypedList()
+    {
+        return typedList;
+    }
+
+
+    /**
+     * @return the stGroup
+     */
+    public SimpleTypeGroup getStGroup()
+    {
+        return stGroup;
+    }
+
+
+    /**
+     * @return the show
+     */
+    public boolean isShow()
+    {
+        return show;
+    }
+
+
+    /**
+     * @return the baseDn
+     */
+    public String getBaseDn()
+    {
+        return baseDn;
+    }
+
+
+    /**
+     * @return the filter
+     */
+    public String getFilter()
+    {
+        return filter;
+    }
+
+
+    /**
+     * @return the format
+     */
+    public String getFormat()
+    {
+        return format;
+    }
+
+
+    /**
+     * @return the name
+     */
+    public String getName()
+    {
+        return name;
+    }
+
+
+    @Override
+    public boolean isComplex()
+    {
+        return true;
+    }
+
+
+    /* (non-Javadoc)
+     * @see java.lang.Object#toString()
+     */
+    @Override
+    public String toString()
+    {
+        return "ComplexType [name=" + name + ", stGroup=" + stGroup + ", typedList="
+            + typedList + ", show=" + show + ", format=" + format + "]";
+    }
+
+}

Modified: directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/schema/SimpleTypeGroup.java
URL: http://svn.apache.org/viewvc/directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/schema/SimpleTypeGroup.java?rev=1507826&r1=1507825&r2=1507826&view=diff
==============================================================================
--- directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/schema/SimpleTypeGroup.java
(original)
+++ directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/schema/SimpleTypeGroup.java
Sun Jul 28 18:20:42 2013
@@ -33,6 +33,7 @@ public class SimpleTypeGroup
 {
     private List<SimpleType> lstSTypes;
 
+    /** used for setting the value of "formatted" attribute */
     private String format;
 
     public SimpleTypeGroup( List<SimpleType> lstSTypes, String format )
@@ -58,6 +59,19 @@ public class SimpleTypeGroup
         return Collections.unmodifiableList( lstSTypes );
     }
 
+    
+    public SimpleType getValueType()
+    {
+        for( SimpleType st : lstSTypes )
+        {
+            if( "value".equals( st.getName() ))
+            {
+                return st;
+            }
+        }
+        
+        return null;
+    }
 
     /* (non-Javadoc)
      * @see java.lang.Object#toString()

Modified: directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/schema/TypedType.java
URL: http://svn.apache.org/viewvc/directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/schema/TypedType.java?rev=1507826&r1=1507825&r2=1507826&view=diff
==============================================================================
--- directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/schema/TypedType.java
(original)
+++ directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/schema/TypedType.java
Sun Jul 28 18:20:42 2013
@@ -75,6 +75,11 @@ public class TypedType extends BaseType
         return true;
     }
 
+    public String getName()
+    {
+        return name;
+    }
+
     /* (non-Javadoc)
      * @see java.lang.Object#toString()
      */

Modified: directory/escimo/trunk/ldap/src/main/resources/escimo-ldap-mapping.xml
URL: http://svn.apache.org/viewvc/directory/escimo/trunk/ldap/src/main/resources/escimo-ldap-mapping.xml?rev=1507826&r1=1507825&r2=1507826&view=diff
==============================================================================
--- directory/escimo/trunk/ldap/src/main/resources/escimo-ldap-mapping.xml (original)
+++ directory/escimo/trunk/ldap/src/main/resources/escimo-ldap-mapping.xml Sun Jul 28 18:20:42
2013
@@ -1,109 +1,111 @@
 <?xml version="1.0"?>
 <entities>
-	<schema id="user-core" uri="urn:scim:schemas:core:1.0">
-		<attribute name="id" mappedTo="entryUUID" />
-		<attribute name="userName" mappedTo="uid" />
-		<attribute name="displayName" mappedTo="displayName" />
-		<attribute name="nickName" mappedTo="" />
-		<attribute name="profileUrl" mappedTo="" />
-		<attribute name="title" mappedTo="title" />
-		<attribute name="userType" mappedTo="employeeType" />
-		<attribute name="preferredLanguage" mappedTo="preferredLanguage" />
-		<attribute name="locale" mappedTo="" />
-		<attribute name="timezone" mappedTo="" />
-		<attribute name="active" mappedTo="" />
-		<attribute name="password" show="false" mappedTo="userPassword" />
-
-		<complex-attribute name="name">
-			<at-group>
-				<attribute name="familyName" mappedTo="sn" />
-				<attribute name="givenName" mappedTo="cn" />
-				<attribute name="middleName" mappedTo="" />
-				<attribute name="honorificPrefix" mappedTo="title" />
-				<attribute name="honorificSuffix" mappedTo="" />
-				<formatted format="$givenName $familyName" />
-			</at-group>
-		</complex-attribute>
-
-		<complex-attribute name="emails">
-			<type name="work" primary="true">
-				<attribute name="value" mappedTo="mail" />
-			</type>
-		</complex-attribute>
-
-		<complex-attribute name="phoneNumbers">
-			<type name="work" primary="true">
-				<at-group>
-					<attribute name="value" mappedTo="telephoneNumber" />
-				</at-group>
-			</type>
-			<type name="home" primary="false">
-				<at-group>
-					<attribute name="value" mappedTo="homePhone" />
-				</at-group>
-			</type>
-		</complex-attribute>
-
-		<complex-attribute name="ims">
-		</complex-attribute>
-
-		<complex-attribute name="photos">
-			<type name="photo" primary="true">
-				<at-group>
-					<attribute name="value" mappedTo="jpegPhoto" />
-				</at-group>
-			</type>
-		</complex-attribute>
-
-		<complex-attribute name="addresses">
-			<type name="work" primary="true">
-				<at-group>
-					<attribute name="streetAddress" mappedTo="street" />
-					<attribute name="locality" mappedTo="l" />
-					<attribute name="region" mappedTo="region" />
-					<attribute name="postalCode" mappedTo="postalCode" />
-					<attribute name="country" mappedTo="" />
-					<formatted format="$streetAddress $locality" />
-				</at-group>
-			</type>
-		</complex-attribute>
-
-		<complex-attribute name="groups">
-			<at-group>
-				<attribute name="value" mappedTo="entryUUID" />
-			</at-group>
-		</complex-attribute>
-
-		<complex-attribute name="meta">
-			<at-group>
-				<attribute name="created" mappedTo="createTimestamp" />
-				<attribute name="lastModified" mappedTo="lastModifiedTimestamp" />
-			</at-group>
-		</complex-attribute>
-		
-	</schema>
-
-	<schema id="group" uri="urn:scim:schemas:core:1.0">
-		<attribute name="displayName" mappedTo="cn" />
-		<attribute name="id" mappedTo="entryUUID" />
-		<complex-attribute name="members">
-			<at-group>
-				<attribute name="streetAddress" mappedTo="street" />
-				<attribute name="locality" mappedTo="l" />
-				<attribute name="region" mappedTo="region" />
-				<attribute name="postalCode" mappedTo="postalCode" />
-				<attribute name="country" mappedTo="" />
-				<formatted format="$streetAddress $locality" />
-			</at-group>
-		</complex-attribute>
-
-	</schema>
-
-	<userType basedDn="ou=system" filter="(objectClass = inetOrgPerson)">
-		<schemaRef id="user-core" />
-	</userType>
-
-	<groupType  basedDn="ou=system" filter="(objectClass = inetOrgPerson)">
-		<schemaRef id="group" />
-	</groupType>
+    <schema id="user-core" uri="urn:scim:schemas:core:1.0">
+        <attribute name="id" mappedTo="entryUUID" />
+        <attribute name="userName" mappedTo="uid" />
+        <attribute name="displayName" mappedTo="displayName" />
+        <attribute name="nickName" mappedTo="" />
+        <attribute name="profileUrl" mappedTo="" />
+        <attribute name="title" mappedTo="title" />
+        <attribute name="userType" mappedTo="employeeType" />
+        <attribute name="preferredLanguage" mappedTo="preferredLanguage" />
+        <attribute name="locale" mappedTo="" />
+        <attribute name="timezone" mappedTo="" />
+        <attribute name="active" mappedTo="" />
+        <attribute name="password" show="false" mappedTo="userPassword" />
+
+        <complex-attribute name="name">
+            <at-group>
+                <attribute name="familyName" mappedTo="sn" />
+                <attribute name="givenName" mappedTo="cn" />
+                <attribute name="middleName" mappedTo="" />
+                <attribute name="honorificPrefix" mappedTo="title" />
+                <attribute name="honorificSuffix" mappedTo="" />
+                <formatted format="$givenName $familyName" />
+            </at-group>
+        </complex-attribute>
+
+        <multival-attribute name="emails">
+            <type name="work" primary="true">
+                <at-group>
+                    <attribute name="value" mappedTo="mail" />
+                </at-group>
+            </type>
+        </multival-attribute>
+
+        <multival-attribute name="phoneNumbers">
+            <type name="work" primary="true">
+                <at-group>
+                    <attribute name="value" mappedTo="telephoneNumber" />
+                </at-group>
+            </type>
+            <type name="home" primary="false">
+                <at-group>
+                    <attribute name="value" mappedTo="homePhone" />
+                </at-group>
+            </type>
+        </multival-attribute>
+
+        <multival-attribute name="ims">
+        </multival-attribute>
+
+        <multival-attribute name="photos">
+            <type name="photo" primary="true">
+                <at-group>
+                    <attribute name="value" mappedTo="jpegPhoto" />
+                </at-group>
+            </type>
+        </multival-attribute>
+
+        <multival-attribute name="addresses">
+            <type name="work" primary="true">
+                <at-group>
+                    <attribute name="streetAddress" mappedTo="street" />
+                    <attribute name="locality" mappedTo="l" />
+                    <attribute name="region" mappedTo="region" />
+                    <attribute name="postalCode" mappedTo="postalCode" />
+                    <attribute name="country" mappedTo="" />
+                    <formatted format="$streetAddress $locality" />
+                </at-group>
+            </type>
+        </multival-attribute>
+
+        <multival-attribute name="groups">
+            <at-group>
+                <attribute name="value" mappedTo="entryUUID" />
+            </at-group>
+        </multival-attribute>
+
+        <complex-attribute name="meta">
+            <at-group>
+                <attribute name="created" mappedTo="createTimestamp" />
+                <attribute name="lastModified" mappedTo="lastModifiedTimestamp" />
+            </at-group>
+        </complex-attribute>
+
+    </schema>
+
+    <schema id="group" uri="urn:scim:schemas:core:1.0">
+        <attribute name="displayName" mappedTo="cn" />
+        <attribute name="id" mappedTo="entryUUID" />
+        <complex-attribute name="members">
+            <at-group>
+                <attribute name="streetAddress" mappedTo="street" />
+                <attribute name="locality" mappedTo="l" />
+                <attribute name="region" mappedTo="region" />
+                <attribute name="postalCode" mappedTo="postalCode" />
+                <attribute name="country" mappedTo="" />
+                <formatted format="$streetAddress $locality" />
+            </at-group>
+        </complex-attribute>
+
+    </schema>
+
+    <userType basedDn="ou=system" filter="(objectClass = inetOrgPerson)">
+        <schemaRef id="user-core" />
+    </userType>
+
+    <groupType basedDn="ou=system" filter="(objectClass = inetOrgPerson)">
+        <schemaRef id="group" />
+    </groupType>
 </entities>
\ No newline at end of file



Mime
View raw message