directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kayyag...@apache.org
Subject svn commit: r1510433 - in /directory/escimo/trunk: ./ common/src/main/java/org/apache/directory/scim/ ldap/src/main/java/org/apache/directory/scim/ldap/ ldap/src/main/java/org/apache/directory/scim/ldap/schema/ ldap/src/main/resources/ server/ server/s...
Date Mon, 05 Aug 2013 11:32:57 GMT
Author: kayyagari
Date: Mon Aug  5 11:32:57 2013
New Revision: 1510433

URL: http://svn.apache.org/r1510433
Log:
o initialize ldap connection
o integrating with REST service

Added:
    directory/escimo/trunk/ldap/src/main/resources/ldap-server.properties
    directory/escimo/trunk/server/src/main/java/org/apache/directory/scim/rest/
    directory/escimo/trunk/server/src/main/java/org/apache/directory/scim/rest/EscimoApplication.java
    directory/escimo/trunk/server/src/main/java/org/apache/directory/scim/rest/ServerInitializer.java
    directory/escimo/trunk/server/src/main/java/org/apache/directory/scim/rest/UserService.java
    directory/escimo/trunk/server/src/main/webapp/WEB-INF/application
Removed:
    directory/escimo/trunk/server/src/main/java/org/apache/directory/scim/UserService.java
Modified:
    directory/escimo/trunk/common/src/main/java/org/apache/directory/scim/ProviderService.java
    directory/escimo/trunk/common/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/schema/ResourceSchema.java
    directory/escimo/trunk/pom.xml
    directory/escimo/trunk/server/pom.xml
    directory/escimo/trunk/server/src/main/webapp/WEB-INF/web.xml

Modified: directory/escimo/trunk/common/src/main/java/org/apache/directory/scim/ProviderService.java
URL: http://svn.apache.org/viewvc/directory/escimo/trunk/common/src/main/java/org/apache/directory/scim/ProviderService.java?rev=1510433&r1=1510432&r2=1510433&view=diff
==============================================================================
--- directory/escimo/trunk/common/src/main/java/org/apache/directory/scim/ProviderService.java
(original)
+++ directory/escimo/trunk/common/src/main/java/org/apache/directory/scim/ProviderService.java
Mon Aug  5 11:32:57 2013
@@ -24,5 +24,7 @@ package org.apache.directory.scim;
  */
 public interface ProviderService 
 {
-
+    void init() throws Exception;
+    void stop();;
+    User getUser( String userId ) throws ResourceNotFoundException;
 }

Modified: directory/escimo/trunk/common/src/main/java/org/apache/directory/scim/User.java
URL: http://svn.apache.org/viewvc/directory/escimo/trunk/common/src/main/java/org/apache/directory/scim/User.java?rev=1510433&r1=1510432&r2=1510433&view=diff
==============================================================================
--- directory/escimo/trunk/common/src/main/java/org/apache/directory/scim/User.java (original)
+++ directory/escimo/trunk/common/src/main/java/org/apache/directory/scim/User.java Mon Aug
 5 11:32:57 2013
@@ -31,10 +31,6 @@ import java.util.Map;
  */
 public class User
 {
-    private List<SimpleAttribute> simpleList;
-    
-    private List<ComplexAttribute> complexList;
-    
     private Map<String,List<AbstractAttribute>> uriAtMap = new HashMap<String,
List<AbstractAttribute>>();
     
     public void addAttribute( String uri, AbstractAttribute at )
@@ -54,12 +50,11 @@ public class User
     {
         return uriAtMap;
     }
-    
+
     @Override
     public String toString()
     {
-        return "User [simpleList=" + simpleList + ", complexList=" + complexList + ", uriAtMap="
+ uriAtMap + "]";
+        return "User [uriAtMap=" + uriAtMap + "]";
     }
     
-    
 }

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=1510433&r1=1510432&r2=1510433&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
Mon Aug  5 11:32:57 2013
@@ -24,10 +24,12 @@ import static org.apache.directory.api.l
 import static org.apache.directory.api.ldap.model.message.SearchScope.SUBTREE;
 
 import java.io.IOException;
+import java.io.InputStream;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Iterator;
 import java.util.List;
+import java.util.Properties;
 
 import org.apache.directory.api.ldap.codec.standalone.StandaloneLdapApiService;
 import org.apache.directory.api.ldap.model.constants.SchemaConstants;
@@ -56,14 +58,16 @@ import org.apache.directory.api.ldap.sch
 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.LdapConnectionConfig;
 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.ProviderService;
 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.json.JsonSerializer;
+import org.apache.directory.scim.json.ResourceSerializer;
 import org.apache.directory.scim.ldap.schema.BaseType;
 import org.apache.directory.scim.ldap.schema.ComplexType;
 import org.apache.directory.scim.ldap.schema.MultiValType;
@@ -80,7 +84,7 @@ import org.slf4j.LoggerFactory;
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public class LdapResourceProvider
+public class LdapResourceProvider implements ProviderService
 {
     private LdapConnection connection;
 
@@ -89,15 +93,83 @@ public class LdapResourceProvider
     private UserSchema userSchema;
 
     private static final Logger LOG = LoggerFactory.getLogger( LdapResourceProvider.class
);
-    
+
+
+    public LdapResourceProvider()
+    {
+    }
+
+
     public LdapResourceProvider( LdapConnection connection )
     {
+        this.connection = connection;
+    }
+
+
+    public void init() throws Exception
+    {
+        LOG.info( "Initializing LDAP resource provider" );
+        if ( connection == null )
+        {
+            createConnection();
+        }
+
+        if ( connection instanceof LdapNetworkConnection )
+        {
+            ( ( LdapNetworkConnection ) connection ).loadSchema( new JarLdifSchemaLoader()
);
+        }
+
         schema = new LdapSchemaMapper();
         schema.loadMappings();
         userSchema = schema.getUserSchema();
     }
 
 
+    public void stop()
+    {
+        LOG.info( "Closing the LDAP server connection" );
+        
+        if ( connection != null )
+        {
+            try
+            {
+                connection.close();
+            }
+            catch ( Exception e )
+            {
+                LOG.warn( "Failed to close the LDAP server connection", e );
+            }
+        }
+    }
+
+
+    private void createConnection() throws IOException, LdapException
+    {
+        LOG.info( "Creating LDAP server connection" );
+        
+        InputStream in = this.getClass().getClassLoader().getResourceAsStream( "ldap-server.properties"
);
+        Properties prop = new Properties();
+        prop.load( in );
+
+        String host = prop.getProperty( "escimo.ldap.server.host" );
+        String portVal = prop.getProperty( "escimo.ldap.server.port" );
+        int port = Integer.parseInt( portVal );
+        String user = prop.getProperty( "escimo.ldap.server.user" );
+        String password = prop.getProperty( "escimo.ldap.server.password" );
+        String tlsVal = prop.getProperty( "escimo.ldap.server.useTls" );
+
+        LdapConnectionConfig config = new LdapConnectionConfig();
+        config.setLdapHost( host );
+        config.setLdapPort( port );
+        config.setUseTls( Boolean.parseBoolean( tlsVal ) );
+        config.setName( user );
+        config.setCredentials( password );
+
+        connection = new LdapNetworkConnection( config );
+        connection.bind();
+    }
+
+
     public User getUser( String id ) throws ResourceNotFoundException
     {
         SimpleType st = ( SimpleType ) userSchema.getCoreAttribute( "id" );
@@ -230,7 +302,7 @@ public class LdapResourceProvider
                         atGroupList = getValuesFor( stg, entry );
                     }
 
-                    if( atGroupList != null )
+                    if ( atGroupList != null )
                     {
                         MultiValAttribute mv = new MultiValAttribute( mt.getName(), atGroupList
);
                         user.addAttribute( bt.getUri(), mv );
@@ -408,6 +480,7 @@ public class LdapResourceProvider
         return ldapValue.getString();
     }
 
+
     public String formatDate( String zTime )
     {
         //parse a value like 20120302164134Z to 2012-03-02T16:41:34Z 
@@ -415,39 +488,40 @@ public class LdapResourceProvider
         int start = 0;
         int end = 4;
         sb.append( zTime.substring( start, end ) )
-          .append("-");
-        
+            .append( "-" );
+
         start = end;
         end += 2;
         sb.append( zTime.substring( start, end ) )
-        .append("-");
-        
+            .append( "-" );
+
         start = end;
         end += 2;
         sb.append( zTime.substring( start, end ) )
-        .append("-");
-        
+            .append( "-" );
+
         sb.append( "T" );
-        
+
         start = end;
         end += 2;
         sb.append( zTime.substring( start, end ) )
-        .append(":");
-        
+            .append( ":" );
+
         start = end;
         end += 2;
         sb.append( zTime.substring( start, end ) )
-        .append(":");
+            .append( ":" );
 
         start = end;
         end += 2;
         sb.append( zTime.substring( start, end ) );
 
         sb.append( "Z" );
-        
+
         return sb.toString();
     }
 
+
     //    public List<SimpleAttribute> getValuesInto( List<SimpleType> lstTyps,
Entry entry ) throws LdapException
     //    {
     //    }
@@ -485,11 +559,11 @@ public class LdapResourceProvider
         LdapNetworkConnection c = new LdapNetworkConnection( "localhost", 10389 );
         c.setTimeOut( Long.MAX_VALUE );
         c.bind( "uid=admin,ou=system", "secret" );
-        c.loadSchema(new JarLdifSchemaLoader());
+        c.loadSchema( new JarLdifSchemaLoader() );
 
-//        PersistentSearch ps = new PersistentSearchImpl();
-//        ps.setChangesOnly( false );
-//        ps.setReturnECs( true );
+        //        PersistentSearch ps = new PersistentSearchImpl();
+        //        ps.setChangesOnly( false );
+        //        ps.setReturnECs( true );
 
         SearchRequest searchRequest = new SearchRequestImpl().setBase( new Dn(
             "uid=kirana,ou=users,dc=signon,dc=mirth,dc=com" ) ).setFilter( "(objectclass=*)"
).setScope(
@@ -505,14 +579,14 @@ public class LdapResourceProvider
             SearchResultEntry se = ( SearchResultEntry ) response;
             entry = se.getEntry();
         }
-        
+
         cursor.close();
-        
+
         System.out.println( entry );
         LdapResourceProvider lr = new LdapResourceProvider( c );
         User user = lr.toUser( entry );
         System.out.println( user );
-        System.out.println( JsonSerializer.serialize( user ) );
+        System.out.println( ResourceSerializer.serialize( user ) );
         c.close();
     }
 }

Modified: directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/schema/ResourceSchema.java
URL: http://svn.apache.org/viewvc/directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/schema/ResourceSchema.java?rev=1510433&r1=1510432&r2=1510433&view=diff
==============================================================================
--- directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/schema/ResourceSchema.java
(original)
+++ directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/schema/ResourceSchema.java
Mon Aug  5 11:32:57 2013
@@ -23,6 +23,7 @@ package org.apache.directory.scim.ldap.s
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.HashMap;
+import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
 
@@ -40,8 +41,8 @@ public abstract class ResourceSchema
 
     private List<String> uris = new ArrayList<String>();
 
-    private Map<String, BaseType> coreTypes = new HashMap<String, BaseType>();
-    private Map<String, BaseType> extendedTypes = new HashMap<String, BaseType>();
+    private Map<String, BaseType> coreTypes = new LinkedHashMap<String, BaseType>();
+    private Map<String, BaseType> extendedTypes = new LinkedHashMap<String, BaseType>();
 
 
     public ResourceSchema( String baseDn, String filter )

Added: directory/escimo/trunk/ldap/src/main/resources/ldap-server.properties
URL: http://svn.apache.org/viewvc/directory/escimo/trunk/ldap/src/main/resources/ldap-server.properties?rev=1510433&view=auto
==============================================================================
--- directory/escimo/trunk/ldap/src/main/resources/ldap-server.properties (added)
+++ directory/escimo/trunk/ldap/src/main/resources/ldap-server.properties Mon Aug  5 11:32:57
2013
@@ -0,0 +1,22 @@
+#############################################################################
+#    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.
+#############################################################################
+
+escimo.ldap.server.host = localhost
+escimo.ldap.server.port = 10389
+escimo.ldap.server.user = uid=admin,ou=system
+escimo.ldap.server.password = secret
+escimo.ldap.server.useTls = false

Modified: directory/escimo/trunk/pom.xml
URL: http://svn.apache.org/viewvc/directory/escimo/trunk/pom.xml?rev=1510433&r1=1510432&r2=1510433&view=diff
==============================================================================
--- directory/escimo/trunk/pom.xml (original)
+++ directory/escimo/trunk/pom.xml Mon Aug  5 11:32:57 2013
@@ -16,9 +16,7 @@
   KIND, either express or implied.  See the License for the
   specific language governing permissions and limitations
   under the License.
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+--><project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
   <modelVersion>4.0.0</modelVersion>
   <groupId>org.apache.directory.scim</groupId>
   <artifactId>escimo</artifactId>
@@ -38,6 +36,7 @@
     <module>common</module>
     <module>client</module>
     <module>ldap</module>
+    <module>tests</module>
   </modules>
   
  <dependencyManagement>
@@ -77,4 +76,4 @@
     </dependency>
   </dependencies>
 
-</project>
+</project>
\ No newline at end of file

Modified: directory/escimo/trunk/server/pom.xml
URL: http://svn.apache.org/viewvc/directory/escimo/trunk/server/pom.xml?rev=1510433&r1=1510432&r2=1510433&view=diff
==============================================================================
--- directory/escimo/trunk/server/pom.xml (original)
+++ directory/escimo/trunk/server/pom.xml Mon Aug  5 11:32:57 2013
@@ -1,44 +1,38 @@
 <?xml version="1.0"?>
-<!--
-    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.
--->
+<!-- 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. -->
 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
-  <modelVersion>4.0.0</modelVersion>
-  <parent>
-    <groupId>org.apache.directory.scim</groupId>
-    <artifactId>escimo</artifactId>
+    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.apache.directory.scim</groupId>
+        <artifactId>escimo</artifactId>
+        <version>1.0-SNAPSHOT</version>
+    </parent>
+    <artifactId>escimo-server</artifactId>
+    <packaging>war</packaging>
     <version>1.0-SNAPSHOT</version>
-  </parent>
-  <artifactId>escimo-server</artifactId>
-  <packaging>war</packaging>
-  <version>1.0-SNAPSHOT</version>
-  <name>eSCIMo server</name>
+    <name>eSCIMo server</name>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.wink</groupId>
+            <artifactId>wink-server</artifactId>
+            <version>${wink.version}</version>
+        </dependency>
 
-  <dependencies>
-   <dependency>
-    <groupId>org.apache.wink</groupId>
-    <artifactId>wink-server</artifactId>
-    <version>${wink.version}</version>
-   </dependency>
-   
-   <dependency>
-    <groupId>${project.groupId}</groupId>
-    <artifactId>escimo-common</artifactId>
-    <version>${project.version}</version>
-   </dependency>   
-  </dependencies>
+        <dependency>
+            <groupId>${project.groupId}</groupId>
+            <artifactId>escimo-common</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+    </dependencies>
 </project>

Added: directory/escimo/trunk/server/src/main/java/org/apache/directory/scim/rest/EscimoApplication.java
URL: http://svn.apache.org/viewvc/directory/escimo/trunk/server/src/main/java/org/apache/directory/scim/rest/EscimoApplication.java?rev=1510433&view=auto
==============================================================================
--- directory/escimo/trunk/server/src/main/java/org/apache/directory/scim/rest/EscimoApplication.java
(added)
+++ directory/escimo/trunk/server/src/main/java/org/apache/directory/scim/rest/EscimoApplication.java
Mon Aug  5 11:32:57 2013
@@ -0,0 +1,48 @@
+/*
+ *   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.rest;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.ws.rs.core.Application;
+
+/**
+ * TODO EscimoApplication.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class EscimoApplication extends Application
+{
+    private Set<Class<?>> resources = new HashSet<Class<?>>();
+    
+    
+    public EscimoApplication()
+    {
+        resources.add( UserService.class );
+    }
+    
+    @Override
+    public Set<Class<?>> getClasses()
+    {
+        return resources;
+    }
+
+}

Added: directory/escimo/trunk/server/src/main/java/org/apache/directory/scim/rest/ServerInitializer.java
URL: http://svn.apache.org/viewvc/directory/escimo/trunk/server/src/main/java/org/apache/directory/scim/rest/ServerInitializer.java?rev=1510433&view=auto
==============================================================================
--- directory/escimo/trunk/server/src/main/java/org/apache/directory/scim/rest/ServerInitializer.java
(added)
+++ directory/escimo/trunk/server/src/main/java/org/apache/directory/scim/rest/ServerInitializer.java
Mon Aug  5 11:32:57 2013
@@ -0,0 +1,64 @@
+/*
+ *   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.rest;
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.directory.scim.ProviderService;
+
+/**
+ * TODO ServerInitializer.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class ServerInitializer
+{
+    private static ProviderService provider;
+    
+    private static void init()
+    {
+        String fqcn = System.getProperty( "escimo.resource.provider", "org.apache.directory.scim.ldap.LdapResourceProvider"
);
+        if(StringUtils.isBlank( fqcn ))
+        {
+            throw new RuntimeException( "No resource provider implementation class is found"
);
+        }
+        
+        try
+        {
+            provider = ( ProviderService ) Class.forName( fqcn ).newInstance();
+            provider.init();
+        }
+        catch( Exception e )
+        {
+            RuntimeException re = new RuntimeException( "Unable to instantiate the resource
provider implementation class " + fqcn );
+            re.initCause( e );
+            throw re;
+        }
+    }
+    
+    public static ProviderService getProvider()
+    {
+        if( provider == null )
+        {
+            init();
+        }
+        
+        return provider;
+    }
+}

Added: directory/escimo/trunk/server/src/main/java/org/apache/directory/scim/rest/UserService.java
URL: http://svn.apache.org/viewvc/directory/escimo/trunk/server/src/main/java/org/apache/directory/scim/rest/UserService.java?rev=1510433&view=auto
==============================================================================
--- directory/escimo/trunk/server/src/main/java/org/apache/directory/scim/rest/UserService.java
(added)
+++ directory/escimo/trunk/server/src/main/java/org/apache/directory/scim/rest/UserService.java
Mon Aug  5 11:32:57 2013
@@ -0,0 +1,70 @@
+/*
+ * 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.rest;
+
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.Response.Status;
+import javax.ws.rs.core.UriInfo;
+import javax.ws.rs.core.Response.ResponseBuilder;
+
+import org.apache.directory.scim.ProviderService;
+import org.apache.directory.scim.ResourceNotFoundException;
+import org.apache.directory.scim.User;
+import org.apache.directory.scim.json.ResourceSerializer;
+
+/**
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+@Path( "Users" )
+public class UserService
+{
+
+    @Context
+    UriInfo uriInfo;
+    
+    private ProviderService provider = ServerInitializer.getProvider();
+    
+    @GET
+    @Produces({MediaType.APPLICATION_JSON})
+    @Path("{id}")
+    public Response getUser( @PathParam("id") String userId )
+    {
+        ResponseBuilder rb = null;
+        
+        try
+        {
+            User user = provider.getUser( userId );
+            String json = ResourceSerializer.serialize( user );
+            rb = Response.ok( json, MediaType.APPLICATION_JSON );
+        }
+        catch( ResourceNotFoundException e )
+        {
+            rb = Response.status( Status.INTERNAL_SERVER_ERROR );
+        }
+        
+        return rb.build();
+    }
+}

Added: directory/escimo/trunk/server/src/main/webapp/WEB-INF/application
URL: http://svn.apache.org/viewvc/directory/escimo/trunk/server/src/main/webapp/WEB-INF/application?rev=1510433&view=auto
==============================================================================
--- directory/escimo/trunk/server/src/main/webapp/WEB-INF/application (added)
+++ directory/escimo/trunk/server/src/main/webapp/WEB-INF/application Mon Aug  5 11:32:57
2013
@@ -0,0 +1 @@
+org.apache.directory.scim.rest.UserService
\ No newline at end of file

Modified: directory/escimo/trunk/server/src/main/webapp/WEB-INF/web.xml
URL: http://svn.apache.org/viewvc/directory/escimo/trunk/server/src/main/webapp/WEB-INF/web.xml?rev=1510433&r1=1510432&r2=1510433&view=diff
==============================================================================
--- directory/escimo/trunk/server/src/main/webapp/WEB-INF/web.xml (original)
+++ directory/escimo/trunk/server/src/main/webapp/WEB-INF/web.xml Mon Aug  5 11:32:57 2013
@@ -4,28 +4,28 @@
     "http://java.sun.com/dtd/web-app_2_3.dtd">
 
 <web-app>
-	<listener>
-		<listener-class></listener-class>
-	</listener>
-	<!-- Servlets -->
-	<servlet>
-		<servlet-name>scimService</servlet-name>
-		<servlet-class>
-			org.apache.wink.server.internal.servlet.RestServlet
-		</servlet-class>
-		<init-param>
-			<param-name>propertiesLocation</param-name>
-			<param-value>/WEB-INF/configuration.properties</param-value>
-		</init-param>
-		<!-- <init-param>
-			<param-name>winkApplicationConfigLocation</param-name>
-			<param-value>/WEB-INF/application</param-value>
-		</init-param>-->
-		<load-on-startup>0</load-on-startup>
-	</servlet>
-	
-	<servlet-mapping>
-		<servlet-name>scimService</servlet-name>
-		<url-pattern>/scim/*</url-pattern>
-	</servlet-mapping>
+    <listener>
+        <listener-class></listener-class>
+    </listener>
+    <!-- Servlets -->
+    <servlet>
+        <servlet-name>escimoService</servlet-name>
+        <servlet-class>
+            org.apache.wink.server.internal.servlet.RestServlet
+        </servlet-class>
+        <init-param>
+            <param-name>propertiesLocation</param-name>
+            <param-value>/WEB-INF/configuration.properties</param-value>
+        </init-param>
+        <init-param>
+            <param-name>javax.ws.rs.Application</param-name>
+            <param-value>org.apache.directory.scim.rest.EscimoApplication</param-value>
+        </init-param>
+        <load-on-startup>1</load-on-startup>
+    </servlet>
+
+    <servlet-mapping>
+        <servlet-name>escimoService</servlet-name>
+        <url-pattern>/v2/*</url-pattern>
+    </servlet-mapping>
 </web-app>



Mime
View raw message