You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by ka...@apache.org on 2013/10/12 21:32:13 UTC
svn commit: r1531583 - in /directory/escimo/trunk: ./ client/
client/src/main/java/org/apache/directory/scim/ client/src/main/resources/
common/ common/src/main/java/org/apache/directory/scim/
common/src/main/java/org/apache/directory/scim/json/ common...
Author: kayyagari
Date: Sat Oct 12 19:32:12 2013
New Revision: 1531583
URL: http://svn.apache.org/r1531583
Log:
megred the jsson-schema-escimo branch
Added:
directory/escimo/trunk/client/src/main/java/org/apache/directory/scim/EscimoClient.java
- copied unchanged from r1531581, directory/escimo/branches/json-schema-experiment/client/src/main/java/org/apache/directory/scim/EscimoClient.java
directory/escimo/trunk/client/src/main/java/org/apache/directory/scim/FieldExclusionStrategy.java
- copied unchanged from r1531581, directory/escimo/branches/json-schema-experiment/client/src/main/java/org/apache/directory/scim/FieldExclusionStrategy.java
directory/escimo/trunk/client/src/main/resources/
- copied from r1531581, directory/escimo/branches/json-schema-experiment/client/src/main/resources/
directory/escimo/trunk/common/src/main/java/org/apache/directory/scim/GroupResource.java
- copied unchanged from r1531581, directory/escimo/branches/json-schema-experiment/common/src/main/java/org/apache/directory/scim/GroupResource.java
directory/escimo/trunk/common/src/main/java/org/apache/directory/scim/Resource.java
- copied unchanged from r1531581, directory/escimo/branches/json-schema-experiment/common/src/main/java/org/apache/directory/scim/Resource.java
directory/escimo/trunk/common/src/main/java/org/apache/directory/scim/UserResource.java
- copied unchanged from r1531581, directory/escimo/branches/json-schema-experiment/common/src/main/java/org/apache/directory/scim/UserResource.java
directory/escimo/trunk/json2java/ (props changed)
- copied from r1531581, directory/escimo/branches/json-schema-experiment/json2java/
directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/LdapUtil.java
- copied unchanged from r1531581, directory/escimo/branches/json-schema-experiment/ldap/src/main/java/org/apache/directory/scim/ldap/LdapUtil.java
directory/escimo/trunk/schema/ (props changed)
- copied from r1531581, directory/escimo/branches/json-schema-experiment/schema/
directory/escimo/trunk/server/src/main/java/org/apache/directory/scim/rest/SchemaService.java
- copied unchanged from r1531581, directory/escimo/branches/json-schema-experiment/server/src/main/java/org/apache/directory/scim/rest/SchemaService.java
directory/escimo/trunk/tests/src/test/java/org/apache/directory/scim/UserResourceTest.java
- copied unchanged from r1531581, directory/escimo/branches/json-schema-experiment/tests/src/test/java/org/apache/directory/scim/UserResourceTest.java
Removed:
directory/escimo/trunk/common/src/main/java/org/apache/directory/scim/CoreResource.java
directory/escimo/trunk/common/src/main/java/org/apache/directory/scim/Group.java
directory/escimo/trunk/common/src/main/java/org/apache/directory/scim/User.java
directory/escimo/trunk/common/src/main/java/org/apache/directory/scim/json/SimpleAttributeDeSerializer.java
directory/escimo/trunk/common/src/main/resources/enterprise-user-schema.json
directory/escimo/trunk/common/src/main/resources/group-schema.json
directory/escimo/trunk/common/src/main/resources/user-schema.json
Modified:
directory/escimo/trunk/ (props changed)
directory/escimo/trunk/client/pom.xml
directory/escimo/trunk/common/pom.xml
directory/escimo/trunk/common/src/main/java/org/apache/directory/scim/AttributeHandler.java
directory/escimo/trunk/common/src/main/java/org/apache/directory/scim/ProviderService.java
directory/escimo/trunk/common/src/main/java/org/apache/directory/scim/RequestContext.java
directory/escimo/trunk/common/src/main/java/org/apache/directory/scim/ScimUtil.java
directory/escimo/trunk/common/src/main/java/org/apache/directory/scim/json/ResourceSerializer.java
directory/escimo/trunk/common/src/main/java/org/apache/directory/scim/schema/BaseType.java
directory/escimo/trunk/ldap/pom.xml
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/handlers/ActiveAttributeHandler.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/MembersAttributeHandler.java
directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/handlers/MetaAttributeHandler.java
directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/handlers/PhotosAttributeHandler.java
directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/schema/MultiValType.java
directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/schema/SimpleType.java
directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/schema/SimpleTypeGroup.java
directory/escimo/trunk/ldap/src/main/resources/escimo-ldap-mapping.xml
directory/escimo/trunk/pom.xml
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/GroupService.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/tests/pom.xml
directory/escimo/trunk/tests/src/main/java/org/apache/directory/scim/JettyServer.java
Propchange: directory/escimo/trunk/
------------------------------------------------------------------------------
--- svn:mergeinfo (added)
+++ svn:mergeinfo Sat Oct 12 19:32:12 2013
@@ -0,0 +1 @@
+/directory/escimo/branches/json-schema-experiment:1525389-1531581
Modified: directory/escimo/trunk/client/pom.xml
URL: http://svn.apache.org/viewvc/directory/escimo/trunk/client/pom.xml?rev=1531583&r1=1531582&r2=1531583&view=diff
==============================================================================
--- directory/escimo/trunk/client/pom.xml (original)
+++ directory/escimo/trunk/client/pom.xml Sat Oct 12 19:32:12 2013
@@ -29,9 +29,15 @@
<dependencies>
<dependency>
- <groupId>org.apache.wink</groupId>
- <artifactId>wink-client</artifactId>
- <version>${wink.version}</version>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>escimo-schema</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.httpcomponents</groupId>
+ <artifactId>httpclient</artifactId>
+ <version>${httpclient.version}</version>
</dependency>
<dependency>
@@ -39,6 +45,7 @@
<artifactId>escimo-common</artifactId>
<version>${project.version}</version>
</dependency>
-
+
</dependencies>
+
</project>
Modified: directory/escimo/trunk/common/pom.xml
URL: http://svn.apache.org/viewvc/directory/escimo/trunk/common/pom.xml?rev=1531583&r1=1531582&r2=1531583&view=diff
==============================================================================
--- directory/escimo/trunk/common/pom.xml (original)
+++ directory/escimo/trunk/common/pom.xml Sat Oct 12 19:32:12 2013
@@ -29,54 +29,17 @@
<name>eSCIMo common API</name>
<dependencies>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>escimo-schema</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
<!-- for the lack of any API spec jar for jax-rs 2.0 including Wink server in common -->
<dependency>
<groupId>org.apache.wink</groupId>
<artifactId>wink-server</artifactId>
<version>${wink.version}</version>
</dependency>
- <dependency>
- <groupId>com.google.code.gson</groupId>
- <artifactId>gson</artifactId>
- <version>2.2.4</version>
- </dependency>
</dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>com.sun.tools.xjc.maven2</groupId>
- <artifactId>maven-jaxb-plugin</artifactId>
- <executions>
- <execution>
- <goals>
- <goal>generate</goal>
- </goals>
- </execution>
- </executions>
- <configuration>
- <generatePackage>org.apache.directory.scim.common</generatePackage>
- <includeSchemas>
- <includeSchema>**/*.xsd</includeSchema>
- <includeSchema>**/*.dtd</includeSchema>
- </includeSchemas>
- <excludeSchemas>
- <excludeSchema>test*.xsd</excludeSchema>
- </excludeSchemas>
- <includeBindings>
- <includeBinding>*.xjb</includeBinding>
- </includeBindings>
- <strict>false</strict>
- <verbose>true</verbose>
- </configuration>
- </plugin>
-<!-- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <configuration>
- <source>1.5</source>
- </configuration>
- </plugin>
- --> </plugins>
- </build>
</project>
Modified: directory/escimo/trunk/common/src/main/java/org/apache/directory/scim/AttributeHandler.java
URL: http://svn.apache.org/viewvc/directory/escimo/trunk/common/src/main/java/org/apache/directory/scim/AttributeHandler.java?rev=1531583&r1=1531582&r2=1531583&view=diff
==============================================================================
--- directory/escimo/trunk/common/src/main/java/org/apache/directory/scim/AttributeHandler.java (original)
+++ directory/escimo/trunk/common/src/main/java/org/apache/directory/scim/AttributeHandler.java Sat Oct 12 19:32:12 2013
@@ -22,13 +22,20 @@ package org.apache.directory.scim;
import org.apache.directory.scim.schema.BaseType;
+import com.google.gson.JsonElement;
+
/**
* TODO AttributeHandler.
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
-public interface AttributeHandler
+public abstract class AttributeHandler
{
- void handle( BaseType bt, Object srcResource, RequestContext ctx );
+ public abstract void read( BaseType bt, Object srcResource, RequestContext ctx );
+
+ public void write( BaseType atType, JsonElement jsonData, Object targetEntry, RequestContext ctx )
+ {
+
+ }
}
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=1531583&r1=1531582&r2=1531583&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 Sat Oct 12 19:32:12 2013
@@ -20,6 +20,8 @@ package org.apache.directory.scim;
import java.io.InputStream;
+import org.apache.directory.scim.schema.JsonSchema;
+
/**
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
@@ -30,9 +32,13 @@ public interface ProviderService
void stop();
- User getUser( RequestContext ctx, String userId ) throws ResourceNotFoundException;
+ UserResource getUser( RequestContext ctx, String userId ) throws ResourceNotFoundException;
InputStream getUserPhoto( String id, String atName ) throws MissingParameterException;
- Group getGroup( RequestContext ctx, String groupId ) throws ResourceNotFoundException;
+ GroupResource getGroup( RequestContext ctx, String groupId ) throws ResourceNotFoundException;
+
+ JsonSchema getSchema( String uriId );
+
+ UserResource addUser( String jsonData, RequestContext ctx ) throws Exception;
}
Modified: directory/escimo/trunk/common/src/main/java/org/apache/directory/scim/RequestContext.java
URL: http://svn.apache.org/viewvc/directory/escimo/trunk/common/src/main/java/org/apache/directory/scim/RequestContext.java?rev=1531583&r1=1531582&r2=1531583&view=diff
==============================================================================
--- directory/escimo/trunk/common/src/main/java/org/apache/directory/scim/RequestContext.java (original)
+++ directory/escimo/trunk/common/src/main/java/org/apache/directory/scim/RequestContext.java Sat Oct 12 19:32:12 2013
@@ -20,6 +20,9 @@
package org.apache.directory.scim;
+import java.util.HashMap;
+import java.util.Map;
+
import javax.ws.rs.core.UriInfo;
@@ -34,8 +37,9 @@ public class RequestContext
private UriInfo uriInfo;
- private CoreResource resource;
+ private Resource resource;
+ private Map<String,String> reqParams;
public RequestContext( ProviderService providerService )
{
@@ -43,13 +47,13 @@ public class RequestContext
}
- public CoreResource getCoreResource()
+ public Resource getCoreResource()
{
return resource;
}
- public void setCoreResource( CoreResource resource )
+ public void setCoreResource( Resource resource )
{
this.resource = resource;
}
@@ -72,4 +76,25 @@ public class RequestContext
return providerService;
}
+
+ public void addReqParam( String name, String value )
+ {
+ if( reqParams == null )
+ {
+ reqParams = new HashMap<String, String>();
+ }
+
+ reqParams.put( name, value );
+ }
+
+
+ public String getReqParam( String name )
+ {
+ if( reqParams == null )
+ {
+ return null;
+ }
+
+ return reqParams.get( name );
+ }
}
Modified: directory/escimo/trunk/common/src/main/java/org/apache/directory/scim/ScimUtil.java
URL: http://svn.apache.org/viewvc/directory/escimo/trunk/common/src/main/java/org/apache/directory/scim/ScimUtil.java?rev=1531583&r1=1531582&r2=1531583&view=diff
==============================================================================
--- directory/escimo/trunk/common/src/main/java/org/apache/directory/scim/ScimUtil.java (original)
+++ directory/escimo/trunk/common/src/main/java/org/apache/directory/scim/ScimUtil.java Sat Oct 12 19:32:12 2013
@@ -18,14 +18,30 @@
*/
package org.apache.directory.scim;
+
+import java.io.PrintWriter;
+import java.io.StringWriter;
+
+
/**
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public class ScimUtil
{
- /*public static User toUser( Entry entry )
+ public static String exceptionToStr( Exception e )
{
+ StringWriter sw = new StringWriter();
+
+ PrintWriter pw = new PrintWriter( sw );
+
+ pw.write( e.getMessage() );
- }*/
+ e.printStackTrace( pw );
+
+ pw.close();
+
+ return sw.toString();
+ }
+
}
Modified: directory/escimo/trunk/common/src/main/java/org/apache/directory/scim/json/ResourceSerializer.java
URL: http://svn.apache.org/viewvc/directory/escimo/trunk/common/src/main/java/org/apache/directory/scim/json/ResourceSerializer.java?rev=1531583&r1=1531582&r2=1531583&view=diff
==============================================================================
--- directory/escimo/trunk/common/src/main/java/org/apache/directory/scim/json/ResourceSerializer.java (original)
+++ directory/escimo/trunk/common/src/main/java/org/apache/directory/scim/json/ResourceSerializer.java Sat Oct 12 19:32:12 2013
@@ -25,12 +25,12 @@ import java.util.Map;
import org.apache.directory.scim.AbstractAttribute;
import org.apache.directory.scim.ComplexAttribute;
-import org.apache.directory.scim.CoreResource;
-import org.apache.directory.scim.Group;
+import org.apache.directory.scim.Resource;
+import org.apache.directory.scim.GroupResource;
import org.apache.directory.scim.MultiValAttribute;
import org.apache.directory.scim.SimpleAttribute;
import org.apache.directory.scim.SimpleAttributeGroup;
-import org.apache.directory.scim.User;
+import org.apache.directory.scim.UserResource;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
@@ -48,19 +48,8 @@ public class ResourceSerializer
public static final String CORE_GROUP_URI = "urn:scim:schemas:core:2.0:Group";
public static final String CORE_EXT_USER_URI = "urn:scim:schemas:extension:enterprise:2.0:User";
- public static String serialize( User user )
- {
- return _serialize( user );
- }
-
-
- public static String serialize( Group group )
- {
- return _serialize( group );
- }
-
- private static String _serialize( CoreResource resource )
+ public static String serialize( Resource resource )
{
JsonObject root = new JsonObject();
Modified: directory/escimo/trunk/common/src/main/java/org/apache/directory/scim/schema/BaseType.java
URL: http://svn.apache.org/viewvc/directory/escimo/trunk/common/src/main/java/org/apache/directory/scim/schema/BaseType.java?rev=1531583&r1=1531582&r2=1531583&view=diff
==============================================================================
--- directory/escimo/trunk/common/src/main/java/org/apache/directory/scim/schema/BaseType.java (original)
+++ directory/escimo/trunk/common/src/main/java/org/apache/directory/scim/schema/BaseType.java Sat Oct 12 19:32:12 2013
@@ -38,6 +38,8 @@ public abstract class BaseType
private String atHandlerName;
+ private boolean readOnly = false;
+
public BaseType( String uri, String name, boolean show )
{
this.uri = uri;
@@ -114,4 +116,22 @@ public abstract class BaseType
return false;
}
+
+ /**
+ * @return the readOnly
+ */
+ public boolean isReadOnly()
+ {
+ return readOnly;
+ }
+
+
+ /**
+ * @param readOnly the readOnly to set
+ */
+ public void setReadOnly( boolean readOnly )
+ {
+ this.readOnly = readOnly;
+ }
+
}
Propchange: directory/escimo/trunk/json2java/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Sat Oct 12 19:32:12 2013
@@ -0,0 +1,3 @@
+.classpath
+.project
+target
Modified: directory/escimo/trunk/ldap/pom.xml
URL: http://svn.apache.org/viewvc/directory/escimo/trunk/ldap/pom.xml?rev=1531583&r1=1531582&r2=1531583&view=diff
==============================================================================
--- directory/escimo/trunk/ldap/pom.xml (original)
+++ directory/escimo/trunk/ldap/pom.xml Sat Oct 12 19:32:12 2013
@@ -11,11 +11,6 @@
<artifactId>escimo-ldap</artifactId>
<name>eSCIMo LDAP Backend</name>
- <properties>
- <ldap.api.version>1.0.0-M20-SNAPSHOT</ldap.api.version>
- <dom4j.version>1.6.1</dom4j.version>
- </properties>
-
<dependencies>
<dependency>
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=1531583&r1=1531582&r2=1531583&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 Sat Oct 12 19:32:12 2013
@@ -26,10 +26,13 @@ import static org.apache.directory.api.l
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
+import java.net.URL;
import java.util.ArrayList;
import java.util.Collection;
+import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
+import java.util.Map;
import java.util.Properties;
import org.apache.directory.api.ldap.model.constants.SchemaConstants;
@@ -62,8 +65,8 @@ import org.apache.directory.ldap.client.
import org.apache.directory.ldap.client.api.LdapNetworkConnection;
import org.apache.directory.scim.AttributeHandler;
import org.apache.directory.scim.ComplexAttribute;
-import org.apache.directory.scim.CoreResource;
-import org.apache.directory.scim.Group;
+import org.apache.directory.scim.Resource;
+import org.apache.directory.scim.GroupResource;
import org.apache.directory.scim.MissingParameterException;
import org.apache.directory.scim.MultiValAttribute;
import org.apache.directory.scim.ProviderService;
@@ -71,7 +74,7 @@ import org.apache.directory.scim.Request
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.UserResource;
import org.apache.directory.scim.ldap.schema.ComplexType;
import org.apache.directory.scim.ldap.schema.GroupSchema;
import org.apache.directory.scim.ldap.schema.MultiValType;
@@ -81,6 +84,8 @@ import org.apache.directory.scim.ldap.sc
import org.apache.directory.scim.ldap.schema.TypedType;
import org.apache.directory.scim.ldap.schema.UserSchema;
import org.apache.directory.scim.schema.BaseType;
+import org.apache.directory.scim.schema.JsonSchema;
+import org.apache.directory.scim.schema.SchemaUtil;
import org.apache.directory.scim.util.ResourceUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -107,6 +112,8 @@ public class LdapResourceProvider implem
private SchemaManager ldapSchema;
+ private Map<String,JsonSchema> schemas = new HashMap<String, JsonSchema>();
+
private static final Logger LOG = LoggerFactory.getLogger( LdapResourceProvider.class );
@@ -124,6 +131,25 @@ public class LdapResourceProvider implem
public void init() throws Exception
{
LOG.info( "Initializing LDAP resource provider" );
+
+ try
+ {
+ List<URL> urls = SchemaUtil.getDefaultSchemas();
+ for( URL u : urls )
+ {
+ JsonSchema json = SchemaUtil.getSchemaJson( u );
+ schemas.put( json.getId(), json );
+ }
+
+ // TODO load custom schemas
+ }
+ catch( Exception e )
+ {
+ RuntimeException re = new RuntimeException( "Failed to load the default schemas" );
+ re.initCause( e );
+ throw re;
+ }
+
if ( connection == null )
{
createConnection();
@@ -134,11 +160,13 @@ public class LdapResourceProvider implem
( ( LdapNetworkConnection ) connection ).loadSchema( new JarLdifSchemaLoader() );
}
- schemaMapper = new LdapSchemaMapper();
+ ldapSchema = connection.getSchemaManager();
+
+ Map<String,JsonSchema> jsonSchemaCopy = new HashMap<String, JsonSchema>( schemas );
+ schemaMapper = new LdapSchemaMapper( jsonSchemaCopy, ldapSchema );
schemaMapper.loadMappings();
userSchema = schemaMapper.getUserSchema();
groupSchema = schemaMapper.getGroupSchema();
- ldapSchema = connection.getSchemaManager();
}
@@ -187,13 +215,13 @@ public class LdapResourceProvider implem
}
- public User getUser( RequestContext ctx, String id ) throws ResourceNotFoundException
+ public UserResource getUser( RequestContext ctx, String id ) throws ResourceNotFoundException
{
Entry entry = fetchEntryById( id, userSchema );
if ( entry == null )
{
- throw new ResourceNotFoundException( "No User resource found with the ID " + id );
+ throw new ResourceNotFoundException( "No UserResource resource found with the ID " + id );
}
try
@@ -207,7 +235,6 @@ public class LdapResourceProvider implem
}
- @Override
public InputStream getUserPhoto( String id, String atName ) throws MissingParameterException
{
if ( Strings.isEmpty( id ) )
@@ -240,14 +267,13 @@ public class LdapResourceProvider implem
}
- @Override
- public Group getGroup( RequestContext ctx, String groupId ) throws ResourceNotFoundException
+ public GroupResource getGroup( RequestContext ctx, String groupId ) throws ResourceNotFoundException
{
Entry entry = fetchEntryById( groupId, groupSchema );
if ( entry == null )
{
- throw new ResourceNotFoundException( "No Group resource found with the ID " + groupId );
+ throw new ResourceNotFoundException( "No GroupResource resource found with the ID " + groupId );
}
try
@@ -262,114 +288,112 @@ public class LdapResourceProvider implem
}
- public void addUser( String json )
- {
- JsonParser parser = new JsonParser();
- JsonObject obj = ( JsonObject ) parser.parse( json );
-
- List<String> uris = userSchema.getUris();
- for( String u : uris )
- {
- JsonObject userAtObj = ( JsonObject ) obj.get( u );
- }
- }
-
- private void addAttributes( Entry entry, JsonObject obj )
+ private void addAttributes( Entry entry, JsonObject obj, RequestContext ctx ) throws LdapException
{
for( java.util.Map.Entry<String, JsonElement> e : obj.entrySet() )
{
String name = e.getKey();
- BaseType bt = userSchema.getAttribute( name );
-
- if( bt == null )
+ if( name.startsWith( "urn:scim:schemas:" ) )
{
- throw new IllegalArgumentException( "Unknown attribute name " + name + " is present in the JSON payload" );
+ continue;
}
- String value = e.getValue().getAsString();
- }
- }
-
-
- private void processAttributeData( BaseType bt, JsonElement el, Entry entry ) throws LdapException
- {
- if( bt instanceof SimpleType )
- {
- SimpleType st = ( SimpleType ) bt;
- String ldapAtName = st.getMappedTo();
- if( Strings.isEmpty( ldapAtName ) )
+ BaseType bt = userSchema.getAttribute( name );
+
+ if( bt == null )
{
- throw new IllegalArgumentException( "Attribute " + bt.getName() + " is not mapped to any LDAP attribute in the config" );
+ throw new IllegalArgumentException( "Unknown attribute name " + name + " is present in the JSON payload that has no corresponding mapping in the escimo-ldap-mapping.xml file" );
}
- AttributeType ldapType = ldapSchema.getAttributeType( ldapAtName );
-
- Attribute ldapAt = entry.get( ldapType );
- if( ldapAt == null )
+ if( bt.isReadOnly() )
{
- ldapAt = new DefaultAttribute( ldapAtName );
+ continue;
}
+
+ AttributeHandler handler = userSchema.getHandler( bt.getAtHandlerName() );
- if( !ldapType.getSyntax().isHumanReadable() )
+ if( handler != null )
{
- byte[] value = Base64.decode( el.getAsString().toCharArray() );
- ldapAt.add( value );
+ handler.write( bt, e.getValue(), entry, ctx );
}
else
{
- ldapAt.add( el.getAsString() );
+ LdapUtil.scimToLdapAttribute( bt, e.getValue(), entry, ctx );
}
}
}
- public void addUser( User user, RequestContext ctx )
+
+ public UserResource addUser( String json, RequestContext ctx ) throws Exception
{
try
{
+ JsonParser parser = new JsonParser();
+ JsonObject obj = ( JsonObject ) parser.parse( json );
+
Entry entry = new DefaultEntry();
+ // process the core attributes first
+ addAttributes( entry, obj, ctx );
+
+ List<String> uris = userSchema.getUris();
+
+ for( String u : uris )
+ {
+ JsonObject userAtObj = ( JsonObject ) obj.get( u );
+ if( userAtObj != null )
+ {
+ addAttributes( entry, userAtObj, ctx );
+ }
+ }
+
for( String oc : userSchema.getObjectClasses() )
{
entry.add( SchemaConstants.OBJECT_CLASS, oc );
}
- String dn = null;
+ SimpleType st = ( SimpleType ) userSchema.getCoreAttribute( "userName" );
+ String userIdName = st.getMappedTo();
+
+ String dn = ctx.getReqParam( "userDn" );
- SimpleAttribute at = ( SimpleAttribute ) user.get( "userDn" );
- if( at != null )
+ if( Strings.isEmpty( dn ) )
{
- dn = String.valueOf( at.getValue() );
- if( Strings.isEmpty( dn ) )
- {
- dn = null;
- }
+ dn = null;
}
if( dn == null )
{
- SimpleType st = ( SimpleType ) userSchema.getCoreAttribute( "userName" );
- String userIdName = st.getMappedTo();
-
- dn = userIdName + "=" + String.valueOf( user.getVal( "userName" ) ) + "," + userSchema.getBaseDn();
+ String userName = obj.get( "userName" ).getAsString();
+
+ dn = userIdName + "=" + userName + "," + userSchema.getBaseDn();
}
- if( dn != null )
- {
- entry.setDn( dn );
- }
+ entry.setDn( dn );
+ connection.add( entry );
+ entry = connection.lookup( entry.getDn(), SchemaConstants.ALL_ATTRIBUTES_ARRAY );
+
+ UserResource addedUser = new UserResource();
+
+ ctx.setCoreResource( addedUser );
+
+ _loadCoreResource( ctx, entry, userSchema );
+
+ return addedUser;
}
- catch( LdapException e )
+ catch( Exception e )
{
e.printStackTrace();
+ throw e;
}
}
- public User toUser( RequestContext ctx, Entry entry ) throws Exception
+ public UserResource toUser( RequestContext ctx, Entry entry ) throws Exception
{
- User user = new User();
+ UserResource user = new UserResource();
ctx.setCoreResource( user );
@@ -379,9 +403,9 @@ public class LdapResourceProvider implem
}
- public Group toGroup( RequestContext ctx, Entry entry ) throws Exception
+ public GroupResource toGroup( RequestContext ctx, Entry entry ) throws Exception
{
- Group group = new Group();
+ GroupResource group = new GroupResource();
ctx.setCoreResource( group );
_loadCoreResource( ctx, entry, groupSchema );
@@ -392,7 +416,7 @@ public class LdapResourceProvider implem
private void _loadCoreResource( RequestContext ctx, Entry entry, ResourceSchema resourceSchema ) throws Exception
{
- CoreResource resource = ctx.getCoreResource();
+ Resource resource = ctx.getCoreResource();
// first fill in the id, we need this for deriving location
SimpleType idType = ( SimpleType ) resourceSchema.getCoreAttribute( "id" );
@@ -409,7 +433,7 @@ public class LdapResourceProvider implem
private void _loadAttributes( RequestContext ctx, Entry entry, Collection<BaseType> types, SimpleType idType )
throws Exception
{
- CoreResource user = ctx.getCoreResource();
+ Resource user = ctx.getCoreResource();
for ( BaseType bt : types )
{
@@ -448,7 +472,7 @@ public class LdapResourceProvider implem
if ( atHandler != null )
{
AttributeHandler handler = userSchema.getHandler( atHandler );
- handler.handle( ct, entry, ctx );
+ handler.read( ct, entry, ctx );
continue;
}
@@ -474,39 +498,12 @@ public class LdapResourceProvider implem
if ( atHandler != null )
{
AttributeHandler handler = userSchema.getHandler( atHandler );
- handler.handle( bt, entry, ctx );
+ handler.read( bt, entry, ctx );
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 );
-
- if ( !lstAts.isEmpty() )
- {
- lstAts.add( new SimpleAttribute( "type", tt.getName() ) );
- if ( tt.isPrimary() )
- {
- lstAts.add( new SimpleAttribute( "primary", true ) );
- }
- mv.addAtGroup( new SimpleAttributeGroup( lstAts ) );
- }
- }
-
- if ( mv.getAtGroupList() != null )
- {
- user.addAttribute( bt.getUri(), mv );
- }
- }
- else if ( stg != null )
+ SimpleTypeGroup stg = mt.getAtGroup();
+ if ( stg != null )
{
List<SimpleAttributeGroup> atGroupList = getValuesFor( stg, entry );
@@ -535,7 +532,7 @@ public class LdapResourceProvider implem
return null;
}
- List<SimpleType> types = new ArrayList<SimpleType>( stg.getLstSTypes() );
+ List<SimpleType> types = new ArrayList<SimpleType>( stg.getSubTypes() );
types.remove( valType );
Attribute ldapAt = entry.get( valType.getMappedTo() );
@@ -586,7 +583,7 @@ public class LdapResourceProvider implem
if ( atHandler != null )
{
AttributeHandler handler = userSchema.getHandler( atHandler );
- handler.handle( st, entry, ctx );
+ handler.read( st, entry, ctx );
return null;
}
else
@@ -660,7 +657,7 @@ public class LdapResourceProvider implem
String format = stg.getFormat();
- for ( SimpleType st : stg.getLstSTypes() )
+ for ( SimpleType st : stg.getSubTypes() )
{
SimpleAttribute at = getValueForSimpleType( st, entry );
if ( at != null )
@@ -739,6 +736,21 @@ public class LdapResourceProvider implem
return entry;
}
+
+ public JsonSchema getSchema( String uri )
+ {
+ return schemas.get( uri );
+ }
+
+
+ /**
+ * @return the ldapSchema
+ */
+ public SchemaManager getLdapSchema()
+ {
+ return ldapSchema;
+ }
+
public static void main( String[] args ) throws Exception
{
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=1531583&r1=1531582&r2=1531583&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 Sat Oct 12 19:32:12 2013
@@ -31,6 +31,7 @@ import java.util.List;
import java.util.Map;
import org.apache.directory.api.ldap.model.exception.LdapException;
+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.ldap.client.api.LdapConnection;
@@ -42,8 +43,8 @@ import org.apache.directory.scim.ldap.sc
import org.apache.directory.scim.ldap.schema.ResourceSchema;
import org.apache.directory.scim.ldap.schema.SimpleType;
import org.apache.directory.scim.ldap.schema.SimpleTypeGroup;
-import org.apache.directory.scim.ldap.schema.TypedType;
import org.apache.directory.scim.ldap.schema.UserSchema;
+import org.apache.directory.scim.schema.JsonSchema;
import org.dom4j.Document;
import org.dom4j.DocumentHelper;
import org.dom4j.Element;
@@ -66,25 +67,12 @@ public class LdapSchemaMapper implements
private UserSchema userSchema;
-
- public LdapSchemaMapper()
- {
- }
-
-
- public LdapSchemaMapper( LdapConnection connection )
+ private Map<String,JsonSchema> jsonSchemas;
+
+ public LdapSchemaMapper( Map<String,JsonSchema> jsonSchemas, SchemaManager ldapSchema )
{
- try
- {
- connection.loadSchema();
- }
- catch ( LdapException e )
- {
- LOG.debug( "Failed to load schema from the server", e );
- LOG.info( "Could not load schema from the LDAP server, disabling schema checks" );
- }
-
- ldapSchema = connection.getSchemaManager();
+ this.jsonSchemas = jsonSchemas;
+ this.ldapSchema = ldapSchema;
}
@@ -103,6 +91,21 @@ public class LdapSchemaMapper implements
}
+ /**
+ * @return the ldapSchema
+ */
+ public SchemaManager getLdapSchema()
+ {
+ return ldapSchema;
+ }
+
+
+ public AttributeType getLdapAttributeType( String name )
+ {
+ return ldapSchema.getAttributeType( name );
+ }
+
+
public void loadMappings()
{
InputStream in = this.getClass().getClassLoader().getResourceAsStream( "escimo-ldap-mapping.xml" );
@@ -217,6 +220,8 @@ public class LdapSchemaMapper implements
resourceSchema.addUri( uri );
+ JsonSchema json = jsonSchemas.get( uri );
+
List<Element> simpleAtElmList = schemaRoot.elements( "attribute" );
for ( Element el : simpleAtElmList )
@@ -224,6 +229,7 @@ public class LdapSchemaMapper implements
SimpleType st = parseSimpleType( el, uri );
if ( st != null )
{
+ st.setReadOnly( json.isReadOnly( st.getName() ) );
resourceSchema.addAttributeType( st.getName(), st );
}
}
@@ -244,7 +250,7 @@ public class LdapSchemaMapper implements
boolean show = getShowVal( elmComplex );
Element atGrpElm = elmComplex.element( "at-group" );
- SimpleTypeGroup stg = parseAtGroup( atGrpElm, uri );
+ SimpleTypeGroup stg = parseAtGroup( atGrpElm, uri, name );
ComplexType ct = null;
if ( stg != null )
{
@@ -267,6 +273,7 @@ public class LdapSchemaMapper implements
if( ct != null )
{
ct.setAtHandlerName( handlerRef );
+ ct.setReadOnly( json.isReadOnly( name ) );
resourceSchema.addAttributeType( name, ct );
}
}
@@ -289,52 +296,18 @@ public class LdapSchemaMapper implements
boolean showMultiVal = getShowVal( elmMultiVal );
- MultiValType ct = null;
+ MultiValType mt = null;
Element elmAtGroup = elmMultiVal.element( "at-group" );
if ( elmAtGroup != null )
{
- SimpleTypeGroup stg = parseAtGroup( elmAtGroup, uri );
+ SimpleTypeGroup stg = parseAtGroup( elmAtGroup, uri, name );
if ( stg != null )
{
- ct = new MultiValType( uri, name, showMultiVal, stg, baseDn, filter );
+ mt = new MultiValType( uri, name, showMultiVal, stg, baseDn, filter );
}
}
- else
- {
- List<Element> lstElmTypes = elmMultiVal.elements( "type" );
-
- List<TypedType> lstTypes = new ArrayList<TypedType>();
-
- for ( Element elmType : lstElmTypes )
- {
- Element elmTypeAtGroup = elmType.element( "at-group" );
- SimpleTypeGroup stg = parseAtGroup( elmTypeAtGroup, uri );
-
- boolean show = getShowVal( elmType );
-
- String primary = elmType.attributeValue( "primary" );
-
- if ( Strings.isEmpty( primary ) )
- {
- primary = "false";
- }
-
- String typeName = elmType.attributeValue( "name" );
-
- if ( Strings.isEmpty( typeName ) )
- {
- throw new IllegalArgumentException( "name is missing in the type element " + elmType.asXML() );
- }
-
- TypedType tt = new TypedType( uri, typeName, show, stg,
- Boolean.parseBoolean( primary ) );
- lstTypes.add( tt );
- }
-
- ct = new MultiValType( uri, name, showMultiVal, lstTypes, baseDn, filter );
- }
String handlerRef = elmMultiVal.attributeValue( "handlerRef" );
@@ -343,26 +316,29 @@ public class LdapSchemaMapper implements
handlerRef = null;
}
- if( ( ct == null ) && ( handlerRef != null ) )
+ if( ( mt == null ) && ( handlerRef != null ) )
{
- ct = new MultiValType( uri, name, showMultiVal, ( SimpleTypeGroup ) null, baseDn, filter );
+ mt = new MultiValType( uri, name, showMultiVal, ( SimpleTypeGroup ) null, baseDn, filter );
}
- if( ct != null )
+ if( mt != null )
{
- ct.setAtHandlerName( handlerRef );
- resourceSchema.addAttributeType( name, ct );
+ mt.setAtHandlerName( handlerRef );
+ mt.setReadOnly( json.isReadOnly( name ) );
+ resourceSchema.addAttributeType( name, mt );
}
}
}
- private SimpleTypeGroup parseAtGroup( Element elmAtGroup, String uri )
+ private SimpleTypeGroup parseAtGroup( Element elmAtGroup, String uri, String parentAtName )
{
SimpleTypeGroup stg = null;
List<SimpleType> lstSTypes = null;
-
+
+ JsonSchema json = jsonSchemas.get( uri );
+
if ( elmAtGroup != null )
{
lstSTypes = new ArrayList<SimpleType>();
@@ -373,6 +349,7 @@ public class LdapSchemaMapper implements
SimpleType st = parseSimpleType( elmAt, uri );
if ( st != null )
{
+ st.setReadOnly( json.isReadOnly( parentAtName + "." + st.getName() ) );
lstSTypes.add( st );
}
}
Modified: directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/handlers/ActiveAttributeHandler.java
URL: http://svn.apache.org/viewvc/directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/handlers/ActiveAttributeHandler.java?rev=1531583&r1=1531582&r2=1531583&view=diff
==============================================================================
--- directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/handlers/ActiveAttributeHandler.java (original)
+++ directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/handlers/ActiveAttributeHandler.java Sat Oct 12 19:32:12 2013
@@ -35,13 +35,13 @@ import org.slf4j.LoggerFactory;
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
-public class ActiveAttributeHandler implements AttributeHandler
+public class ActiveAttributeHandler extends AttributeHandler
{
private static final Logger LOG = LoggerFactory.getLogger( ActiveAttributeHandler.class );
@Override
- public void handle( BaseType bt, Object srcResource, RequestContext ctx )
+ public void read( BaseType bt, Object srcResource, RequestContext ctx )
{
if( !bt.getName().equals( "active" ) )
{
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=1531583&r1=1531582&r2=1531583&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 Sat Oct 12 19:32:12 2013
@@ -56,14 +56,14 @@ import org.slf4j.LoggerFactory;
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
-public class GroupsAttributeHandler implements AttributeHandler
+public class GroupsAttributeHandler extends AttributeHandler
{
private static final Logger LOG = LoggerFactory.getLogger( GroupsAttributeHandler.class );
@Override
- public void handle( BaseType bt, Object srcResource, RequestContext ctx )
+ public void read( BaseType bt, Object srcResource, RequestContext ctx )
{
if ( !bt.getName().equals( "groups" ) )
{
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=1531583&r1=1531582&r2=1531583&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 Sat Oct 12 19:32:12 2013
@@ -55,14 +55,14 @@ import org.slf4j.LoggerFactory;
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
-public class MembersAttributeHandler implements AttributeHandler
+public class MembersAttributeHandler extends AttributeHandler
{
private static final Logger LOG = LoggerFactory.getLogger( MembersAttributeHandler.class );
@Override
- public void handle( BaseType bt, Object srcResource, RequestContext ctx )
+ public void read( BaseType bt, Object srcResource, RequestContext ctx )
{
if ( !bt.getName().equals( "members" ) )
{
Modified: directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/handlers/MetaAttributeHandler.java
URL: http://svn.apache.org/viewvc/directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/handlers/MetaAttributeHandler.java?rev=1531583&r1=1531582&r2=1531583&view=diff
==============================================================================
--- directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/handlers/MetaAttributeHandler.java (original)
+++ directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/handlers/MetaAttributeHandler.java Sat Oct 12 19:32:12 2013
@@ -28,8 +28,8 @@ import org.apache.directory.api.ldap.mod
import org.apache.directory.api.ldap.model.exception.LdapException;
import org.apache.directory.scim.AttributeHandler;
import org.apache.directory.scim.ComplexAttribute;
-import org.apache.directory.scim.CoreResource;
-import org.apache.directory.scim.Group;
+import org.apache.directory.scim.Resource;
+import org.apache.directory.scim.GroupResource;
import org.apache.directory.scim.RequestContext;
import org.apache.directory.scim.SimpleAttribute;
import org.apache.directory.scim.schema.BaseType;
@@ -42,13 +42,13 @@ import org.slf4j.LoggerFactory;
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
-public class MetaAttributeHandler implements AttributeHandler
+public class MetaAttributeHandler extends AttributeHandler
{
private static final Logger LOG = LoggerFactory.getLogger( ActiveAttributeHandler.class );
@Override
- public void handle( BaseType bt, Object srcResource, RequestContext ctx )
+ public void read( BaseType bt, Object srcResource, RequestContext ctx )
{
Entry entry = ( Entry ) srcResource;
@@ -84,11 +84,11 @@ public class MetaAttributeHandler implem
atList.add( lastModified );
}
- CoreResource resource = ctx.getCoreResource();
+ Resource resource = ctx.getCoreResource();
String resourceType = "User";
- if( resource instanceof Group )
+ if( resource instanceof GroupResource )
{
resourceType = "Group";
}
Modified: directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/handlers/PhotosAttributeHandler.java
URL: http://svn.apache.org/viewvc/directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/handlers/PhotosAttributeHandler.java?rev=1531583&r1=1531582&r2=1531583&view=diff
==============================================================================
--- directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/handlers/PhotosAttributeHandler.java (original)
+++ directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/handlers/PhotosAttributeHandler.java Sat Oct 12 19:32:12 2013
@@ -27,12 +27,12 @@ import org.apache.directory.api.ldap.mod
import org.apache.directory.api.ldap.model.entry.Entry;
import org.apache.directory.api.ldap.model.entry.Value;
import org.apache.directory.scim.AttributeHandler;
-import org.apache.directory.scim.CoreResource;
+import org.apache.directory.scim.Resource;
import org.apache.directory.scim.MultiValAttribute;
import org.apache.directory.scim.RequestContext;
import org.apache.directory.scim.SimpleAttribute;
import org.apache.directory.scim.SimpleAttributeGroup;
-import org.apache.directory.scim.User;
+import org.apache.directory.scim.UserResource;
import org.apache.directory.scim.ldap.schema.MultiValType;
import org.apache.directory.scim.ldap.schema.SimpleType;
import org.apache.directory.scim.ldap.schema.SimpleTypeGroup;
@@ -47,14 +47,14 @@ import org.slf4j.LoggerFactory;
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
-public class PhotosAttributeHandler implements AttributeHandler
+public class PhotosAttributeHandler extends AttributeHandler
{
private static final Logger LOG = LoggerFactory.getLogger( PhotosAttributeHandler.class );
@Override
- public void handle( BaseType bt, Object srcResource, RequestContext ctx )
+ public void read( BaseType bt, Object srcResource, RequestContext ctx )
{
if ( !bt.getName().equals( "photos" ) )
{
@@ -63,7 +63,7 @@ public class PhotosAttributeHandler impl
return;
}
- CoreResource user = ctx.getCoreResource();
+ Resource user = ctx.getCoreResource();
Entry entry = ( Entry ) srcResource;
@@ -71,9 +71,7 @@ public class PhotosAttributeHandler impl
MultiValType mt = ( MultiValType ) bt;
- SimpleTypeGroup stg = mt.getStGroup();
-
- List<TypedType> ttList = mt.getTypedList();
+ SimpleTypeGroup stg = mt.getAtGroup();
String photoUrlBase = ctx.getUriInfo().getBaseUri().toString();
photoUrlBase += "Users/photo?atName=%s&id=%s";
@@ -89,36 +87,6 @@ public class PhotosAttributeHandler impl
mv.addAtGroup( sg );
}
}
- else if ( ttList != null )
- {
- for ( TypedType tt : ttList )
- {
- SimpleTypeGroup typeStg = tt.getAtGroup();
- SimpleAttribute sa = getPhotoUrlValue( typeStg, entry, photoUrlBase, user );
-
- if ( sa != null )
- {
- SimpleAttributeGroup sg = new SimpleAttributeGroup();
- sg.addAttribute( sa );
-
- SimpleAttribute atType = new SimpleAttribute( "type", tt.getName() );
- sg.addAttribute( atType );
-
- if ( tt.isPrimary() )
- {
- SimpleAttribute atPrimary = new SimpleAttribute( "primary", true );
- sg.addAttribute( atPrimary );
- }
-
- if ( mv == null )
- {
- mv = new MultiValAttribute( bt.getName() );
- }
-
- mv.addAtGroup( sg );
- }
- }
- }
if ( mv != null )
{
@@ -127,7 +95,7 @@ public class PhotosAttributeHandler impl
}
- private SimpleAttribute getPhotoUrlValue( SimpleTypeGroup stg, Entry entry, String photoUrlBase, CoreResource user )
+ private SimpleAttribute getPhotoUrlValue( SimpleTypeGroup stg, Entry entry, String photoUrlBase, Resource user )
{
SimpleType valType = stg.getValueType();
if ( valType != null )
Modified: 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=1531583&r1=1531582&r2=1531583&view=diff
==============================================================================
--- directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/schema/MultiValType.java (original)
+++ directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/schema/MultiValType.java Sat Oct 12 19:32:12 2013
@@ -20,8 +20,6 @@
package org.apache.directory.scim.ldap.schema;
-import java.util.List;
-
import org.apache.directory.scim.schema.BaseType;
@@ -32,9 +30,7 @@ import org.apache.directory.scim.schema.
*/
public class MultiValType extends BaseType
{
- private SimpleTypeGroup stGroup;
-
- private List<TypedType> typedList;
+ private SimpleTypeGroup atGroup;
private String baseDn;
@@ -44,39 +40,21 @@ public class MultiValType extends BaseTy
private String format;
- public MultiValType( String uri, String name, boolean show, SimpleTypeGroup stGroup, String baseDn, String filter )
+ public MultiValType( String uri, String name, boolean show, SimpleTypeGroup atGroup, String baseDn, String filter )
{
super( uri, name, show );
- this.stGroup = stGroup;
+ this.atGroup = atGroup;
this.baseDn = baseDn;
this.filter = filter;
}
- public MultiValType( String uri, String name, boolean show, List<TypedType> typedList, String baseDn, String filter )
- {
- super( uri, name, show );
- this.typedList = typedList;
- this.baseDn = baseDn;
- this.filter = filter;
- }
-
-
- /**
- * @return the typedList
- */
- public List<TypedType> getTypedList()
- {
- return typedList;
- }
-
-
/**
* @return the stGroup
*/
- public SimpleTypeGroup getStGroup()
+ public SimpleTypeGroup getAtGroup()
{
- return stGroup;
+ return atGroup;
}
Modified: directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/schema/SimpleType.java
URL: http://svn.apache.org/viewvc/directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/schema/SimpleType.java?rev=1531583&r1=1531582&r2=1531583&view=diff
==============================================================================
--- directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/schema/SimpleType.java (original)
+++ directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/schema/SimpleType.java Sat Oct 12 19:32:12 2013
@@ -54,4 +54,14 @@ public class SimpleType extends BaseType
return true;
}
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#toString()
+ */
+ @Override
+ public String toString()
+ {
+ return "SimpleType [name=" + getName() + ", mappedTo=" + mappedTo + "]";
+ }
+
}
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=1531583&r1=1531582&r2=1531583&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 Sat Oct 12 19:32:12 2013
@@ -31,14 +31,14 @@ import java.util.List;
*/
public class SimpleTypeGroup
{
- private List<SimpleType> lstSTypes;
+ private List<SimpleType> subTypes;
/** used for setting the value of "formatted" attribute */
private String format;
- public SimpleTypeGroup( List<SimpleType> lstSTypes, String format )
+ public SimpleTypeGroup( List<SimpleType> subTypes, String format )
{
- this.lstSTypes = lstSTypes;
+ this.subTypes = subTypes;
this.format = format;
}
@@ -55,15 +55,15 @@ public class SimpleTypeGroup
/**
* @return the lstSTypes
*/
- public List<SimpleType> getLstSTypes()
+ public List<SimpleType> getSubTypes()
{
- return Collections.unmodifiableList( lstSTypes );
+ return Collections.unmodifiableList( subTypes );
}
public SimpleType getValueType()
{
- for( SimpleType st : lstSTypes )
+ for( SimpleType st : subTypes )
{
if( "value".equals( st.getName() ))
{
@@ -80,7 +80,7 @@ public class SimpleTypeGroup
@Override
public String toString()
{
- return "SimpleTypeGroup [lstSTypes=" + lstSTypes + ", format=" + format + "]";
+ return "SimpleTypeGroup [subTypes=" + subTypes + ", format=" + format + "]";
}
}
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=1531583&r1=1531582&r2=1531583&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 Sat Oct 12 19:32:12 2013
@@ -27,52 +27,39 @@
</complex-attribute>
<multival-attribute name="emails">
- <type name="work" primary="true">
- <at-group>
- <attribute name="value" mappedTo="mail" />
- </at-group>
- </type>
+ <at-group>
+ <attribute name="value" mappedTo="mail" />
+ </at-group>
</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>
+ <at-group>
+ <attribute name="value" mappedTo="telephoneNumber" />
+ </at-group>
</multival-attribute>
<multival-attribute name="ims">
</multival-attribute>
<multival-attribute name="photos" handlerRef="photosHandler">
- <type name="photo" primary="true">
- <at-group>
- <attribute name="value" mappedTo="jpegPhoto" />
- </at-group>
- </type>
+ <at-group>
+ <attribute name="value" mappedTo="jpegPhoto" />
+ </at-group>
</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>
+ <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>
</multival-attribute>
<multival-attribute name="groups" baseDn="ou=system"
- filter="(uniqueMember = $entryDn)" handlerRef="groupsHandler" />
+ filter="(uniqueMember=$entryDn)" handlerRef="groupsHandler" />
<multival-attribute name="entitlements" />
@@ -112,7 +99,7 @@
<complex-attribute name="meta" handlerRef="metaHandler" />
</schema>
- <userType baseDn="" filter="(objectClass = inetOrgPerson)">
+ <userType baseDn="ou=system" filter="(objectClass = inetOrgPerson)">
<schemaRef id="user-core" />
<schemaRef id="enterprise-user" />
<objectClasses>
@@ -122,6 +109,10 @@
<groupType baseDn="" filter="(objectClass = inetOrgPerson)">
<schemaRef id="group" />
+ <objectClasses>
+ <objectClass>groupOfNames</objectClass>
+ <objectClass>groupOfUniqueNames</objectClass>
+ </objectClasses>
</groupType>
<atHandlers>
Modified: directory/escimo/trunk/pom.xml
URL: http://svn.apache.org/viewvc/directory/escimo/trunk/pom.xml?rev=1531583&r1=1531582&r2=1531583&view=diff
==============================================================================
--- directory/escimo/trunk/pom.xml (original)
+++ directory/escimo/trunk/pom.xml Sat Oct 12 19:32:12 2013
@@ -25,7 +25,13 @@
<name>Apache Directory SCIM</name>
<properties>
+ <ldap.api.version>1.0.0-M20</ldap.api.version>
+ <apacheds.version>2.0.0-M15</apacheds.version>
+ <jetty.version>7.5.0.v20110901</jetty.version>
<wink.version>1.3.0</wink.version>
+ <httpclient.version>4.3</httpclient.version>
+ <gson.version>2.2.4</gson.version>
+ <dom4j.version>1.6.1</dom4j.version>
<slf4j.api.version>1.7.5</slf4j.api.version>
<slf4j.log4j12.version>1.7.5</slf4j.log4j12.version>
<log4j.version>1.2.17</log4j.version>
@@ -37,6 +43,8 @@
<module>client</module>
<module>ldap</module>
<module>tests</module>
+ <module>json2java</module>
+ <module>schema</module>
</modules>
<dependencyManagement>
@@ -46,6 +54,11 @@
<artifactId>wink-client</artifactId>
<version>${wink.version}</version>
</dependency>
+ <dependency>
+ <groupId>com.google.code.gson</groupId>
+ <artifactId>gson</artifactId>
+ <version>${gson.version}</version>
+ </dependency>
</dependencies>
</dependencyManagement>
@@ -76,4 +89,17 @@
</dependency>
</dependencies>
-</project>
\ No newline at end of file
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>1.5</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
Propchange: directory/escimo/trunk/schema/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Sat Oct 12 19:32:12 2013
@@ -0,0 +1,3 @@
+.classpath
+.project
+target
Modified: 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=1531583&r1=1531582&r2=1531583&view=diff
==============================================================================
--- directory/escimo/trunk/server/src/main/java/org/apache/directory/scim/rest/EscimoApplication.java (original)
+++ directory/escimo/trunk/server/src/main/java/org/apache/directory/scim/rest/EscimoApplication.java Sat Oct 12 19:32:12 2013
@@ -38,6 +38,7 @@ public class EscimoApplication extends A
{
resources.add( UserService.class );
resources.add( GroupService.class );
+ resources.add( SchemaService.class );
}
@Override
Modified: directory/escimo/trunk/server/src/main/java/org/apache/directory/scim/rest/GroupService.java
URL: http://svn.apache.org/viewvc/directory/escimo/trunk/server/src/main/java/org/apache/directory/scim/rest/GroupService.java?rev=1531583&r1=1531582&r2=1531583&view=diff
==============================================================================
--- directory/escimo/trunk/server/src/main/java/org/apache/directory/scim/rest/GroupService.java (original)
+++ directory/escimo/trunk/server/src/main/java/org/apache/directory/scim/rest/GroupService.java Sat Oct 12 19:32:12 2013
@@ -31,7 +31,7 @@ import javax.ws.rs.core.Response.Respons
import javax.ws.rs.core.Response.Status;
import javax.ws.rs.core.UriInfo;
-import org.apache.directory.scim.Group;
+import org.apache.directory.scim.GroupResource;
import org.apache.directory.scim.ProviderService;
import org.apache.directory.scim.RequestContext;
import org.apache.directory.scim.ResourceNotFoundException;
@@ -60,7 +60,7 @@ public class GroupService
RequestContext ctx = new RequestContext( provider );
ctx.setUriInfo( uriInfo );
- Group group = provider.getGroup( ctx, userId );
+ GroupResource group = provider.getGroup( ctx, userId );
String json = ResourceSerializer.serialize( group );
rb = Response.ok( json, MediaType.APPLICATION_JSON );
}
Modified: 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=1531583&r1=1531582&r2=1531583&view=diff
==============================================================================
--- directory/escimo/trunk/server/src/main/java/org/apache/directory/scim/rest/ServerInitializer.java (original)
+++ directory/escimo/trunk/server/src/main/java/org/apache/directory/scim/rest/ServerInitializer.java Sat Oct 12 19:32:12 2013
@@ -19,8 +19,17 @@
*/
package org.apache.directory.scim.rest;
+import java.net.URL;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
import org.apache.commons.lang.StringUtils;
import org.apache.directory.scim.ProviderService;
+import org.apache.directory.scim.schema.SchemaUtil;
+
+import com.google.gson.JsonObject;
+import com.google.gson.JsonParser;
/**
* TODO ServerInitializer.
@@ -50,6 +59,7 @@ public class ServerInitializer
re.initCause( e );
throw re;
}
+
}
public static ProviderService getProvider()
Modified: 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=1531583&r1=1531582&r2=1531583&view=diff
==============================================================================
--- directory/escimo/trunk/server/src/main/java/org/apache/directory/scim/rest/UserService.java (original)
+++ directory/escimo/trunk/server/src/main/java/org/apache/directory/scim/rest/UserService.java Sat Oct 12 19:32:12 2013
@@ -23,6 +23,7 @@ import java.io.InputStream;
import java.io.OutputStream;
import javax.ws.rs.GET;
+import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
@@ -40,7 +41,7 @@ import org.apache.directory.scim.Missing
import org.apache.directory.scim.ProviderService;
import org.apache.directory.scim.RequestContext;
import org.apache.directory.scim.ResourceNotFoundException;
-import org.apache.directory.scim.User;
+import org.apache.directory.scim.UserResource;
import org.apache.directory.scim.json.ResourceSerializer;
/**
@@ -65,7 +66,7 @@ public class UserService
RequestContext ctx = new RequestContext( provider );
ctx.setUriInfo( uriInfo );
- User user = provider.getUser( ctx, userId );
+ UserResource user = provider.getUser( ctx, userId );
String json = ResourceSerializer.serialize( user );
rb = Response.ok( json, MediaType.APPLICATION_JSON );
}
@@ -78,6 +79,36 @@ public class UserService
}
+ @POST
+ @Produces({MediaType.APPLICATION_JSON})
+ public Response addUser( String jsonData, @Context UriInfo uriInfo )
+ {
+ ResponseBuilder rb = null;
+
+ if( ( jsonData == null ) || ( jsonData.trim().length() == 0 ) )
+ {
+ rb = Response.status( Status.BAD_REQUEST ).entity( "No data is present with the call to " + uriInfo.getPath() );
+ return rb.build();
+ }
+
+ try
+ {
+ RequestContext ctx = new RequestContext( provider );
+ ctx.setUriInfo( uriInfo );
+
+ provider.addUser( jsonData, ctx );
+
+ String json = ResourceSerializer.serialize( ctx.getCoreResource() );
+ rb = Response.ok( json, MediaType.APPLICATION_JSON );
+ }
+ catch( Exception e )
+ {
+ rb = Response.status( Status.INTERNAL_SERVER_ERROR );
+ }
+
+ return rb.build();
+ }
+
@GET
@Produces({MediaType.APPLICATION_OCTET_STREAM})
@Path("photo")
@@ -97,7 +128,6 @@ public class UserService
StreamingOutput streamOut = new StreamingOutput()
{
- @Override
public void write( OutputStream output ) throws IOException, WebApplicationException
{
byte[] buf = new byte[1024];
Modified: directory/escimo/trunk/tests/pom.xml
URL: http://svn.apache.org/viewvc/directory/escimo/trunk/tests/pom.xml?rev=1531583&r1=1531582&r2=1531583&view=diff
==============================================================================
--- directory/escimo/trunk/tests/pom.xml (original)
+++ directory/escimo/trunk/tests/pom.xml Sat Oct 12 19:32:12 2013
@@ -11,18 +11,15 @@
<version>1.0-SNAPSHOT</version>
<name>eSCIMo Tests</name>
- <properties>
- <ldap.api.version>1.0.0-M20-SNAPSHOT</ldap.api.version>
- <apacheds.version>2.0.0-M15-SNAPSHOT</apacheds.version>
- <slf4j.api.version>1.7.5</slf4j.api.version>
- <slf4j.log4j12.version>1.7.5</slf4j.log4j12.version>
- <log4j.version>1.2.17</log4j.version>
- <jetty.version>7.5.0.v20110901</jetty.version>
- </properties>
-
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
+ <artifactId>escimo-client</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>${project.groupId}</groupId>
<artifactId>escimo-server</artifactId>
<version>${project.version}</version>
<type>war</type>
@@ -83,7 +80,7 @@
<version>4.10</version>
<scope>test</scope>
</dependency>
-
+<!--
<dependency>
<groupId>org.apache.directory.server</groupId>
<artifactId>apacheds-core-annotations</artifactId>
@@ -103,12 +100,46 @@
<artifactId>apacheds-test-framework</artifactId>
<version>${apacheds.version}</version>
<scope>test</scope>
- </dependency>
+ </dependency>-->
</dependencies>
<build>
<plugins>
<plugin>
+ <groupId>org.apache.directory.scim</groupId>
+ <artifactId>escimo-json2java-plugin</artifactId>
+ <version>${project.version}</version>
+ <executions>
+ <execution>
+ <goals>
+ <goal>generate</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <generatePackage>org.apache.directory.scim</generatePackage>
+ <useDefaultSchemas>true</useDefaultSchemas>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>build-helper-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>add-source</id>
+ <phase>generate-sources</phase>
+ <goals>
+ <goal>add-source</goal>
+ </goals>
+ <configuration>
+ <sources>
+ <source>${project.build.directory}/generated-sources/json2java</source>
+ </sources>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>2.3.7</version>
Modified: directory/escimo/trunk/tests/src/main/java/org/apache/directory/scim/JettyServer.java
URL: http://svn.apache.org/viewvc/directory/escimo/trunk/tests/src/main/java/org/apache/directory/scim/JettyServer.java?rev=1531583&r1=1531582&r2=1531583&view=diff
==============================================================================
--- directory/escimo/trunk/tests/src/main/java/org/apache/directory/scim/JettyServer.java (original)
+++ directory/escimo/trunk/tests/src/main/java/org/apache/directory/scim/JettyServer.java Sat Oct 12 19:32:12 2013
@@ -3,6 +3,10 @@ package org.apache.directory.scim;
import java.io.File;
import java.io.FilenameFilter;
+import java.io.InputStream;
+import java.util.Enumeration;
+import java.util.jar.JarEntry;
+import java.util.jar.JarFile;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.webapp.WebAppContext;
@@ -27,6 +31,9 @@ public class JettyServer
webapp.setWar( getEscimoWar().getAbsolutePath() );
webapp.setParentLoaderPriority( true );
String cpath = System.getProperty("java.class.path");
+
+ checkForJdk6Compliance( cpath );
+
cpath = cpath.replaceAll( ":", ";" );
// webapp.setExtraClasspath( cpath );
@@ -59,8 +66,6 @@ public class JettyServer
FilenameFilter ff = new FilenameFilter()
{
-
- @Override
public boolean accept( File dir, String name )
{
return ( name.startsWith( "escimo" ) && name.endsWith( ".war" ) );
@@ -104,9 +109,97 @@ public class JettyServer
return warFile;
}
+ private static void checkForJdk6Compliance( String classpath ) throws Exception
+ {
+ String[] files = classpath.split( ":" );
+ StringBuilder offendingJars = new StringBuilder();
+
+ for( String item : files )
+ {
+ //System.out.println("Processing " + item);
+ boolean valid = false;
+ if( item.endsWith( ".jar" ) )
+ {
+ valid = isValidJar( item );
+ if( !valid )
+ {
+ offendingJars.append( item )
+ .append( "\n" );
+ }
+ }
+ else if( item.endsWith( ".war" ) )
+ {
+
+ }
+ }
+
+ if( offendingJars.length() > 0 )
+ {
+ System.out.println("Offending jars:\n" + offendingJars);
+ System.exit( 0 );
+ }
+ }
+ private static boolean isValidJar( String jarFilePath ) throws Exception
+ {
+ byte[] majorVersion = new byte[8];
+
+ JarFile jar = new JarFile( jarFilePath );
+ Enumeration<JarEntry> en = jar.entries();
+ while( en.hasMoreElements() )
+ {
+ JarEntry je = en.nextElement();
+ if( je.isDirectory() )
+ {
+ continue;
+ }
+
+ if( !je.getName().endsWith( ".class" ) )
+ {
+ continue;
+ }
+
+ //System.out.println("Processing entry : " + je.getName());
+ InputStream in = jar.getInputStream( je );
+ //System.out.println(in.available());
+
+ in.read( majorVersion, 0, 8 );
+ in.close();
+
+ int ver = ( majorVersion[6] & 0xFF ) + ( majorVersion[7] & 0xFF );
+
+ return ver <= 50;
+ //System.out.println( ver );
+ // completed processing for the jar, break out
+ }
+
+ return false;
+ }
+
+ private static void recurseRepo( File folder ) throws Exception
+ {
+ File[] files = folder.listFiles();
+ for(File f : files )
+ {
+ if( f.isDirectory() )
+ {
+ recurseRepo( f );
+ }
+ else if( f.getName().endsWith( ".jar" ) )
+ {
+ System.out.println("Processing : " + f);
+ boolean valid = isValidJar( f.getAbsolutePath() );
+ if( !valid )
+ {
+ System.out.println("Not valid: " + f.getAbsolutePath() );
+ }
+ }
+ }
+ }
+
public static void main( String[] args ) throws Exception
{
+ //recurseRepo( new File("/Users/dbugger/.m2/repository") );
System.out.println( getEscimoWar() );
start();
}