You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@usergrid.apache.org by sn...@apache.org on 2015/09/20 22:44:15 UTC

[01/54] usergrid git commit: Switch to Jersey 2, fix all compilation errors. TODO: new MeteringFilter, new JSON-HTMP swap logic and correct use of dependency management.

Repository: usergrid
Updated Branches:
  refs/heads/usergrid-1007-shiro-cache 014986419 -> af5d260ef


http://git-wip-us.apache.org/repos/asf/usergrid/blob/0578d987/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/mgmt/OrgResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/mgmt/OrgResource.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/mgmt/OrgResource.java
index 2a5b813..096422c 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/mgmt/OrgResource.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/mgmt/OrgResource.java
@@ -17,8 +17,6 @@
 
 package org.apache.usergrid.rest.test.resource.endpoints.mgmt;
 
-import javax.ws.rs.core.MediaType;
-
 import com.fasterxml.jackson.databind.ObjectMapper;
 import org.apache.usergrid.rest.test.resource.endpoints.NamedResource;
 import org.apache.usergrid.rest.test.resource.endpoints.UrlResource;
@@ -26,15 +24,14 @@ import org.apache.usergrid.rest.test.resource.model.ApiResponse;
 import org.apache.usergrid.rest.test.resource.model.Organization;
 import org.apache.usergrid.rest.test.resource.model.QueryParameters;
 import org.apache.usergrid.rest.test.resource.model.Token;
-import org.apache.usergrid.rest.test.resource.model.User;
 import org.apache.usergrid.rest.test.resource.state.ClientContext;
-
-import com.sun.jersey.api.client.WebResource;
-
-import com.sun.jersey.api.representation.Form;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import javax.ws.rs.client.Entity;
+import javax.ws.rs.client.WebTarget;
+import javax.ws.rs.core.Form;
+import javax.ws.rs.core.MediaType;
 import java.io.IOException;
 import java.io.StringReader;
 
@@ -62,9 +59,9 @@ public class OrgResource  extends NamedResource {
 
         // Seems like an apiresponse can't handle what gets returned from the from urlended media type
 
-        ApiResponse response = getResource().type( MediaType.APPLICATION_FORM_URLENCODED )
+        ApiResponse response = getTarget().request()
             .accept(MediaType.APPLICATION_JSON)
-            .post(ApiResponse.class, form);
+            .post( Entity.form( form ), ApiResponse.class);
 
         Organization organization = new Organization(response);
         organization.setOwner( response );
@@ -77,12 +74,12 @@ public class OrgResource  extends NamedResource {
     public Organization post(QueryParameters parameters){
 
         // Seems like an ApiResponse can't handle what gets returned from the from URL encoded media type
-        WebResource resource = addParametersToResource( getResource(), parameters);
+        WebTarget resource = addParametersToResource( getTarget(), parameters);
 
         // use string type so we can log actual response from server
-        String responseString = resource.type(MediaType.APPLICATION_JSON_TYPE)
-            .accept(MediaType.APPLICATION_JSON)
-            .post(String.class);
+        String responseString = resource.request()
+            .accept( MediaType.APPLICATION_JSON )
+            .post( Entity.json( null ), String.class );
 
         logger.debug("Response from post: " + responseString);
 
@@ -103,9 +100,9 @@ public class OrgResource  extends NamedResource {
     public Organization post(Organization organization){
 
         // use string type so we can log actual response from server
-        String responseString = getResource(false).type( MediaType.APPLICATION_JSON_TYPE )
-            .accept(MediaType.APPLICATION_JSON)
-            .post(String.class, organization);
+        String responseString = getTarget(false).request()
+            .accept( MediaType.APPLICATION_JSON )
+            .post( Entity.json(organization), String.class );
 
         logger.debug("Response from post: " + responseString);
 
@@ -123,8 +120,9 @@ public class OrgResource  extends NamedResource {
         return org;
     }
     public Organization post(Organization organization, Token token){
-        ApiResponse response = getResource(true,token).type( MediaType.APPLICATION_JSON_TYPE ).accept( MediaType.APPLICATION_JSON )
-                                            .post( ApiResponse.class,organization );
+        ApiResponse response = getTarget(true,token).request()
+            .accept( MediaType.APPLICATION_JSON )
+            .post( Entity.json(organization), ApiResponse.class );
 
         Organization org = new Organization(response);
         org.setOwner( response );
@@ -135,9 +133,9 @@ public class OrgResource  extends NamedResource {
     public Organization put(Organization organization){
 
         // use string type so we can log actual response from server
-        String responseString = getResource().type( MediaType.APPLICATION_JSON_TYPE )
+        String responseString = getTarget().request()
             .accept(MediaType.APPLICATION_JSON)
-            .put(String.class, organization);
+            .post( Entity.json( organization ), String.class );
 
         logger.debug("Response from put: " + responseString);
 

http://git-wip-us.apache.org/repos/asf/usergrid/blob/0578d987/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/mgmt/OrganizationResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/mgmt/OrganizationResource.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/mgmt/OrganizationResource.java
index cf0987e..b9bd35e 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/mgmt/OrganizationResource.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/mgmt/OrganizationResource.java
@@ -43,8 +43,9 @@ public class OrganizationResource extends NamedResource {
     }
 
     public Organization get() {
-        ApiResponse rep = getResource(true).type(MediaType.APPLICATION_JSON_TYPE)
-            .accept(MediaType.APPLICATION_JSON).get(ApiResponse.class);
+        ApiResponse rep = getTarget( true ).request()
+            .accept(MediaType.APPLICATION_JSON)
+            .get(ApiResponse.class);
 
         //TODO: not sure if this will work for multiple users.
         Organization org = new Organization(rep);
@@ -54,9 +55,9 @@ public class OrganizationResource extends NamedResource {
 
     // Doesn't return anything useful server side so this was made as a void. .
     public void put(Organization organization) {
-        Map<String, Object> response = getResource(true).type(MediaType.APPLICATION_JSON_TYPE)
-            .accept(MediaType.APPLICATION_JSON).put(Organization.class,
-                organization);
+        Map<String, Object> response = getTarget(true).request()
+            .accept(MediaType.APPLICATION_JSON)
+            .put( javax.ws.rs.client.Entity.json(organization), Organization.class);
 
     }
 

http://git-wip-us.apache.org/repos/asf/usergrid/blob/0578d987/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/mgmt/PasswordResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/mgmt/PasswordResource.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/mgmt/PasswordResource.java
index 59121ab..5779109 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/mgmt/PasswordResource.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/mgmt/PasswordResource.java
@@ -17,18 +17,10 @@
 package org.apache.usergrid.rest.test.resource.endpoints.mgmt;
 
 
-import java.util.Map;
-
-import javax.ws.rs.core.MediaType;
-
 import org.apache.usergrid.rest.test.resource.endpoints.NamedResource;
 import org.apache.usergrid.rest.test.resource.endpoints.UrlResource;
-import org.apache.usergrid.rest.test.resource.model.ApiResponse;
-import org.apache.usergrid.rest.test.resource.model.Entity;
-import org.apache.usergrid.rest.test.resource.model.Token;
 import org.apache.usergrid.rest.test.resource.state.ClientContext;
 
-import com.sun.jersey.api.client.WebResource;
 
 
 /**

http://git-wip-us.apache.org/repos/asf/usergrid/blob/0578d987/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/mgmt/ReactivateResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/mgmt/ReactivateResource.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/mgmt/ReactivateResource.java
index 3959b3e..70feb29 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/mgmt/ReactivateResource.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/mgmt/ReactivateResource.java
@@ -18,15 +18,14 @@
 package org.apache.usergrid.rest.test.resource.endpoints.mgmt;
 
 
-import javax.ws.rs.core.MediaType;
-
 import org.apache.usergrid.rest.test.resource.endpoints.NamedResource;
 import org.apache.usergrid.rest.test.resource.endpoints.UrlResource;
 import org.apache.usergrid.rest.test.resource.model.ApiResponse;
 import org.apache.usergrid.rest.test.resource.model.Entity;
 import org.apache.usergrid.rest.test.resource.state.ClientContext;
 
-import com.sun.jersey.api.client.WebResource;
+import javax.ws.rs.client.WebTarget;
+import javax.ws.rs.core.MediaType;
 
 
 /**
@@ -38,9 +37,8 @@ public class ReactivateResource extends NamedResource {
     }
 
     public Entity get(){
-        WebResource resource = getResource(true);
-        ApiResponse response = resource.type( MediaType.APPLICATION_JSON_TYPE )
-                                       .accept( MediaType.APPLICATION_JSON ).get( ApiResponse.class);
+        WebTarget resource = getTarget(true);
+        ApiResponse response = resource.request().accept( MediaType.APPLICATION_JSON ).get( ApiResponse.class);
         return new Entity(response);
     }
 }

http://git-wip-us.apache.org/repos/asf/usergrid/blob/0578d987/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/mgmt/ResetResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/mgmt/ResetResource.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/mgmt/ResetResource.java
index 076e284..739e2ac 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/mgmt/ResetResource.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/mgmt/ResetResource.java
@@ -17,13 +17,12 @@
 package org.apache.usergrid.rest.test.resource.endpoints.mgmt;
 
 
-import javax.ws.rs.core.MediaType;
-
 import org.apache.usergrid.rest.test.resource.endpoints.NamedResource;
 import org.apache.usergrid.rest.test.resource.endpoints.UrlResource;
 import org.apache.usergrid.rest.test.resource.state.ClientContext;
 
-import com.sun.jersey.api.representation.Form;
+import javax.ws.rs.core.Form;
+import javax.ws.rs.core.MediaType;
 
 
 /**
@@ -36,7 +35,8 @@ public class ResetResource extends NamedResource {
     }
 
     public String post(Form formPayload) {
-        return getResource().type( MediaType.APPLICATION_FORM_URLENCODED_TYPE )
-            .accept( MediaType.TEXT_HTML ).post( String.class, formPayload);
+        return getTarget().request()
+            .accept( MediaType.TEXT_HTML )
+            .post( javax.ws.rs.client.Entity.form(formPayload), String.class);
     }
 }

http://git-wip-us.apache.org/repos/asf/usergrid/blob/0578d987/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/mgmt/TokenResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/mgmt/TokenResource.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/mgmt/TokenResource.java
index 613955a..54fe477 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/mgmt/TokenResource.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/mgmt/TokenResource.java
@@ -17,13 +17,13 @@
 package org.apache.usergrid.rest.test.resource.endpoints.mgmt;
 
 
-import com.sun.jersey.api.client.WebResource;
 import org.apache.usergrid.rest.test.resource.endpoints.NamedResource;
 import org.apache.usergrid.rest.test.resource.endpoints.UrlResource;
 import org.apache.usergrid.rest.test.resource.model.QueryParameters;
 import org.apache.usergrid.rest.test.resource.model.Token;
 import org.apache.usergrid.rest.test.resource.state.ClientContext;
 
+import javax.ws.rs.client.WebTarget;
 import javax.ws.rs.core.MediaType;
 
 
@@ -49,10 +49,9 @@ public class TokenResource extends NamedResource {
      * @return
      */
     public Token get(QueryParameters params) {
-        WebResource resource = getResource(false);
+        WebTarget resource = getTarget( false );
         resource = addParametersToResource(resource, params);
-        Token token = resource.type(MediaType.APPLICATION_JSON_TYPE).accept(MediaType.APPLICATION_JSON)
-                              .get(Token.class);
+        Token token = resource.request().accept(MediaType.APPLICATION_JSON).get(Token.class);
 
         this.context.setToken(token);
         return token;

http://git-wip-us.apache.org/repos/asf/usergrid/blob/0578d987/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/mgmt/UserResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/mgmt/UserResource.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/mgmt/UserResource.java
index ee804e6..a25784b 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/mgmt/UserResource.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/mgmt/UserResource.java
@@ -16,15 +16,15 @@
  */
 package org.apache.usergrid.rest.test.resource.endpoints.mgmt;
 
-import javax.ws.rs.core.MediaType;
-
 import org.apache.usergrid.rest.test.resource.endpoints.NamedResource;
 import org.apache.usergrid.rest.test.resource.endpoints.UrlResource;
 import org.apache.usergrid.rest.test.resource.model.ApiResponse;
 import org.apache.usergrid.rest.test.resource.model.Entity;
 import org.apache.usergrid.rest.test.resource.state.ClientContext;
 
-import com.sun.jersey.api.client.WebResource;
+import javax.ws.rs.client.WebTarget;
+import javax.ws.rs.core.MediaType;
+
 
 
 /**
@@ -71,17 +71,19 @@ public class UserResource extends NamedResource {
     }
 
     public Entity get() {
-        WebResource resource = getResource( true );
-        ApiResponse response = resource.type( MediaType.APPLICATION_JSON_TYPE )
-                                       .accept( MediaType.APPLICATION_JSON ).get( ApiResponse.class );
+        WebTarget resource = getTarget( true );
+        ApiResponse response = resource.request()
+            .accept( MediaType.APPLICATION_JSON )
+            .get( ApiResponse.class );
         return new Entity(response);
     }
 
     public Entity put(Entity userPayload){
-        WebResource resource = getResource(true);
+        WebTarget resource = getTarget( true );
 
-        ApiResponse response = resource.type( MediaType.APPLICATION_JSON_TYPE )
-                                       .accept( MediaType.APPLICATION_JSON ).put( ApiResponse.class, userPayload);
+        ApiResponse response = resource.request()
+            .accept( MediaType.APPLICATION_JSON )
+            .put( javax.ws.rs.client.Entity.json(userPayload), ApiResponse.class);
         return new Entity(response);
     }
 

http://git-wip-us.apache.org/repos/asf/usergrid/blob/0578d987/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/mgmt/UsersResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/mgmt/UsersResource.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/mgmt/UsersResource.java
index 5ef681d..6c22469 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/mgmt/UsersResource.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/mgmt/UsersResource.java
@@ -18,17 +18,11 @@
 package org.apache.usergrid.rest.test.resource.endpoints.mgmt;
 
 
-import javax.ws.rs.core.MediaType;
-
 import org.apache.usergrid.rest.test.resource.endpoints.EntityEndpoint;
 import org.apache.usergrid.rest.test.resource.endpoints.NamedResource;
 import org.apache.usergrid.rest.test.resource.endpoints.UrlResource;
-import org.apache.usergrid.rest.test.resource.model.ApiResponse;
-import org.apache.usergrid.rest.test.resource.model.Entity;
 import org.apache.usergrid.rest.test.resource.state.ClientContext;
 
-import com.sun.jersey.api.client.WebResource;
-
 
 /**
  * Handles calls to the users management endpoint

http://git-wip-us.apache.org/repos/asf/usergrid/blob/0578d987/stack/services/pom.xml
----------------------------------------------------------------------
diff --git a/stack/services/pom.xml b/stack/services/pom.xml
index d1ec212..466bd45 100644
--- a/stack/services/pom.xml
+++ b/stack/services/pom.xml
@@ -197,20 +197,27 @@
 
     <!-- SUN, Javax Package and Other Com Dependencies -->
 
-    <dependency>
-      <groupId>com.sun.jersey</groupId>
-      <artifactId>jersey-core</artifactId>
-    </dependency>
+      <!-- Required only when you are using JAX-RS Client -->
+      <dependency>
+          <groupId>org.glassfish.jersey.core</groupId>
+          <artifactId>jersey-client</artifactId>
+          <version>2.21</version>
+      </dependency>
 
-    <dependency>
-      <groupId>com.sun.jersey</groupId>
-      <artifactId>jersey-client</artifactId>
-    </dependency>
+    <!--<dependency>-->
+      <!--<groupId>com.sun.jersey</groupId>-->
+      <!--<artifactId>jersey-core</artifactId>-->
+    <!--</dependency>-->
 
-    <dependency>
-      <groupId>com.sun.jersey</groupId>
-      <artifactId>jersey-json</artifactId>
-    </dependency>
+    <!--<dependency>-->
+      <!--<groupId>com.sun.jersey</groupId>-->
+      <!--<artifactId>jersey-client</artifactId>-->
+    <!--</dependency>-->
+
+    <!--<dependency>-->
+      <!--<groupId>com.sun.jersey</groupId>-->
+      <!--<artifactId>jersey-json</artifactId>-->
+    <!--</dependency>-->
 
     <!-- Codehaus, JClouds, Spring and Other Org Dependencies -->
 
@@ -434,6 +441,7 @@
       <artifactId>stream</artifactId>
       <version>2.7.0</version>
     </dependency>
+
       <dependency>
           <groupId>com.github.fernandospr</groupId>
           <artifactId>java-wns</artifactId>
@@ -443,6 +451,17 @@
                   <artifactId>jackson-jaxrs</artifactId>
                   <groupId>org.codehaus.jackson</groupId>
               </exclusion>
+              <!-- Would be nice if we could exclude this dependency on Jersey 1.
+                   Apparently Java-WNS 1.3.1 will move to Jersey 2.
+              <exclusion>
+                  <artifactId>jersey-apache-client</artifactId>
+                  <groupId>com.sun.jersey.contribs</groupId>
+              </exclusion>
+              <exclusion>
+                  <artifactId>jersey-client</artifactId>
+                  <groupId>com.sun.jersey</groupId>
+              </exclusion>
+              -->
           </exclusions>
       </dependency>
 

http://git-wip-us.apache.org/repos/asf/usergrid/blob/0578d987/stack/services/src/main/java/org/apache/usergrid/security/providers/AbstractProvider.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/security/providers/AbstractProvider.java b/stack/services/src/main/java/org/apache/usergrid/security/providers/AbstractProvider.java
index 85179e3..2ca1052 100644
--- a/stack/services/src/main/java/org/apache/usergrid/security/providers/AbstractProvider.java
+++ b/stack/services/src/main/java/org/apache/usergrid/security/providers/AbstractProvider.java
@@ -22,13 +22,11 @@ import java.util.Map;
 import com.sun.jersey.core.util.MultivaluedMapImpl;
 import org.apache.usergrid.management.ManagementService;
 import org.apache.usergrid.persistence.EntityManager;
+import org.glassfish.jersey.client.ClientConfig;
+import org.glassfish.jersey.jackson.JacksonFeature;
 
-import com.sun.jersey.api.client.Client;
-import com.sun.jersey.api.client.config.ClientConfig;
-import com.sun.jersey.api.client.config.DefaultClientConfig;
-import com.sun.jersey.api.json.JSONConfiguration;
-import com.sun.jersey.core.util.MultivaluedMapImpl;
-
+import javax.ws.rs.client.Client;
+import javax.ws.rs.client.ClientBuilder;
 import javax.ws.rs.core.MultivaluedMap;
 
 
@@ -43,9 +41,9 @@ public abstract class AbstractProvider implements SignInAsProvider {
     AbstractProvider( EntityManager entityManager, ManagementService managementService ) {
         this.entityManager = entityManager;
         this.managementService = managementService;
-        ClientConfig clientConfig = new DefaultClientConfig();
-        clientConfig.getFeatures().put( JSONConfiguration.FEATURE_POJO_MAPPING, Boolean.TRUE );
-        client = Client.create( clientConfig );
+        ClientConfig clientConfig = new ClientConfig();
+        clientConfig.register( new JacksonFeature() );
+        client = ClientBuilder.newClient( clientConfig );
     }
 
 

http://git-wip-us.apache.org/repos/asf/usergrid/blob/0578d987/stack/services/src/main/java/org/apache/usergrid/security/providers/FacebookProvider.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/security/providers/FacebookProvider.java b/stack/services/src/main/java/org/apache/usergrid/security/providers/FacebookProvider.java
index 30a497e..3931091 100644
--- a/stack/services/src/main/java/org/apache/usergrid/security/providers/FacebookProvider.java
+++ b/stack/services/src/main/java/org/apache/usergrid/security/providers/FacebookProvider.java
@@ -93,8 +93,11 @@ public class FacebookProvider extends AbstractProvider {
 
     @Override
     Map<String, Object> userFromResource( String externalToken ) {
-        return client.resource( apiUrl ).queryParam( "access_token", externalToken )
-                     .accept( MediaType.APPLICATION_JSON ).get( Map.class );
+        return client.target( apiUrl )
+            .queryParam( "access_token", externalToken )
+            .request()
+                .accept( MediaType.APPLICATION_JSON )
+                .get( Map.class );
     }
 
 

http://git-wip-us.apache.org/repos/asf/usergrid/blob/0578d987/stack/services/src/main/java/org/apache/usergrid/security/providers/FoursquareProvider.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/security/providers/FoursquareProvider.java b/stack/services/src/main/java/org/apache/usergrid/security/providers/FoursquareProvider.java
index d7b136e..738a20f 100644
--- a/stack/services/src/main/java/org/apache/usergrid/security/providers/FoursquareProvider.java
+++ b/stack/services/src/main/java/org/apache/usergrid/security/providers/FoursquareProvider.java
@@ -17,14 +17,8 @@
 package org.apache.usergrid.security.providers;
 
 
-import java.util.ArrayList;
-import java.util.LinkedHashMap;
-import java.util.Map;
-
-import javax.ws.rs.core.MediaType;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import com.fasterxml.jackson.core.type.TypeReference;
+import com.sun.jersey.api.client.WebResource;
 import org.apache.usergrid.management.ManagementService;
 import org.apache.usergrid.persistence.EntityManager;
 import org.apache.usergrid.persistence.Query;
@@ -32,12 +26,18 @@ import org.apache.usergrid.persistence.Results;
 import org.apache.usergrid.persistence.entities.User;
 import org.apache.usergrid.security.tokens.exceptions.BadTokenException;
 import org.apache.usergrid.utils.JsonUtils;
+import org.glassfish.jersey.client.ClientConfig;
+import org.glassfish.jersey.jackson.JacksonFeature;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
-import com.sun.jersey.api.client.Client;
-import com.sun.jersey.api.client.WebResource;
-import com.sun.jersey.api.client.config.ClientConfig;
-import com.sun.jersey.api.client.config.DefaultClientConfig;
-import com.sun.jersey.api.json.JSONConfiguration;
+import javax.ws.rs.client.ClientBuilder;
+import javax.ws.rs.client.WebTarget;
+import javax.ws.rs.core.GenericType;
+import javax.ws.rs.core.MediaType;
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+import java.util.Map;
 
 import static org.apache.usergrid.utils.ListUtils.anyNull;
 
@@ -85,12 +85,16 @@ public class FoursquareProvider extends AbstractProvider {
 
     @Override
     public User createOrAuthenticate( String externalToken ) throws BadTokenException {
-        ClientConfig clientConfig = new DefaultClientConfig();
-        clientConfig.getFeatures().put( JSONConfiguration.FEATURE_POJO_MAPPING, Boolean.TRUE );
-        Client client = Client.create( clientConfig );
-        WebResource web_resource = client.resource( "https://api.foursquare.com/v2/users/self" );
-        Map<String, Object> body = web_resource.queryParam( "oauth_token", externalToken ).queryParam( "v", "20120623" )
-                                               .accept( MediaType.APPLICATION_JSON ).get( Map.class );
+        ClientConfig clientConfig = new ClientConfig();
+        clientConfig.register( new JacksonFeature() );
+        client = ClientBuilder.newClient( clientConfig );
+
+        Map<String, Object> body = client.target( "https://api.foursquare.com/v2/users/self" )
+            .queryParam( "oauth_token", externalToken )
+            .queryParam( "v", "20120623" )
+            .request()
+                .accept( MediaType.APPLICATION_JSON )
+                .get(Map.class);
 
         Map<String, Object> fq_user = ( Map<String, Object> ) ( ( Map<?, ?> ) body.get( "response" ) ).get( "user" );
 

http://git-wip-us.apache.org/repos/asf/usergrid/blob/0578d987/stack/services/src/main/java/org/apache/usergrid/security/providers/PingIdentityProvider.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/security/providers/PingIdentityProvider.java b/stack/services/src/main/java/org/apache/usergrid/security/providers/PingIdentityProvider.java
index f8a66e9..939532f 100644
--- a/stack/services/src/main/java/org/apache/usergrid/security/providers/PingIdentityProvider.java
+++ b/stack/services/src/main/java/org/apache/usergrid/security/providers/PingIdentityProvider.java
@@ -17,22 +17,21 @@
 package org.apache.usergrid.security.providers;
 
 
-import java.util.HashMap;
-import java.util.LinkedHashMap;
-import java.util.Map;
-
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.MultivaluedMap;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import com.fasterxml.jackson.databind.JsonNode;
 import org.apache.usergrid.management.ManagementService;
 import org.apache.usergrid.persistence.EntityManager;
-import org.apache.usergrid.persistence.index.query.Identifier;
 import org.apache.usergrid.persistence.entities.User;
+import org.apache.usergrid.persistence.index.query.Identifier;
 import org.apache.usergrid.security.tokens.exceptions.BadTokenException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
-import com.fasterxml.jackson.databind.JsonNode;
+import javax.ws.rs.client.Entity;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.MultivaluedMap;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.Map;
 
 
 /**
@@ -122,18 +121,17 @@ public class PingIdentityProvider extends AbstractProvider {
 
 
     @Override
-    Map<String, Object> userFromResource( String externalToken ) {
+    Map<String, Object> userFromResource(String externalToken) {
 
 
-      MultivaluedMap<String, String> formData =  getMultivaluedMapImpl();
-      formData.add("grant_type", "urn:pingidentity.com:oauth2:grant_type:validate_bearer");
-      formData.add("client_id", clientId);
-      formData.add("client_secret", clientSecret);
-      formData.add("token", externalToken);
+        MultivaluedMap<String, String> formData = getMultivaluedMapImpl();
+        formData.add( "grant_type", "urn:pingidentity.com:oauth2:grant_type:validate_bearer" );
+        formData.add( "client_id", clientId );
+        formData.add( "client_secret", clientSecret );
+        formData.add( "token", externalToken );
 
-      JsonNode node = client.resource( apiUrl )
-          .type( MediaType.APPLICATION_FORM_URLENCODED_TYPE )
-          .post( JsonNode.class, formData );
+        JsonNode node = client.target( apiUrl ).request()
+            .post( Entity.entity( formData, MediaType.APPLICATION_FORM_URLENCODED_TYPE ), JsonNode.class );
 
         String rawEmail = node.get( "access_token" ).get( "subject" ).asText();
 


[07/54] usergrid git commit: Switch to Jersey 2, fix all compilation errors. TODO: new MeteringFilter, new JSON-HTMP swap logic and correct use of dependency management.

Posted by sn...@apache.org.
Switch to Jersey 2, fix all compilation errors. TODO: new MeteringFilter, new JSON-HTMP swap logic and correct use of dependency management.


Project: http://git-wip-us.apache.org/repos/asf/usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/usergrid/commit/0578d987
Tree: http://git-wip-us.apache.org/repos/asf/usergrid/tree/0578d987
Diff: http://git-wip-us.apache.org/repos/asf/usergrid/diff/0578d987

Branch: refs/heads/usergrid-1007-shiro-cache
Commit: 0578d987abc9eacb41af50f8957e90d16f6f7025
Parents: 2303eea
Author: Dave Johnson <sn...@apache.org>
Authored: Fri Aug 28 10:57:13 2015 -0400
Committer: Dave Johnson <sn...@apache.org>
Committed: Fri Aug 28 10:57:13 2015 -0400

----------------------------------------------------------------------
 stack/pom.xml                                   | 248 ++++----
 stack/rest/pom.xml                              |  91 ++-
 .../usergrid/rest/AbstractContextResource.java  |  45 +-
 .../org/apache/usergrid/rest/IndexResource.java |  54 +-
 .../apache/usergrid/rest/MigrateResource.java   |  61 +-
 .../org/apache/usergrid/rest/RootResource.java  |  92 ++-
 .../apache/usergrid/rest/SystemResource.java    |  45 +-
 .../usergrid/rest/TextToJsonSwapWriter.java     | 180 +++---
 .../rest/applications/ApplicationResource.java  |  31 +-
 .../rest/applications/ServiceResource.java      | 109 ++--
 .../applications/assets/AssetsResource.java     |  13 +-
 .../applications/events/EventsResource.java     |  36 +-
 .../notifiers/NotifierResource.java             |  29 +-
 .../notifiers/NotifiersResource.java            |  29 +-
 .../rest/applications/queues/QueueResource.java |  86 ++-
 .../queues/QueueSubscriberResource.java         |  63 +-
 .../queues/QueueSubscriptionResource.java       |  63 +-
 .../queues/QueueTransactionsResource.java       |  40 +-
 .../rest/applications/users/UserResource.java   | 134 ++--
 .../rest/applications/users/UsersResource.java  |  51 +-
 .../exceptions/NotFoundExceptionMapper.java     |   3 +-
 .../rest/exceptions/SecurityException.java      |  31 +-
 .../rest/filters/JSONPCallbackFilter.java       |  22 +-
 .../usergrid/rest/filters/MeteringFilter.java   | 632 ++++++++++---------
 .../usergrid/rest/filters/TracingFilter.java    |  37 +-
 .../rest/management/ManagementResource.java     |  51 +-
 .../management/metrics/MetricsResource.java     |   9 +-
 .../organizations/OrganizationResource.java     |  50 +-
 .../organizations/OrganizationsResource.java    |  56 +-
 .../applications/ApplicationResource.java       |  50 +-
 .../applications/ApplicationsResource.java      |  48 +-
 .../imports/FileErrorsResource.java             |  41 +-
 .../imports/FileIncludesResource.java           |  15 +-
 .../applications/imports/ImportsResource.java   |  57 +-
 .../organizations/users/UsersResource.java      |  88 +--
 .../rest/management/users/UserResource.java     |  95 +--
 .../rest/management/users/UsersResource.java    |  11 +-
 .../organizations/OrganizationsResource.java    |  76 +--
 .../organizations/OrganizationResource.java     |  28 +-
 .../rest/security/CrossOriginRequestFilter.java |  16 +-
 .../security/SecuredResourceFilterFactory.java  |  99 ++-
 .../shiro/filters/BasicAuthSecurityFilter.java  |  24 +-
 .../ClientCredentialsSecurityFilter.java        |  17 +-
 .../OAuth2AccessTokenSecurityFilter.java        | 143 ++---
 .../security/shiro/filters/SecurityFilter.java  |  11 +-
 .../apache/usergrid/rest/utils/CORSUtils.java   |  42 +-
 .../java/org/apache/usergrid/rest/BasicIT.java  |  23 +-
 .../apache/usergrid/rest/IndexResourceIT.java   |  39 +-
 .../apache/usergrid/rest/PartialUpdateTest.java |  10 +-
 .../apache/usergrid/rest/SystemResourceIT.java  |   7 +-
 .../org/apache/usergrid/rest/TomcatRuntime.java |  12 +-
 .../rest/applications/ApplicationCreateIT.java  |  14 +-
 .../rest/applications/ApplicationDeleteIT.java  | 153 ++---
 .../applications/ApplicationResourceIT.java     | 253 ++++----
 .../applications/assets/AssetResourceIT.java    |   9 +-
 .../applications/assets/AwsAssetResourceIT.java |  53 +-
 .../applications/assets/aws/NoAWSCredsRule.java |  15 +-
 .../collection/CollectionsResourceIT.java       |  26 +-
 .../collection/DuplicateNameIT.java             |   5 +-
 .../activities/ActivityResourceIT.java          |   5 +-
 .../collection/devices/DevicesResourceIT.java   |   4 +-
 .../collection/groups/GroupResourceIT.java      |  28 +-
 .../users/ConnectionResourceTest.java           |   8 +-
 .../collection/users/OwnershipResourceIT.java   |  15 +-
 .../collection/users/PermissionsResourceIT.java |  34 +-
 .../collection/users/UserResourceIT.java        | 126 ++--
 .../queries/BadGrammarQueryTest.java            |  15 +-
 .../applications/queries/BasicGeoTests.java     |  45 +-
 .../rest/filters/ContentTypeResourceIT.java     |  43 +-
 .../usergrid/rest/management/AccessTokenIT.java |  42 +-
 .../usergrid/rest/management/AdminUsersIT.java  |  31 +-
 .../rest/management/ExportResourceIT.java       | 137 ++--
 .../rest/management/ImportResourceIT.java       |  50 +-
 .../rest/management/ManagementResourceIT.java   |  88 +--
 .../rest/management/OrganizationsIT.java        |  32 +-
 .../rest/management/RegistrationIT.java         |  32 +-
 .../organizations/AdminEmailEncodingIT.java     |   5 +-
 .../rest/test/resource/AbstractRestIT.java      |  43 +-
 .../usergrid/rest/test/resource/RestClient.java |  41 +-
 .../test/resource/TestPropertiesResource.java   |  14 +-
 .../endpoints/ApplicationsResource.java         |   8 +-
 .../resource/endpoints/CollectionEndpoint.java  |  88 +--
 .../test/resource/endpoints/EntityEndpoint.java |  40 +-
 .../test/resource/endpoints/NamedResource.java  | 128 ++--
 .../test/resource/endpoints/RootResource.java   |   4 +-
 .../test/resource/endpoints/SetupResource.java  |  22 +-
 .../test/resource/endpoints/SystemResource.java |  11 +-
 .../test/resource/endpoints/TokenResource.java  |  15 +-
 .../test/resource/endpoints/UrlResource.java    |   7 +-
 .../endpoints/mgmt/ApplicationResource.java     |  27 +-
 .../endpoints/mgmt/ApplicationsResource.java    |   4 +-
 .../endpoints/mgmt/AuthorizeResource.java       |   7 +-
 .../endpoints/mgmt/ConfirmResource.java         |  12 +-
 .../endpoints/mgmt/CredentialsResource.java     |   7 +-
 .../resource/endpoints/mgmt/FeedResource.java   |   5 +-
 .../resource/endpoints/mgmt/OrgResource.java    |  38 +-
 .../endpoints/mgmt/OrganizationResource.java    |  11 +-
 .../endpoints/mgmt/PasswordResource.java        |   8 -
 .../endpoints/mgmt/ReactivateResource.java      |  10 +-
 .../resource/endpoints/mgmt/ResetResource.java  |  10 +-
 .../resource/endpoints/mgmt/TokenResource.java  |   7 +-
 .../resource/endpoints/mgmt/UserResource.java   |  20 +-
 .../resource/endpoints/mgmt/UsersResource.java  |   6 -
 stack/services/pom.xml                          |  43 +-
 .../security/providers/AbstractProvider.java    |  16 +-
 .../security/providers/FacebookProvider.java    |   7 +-
 .../security/providers/FoursquareProvider.java  |  42 +-
 .../providers/PingIdentityProvider.java         |  38 +-
 108 files changed, 2655 insertions(+), 2695 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/usergrid/blob/0578d987/stack/pom.xml
----------------------------------------------------------------------
diff --git a/stack/pom.xml b/stack/pom.xml
index 16783b2..dc42920 100644
--- a/stack/pom.xml
+++ b/stack/pom.xml
@@ -107,11 +107,11 @@
       <jackson-version>1.9.9</jackson-version>
       <jackson-2-version>2.3.3</jackson-2-version>
       <jclouds.version>1.9.0</jclouds.version>
-      <jersey-version>1.19</jersey-version>
+      <!--<jersey-version>1.19</jersey-version>-->
       <junit-version>4.12</junit-version>
       <log4j-version>1.2.16</log4j-version>
       <org.springframework.version>3.2.13.RELEASE</org.springframework.version>
-      <shiro-version>1.2.3</shiro-version>
+      <shiro-version>1.2.4</shiro-version>
       <slf4j-version>1.6.1</slf4j-version>
       <snakeyaml-version>1.9</snakeyaml-version>
       <tomcat-version>7.0.59</tomcat-version>
@@ -579,139 +579,139 @@
 
       <!-- Sun and Javax Package Dependencies -->
 
-      <dependency>
-        <groupId>com.sun.jersey</groupId>
-        <artifactId>jersey-core</artifactId>
-        <version>${jersey-version}</version>
-      </dependency>
-
-      <dependency>
-        <groupId>com.sun.jersey</groupId>
-        <artifactId>jersey-json</artifactId>
-        <version>${jersey-version}</version>
-        <exclusions>
-          <exclusion>
-            <groupId>org.codehaus.jettison</groupId>
-            <artifactId>jettison</artifactId>
-          </exclusion>
-
-          <exclusion>
-            <groupId>org.codehaus.jackson</groupId>
-            <artifactId>jackson-core-asl</artifactId>
-          </exclusion>
-
-          <exclusion>
-            <groupId>org.codehaus.jackson</groupId>
-            <artifactId>jackson-mapper-asl</artifactId>
-          </exclusion>
-
-          <exclusion>
-            <groupId>org.codehaus.jackson</groupId>
-            <artifactId>jackson-jaxrs</artifactId>
-          </exclusion>
-
-          <exclusion>
-            <groupId>org.codehaus.jackson</groupId>
-            <artifactId>jackson-xc</artifactId>
-          </exclusion>
-
-          <exclusion>
-            <groupId>javax.activation</groupId>
-            <artifactId>activation</artifactId>
-          </exclusion>
-        </exclusions>
-      </dependency>
-
-      <dependency>
-        <groupId>com.sun.jersey</groupId>
-        <artifactId>jersey-client</artifactId>
-        <version>${jersey-version}</version>
-      </dependency>
-
-      <dependency>
-        <groupId>com.sun.jersey</groupId>
-        <artifactId>jersey-server</artifactId>
-        <version>${jersey-version}</version>
-      </dependency>
-
-      <dependency>
-        <groupId>com.sun.jersey</groupId>
-        <artifactId>jersey-grizzly2</artifactId>
-        <version>${jersey-version}</version>
-      </dependency>
-
-      <dependency>
-        <groupId>org.glassfish.grizzly</groupId>
-        <artifactId>grizzly-http-servlet-server</artifactId>
-        <version>2.1.2</version>
-      </dependency>
+      <!--<dependency>-->
+        <!--<groupId>com.sun.jersey</groupId>-->
+        <!--<artifactId>jersey-core</artifactId>-->
+        <!--<version>${jersey-version}</version>-->
+      <!--</dependency>-->
 
-      <dependency>
-        <groupId>com.sun.jersey.contribs</groupId>
-        <artifactId>jersey-spring</artifactId>
-        <version>${jersey-version}</version>
-        <exclusions>
-          <exclusion>
-            <groupId>org.springframework</groupId>
-            <artifactId>spring-aop</artifactId>
-          </exclusion>
+      <!--<dependency>-->
+        <!--<groupId>com.sun.jersey</groupId>-->
+        <!--<artifactId>jersey-json</artifactId>-->
+        <!--<version>${jersey-version}</version>-->
+        <!--<exclusions>-->
+          <!--<exclusion>-->
+            <!--<groupId>org.codehaus.jettison</groupId>-->
+            <!--<artifactId>jettison</artifactId>-->
+          <!--</exclusion>-->
+
+          <!--<exclusion>-->
+            <!--<groupId>org.codehaus.jackson</groupId>-->
+            <!--<artifactId>jackson-core-asl</artifactId>-->
+          <!--</exclusion>-->
+
+          <!--<exclusion>-->
+            <!--<groupId>org.codehaus.jackson</groupId>-->
+            <!--<artifactId>jackson-mapper-asl</artifactId>-->
+          <!--</exclusion>-->
+
+          <!--<exclusion>-->
+            <!--<groupId>org.codehaus.jackson</groupId>-->
+            <!--<artifactId>jackson-jaxrs</artifactId>-->
+          <!--</exclusion>-->
+
+          <!--<exclusion>-->
+            <!--<groupId>org.codehaus.jackson</groupId>-->
+            <!--<artifactId>jackson-xc</artifactId>-->
+          <!--</exclusion>-->
+
+          <!--<exclusion>-->
+            <!--<groupId>javax.activation</groupId>-->
+            <!--<artifactId>activation</artifactId>-->
+          <!--</exclusion>-->
+        <!--</exclusions>-->
+      <!--</dependency>-->
 
-          <exclusion>
-            <groupId>org.springframework</groupId>
-            <artifactId>spring-core</artifactId>
-          </exclusion>
+      <!--<dependency>-->
+        <!--<groupId>com.sun.jersey</groupId>-->
+        <!--<artifactId>jersey-client</artifactId>-->
+        <!--<version>${jersey-version}</version>-->
+      <!--</dependency>-->
 
-          <exclusion>
-            <groupId>org.springframework</groupId>
-            <artifactId>spring</artifactId>
-          </exclusion>
+      <!--<dependency>-->
+        <!--<groupId>com.sun.jersey</groupId>-->
+        <!--<artifactId>jersey-server</artifactId>-->
+        <!--<version>${jersey-version}</version>-->
+      <!--</dependency>-->
 
-          <exclusion>
-            <groupId>org.springframework</groupId>
-            <artifactId>spring-beans</artifactId>
-          </exclusion>
+      <!--<dependency>-->
+        <!--<groupId>com.sun.jersey</groupId>-->
+        <!--<artifactId>jersey-grizzly2</artifactId>-->
+        <!--<version>${jersey-version}</version>-->
+      <!--</dependency>-->
 
-          <exclusion>
-            <groupId>org.springframework</groupId>
-            <artifactId>spring-context</artifactId>
-          </exclusion>
+      <!--<dependency>-->
+        <!--<groupId>org.glassfish.grizzly</groupId>-->
+        <!--<artifactId>grizzly-http-servlet-server</artifactId>-->
+        <!--<version>2.1.2</version>-->
+      <!--</dependency>-->
 
-          <exclusion>
-            <groupId>org.springframework</groupId>
-            <artifactId>spring-web</artifactId>
-          </exclusion>
-        </exclusions>
-      </dependency>
+      <!--<dependency>-->
+        <!--<groupId>com.sun.jersey.contribs</groupId>-->
+        <!--<artifactId>jersey-spring</artifactId>-->
+        <!--<version>${jersey-version}</version>-->
+        <!--<exclusions>-->
+          <!--<exclusion>-->
+            <!--<groupId>org.springframework</groupId>-->
+            <!--<artifactId>spring-aop</artifactId>-->
+          <!--</exclusion>-->
+
+          <!--<exclusion>-->
+            <!--<groupId>org.springframework</groupId>-->
+            <!--<artifactId>spring-core</artifactId>-->
+          <!--</exclusion>-->
+
+          <!--<exclusion>-->
+            <!--<groupId>org.springframework</groupId>-->
+            <!--<artifactId>spring</artifactId>-->
+          <!--</exclusion>-->
+
+          <!--<exclusion>-->
+            <!--<groupId>org.springframework</groupId>-->
+            <!--<artifactId>spring-beans</artifactId>-->
+          <!--</exclusion>-->
+
+          <!--<exclusion>-->
+            <!--<groupId>org.springframework</groupId>-->
+            <!--<artifactId>spring-context</artifactId>-->
+          <!--</exclusion>-->
+
+          <!--<exclusion>-->
+            <!--<groupId>org.springframework</groupId>-->
+            <!--<artifactId>spring-web</artifactId>-->
+          <!--</exclusion>-->
+        <!--</exclusions>-->
+      <!--</dependency>-->
 
-      <dependency>
-        <groupId>com.sun.jersey.contribs</groupId>
-        <artifactId>jersey-multipart</artifactId>
-        <version>${jersey-version}</version>
-      </dependency>
+      <!--<dependency>-->
+        <!--<groupId>com.sun.jersey.contribs</groupId>-->
+        <!--<artifactId>jersey-multipart</artifactId>-->
+        <!--<version>${jersey-version}</version>-->
+      <!--</dependency>-->
 
-      <dependency>
-        <groupId>com.sun.jersey.contribs.jersey-oauth</groupId>
-        <artifactId>oauth-signature</artifactId>
-        <version>${jersey-version}</version>
-      </dependency>
+      <!--<dependency>-->
+        <!--<groupId>com.sun.jersey.contribs.jersey-oauth</groupId>-->
+        <!--<artifactId>oauth-signature</artifactId>-->
+        <!--<version>${jersey-version}</version>-->
+      <!--</dependency>-->
 
-      <dependency>
-        <groupId>com.sun.jersey.contribs.jersey-oauth</groupId>
-        <artifactId>oauth-server</artifactId>
-        <version>${jersey-version}</version>
-      </dependency>
+      <!--<dependency>-->
+        <!--<groupId>com.sun.jersey.contribs.jersey-oauth</groupId>-->
+        <!--<artifactId>oauth-server</artifactId>-->
+        <!--<version>${jersey-version}</version>-->
+      <!--</dependency>-->
 
-      <dependency>
-        <groupId>com.sun.jersey.jersey-test-framework</groupId>
-        <artifactId>jersey-test-framework-external</artifactId>
-        <version>${jersey-version}</version>
-      </dependency>
+      <!--<dependency>-->
+        <!--<groupId>com.sun.jersey.jersey-test-framework</groupId>-->
+        <!--<artifactId>jersey-test-framework-external</artifactId>-->
+        <!--<version>${jersey-version}</version>-->
+      <!--</dependency>-->
 
-      <dependency>
-        <groupId>com.sun.jersey.jersey-test-framework</groupId>
-        <artifactId>jersey-test-framework-core</artifactId>
-        <version>${jersey-version}</version>
-      </dependency>
+      <!--<dependency>-->
+        <!--<groupId>com.sun.jersey.jersey-test-framework</groupId>-->
+        <!--<artifactId>jersey-test-framework-core</artifactId>-->
+        <!--<version>${jersey-version}</version>-->
+      <!--</dependency>-->
 
       <dependency>
         <groupId>com.sun.mail</groupId>

http://git-wip-us.apache.org/repos/asf/usergrid/blob/0578d987/stack/rest/pom.xml
----------------------------------------------------------------------
diff --git a/stack/rest/pom.xml b/stack/rest/pom.xml
index 6c47d82..e95e66f 100644
--- a/stack/rest/pom.xml
+++ b/stack/rest/pom.xml
@@ -240,46 +240,79 @@
         </dependency>
 
         <dependency>
-            <groupId>com.sun.jersey.contribs</groupId>
-            <artifactId>jersey-multipart</artifactId>
+            <groupId>org.glassfish.jersey.containers</groupId>
+            <!-- if your container implements Servlet API older than 3.0, use "jersey-container-servlet-core"  -->
+            <artifactId>jersey-container-servlet</artifactId>
+            <version>2.21</version>
         </dependency>
 
+        <!-- Required only when you are using JAX-RS Client -->
         <dependency>
-            <groupId>com.sun.jersey</groupId>
-            <artifactId>jersey-json</artifactId>
+            <groupId>org.glassfish.jersey.core</groupId>
+            <artifactId>jersey-client</artifactId>
+            <version>2.21</version>
         </dependency>
 
         <dependency>
-            <groupId>com.fasterxml.jackson.jaxrs</groupId>
-            <artifactId>jackson-jaxrs-json-provider</artifactId>
+            <groupId>org.glassfish.jersey.connectors</groupId>
+            <artifactId>jersey-apache-connector</artifactId>
+            <version>2.21</version>
         </dependency>
 
+        <!-- support for JSP and Viewable -->
         <dependency>
-            <groupId>com.fasterxml.jackson.jaxrs</groupId>
-            <artifactId>jackson-jaxrs-json-provider</artifactId>
+            <groupId>org.glassfish.jersey.ext</groupId>
+            <artifactId>jersey-mvc-jsp</artifactId>
+            <version>2.21</version>
         </dependency>
 
-
         <dependency>
-            <groupId>com.sun.jersey</groupId>
-            <artifactId>jersey-client</artifactId>
+            <groupId>org.glassfish.jersey.media</groupId>
+            <artifactId>jersey-media-multipart</artifactId>
+            <version>2.7</version>
         </dependency>
 
         <dependency>
-            <groupId>com.google.code.maven-play-plugin.net.tanesha.recaptcha4j</groupId>
-            <artifactId>recaptcha4j</artifactId>
+            <groupId>org.glassfish.jersey.media</groupId>
+            <artifactId>jersey-media-json-jackson</artifactId>
+            <version>2.21</version>
         </dependency>
 
+        <!--<dependency>-->
+            <!--<groupId>com.sun.jersey.contribs</groupId>-->
+            <!--<artifactId>jersey-multipart</artifactId>-->
+        <!--</dependency>-->
+
+        <!--<dependency>-->
+            <!--<groupId>com.sun.jersey</groupId>-->
+            <!--<artifactId>jersey-json</artifactId>-->
+        <!--</dependency>-->
+
         <dependency>
-            <groupId>com.sun.jersey</groupId>
-            <artifactId>jersey-server</artifactId>
+            <groupId>com.fasterxml.jackson.jaxrs</groupId>
+            <artifactId>jackson-jaxrs-json-provider</artifactId>
         </dependency>
 
+        <!--<dependency>-->
+            <!--<groupId>com.sun.jersey</groupId>-->
+            <!--<artifactId>jersey-client</artifactId>-->
+        <!--</dependency>-->
+
         <dependency>
-            <groupId>com.sun.jersey.contribs</groupId>
-            <artifactId>jersey-spring</artifactId>
+            <groupId>com.google.code.maven-play-plugin.net.tanesha.recaptcha4j</groupId>
+            <artifactId>recaptcha4j</artifactId>
         </dependency>
 
+        <!--<dependency>-->
+            <!--<groupId>com.sun.jersey</groupId>-->
+            <!--<artifactId>jersey-server</artifactId>-->
+        <!--</dependency>-->
+
+        <!--<dependency>-->
+            <!--<groupId>com.sun.jersey.contribs</groupId>-->
+            <!--<artifactId>jersey-spring</artifactId>-->
+        <!--</dependency>-->
+
         <!-- Codehaus, Spring, and Other Org Dependencies -->
 
         <dependency>
@@ -382,18 +415,24 @@
             <scope>test</scope>
         </dependency>
 
-        <!--  use the external test client.  Just depend on the maven jetty plugin to launch jetty -->
+        <!--  use the in-memory test setup.  Just depend on the maven jetty plugin to launch jetty -->
         <dependency>
-            <groupId>com.sun.jersey.jersey-test-framework</groupId>
-            <artifactId>jersey-test-framework-external</artifactId>
-            <scope>test</scope>
+            <groupId>org.glassfish.jersey.test-framework.providers</groupId>
+            <artifactId>jersey-test-framework-provider-inmemory</artifactId>
+            <version>2.21</version>
         </dependency>
 
-        <dependency>
-            <groupId>com.sun.jersey.jersey-test-framework</groupId>
-            <artifactId>jersey-test-framework-core</artifactId>
-            <scope>test</scope>
-        </dependency>
+        <!--<dependency>-->
+            <!--<groupId>com.sun.jersey.jersey-test-framework</groupId>-->
+            <!--<artifactId>jersey-test-framework-external</artifactId>-->
+            <!--<scope>test</scope>-->
+        <!--</dependency>-->
+
+        <!--<dependency>-->
+            <!--<groupId>com.sun.jersey.jersey-test-framework</groupId>-->
+            <!--<artifactId>jersey-test-framework-core</artifactId>-->
+            <!--<scope>test</scope>-->
+        <!--</dependency>-->
 
         <dependency>
             <groupId>org.apache.usergrid</groupId>

http://git-wip-us.apache.org/repos/asf/usergrid/blob/0578d987/stack/rest/src/main/java/org/apache/usergrid/rest/AbstractContextResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/AbstractContextResource.java b/stack/rest/src/main/java/org/apache/usergrid/rest/AbstractContextResource.java
index 1494814..c10b20f 100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/AbstractContextResource.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/AbstractContextResource.java
@@ -17,41 +17,32 @@
 package org.apache.usergrid.rest;
 
 
-import java.io.IOException;
-import java.util.List;
-import java.util.Map;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.ws.rs.core.Context;
-import javax.ws.rs.core.PathSegment;
-import javax.ws.rs.core.Request;
-import javax.ws.rs.core.SecurityContext;
-import javax.ws.rs.core.UriInfo;
-
+import com.fasterxml.jackson.core.type.TypeReference;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
 import com.google.inject.Injector;
-import org.apache.usergrid.persistence.index.EntityIndex;
-import org.springframework.beans.factory.annotation.Autowired;
+import net.tanesha.recaptcha.ReCaptcha;
+import net.tanesha.recaptcha.ReCaptchaFactory;
+import org.apache.commons.lang.StringUtils;
 import org.apache.usergrid.management.ManagementService;
 import org.apache.usergrid.mq.QueueManagerFactory;
 import org.apache.usergrid.persistence.EntityManagerFactory;
 import org.apache.usergrid.rest.exceptions.RedirectionException;
 import org.apache.usergrid.security.tokens.TokenService;
 import org.apache.usergrid.services.ServiceManagerFactory;
-
-import com.fasterxml.jackson.core.type.TypeReference;
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.sun.jersey.api.core.HttpContext;
-import com.sun.jersey.api.core.ResourceContext;
-import com.sun.jersey.api.view.Viewable;
-import com.sun.jersey.spi.CloseableService;
-
-import net.tanesha.recaptcha.ReCaptcha;
-import net.tanesha.recaptcha.ReCaptchaFactory;
-
-import org.apache.commons.lang.StringUtils;
+import org.glassfish.jersey.server.CloseableService;
+import org.glassfish.jersey.server.mvc.Viewable;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.container.ResourceContext;
+import javax.ws.rs.core.*;
+import javax.xml.ws.spi.http.HttpContext;
+import java.io.IOException;
+import java.util.List;
+import java.util.Map;
 
 
 public abstract class AbstractContextResource {
@@ -187,7 +178,7 @@ public abstract class AbstractContextResource {
         logger.debug("Dispatching to viewable with template: {}",
             template, template_property);
 
-        Viewable viewable = new Viewable(template, model, this.getClass());
+        Viewable viewable = new Viewable(template, model);
         return viewable;
     }
 

http://git-wip-us.apache.org/repos/asf/usergrid/blob/0578d987/stack/rest/src/main/java/org/apache/usergrid/rest/IndexResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/IndexResource.java b/stack/rest/src/main/java/org/apache/usergrid/rest/IndexResource.java
index a4a56bc..a785c0b 100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/IndexResource.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/IndexResource.java
@@ -21,8 +21,8 @@
 package org.apache.usergrid.rest;
 
 
+import com.fasterxml.jackson.jaxrs.json.annotation.JSONP;
 import com.google.common.base.Preconditions;
-import com.sun.jersey.api.json.JSONWithPadding;
 import org.apache.usergrid.corepersistence.index.ReIndexRequestBuilder;
 import org.apache.usergrid.corepersistence.index.ReIndexRequestBuilderImpl;
 import org.apache.usergrid.corepersistence.index.ReIndexService;
@@ -68,7 +68,7 @@ public class IndexResource extends AbstractContextResource {
     @RequireSystemAccess
     @POST
     @Path( "rebuild" )
-    public JSONWithPadding rebuildIndexesPost( @QueryParam( "callback" ) @DefaultValue( "callback" ) String callback )
+    public ApiResponse rebuildIndexesPost( @QueryParam( "callback" ) @DefaultValue( "callback" ) String callback )
         throws Exception {
 
 
@@ -82,7 +82,13 @@ public class IndexResource extends AbstractContextResource {
     @RequireSystemAccess
     @GET
     @Path( "rebuild/{jobId}" )
-    public JSONWithPadding rebuildIndexesGet(@PathParam( "jobId" ) String jobId, @QueryParam( "callback" ) @DefaultValue( "callback" ) String callback )
+    @JSONP
+    @Produces({"application/json", "application/javascript"})
+    public ApiResponse rebuildIndexesGet(
+        @PathParam( "jobId" ) String jobId,
+        @QueryParam( "callback" ) @DefaultValue( "callback" ) String callback )
+
+
         throws Exception {
         logger.info("Getting status for index jobs");
 
@@ -101,13 +107,15 @@ public class IndexResource extends AbstractContextResource {
         response.setProperty( "numberQueued", status.getNumberProcessed() );
         response.setSuccess();
 
-        return new JSONWithPadding( response, callback );
+        return response;
     }
 
     @RequireSystemAccess
     @PUT
     @Path( "rebuild" )
-    public JSONWithPadding rebuildIndexesPut( final Map<String, Object> payload,
+    @JSONP
+    @Produces({"application/json", "application/javascript"})
+    public ApiResponse rebuildIndexesPut( final Map<String, Object> payload,
                                               @QueryParam( "callback" ) @DefaultValue( "callback" ) String callback )
         throws Exception {
 
@@ -122,7 +130,9 @@ public class IndexResource extends AbstractContextResource {
     @RequireSystemAccess
     @POST
     @Path( "rebuild/" + RootResource.APPLICATION_ID_PATH )
-    public JSONWithPadding rebuildIndexesPut( @PathParam( "applicationId" ) String applicationIdStr,
+    @JSONP
+    @Produces({"application/json", "application/javascript"})
+    public ApiResponse rebuildIndexesPut( @PathParam( "applicationId" ) String applicationIdStr,
                                               @QueryParam( "callback" ) @DefaultValue( "callback" ) String callback,
                                               @QueryParam( "delay" ) @DefaultValue( "10" ) final long delay )
 
@@ -143,7 +153,9 @@ public class IndexResource extends AbstractContextResource {
     @RequireSystemAccess
     @PUT
     @Path( "rebuild/" + RootResource.APPLICATION_ID_PATH )
-    public JSONWithPadding rebuildIndexesPut( final Map<String, Object> payload,
+    @JSONP
+    @Produces({"application/json", "application/javascript"})
+    public ApiResponse rebuildIndexesPut( final Map<String, Object> payload,
                                               @PathParam( "applicationId" ) String applicationIdStr,
                                               @QueryParam( "callback" ) @DefaultValue( "callback" ) String callback,
                                               @QueryParam( "delay" ) @DefaultValue( "10" ) final long delay )
@@ -163,7 +175,9 @@ public class IndexResource extends AbstractContextResource {
     @RequireSystemAccess
     @POST
     @Path( "rebuild/" + RootResource.APPLICATION_ID_PATH + "/{collectionName}" )
-    public JSONWithPadding rebuildIndexesPost( @PathParam( "applicationId" ) final String applicationIdStr,
+    @JSONP
+    @Produces({"application/json", "application/javascript"})
+    public ApiResponse rebuildIndexesPost( @PathParam( "applicationId" ) final String applicationIdStr,
                                                @PathParam( "collectionName" ) final String collectionName,
                                                @QueryParam( "reverse" ) @DefaultValue( "false" ) final Boolean reverse,
                                                @QueryParam( "callback" ) @DefaultValue( "callback" ) String callback )
@@ -184,7 +198,9 @@ public class IndexResource extends AbstractContextResource {
     @RequireSystemAccess
     @PUT
     @Path( "rebuild/" + RootResource.APPLICATION_ID_PATH + "/{collectionName}" )
-    public JSONWithPadding rebuildIndexesPut( final Map<String, Object> payload,
+    @JSONP
+    @Produces({"application/json", "application/javascript"})
+    public ApiResponse rebuildIndexesPut( final Map<String, Object> payload,
                                               @PathParam( "applicationId" ) final String applicationIdStr,
                                               @PathParam( "collectionName" ) final String collectionName,
                                               @QueryParam( "reverse" ) @DefaultValue( "false" ) final Boolean reverse,
@@ -205,7 +221,9 @@ public class IndexResource extends AbstractContextResource {
     @RequireSystemAccess
     @POST
     @Path( "rebuild/management" )
-    public JSONWithPadding rebuildInternalIndexesPost(
+    @JSONP
+    @Produces({"application/json", "application/javascript"})
+    public ApiResponse rebuildInternalIndexesPost(
         @QueryParam( "callback" ) @DefaultValue( "callback" ) String callback ) throws Exception {
 
 
@@ -221,7 +239,9 @@ public class IndexResource extends AbstractContextResource {
     @RequireSystemAccess
     @PUT
     @Path( "rebuild/management" )
-    public JSONWithPadding rebuildInternalIndexesPut( final Map<String, Object> payload,
+    @JSONP
+    @Produces({"application/json", "application/javascript"})
+    public ApiResponse rebuildInternalIndexesPut( final Map<String, Object> payload,
                                                       @QueryParam( "callback" ) @DefaultValue( "callback" )
                                                       String callback ) throws Exception {
 
@@ -238,7 +258,9 @@ public class IndexResource extends AbstractContextResource {
     @RequireSystemAccess
     @POST
     @Path(RootResource.APPLICATION_ID_PATH)
-    public JSONWithPadding addIndex( @Context UriInfo ui,
+    @JSONP
+    @Produces({"application/json", "application/javascript"})
+    public ApiResponse addIndex( @Context UriInfo ui,
                                      @PathParam( "applicationId" ) final String applicationIdStr,
                                      Map<String, Object> config,
                                      @QueryParam( "callback" ) @DefaultValue( "callback" ) String callback )
@@ -268,7 +290,7 @@ public class IndexResource extends AbstractContextResource {
             (int) config.get("replicas"), (String) config.get("writeConsistency"));
         response.setAction( "Add index to alias" );
 
-        return new JSONWithPadding( response, callback );
+        return response;
     }
 
 
@@ -283,7 +305,7 @@ public class IndexResource extends AbstractContextResource {
     }
 
 
-    private JSONWithPadding executeResumeAndCreateResponse( final Map<String, Object> payload,
+    private ApiResponse executeResumeAndCreateResponse( final Map<String, Object> payload,
                                                             final ReIndexRequestBuilder request,
                                                             final String callback ) {
 
@@ -309,7 +331,7 @@ public class IndexResource extends AbstractContextResource {
     /**
      * Execute the request and return the response.
      */
-    private JSONWithPadding executeAndCreateResponse( final ReIndexRequestBuilder request, final String callback ) {
+    private ApiResponse executeAndCreateResponse( final ReIndexRequestBuilder request, final String callback ) {
 
 
         final ReIndexService.ReIndexStatus status = getReIndexService().rebuildIndex( request );
@@ -323,6 +345,6 @@ public class IndexResource extends AbstractContextResource {
         response.setProperty( "numberQueued", status.getNumberProcessed() );
         response.setSuccess();
 
-        return new JSONWithPadding( response, callback );
+        return response;
     }
 }

http://git-wip-us.apache.org/repos/asf/usergrid/blob/0578d987/stack/rest/src/main/java/org/apache/usergrid/rest/MigrateResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/MigrateResource.java b/stack/rest/src/main/java/org/apache/usergrid/rest/MigrateResource.java
index 7410927..168a3b7 100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/MigrateResource.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/MigrateResource.java
@@ -19,29 +19,26 @@
 package org.apache.usergrid.rest;
 
 
-import java.util.Map;
-import java.util.Set;
-
-import javax.ws.rs.*;
-import javax.ws.rs.core.Context;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.UriInfo;
-
+import com.fasterxml.jackson.databind.node.JsonNodeFactory;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import com.fasterxml.jackson.jaxrs.json.annotation.JSONP;
+import com.google.common.base.Preconditions;
+import com.google.inject.Injector;
+import org.apache.usergrid.persistence.core.migration.data.DataMigrationManager;
+import org.apache.usergrid.persistence.core.migration.schema.MigrationManager;
+import org.apache.usergrid.rest.security.annotations.RequireSystemAccess;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.annotation.Scope;
 import org.springframework.stereotype.Component;
 
-import org.apache.usergrid.persistence.core.migration.data.DataMigrationManager;
-import org.apache.usergrid.persistence.core.migration.schema.MigrationManager;
-import org.apache.usergrid.rest.security.annotations.RequireSystemAccess;
-
-import com.fasterxml.jackson.databind.node.JsonNodeFactory;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-import com.google.common.base.Preconditions;
-import com.google.inject.Injector;
-import com.sun.jersey.api.json.JSONWithPadding;
+import javax.ws.rs.*;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.UriInfo;
+import java.util.Map;
+import java.util.Set;
 
 
 @Component
@@ -68,7 +65,9 @@ public class MigrateResource extends AbstractContextResource {
     @RequireSystemAccess
     @PUT
     @Path( "run" )
-    public JSONWithPadding migrateData( @Context UriInfo ui,
+    @JSONP
+    @Produces({"application/json", "application/javascript"})
+    public ApiResponse migrateData( @Context UriInfo ui,
                                         @QueryParam( "callback" ) @DefaultValue( "callback" ) String callback )
         throws Exception {
 
@@ -108,13 +107,15 @@ public class MigrateResource extends AbstractContextResource {
 
         response.setSuccess();
 
-        return new JSONWithPadding( response, callback );
+        return response;
     }
 
     @RequireSystemAccess
     @PUT
     @Path( "run/{pluginName}" )
-    public JSONWithPadding migrateData(@PathParam("pluginName") String pluginName ,  @Context UriInfo ui,
+    @JSONP
+    @Produces({"application/json", "application/javascript"})
+    public ApiResponse migrateData(@PathParam("pluginName") String pluginName ,  @Context UriInfo ui,
                                         @QueryParam( "callback" ) @DefaultValue( "callback" ) String callback )
         throws Exception {
 
@@ -151,13 +152,15 @@ public class MigrateResource extends AbstractContextResource {
 
         response.setSuccess();
 
-        return new JSONWithPadding( response, callback );
+        return response;
     }
 
     @RequireSystemAccess
     @PUT
     @Path( "set" )
-    public JSONWithPadding setMigrationVersion(
+    @JSONP
+    @Produces({"application/json", "application/javascript"})
+    public ApiResponse setMigrationVersion(
         @Context UriInfo ui, Map<String, Object> json,
         @QueryParam( "callback" ) @DefaultValue( "" ) String callback )
         throws Exception {
@@ -197,14 +200,16 @@ public class MigrateResource extends AbstractContextResource {
         response.setData( node );
         response.setSuccess();
 
-        return new JSONWithPadding( response, callback );
+        return response;
     }
 
 
     @RequireSystemAccess
     @GET
     @Path( "status" )
-    public JSONWithPadding migrateStatus(
+    @JSONP
+    @Produces({"application/json", "application/javascript"})
+    public ApiResponse migrateStatus(
         @Context UriInfo ui,
         @QueryParam( "callback" ) @DefaultValue( "callback" ) String callback )
         throws Exception {
@@ -228,14 +233,16 @@ public class MigrateResource extends AbstractContextResource {
 
         response.setSuccess();
 
-        return new JSONWithPadding( response, callback );
+        return response;
     }
 
 
     @RequireSystemAccess
     @GET
     @Path( "count" )
-    public JSONWithPadding migrateCount(
+    @JSONP
+    @Produces({"application/json", "application/javascript"})
+    public ApiResponse migrateCount(
         @Context UriInfo ui,
         @QueryParam( "callback" ) @DefaultValue( "callback" ) String callback )
         throws Exception {
@@ -247,7 +254,7 @@ public class MigrateResource extends AbstractContextResource {
 
         response.setSuccess();
 
-        return new JSONWithPadding( response, callback );
+        return response;
     }
 
 

http://git-wip-us.apache.org/repos/asf/usergrid/blob/0578d987/stack/rest/src/main/java/org/apache/usergrid/rest/RootResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/RootResource.java b/stack/rest/src/main/java/org/apache/usergrid/rest/RootResource.java
index 7c17b7c..8875295 100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/RootResource.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/RootResource.java
@@ -19,66 +19,40 @@ package org.apache.usergrid.rest;
 
 import com.fasterxml.jackson.databind.node.JsonNodeFactory;
 import com.fasterxml.jackson.databind.node.ObjectNode;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.Map;
-import java.util.SortedMap;
-import java.util.UUID;
-
-import javax.ws.rs.DefaultValue;
-import javax.ws.rs.GET;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.Produces;
-import javax.ws.rs.QueryParam;
-import javax.ws.rs.core.Context;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-import javax.ws.rs.core.Response.ResponseBuilder;
-import javax.ws.rs.core.UriInfo;
-
+import com.fasterxml.jackson.jaxrs.json.annotation.JSONP;
+import com.google.common.collect.BiMap;
 import com.google.inject.Injector;
+import com.yammer.metrics.Metrics;
+import com.yammer.metrics.core.*;
+import com.yammer.metrics.stats.Snapshot;
+import org.apache.commons.lang.StringUtils;
+import org.apache.shiro.authz.UnauthorizedException;
 import org.apache.usergrid.corepersistence.asyncevents.AsyncEventService;
-import org.apache.usergrid.persistence.index.IndexFig;
-import org.apache.usergrid.persistence.index.IndexRefreshCommand;
+import org.apache.usergrid.persistence.core.util.Health;
 import org.apache.usergrid.persistence.index.query.Identifier;
-import org.apache.usergrid.persistence.queue.Queue;
-import org.apache.usergrid.persistence.queue.QueueManager;
-import org.apache.usergrid.persistence.queue.QueueManagerFactory;
-import org.apache.usergrid.persistence.queue.QueueScope;
-import org.apache.usergrid.persistence.queue.impl.QueueScopeImpl;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.context.annotation.Scope;
-import org.springframework.stereotype.Component;
 import org.apache.usergrid.rest.applications.ApplicationResource;
 import org.apache.usergrid.rest.exceptions.NoOpException;
 import org.apache.usergrid.rest.organizations.OrganizationResource;
 import org.apache.usergrid.rest.security.annotations.RequireSystemAccess;
 import org.apache.usergrid.system.UsergridSystemMonitor;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Component;
 
-import org.apache.commons.lang.StringUtils;
-import org.apache.shiro.authz.UnauthorizedException;
-
-import com.google.common.collect.BiMap;
-import com.sun.jersey.api.json.JSONWithPadding;
-import com.yammer.metrics.Metrics;
-import com.yammer.metrics.core.Counter;
-import com.yammer.metrics.core.Gauge;
-import com.yammer.metrics.core.Histogram;
-import com.yammer.metrics.core.Metered;
-import com.yammer.metrics.core.Metric;
-import com.yammer.metrics.core.MetricName;
-import com.yammer.metrics.core.MetricProcessor;
-import com.yammer.metrics.core.MetricsRegistry;
-import com.yammer.metrics.core.Sampling;
-import com.yammer.metrics.core.Summarizable;
-import com.yammer.metrics.core.Timer;
-import com.yammer.metrics.stats.Snapshot;
+import javax.ws.rs.*;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.Response.ResponseBuilder;
+import javax.ws.rs.core.UriInfo;
 import java.io.IOException;
-import org.apache.usergrid.persistence.EntityManager;
-import org.apache.usergrid.persistence.core.util.Health;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.Map;
+import java.util.SortedMap;
+import java.util.UUID;
 
 
 /** @author ed@anuff.com */
@@ -121,7 +95,9 @@ public class RootResource extends AbstractContextResource implements MetricProce
     @RequireSystemAccess
     @GET
     @Path("applications")
-    public JSONWithPadding getAllApplications(
+    @JSONP
+    @Produces({"application/json", "application/javascript"})
+    public ApiResponse getAllApplications(
         @Context UriInfo ui,
         @QueryParam("deleted") @DefaultValue("false") Boolean deleted,
         @QueryParam("callback") @DefaultValue("callback") String callback ) throws URISyntaxException {
@@ -146,14 +122,16 @@ public class RootResource extends AbstractContextResource implements MetricProce
             response.setError( "Unable to retrieve applications" );
         }
 
-        return new JSONWithPadding( response, callback );
+        return response;
     }
 
 
     @RequireSystemAccess
     @GET
     @Path("apps")
-    public JSONWithPadding getAllApplications2( @Context UriInfo ui,
+    @JSONP
+    @Produces({"application/json", "application/javascript"})
+    public ApiResponse getAllApplications2( @Context UriInfo ui,
                                                 @QueryParam("callback") @DefaultValue("callback") String callback )
             throws URISyntaxException {
         return getAllApplications( ui, false, callback );
@@ -186,7 +164,9 @@ public class RootResource extends AbstractContextResource implements MetricProce
      */
     @GET
     @Path("status")
-    public JSONWithPadding getStatus(
+    @JSONP
+    @Produces({"application/json", "application/javascript"})
+    public ApiResponse getStatus(
             @QueryParam("ignore_error") @DefaultValue("true") Boolean ignoreError,
             @QueryParam("callback") @DefaultValue("callback") String callback ) {
 
@@ -225,12 +205,14 @@ public class RootResource extends AbstractContextResource implements MetricProce
 
         dumpMetrics(node);
         response.setProperty( "status", node );
-        return new JSONWithPadding( response, callback );
+        return response;
     }
 
 
     @GET
     @Path("lb-status")
+    @JSONP
+    @Produces({"application/json", "application/javascript"})
     public Response getLbStatus() {
         ResponseBuilder response;
         if ( usergridSystemMonitor.getIsCassandraAlive() ) {

http://git-wip-us.apache.org/repos/asf/usergrid/blob/0578d987/stack/rest/src/main/java/org/apache/usergrid/rest/SystemResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/SystemResource.java b/stack/rest/src/main/java/org/apache/usergrid/rest/SystemResource.java
index fca3333..0a09eba 100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/SystemResource.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/SystemResource.java
@@ -17,38 +17,17 @@
 package org.apache.usergrid.rest;
 
 
-import java.util.Map;
-import java.util.Set;
-import java.util.UUID;
-
-import javax.ws.rs.DefaultValue;
-import javax.ws.rs.GET;
-import javax.ws.rs.PUT;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.Produces;
-import javax.ws.rs.QueryParam;
-import javax.ws.rs.core.Context;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.UriInfo;
-
+import com.fasterxml.jackson.jaxrs.json.annotation.JSONP;
+import org.apache.usergrid.rest.security.annotations.RequireSystemAccess;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.context.annotation.Scope;
 import org.springframework.stereotype.Component;
 
-import org.apache.usergrid.persistence.EntityManager;
-import org.apache.usergrid.persistence.EntityManagerFactory;
-import org.apache.usergrid.persistence.EntityManagerFactory.ProgressObserver;
-import org.apache.usergrid.persistence.EntityRef;
-import org.apache.usergrid.persistence.index.utils.UUIDUtils;
-import org.apache.usergrid.rest.management.organizations.OrganizationsResource;
-import org.apache.usergrid.rest.security.annotations.RequireSystemAccess;
-
-import com.clearspring.analytics.util.Preconditions;
-import com.fasterxml.jackson.databind.node.JsonNodeFactory;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-import com.sun.jersey.api.json.JSONWithPadding;
+import javax.ws.rs.*;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.UriInfo;
 
 
 @Path( "/system" )
@@ -71,7 +50,9 @@ public class SystemResource extends AbstractContextResource {
     @RequireSystemAccess
     @GET
     @Path( "database/setup" )
-    public JSONWithPadding getSetup( @Context UriInfo ui,
+    @JSONP
+    @Produces({"application/json", "application/javascript"})
+    public ApiResponse getSetup( @Context UriInfo ui,
                                      @QueryParam( "callback" ) @DefaultValue( "callback" ) String callback )
             throws Exception {
 
@@ -88,14 +69,16 @@ public class SystemResource extends AbstractContextResource {
 
         response.setSuccess();
 
-        return new JSONWithPadding( response, callback );
+        return response;
     }
 
 
     @RequireSystemAccess
     @GET
     @Path( "superuser/setup" )
-    public JSONWithPadding getSetupSuperuser( @Context UriInfo ui,
+    @JSONP
+    @Produces({"application/json", "application/javascript"})
+    public ApiResponse getSetupSuperuser( @Context UriInfo ui,
                                               @QueryParam( "callback" ) @DefaultValue( "callback" ) String callback )
             throws Exception {
 
@@ -113,7 +96,7 @@ public class SystemResource extends AbstractContextResource {
 
         response.setSuccess();
 
-        return new JSONWithPadding( response, callback );
+        return response;
     }
 
     @Path( "migrate" )

http://git-wip-us.apache.org/repos/asf/usergrid/blob/0578d987/stack/rest/src/main/java/org/apache/usergrid/rest/TextToJsonSwapWriter.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/TextToJsonSwapWriter.java b/stack/rest/src/main/java/org/apache/usergrid/rest/TextToJsonSwapWriter.java
index 546a9f3..f4067df 100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/TextToJsonSwapWriter.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/TextToJsonSwapWriter.java
@@ -32,11 +32,13 @@ import javax.ws.rs.core.MultivaluedMap;
 import javax.ws.rs.ext.MessageBodyWriter;
 import javax.ws.rs.ext.Provider;
 
-import com.sun.jersey.api.json.JSONWithPadding;
-import com.sun.jersey.api.view.Viewable;
-import com.sun.jersey.spi.MessageBodyWorkers;
+import org.glassfish.jersey.message.MessageBodyWorkers;
+import org.glassfish.jersey.server.mvc.Viewable;
 
 
+
+// TODO: text to JSON swapping for Jersey 2
+
 /**
  * A writer that will redirect requests for "text/html" to "application/json" if the value
  * returned by the resource is an instance of JSONWithPadding
@@ -46,91 +48,91 @@ import com.sun.jersey.spi.MessageBodyWorkers;
  */
 @Provider
 @Produces( MediaType.TEXT_HTML )
-public class TextToJsonSwapWriter implements MessageBodyWriter<JSONWithPadding> {
-
-
-    private static final MediaType JSON_MEDIA_TYPE = MediaType.APPLICATION_JSON_TYPE;
-
-    @Context
-    MessageBodyWorkers bodyWorker;
-
-
-    @Override
-    public boolean isWriteable( final Class<?> type, final Type genericType, final Annotation[] annotations,
-                                final MediaType mediaType ) {
-
-
-        // if type is Viewable them we want to return HTML, so no swap needed
-        if ( type.isAssignableFrom(Viewable.class) ) {
-            return false;
-        }
-
-        // this should only map no media type, or text/html requests with json responses
-        final boolean mediaTypeCorrect = mediaType == null || MediaType.TEXT_HTML_TYPE.equals( mediaType );
-
-        if(!mediaTypeCorrect){
-            return false;
-        }
-
-        return true;
-
-// JsonSerializableWithType no longer exists in FasterXML Jackson
+public class TextToJsonSwapWriter { // implements MessageBodyWriter<JSONWithPadding> {
 //
-//        final boolean serializableAnnotation = type.getAnnotation( XmlRootElement.class ) != null;
-//        final boolean jsonSerializable = JsonSerializableWithType.class.isAssignableFrom( type );
-//        return serializableAnnotation || jsonSerializable;
-    }
-
-
-    @Override
-    public long getSize( final JSONWithPadding jsonWithPadding, final Class<?> type, final Type genericType,
-                         final Annotation[] annotations, final MediaType mediaType ) {
-        return -1;
-    }
-
-
-    @Override
-    public void writeTo( final JSONWithPadding jsonWithPadding, final Class<?> type, final Type genericType,
-                         final Annotation[] annotations, final MediaType mediaType,
-                         final MultivaluedMap<String, Object> httpHeaders, final OutputStream entityStream )
-            throws IOException, WebApplicationException {
-
-
-        Object jsonEntity = jsonWithPadding.getJsonSource();
-        Type entityGenericType = jsonEntity.getClass();
-        Class<?> entityType = jsonEntity.getClass();
-
-        final boolean genericEntityUsed = jsonEntity instanceof GenericEntity;
-
-        if ( genericEntityUsed ) {
-            GenericEntity ge = ( GenericEntity ) jsonEntity;
-            jsonEntity = ge.getEntity();
-            entityGenericType = ge.getType();
-            entityType = ge.getRawType();
-        }
-
-
-        //replace the text/html content type with application Json
-        httpHeaders.remove( HttpHeaders.CONTENT_TYPE);
-
-        httpHeaders.putSingle( HttpHeaders.CONTENT_TYPE,  JSON_MEDIA_TYPE);
-
-
-
-
-        MessageBodyWriter bw = bodyWorker.getMessageBodyWriter( entityType, entityGenericType, annotations, JSON_MEDIA_TYPE );
-
-        if ( bw == null ) {
-
-            throw new RuntimeException( "Couldn't find the serailziation writer for json type");
-        }
-
-
-
-
-        bw.writeTo( jsonEntity, entityType, entityGenericType, annotations, JSON_MEDIA_TYPE, httpHeaders,
-                entityStream );
-
-
-    }
+//
+//    private static final MediaType JSON_MEDIA_TYPE = MediaType.APPLICATION_JSON_TYPE;
+//
+//    @Context
+//    MessageBodyWorkers bodyWorker;
+//
+//
+//    @Override
+//    public boolean isWriteable( final Class<?> type, final Type genericType, final Annotation[] annotations,
+//                                final MediaType mediaType ) {
+//
+//
+//        // if type is Viewable them we want to return HTML, so no swap needed
+//        if ( type.isAssignableFrom(Viewable.class) ) {
+//            return false;
+//        }
+//
+//        // this should only map no media type, or text/html requests with json responses
+//        final boolean mediaTypeCorrect = mediaType == null || MediaType.TEXT_HTML_TYPE.equals( mediaType );
+//
+//        if(!mediaTypeCorrect){
+//            return false;
+//        }
+//
+//        return true;
+//
+//// JsonSerializableWithType no longer exists in FasterXML Jackson
+////
+////        final boolean serializableAnnotation = type.getAnnotation( XmlRootElement.class ) != null;
+////        final boolean jsonSerializable = JsonSerializableWithType.class.isAssignableFrom( type );
+////        return serializableAnnotation || jsonSerializable;
+//    }
+//
+//
+//    @Override
+//    public long getSize( final JSONWithPadding jsonWithPadding, final Class<?> type, final Type genericType,
+//                         final Annotation[] annotations, final MediaType mediaType ) {
+//        return -1;
+//    }
+//
+//
+//    @Override
+//    public void writeTo( final JSONWithPadding jsonWithPadding, final Class<?> type, final Type genericType,
+//                         final Annotation[] annotations, final MediaType mediaType,
+//                         final MultivaluedMap<String, Object> httpHeaders, final OutputStream entityStream )
+//            throws IOException, WebApplicationException {
+//
+//
+//        Object jsonEntity = jsonWithPadding.getJsonSource();
+//        Type entityGenericType = jsonEntity.getClass();
+//        Class<?> entityType = jsonEntity.getClass();
+//
+//        final boolean genericEntityUsed = jsonEntity instanceof GenericEntity;
+//
+//        if ( genericEntityUsed ) {
+//            GenericEntity ge = ( GenericEntity ) jsonEntity;
+//            jsonEntity = ge.getEntity();
+//            entityGenericType = ge.getType();
+//            entityType = ge.getRawType();
+//        }
+//
+//
+//        //replace the text/html content type with application Json
+//        httpHeaders.remove( HttpHeaders.CONTENT_TYPE);
+//
+//        httpHeaders.putSingle( HttpHeaders.CONTENT_TYPE,  JSON_MEDIA_TYPE);
+//
+//
+//
+//
+//        MessageBodyWriter bw = bodyWorker.getMessageBodyWriter( entityType, entityGenericType, annotations, JSON_MEDIA_TYPE );
+//
+//        if ( bw == null ) {
+//
+//            throw new RuntimeException( "Couldn't find the serailziation writer for json type");
+//        }
+//
+//
+//
+//
+//        bw.writeTo( jsonEntity, entityType, entityGenericType, annotations, JSON_MEDIA_TYPE, httpHeaders,
+//                entityStream );
+//
+//
+//    }
 }

http://git-wip-us.apache.org/repos/asf/usergrid/blob/0578d987/stack/rest/src/main/java/org/apache/usergrid/rest/applications/ApplicationResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/applications/ApplicationResource.java b/stack/rest/src/main/java/org/apache/usergrid/rest/applications/ApplicationResource.java
index c49c543..f2bd8fc 100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/applications/ApplicationResource.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/applications/ApplicationResource.java
@@ -38,6 +38,9 @@ import javax.ws.rs.core.PathSegment;
 import javax.ws.rs.core.Response;
 import javax.ws.rs.core.UriInfo;
 
+import com.fasterxml.jackson.jaxrs.json.annotation.JSONP;
+import org.apache.usergrid.rest.ApiResponse;
+import org.glassfish.jersey.server.mvc.Viewable;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.context.annotation.Scope;
@@ -73,9 +76,6 @@ import org.apache.usergrid.rest.security.annotations.RequireOrganizationAccess;
 import org.apache.usergrid.security.oauth.AccessInfo;
 import org.apache.usergrid.security.oauth.ClientCredentialsInfo;
 
-import com.sun.jersey.api.json.JSONWithPadding;
-import com.sun.jersey.api.view.Viewable;
-
 import static javax.servlet.http.HttpServletResponse.SC_BAD_REQUEST;
 import static javax.servlet.http.HttpServletResponse.SC_OK;
 import static javax.ws.rs.core.MediaType.APPLICATION_FORM_URLENCODED;
@@ -354,7 +354,9 @@ public class ApplicationResource extends ServiceResource {
     @GET
     @Path("credentials")
     @RequireApplicationAccess
-    public JSONWithPadding getKeys( @Context UriInfo ui,
+    @JSONP
+    @Produces({"application/json", "application/javascript"})
+    public ApiResponse getKeys( @Context UriInfo ui,
                                     @QueryParam("callback") @DefaultValue("callback") String callback )
             throws Exception {
 
@@ -368,17 +370,16 @@ public class ApplicationResource extends ServiceResource {
                 new ClientCredentialsInfo( management.getClientIdForApplication( services.getApplicationId() ),
                         management.getClientSecretForApplication( services.getApplicationId() ) );
 
-        return new JSONWithPadding(
-                createApiResponse().withCredentials( kp ).withAction( "get application keys" ).withSuccess(),
-                callback );
+        return   createApiResponse().withCredentials( kp ).withAction( "get application keys" ).withSuccess();
     }
 
 
     @POST
     @Path("credentials")
     @RequireApplicationAccess
-    @Produces(MediaType.APPLICATION_JSON)
-    public JSONWithPadding generateKeys( @Context UriInfo ui,
+    @JSONP
+    @Produces({"application/json", "application/javascript"})
+    public ApiResponse generateKeys( @Context UriInfo ui,
         @QueryParam("callback") @DefaultValue("callback") String callback ) throws Exception {
 
         logger.debug( "AuthResource.keys" );
@@ -391,9 +392,7 @@ public class ApplicationResource extends ServiceResource {
             management.getClientIdForApplication( services.getApplicationId() ),
             management.newClientSecretForApplication( services.getApplicationId() ) );
 
-        return new JSONWithPadding(
-                createApiResponse().withCredentials( kp ).withAction( "generate application keys" ).withSuccess(),
-                callback );
+        return createApiResponse().withCredentials( kp ).withAction( "generate application keys" ).withSuccess();
     }
 
 
@@ -498,7 +497,7 @@ public class ApplicationResource extends ServiceResource {
     @Override
     @DELETE
     @RequireOrganizationAccess
-    public JSONWithPadding executeDelete( @Context final UriInfo ui, @DefaultValue( "callback" ) final String callback,
+    public ApiResponse executeDelete( @Context final UriInfo ui, @DefaultValue( "callback" ) final String callback,
                                           final String confirmAppDelete ) throws Exception {
         throw new UnsupportedOperationException( "Delete must be done from the management endpoint" );
     }
@@ -599,7 +598,9 @@ public class ApplicationResource extends ServiceResource {
 
     @GET
     @Path("apm/apigeeMobileConfig")
-    public JSONWithPadding getAPMConfig( @Context UriInfo ui,
+    @JSONP
+    @Produces({"application/json", "application/javascript"})
+    public Object getAPMConfig( @Context UriInfo ui,
                                          @QueryParam("callback") @DefaultValue("callback") String callback )
             throws Exception {
         EntityManager em = emf.getEntityManager( applicationId );
@@ -610,6 +611,6 @@ public class ApplicationResource extends ServiceResource {
             value = management.registerAppWithAPM( management.getOrganizationForApplication( applicationId ),
                     management.getApplicationInfo( applicationId ) );
         }
-        return new JSONWithPadding( value, callback );
+        return value;
     }
 }

http://git-wip-us.apache.org/repos/asf/usergrid/blob/0578d987/stack/rest/src/main/java/org/apache/usergrid/rest/applications/ServiceResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/applications/ServiceResource.java b/stack/rest/src/main/java/org/apache/usergrid/rest/applications/ServiceResource.java
index 9a5a403..6e10a9f 100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/applications/ServiceResource.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/applications/ServiceResource.java
@@ -17,40 +17,9 @@
 package org.apache.usergrid.rest.applications;
 
 
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.UUID;
-
-import javax.ws.rs.Consumes;
-import javax.ws.rs.DELETE;
-import javax.ws.rs.DefaultValue;
-import javax.ws.rs.GET;
-import javax.ws.rs.HeaderParam;
-import javax.ws.rs.POST;
-import javax.ws.rs.PUT;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.Produces;
-import javax.ws.rs.QueryParam;
-import javax.ws.rs.core.Context;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.MultivaluedMap;
-import javax.ws.rs.core.PathSegment;
-import javax.ws.rs.core.Response;
-import javax.ws.rs.core.UriInfo;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.context.annotation.Scope;
-import org.springframework.stereotype.Component;
-
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.jaxrs.json.annotation.JSONP;
 import org.apache.commons.lang.StringUtils;
-
 import org.apache.usergrid.persistence.Entity;
 import org.apache.usergrid.persistence.EntityManager;
 import org.apache.usergrid.persistence.Query;
@@ -61,12 +30,7 @@ import org.apache.usergrid.rest.RootResource;
 import org.apache.usergrid.rest.applications.assets.AssetsResource;
 import org.apache.usergrid.rest.security.annotations.RequireApplicationAccess;
 import org.apache.usergrid.security.oauth.AccessInfo;
-import org.apache.usergrid.services.ServiceAction;
-import org.apache.usergrid.services.ServiceManager;
-import org.apache.usergrid.services.ServiceParameter;
-import org.apache.usergrid.services.ServicePayload;
-import org.apache.usergrid.services.ServiceRequest;
-import org.apache.usergrid.services.ServiceResults;
+import org.apache.usergrid.services.*;
 import org.apache.usergrid.services.assets.data.AssetUtils;
 import org.apache.usergrid.services.assets.data.AwsSdkS3BinaryStore;
 import org.apache.usergrid.services.assets.data.BinaryStore;
@@ -74,16 +38,22 @@ import org.apache.usergrid.services.assets.data.LocalFileBinaryStore;
 import org.apache.usergrid.services.exceptions.AwsPropertiesNotFoundException;
 import org.apache.usergrid.utils.InflectionUtils;
 import org.apache.usergrid.utils.JsonUtils;
+import org.glassfish.jersey.media.multipart.BodyPart;
+import org.glassfish.jersey.media.multipart.BodyPartEntity;
+import org.glassfish.jersey.media.multipart.FormDataBodyPart;
+import org.glassfish.jersey.media.multipart.FormDataMultiPart;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Component;
 
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.sun.jersey.api.json.JSONWithPadding;
-import com.sun.jersey.multipart.BodyPart;
-import com.sun.jersey.multipart.BodyPartEntity;
-import com.sun.jersey.multipart.FormDataBodyPart;
-import com.sun.jersey.multipart.FormDataMultiPart;
+import javax.ws.rs.*;
+import javax.ws.rs.core.*;
+import java.io.InputStream;
+import java.util.*;
 
 import static javax.ws.rs.core.MediaType.APPLICATION_JSON_TYPE;
-
 import static org.apache.usergrid.management.AccountCreationProps.PROPERTIES_USERGRID_BINARY_UPLOADER;
 
 
@@ -306,9 +276,10 @@ public class ServiceResource extends AbstractContextResource {
 
 
     @GET
-    @Produces({MediaType.APPLICATION_JSON, MediaType.TEXT_HTML})
+    @Produces({MediaType.APPLICATION_JSON, MediaType.TEXT_HTML, "application/javascript"})
     @RequireApplicationAccess
-    public JSONWithPadding executeGet( @Context UriInfo ui,
+    @JSONP
+    public ApiResponse executeGet( @Context UriInfo ui,
                                        @QueryParam("callback") @DefaultValue("callback") String callback )
             throws Exception {
 
@@ -322,7 +293,7 @@ public class ServiceResource extends AbstractContextResource {
 
         executeServiceRequest( ui, response, ServiceAction.GET, null );
 
-        return new JSONWithPadding( response, callback );
+        return response;
     }
 
 
@@ -358,7 +329,7 @@ public class ServiceResource extends AbstractContextResource {
      * Necessary to work around inexplicable problems with EntityHolder.
      * See above.
      */
-    public JSONWithPadding executePostWithObject( @Context UriInfo ui, Object json,
+    public ApiResponse executePostWithObject( @Context UriInfo ui, Object json,
             @QueryParam("callback") @DefaultValue("callback") String callback ) throws Exception {
 
         logger.debug( "ServiceResource.executePostWithMap" );
@@ -374,7 +345,7 @@ public class ServiceResource extends AbstractContextResource {
 
         executeServiceRequest( ui, response, ServiceAction.POST, payload );
 
-        return new JSONWithPadding( response, callback );
+        return response;
     }
 
 
@@ -382,7 +353,7 @@ public class ServiceResource extends AbstractContextResource {
      * Necessary to work around inexplicable problems with EntityHolder.
      * See above.
      */
-    public JSONWithPadding executePutWithMap( @Context UriInfo ui, Map<String, Object> json,
+    public ApiResponse executePutWithMap( @Context UriInfo ui, Map<String, Object> json,
             @QueryParam("callback") @DefaultValue("callback") String callback ) throws Exception {
 
         ApiResponse response = createApiResponse();
@@ -396,14 +367,16 @@ public class ServiceResource extends AbstractContextResource {
 
         executeServiceRequest( ui, response, ServiceAction.PUT, payload );
 
-        return new JSONWithPadding( response, callback );
+        return response;
     }
 
 
     @POST
     @RequireApplicationAccess
     @Consumes(MediaType.APPLICATION_JSON)
-    public JSONWithPadding executePost( @Context UriInfo ui, String body,
+    @JSONP
+    @Produces({"application/json", "application/javascript"})
+    public ApiResponse executePost( @Context UriInfo ui, String body,
             @QueryParam("callback") @DefaultValue("callback") String callback ) throws Exception {
 
         logger.debug( "ServiceResource.executePost: body = " + body );
@@ -426,7 +399,7 @@ public class ServiceResource extends AbstractContextResource {
 
         executeServiceRequest( ui, response, ServiceAction.POST, payload );
 
-        return new JSONWithPadding( response, callback );
+        return response;
     }
 
 
@@ -434,7 +407,9 @@ public class ServiceResource extends AbstractContextResource {
     @PUT
     @RequireApplicationAccess
     @Consumes(MediaType.APPLICATION_JSON)
-    public JSONWithPadding executePut( @Context UriInfo ui, String body,
+    @JSONP
+    @Produces({"application/json", "application/javascript"})
+    public ApiResponse executePut( @Context UriInfo ui, String body,
                                        @QueryParam("callback") @DefaultValue("callback") String callback )
             throws Exception {
 
@@ -449,7 +424,9 @@ public class ServiceResource extends AbstractContextResource {
 
     @DELETE
     @RequireApplicationAccess
-    public JSONWithPadding executeDelete(
+    @JSONP
+    @Produces({"application/json", "application/javascript"})
+    public ApiResponse executeDelete(
         @Context UriInfo ui,
         @QueryParam("callback") @DefaultValue("callback") String callback,
         @QueryParam("app_delete_confirm") String confirmAppDelete )
@@ -482,7 +459,7 @@ public class ServiceResource extends AbstractContextResource {
             }
         }
 
-        return new JSONWithPadding( response, callback );
+        return response;
     }
 
     //    TODO Temporarily removed until we test further
@@ -566,7 +543,9 @@ public class ServiceResource extends AbstractContextResource {
     @POST
     @RequireApplicationAccess
     @Consumes(MediaType.MULTIPART_FORM_DATA)
-    public JSONWithPadding executeMultiPartPost( @Context UriInfo ui,
+    @JSONP
+    @Produces({"application/json", "application/javascript"})
+    public ApiResponse executeMultiPartPost( @Context UriInfo ui,
                                                  @QueryParam("callback") @DefaultValue("callback") String callback,
                                                  FormDataMultiPart multiPart ) throws Exception {
 
@@ -578,7 +557,9 @@ public class ServiceResource extends AbstractContextResource {
     @PUT
     @RequireApplicationAccess
     @Consumes(MediaType.MULTIPART_FORM_DATA)
-    public JSONWithPadding executeMultiPartPut( @Context UriInfo ui,
+    @JSONP
+    @Produces({"application/json", "application/javascript"})
+    public ApiResponse executeMultiPartPut( @Context UriInfo ui,
                                                 @QueryParam("callback") @DefaultValue("callback") String callback,
                                                 FormDataMultiPart multiPart ) throws Exception {
 
@@ -587,7 +568,9 @@ public class ServiceResource extends AbstractContextResource {
     }
 
 
-    private JSONWithPadding executeMultiPart( UriInfo ui, String callback, FormDataMultiPart multiPart,
+    @JSONP
+    @Produces({"application/json", "application/javascript"})
+    private ApiResponse executeMultiPart( UriInfo ui, String callback, FormDataMultiPart multiPart,
                                               ServiceAction serviceAction ) throws Exception {
 
         //needed for testing
@@ -627,7 +610,7 @@ public class ServiceResource extends AbstractContextResource {
 
         // process file part
         if ( fileBodyPart != null ) {
-            InputStream fileInput = ( ( BodyPartEntity ) fileBodyPart.getEntity() ).getInputStream();
+            InputStream fileInput = ( (BodyPartEntity) fileBodyPart.getEntity() ).getInputStream();
             if ( fileInput != null ) {
                 Entity entity = serviceResults.getEntity();
                 EntityManager em = emf.getEntityManager( getApplicationId() );
@@ -647,7 +630,7 @@ public class ServiceResource extends AbstractContextResource {
             }
         }
 
-        return new JSONWithPadding( response, callback );
+        return response;
     }
 
 

http://git-wip-us.apache.org/repos/asf/usergrid/blob/0578d987/stack/rest/src/main/java/org/apache/usergrid/rest/applications/assets/AssetsResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/applications/assets/AssetsResource.java b/stack/rest/src/main/java/org/apache/usergrid/rest/applications/assets/AssetsResource.java
index fedffc4..4e2e6bb 100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/applications/assets/AssetsResource.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/applications/assets/AssetsResource.java
@@ -18,11 +18,11 @@ package org.apache.usergrid.rest.applications.assets;
 
 
 import com.fasterxml.jackson.databind.ObjectMapper;
-import com.sun.jersey.api.json.JSONWithPadding;
-import com.sun.jersey.multipart.FormDataParam;
+import com.fasterxml.jackson.jaxrs.json.annotation.JSONP;
 import org.apache.usergrid.persistence.EntityManager;
 import org.apache.usergrid.persistence.entities.Asset;
 import org.apache.usergrid.rest.AbstractContextResource;
+import org.apache.usergrid.rest.ApiResponse;
 import org.apache.usergrid.rest.applications.ServiceResource;
 import org.apache.usergrid.rest.security.annotations.RequireApplicationAccess;
 import org.apache.usergrid.services.assets.data.AssetUtils;
@@ -30,6 +30,7 @@ import org.apache.usergrid.services.assets.data.AwsSdkS3BinaryStore;
 import org.apache.usergrid.services.assets.data.BinaryStore;
 import org.apache.usergrid.services.assets.data.LocalFileBinaryStore;
 import org.apache.usergrid.utils.StringUtils;
+import org.glassfish.jersey.media.multipart.FormDataParam;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -80,7 +81,9 @@ public class AssetsResource extends ServiceResource {
     @Override
     @RequireApplicationAccess
     @GET
-    public JSONWithPadding executeGet( @Context UriInfo ui,
+    @JSONP
+    @Produces({"application/json", "application/javascript"})
+    public ApiResponse executeGet( @Context UriInfo ui,
                                        @QueryParam("callback") @DefaultValue("callback") String callback )
             throws Exception {
         logger.info( "In AssetsResource.executeGet with ui: {} and callback: {}", ui, callback );
@@ -92,7 +95,9 @@ public class AssetsResource extends ServiceResource {
     @PUT
     @RequireApplicationAccess
     @Consumes(MediaType.APPLICATION_JSON)
-    public JSONWithPadding executePut( @Context UriInfo ui, String body,
+    @JSONP
+    @Produces({"application/json", "application/javascript"})
+    public ApiResponse executePut( @Context UriInfo ui, String body,
                                        @QueryParam("callback") @DefaultValue("callback") String callback )
             throws Exception {
 

http://git-wip-us.apache.org/repos/asf/usergrid/blob/0578d987/stack/rest/src/main/java/org/apache/usergrid/rest/applications/events/EventsResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/applications/events/EventsResource.java b/stack/rest/src/main/java/org/apache/usergrid/rest/applications/events/EventsResource.java
index ec6c937..5c528bd 100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/applications/events/EventsResource.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/applications/events/EventsResource.java
@@ -17,26 +17,25 @@
 package org.apache.usergrid.rest.applications.events;
 
 
-import javax.ws.rs.DefaultValue;
-import javax.ws.rs.GET;
-import javax.ws.rs.Produces;
-import javax.ws.rs.QueryParam;
-import javax.ws.rs.core.Context;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.UriInfo;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.context.annotation.Scope;
-import org.springframework.stereotype.Component;
+import com.fasterxml.jackson.jaxrs.json.annotation.JSONP;
 import org.apache.usergrid.mq.QueuePosition;
 import org.apache.usergrid.mq.QueueQuery;
 import org.apache.usergrid.mq.QueueResults;
 import org.apache.usergrid.persistence.entities.User;
 import org.apache.usergrid.rest.applications.ApplicationResource;
 import org.apache.usergrid.rest.applications.ServiceResource;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Component;
 
-import com.sun.jersey.api.json.JSONWithPadding;
+import javax.ws.rs.DefaultValue;
+import javax.ws.rs.GET;
+import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.UriInfo;
 
 
 @Component("org.apache.usergrid.rest.applications.events.EventsResource")
@@ -54,17 +53,18 @@ public class EventsResource extends ServiceResource {
     }
 
 
-    @Override
     @GET
-    public JSONWithPadding executeGet( @Context UriInfo ui,
-                                       @QueryParam("callback") @DefaultValue("callback") String callback )
-            throws Exception {
+    @JSONP
+    @Produces({"application/json", "application/javascript"})
+    public QueueResults executeQueueGet(
+        @Context UriInfo ui, @QueryParam("callback") @DefaultValue("callback") String callback ) throws Exception {
+
         QueueQuery query = QueueQuery.fromQueryParams( ui.getQueryParameters() );
         if ( query == null ) {
             query = new QueueQuery();
         }
         query.setPosition( QueuePosition.START );
         QueueResults results = ( ( ApplicationResource ) parent ).getQueues().getFromQueue( "/events", query );
-        return new JSONWithPadding( results, callback );
+        return results;
     }
 }

http://git-wip-us.apache.org/repos/asf/usergrid/blob/0578d987/stack/rest/src/main/java/org/apache/usergrid/rest/applications/notifiers/NotifierResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/applications/notifiers/NotifierResource.java b/stack/rest/src/main/java/org/apache/usergrid/rest/applications/notifiers/NotifierResource.java
index 72883b0..1997601 100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/applications/notifiers/NotifierResource.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/applications/notifiers/NotifierResource.java
@@ -16,11 +16,15 @@
  */
 package org.apache.usergrid.rest.applications.notifiers;
 
-import com.sun.jersey.api.json.JSONWithPadding;
-import com.sun.jersey.multipart.FormDataMultiPart;
-import java.io.InputStream;
+import com.fasterxml.jackson.jaxrs.json.annotation.JSONP;
 import org.apache.commons.io.IOUtils;
 import org.apache.usergrid.persistence.index.query.Identifier;
+import org.apache.usergrid.rest.ApiResponse;
+import org.apache.usergrid.rest.applications.ServiceResource;
+import org.apache.usergrid.rest.security.annotations.RequireApplicationAccess;
+import org.apache.usergrid.services.ServiceAction;
+import org.apache.usergrid.services.ServicePayload;
+import org.glassfish.jersey.media.multipart.FormDataMultiPart;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.context.annotation.Scope;
@@ -30,15 +34,10 @@ import javax.ws.rs.*;
 import javax.ws.rs.core.Context;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.UriInfo;
+import java.io.InputStream;
 import java.util.HashMap;
 import java.util.LinkedHashMap;
 
-import org.apache.usergrid.rest.ApiResponse;
-import org.apache.usergrid.rest.applications.ServiceResource;
-import org.apache.usergrid.rest.security.annotations.RequireApplicationAccess;
-import org.apache.usergrid.services.ServiceAction;
-import org.apache.usergrid.services.ServicePayload;
-
 @Component("org.apache.usergrid.rest.applications.notifiers.NotifierResource")
 @Scope("prototype")
 @Produces(MediaType.APPLICATION_JSON)
@@ -57,16 +56,18 @@ public class NotifierResource extends ServiceResource {
     @PUT
     @RequireApplicationAccess
     @Consumes(MediaType.MULTIPART_FORM_DATA)
+    @JSONP
+    @Produces({"application/json", "application/javascript"})
     @Override
-    public JSONWithPadding executeMultiPartPut(@Context UriInfo ui,
+    public ApiResponse executeMultiPartPut(@Context UriInfo ui,
         @QueryParam("callback") @DefaultValue("callback") String callback,
         FormDataMultiPart multiPart) throws Exception {
 
         logger.debug("NotifierResource.executePut");
 
-        String name =         getValueOrNull(multiPart, "name"); 
-        String provider =     getValueOrNull(multiPart, "provider"); 
-        String certPassword = getValueOrNull(multiPart, "certificatePassword"); 
+        String name =         getValueOrNull(multiPart, "name");
+        String provider =     getValueOrNull(multiPart, "provider");
+        String certPassword = getValueOrNull(multiPart, "certificatePassword");
 
         InputStream is = null;
         if (multiPart.getField("p12Certificate") != null) {
@@ -90,7 +91,7 @@ public class NotifierResource extends ServiceResource {
         ServicePayload payload = getPayload(properties);
         executeServiceRequest(ui, response, ServiceAction.PUT, payload);
 
-        return new JSONWithPadding(response, callback);
+        return response;
     }
 
     private String getValueOrNull(FormDataMultiPart multiPart, String name) {

http://git-wip-us.apache.org/repos/asf/usergrid/blob/0578d987/stack/rest/src/main/java/org/apache/usergrid/rest/applications/notifiers/NotifiersResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/applications/notifiers/NotifiersResource.java b/stack/rest/src/main/java/org/apache/usergrid/rest/applications/notifiers/NotifiersResource.java
index 1787be5..b72a857 100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/applications/notifiers/NotifiersResource.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/applications/notifiers/NotifiersResource.java
@@ -16,35 +16,32 @@
  */
 package org.apache.usergrid.rest.applications.notifiers;
 
-import com.sun.jersey.api.json.JSONWithPadding;
-import com.sun.jersey.multipart.FormDataMultiPart;
-import java.io.InputStream;
-import java.util.HashMap;
+import com.fasterxml.jackson.jaxrs.json.annotation.JSONP;
 import org.apache.commons.io.IOUtils;
-
 import org.apache.usergrid.persistence.Query;
 import org.apache.usergrid.persistence.index.query.Identifier;
+import org.apache.usergrid.rest.AbstractContextResource;
+import org.apache.usergrid.rest.ApiResponse;
+import org.apache.usergrid.rest.applications.ServiceResource;
+import org.apache.usergrid.rest.security.annotations.RequireApplicationAccess;
+import org.apache.usergrid.services.ServiceAction;
+import org.apache.usergrid.services.ServicePayload;
+import org.glassfish.jersey.media.multipart.FormDataMultiPart;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.context.annotation.Scope;
 import org.springframework.stereotype.Component;
 
-
 import javax.ws.rs.*;
 import javax.ws.rs.core.Context;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.PathSegment;
 import javax.ws.rs.core.UriInfo;
+import java.io.InputStream;
+import java.util.HashMap;
 import java.util.LinkedHashMap;
 import java.util.UUID;
 
-import org.apache.usergrid.rest.AbstractContextResource;
-import org.apache.usergrid.rest.ApiResponse;
-import org.apache.usergrid.rest.applications.ServiceResource;
-import org.apache.usergrid.rest.security.annotations.RequireApplicationAccess;
-import org.apache.usergrid.services.ServiceAction;
-import org.apache.usergrid.services.ServicePayload;
-
 import static org.apache.usergrid.services.ServiceParameter.addParameter;
 
 @Component("org.apache.usergrid.rest.applications.notifiers.NotifiersResource")
@@ -106,7 +103,9 @@ public class NotifiersResource extends ServiceResource {
     @RequireApplicationAccess
     @Consumes(MediaType.MULTIPART_FORM_DATA)
     @Override
-    public JSONWithPadding executeMultiPartPost(
+    @JSONP
+    @Produces({"application/json", "application/javascript"})
+    public ApiResponse executeMultiPartPost(
             @Context UriInfo ui,
             @QueryParam("callback") @DefaultValue("callback") String callback,
             FormDataMultiPart multiPart)
@@ -142,7 +141,7 @@ public class NotifiersResource extends ServiceResource {
         ServicePayload payload = getPayload(certProps);
         executeServiceRequest(ui, response, ServiceAction.POST, payload);
 
-        return new JSONWithPadding(response, callback);
+        return response;
     }
 
     private String getValueOrNull(FormDataMultiPart multiPart, String name) {


[04/54] usergrid git commit: Switch to Jersey 2, fix all compilation errors. TODO: new MeteringFilter, new JSON-HTMP swap logic and correct use of dependency management.

Posted by sn...@apache.org.
http://git-wip-us.apache.org/repos/asf/usergrid/blob/0578d987/stack/rest/src/main/java/org/apache/usergrid/rest/security/shiro/filters/OAuth2AccessTokenSecurityFilter.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/security/shiro/filters/OAuth2AccessTokenSecurityFilter.java b/stack/rest/src/main/java/org/apache/usergrid/rest/security/shiro/filters/OAuth2AccessTokenSecurityFilter.java
index 87b85ac..08de618 100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/security/shiro/filters/OAuth2AccessTokenSecurityFilter.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/security/shiro/filters/OAuth2AccessTokenSecurityFilter.java
@@ -17,12 +17,13 @@
 package org.apache.usergrid.rest.security.shiro.filters;
 
 
-import javax.servlet.http.HttpServletRequest;
-import javax.ws.rs.core.Context;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.stereotype.Component;
+import org.apache.amber.oauth2.common.exception.OAuthProblemException;
+import org.apache.amber.oauth2.common.exception.OAuthSystemException;
+import org.apache.amber.oauth2.common.message.types.ParameterStyle;
+import org.apache.amber.oauth2.common.utils.OAuthUtils;
+import org.apache.amber.oauth2.rs.request.OAuthAccessResourceRequest;
+import org.apache.commons.lang.StringUtils;
+import org.apache.shiro.subject.Subject;
 import org.apache.usergrid.management.ApplicationInfo;
 import org.apache.usergrid.management.OrganizationInfo;
 import org.apache.usergrid.management.UserInfo;
@@ -35,22 +36,16 @@ import org.apache.usergrid.security.tokens.TokenInfo;
 import org.apache.usergrid.security.tokens.exceptions.BadTokenException;
 import org.apache.usergrid.security.tokens.exceptions.ExpiredTokenException;
 import org.apache.usergrid.security.tokens.exceptions.InvalidTokenException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Component;
 
-import org.apache.amber.oauth2.common.exception.OAuthProblemException;
-import org.apache.amber.oauth2.common.exception.OAuthSystemException;
-import org.apache.amber.oauth2.common.message.types.ParameterStyle;
-import org.apache.amber.oauth2.common.utils.OAuthUtils;
-import org.apache.amber.oauth2.rs.request.OAuthAccessResourceRequest;
-import org.apache.shiro.subject.Subject;
-
-import com.sun.jersey.api.container.MappableContainerException;
-import com.sun.jersey.spi.container.ContainerRequest;
-import org.apache.commons.lang.StringUtils;
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.container.ContainerRequestContext;
+import javax.ws.rs.core.Context;
+import java.io.IOException;
 
-import static org.apache.usergrid.rest.exceptions.AuthErrorInfo.BAD_ACCESS_TOKEN_ERROR;
-import static org.apache.usergrid.rest.exceptions.AuthErrorInfo.EXPIRED_ACCESS_TOKEN_ERROR;
-import static org.apache.usergrid.rest.exceptions.AuthErrorInfo.INVALID_AUTH_ERROR;
-import static org.apache.usergrid.rest.exceptions.AuthErrorInfo.UNVERIFIED_OAUTH_ERROR;
+import static org.apache.usergrid.rest.exceptions.AuthErrorInfo.*;
 import static org.apache.usergrid.rest.exceptions.SecurityException.mappableSecurityException;
 
 
@@ -72,47 +67,42 @@ public class OAuth2AccessTokenSecurityFilter extends SecurityFilter {
 
 
     @Override
-    public ContainerRequest filter( ContainerRequest request ) {
+    public void filter(ContainerRequestContext request) throws IOException {
 
         try {
             try {
 
-                String accessToken = request.getQueryParameters().getFirst( "access_token" );
+                String accessToken = httpServletRequest.getParameter( "access_token" );
 
-                if ( StringUtils.isEmpty(accessToken) ) {
+                if (StringUtils.isEmpty( accessToken )) {
 
                     // Make the OAuth Request out of this request
                     OAuthAccessResourceRequest oauthRequest =
-                            new OAuthAccessResourceRequest( httpServletRequest, ParameterStyle.HEADER );
+                        new OAuthAccessResourceRequest( httpServletRequest, ParameterStyle.HEADER );
 
                     // Get the access token
                     accessToken = oauthRequest.getAccessToken();
                 }
 
-                if ( StringUtils.isEmpty(accessToken) ) {
-                    return request;
+                if (StringUtils.isEmpty( accessToken )) {
+                    return;
                 }
 
                 AuthPrincipalInfo principal = null;
                 try {
                     TokenInfo tokenInfo = tokens.getTokenInfo( accessToken );
                     principal = tokenInfo.getPrincipal();
-                }
-                catch ( BadTokenException e1 ) {
+                } catch (BadTokenException e1) {
                     throw mappableSecurityException( BAD_ACCESS_TOKEN_ERROR );
-                }
-                catch ( ExpiredTokenException ete ) {
+                } catch (ExpiredTokenException ete) {
                     throw mappableSecurityException( EXPIRED_ACCESS_TOKEN_ERROR );
-                }
-                catch ( InvalidTokenException ite ) {
+                } catch (InvalidTokenException ite) {
                     throw mappableSecurityException( INVALID_AUTH_ERROR );
-                }
-                catch ( IndexOutOfBoundsException ioobe ) {
+                } catch (IndexOutOfBoundsException ioobe) {
                     // token is just some rubbish string
                     throw mappableSecurityException( BAD_ACCESS_TOKEN_ERROR );
-                }
-                catch ( Exception e ) {
-                    if ( LOG.isDebugEnabled() ) {
+                } catch (Exception e) {
+                    if (LOG.isDebugEnabled()) {
                         LOG.debug( "Unable to verify OAuth token: " + accessToken, e );
                     } else {
                         LOG.warn( "Unable to verify OAuth token" );
@@ -120,81 +110,70 @@ public class OAuth2AccessTokenSecurityFilter extends SecurityFilter {
                     throw mappableSecurityException( UNVERIFIED_OAUTH_ERROR );
                 }
 
-                if ( principal == null ) {
-                    return request;
+                if (principal == null) {
+                    return;
                 }
 
                 PrincipalCredentialsToken token = null;
 
-                if ( AuthPrincipalType.ADMIN_USER.equals( principal.getType() ) ) {
+                if (AuthPrincipalType.ADMIN_USER.equals( principal.getType() )) {
 
                     UserInfo user = null;
                     try {
                         user = management.getAdminUserInfoFromAccessToken( accessToken );
-                    }
-                    catch ( ManagementException e ) {
-                        throw new MappableContainerException( e );
-                    }
-                    catch ( Exception e ) {
+                    } catch (ManagementException e) {
+                        throw mappableSecurityException( e, BAD_ACCESS_TOKEN_ERROR );
+                    } catch (Exception e) {
                         LOG.error( "failed to get admin user info from access token", e );
                     }
-                    if ( user == null ) {
+                    if (user == null) {
                         throw mappableSecurityException( BAD_ACCESS_TOKEN_ERROR );
                     }
 
                     token = PrincipalCredentialsToken.getFromAdminUserInfoAndAccessToken(
-                            user, accessToken, emf.getManagementAppId() );
-                }
-                else if ( AuthPrincipalType.APPLICATION_USER.equals( principal.getType() ) ) {
+                        user, accessToken, emf.getManagementAppId() );
+                } else if (AuthPrincipalType.APPLICATION_USER.equals( principal.getType() )) {
 
                     UserInfo user = null;
                     try {
                         user = management.getAppUserFromAccessToken( accessToken );
-                    }
-                    catch ( ManagementException e ) {
-                        throw new MappableContainerException( e );
-                    }
-                    catch ( Exception e ) {
+                    } catch (ManagementException e) {
+                        throw mappableSecurityException( e, BAD_ACCESS_TOKEN_ERROR );
+                    } catch (Exception e) {
                         LOG.error( "failed to get app user from access token", e );
                     }
-                    if ( user == null ) {
+                    if (user == null) {
                         throw mappableSecurityException( BAD_ACCESS_TOKEN_ERROR );
                     }
 
                     token = PrincipalCredentialsToken.getFromAppUserInfoAndAccessToken( user, accessToken );
-                }
-                else if ( AuthPrincipalType.ORGANIZATION.equals( principal.getType() ) ) {
+                } else if (AuthPrincipalType.ORGANIZATION.equals( principal.getType() )) {
 
                     OrganizationInfo organization = null;
                     try {
                         organization = management.getOrganizationInfoFromAccessToken( accessToken );
-                    }
-                    catch ( ManagementException e ) {
-                        throw new MappableContainerException( e );
-                    }
-                    catch ( Exception e ) {
+                    } catch (ManagementException e) {
+                        throw mappableSecurityException( e, BAD_ACCESS_TOKEN_ERROR );
+                    } catch (Exception e) {
                         LOG.error( "failed to get organization info from access token", e );
                     }
-                    if ( organization == null ) {
+                    if (organization == null) {
                         throw mappableSecurityException( BAD_ACCESS_TOKEN_ERROR );
                     }
 
                     token = PrincipalCredentialsToken
-                            .getFromOrganizationInfoAndAccessToken( organization, accessToken );
-                }
-                else if ( AuthPrincipalType.APPLICATION.equals( principal.getType() ) ) {
+                        .getFromOrganizationInfoAndAccessToken( organization, accessToken );
+                } else if (AuthPrincipalType.APPLICATION.equals( principal.getType() )) {
 
                     ApplicationInfo application = null;
                     try {
                         application = management.getApplicationInfoFromAccessToken( accessToken );
-                    }
-                    catch ( ManagementException e ) {
-                        throw new MappableContainerException( e );
-                    }
-                    catch ( Exception e ) {
+                    } catch (ManagementException e) {
+                        throw mappableSecurityException( e, BAD_ACCESS_TOKEN_ERROR );
+                    } catch (Exception e) {
                         LOG.error( "failed to get application info from access token", e );
                     }
-                    if ( application == null ) {
+                    if (application == null) {
                         throw mappableSecurityException( BAD_ACCESS_TOKEN_ERROR );
                     }
 
@@ -203,22 +182,22 @@ public class OAuth2AccessTokenSecurityFilter extends SecurityFilter {
 
                 Subject subject = SubjectUtils.getSubject();
                 subject.login( token );
-            }
-            catch ( OAuthProblemException e ) {
+
+            } catch (OAuthProblemException e) {
                 // Check if the error code has been set
                 String errorCode = e.getError();
-                if ( OAuthUtils.isEmpty( errorCode ) ) {
-
-                    return request;
+                if (OAuthUtils.isEmpty( errorCode )) {
+                    return;
                 }
 
-                throw new MappableContainerException( e );
+                throw mappableSecurityException( errorCode, e.getMessage(), null );
             }
-        }
-        catch ( OAuthSystemException ose ) {
-            throw new MappableContainerException( ose );
+
+        } catch (OAuthSystemException ose) {
+            throw mappableSecurityException( ose, null );
         }
 
-        return request;
     }
+
 }
+

http://git-wip-us.apache.org/repos/asf/usergrid/blob/0578d987/stack/rest/src/main/java/org/apache/usergrid/rest/security/shiro/filters/SecurityFilter.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/security/shiro/filters/SecurityFilter.java b/stack/rest/src/main/java/org/apache/usergrid/rest/security/shiro/filters/SecurityFilter.java
index 53f9354..625d352 100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/security/shiro/filters/SecurityFilter.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/security/shiro/filters/SecurityFilter.java
@@ -21,10 +21,14 @@ import java.util.LinkedHashMap;
 import java.util.Map;
 import java.util.Properties;
 
+import javax.ws.rs.container.ContainerRequestContext;
+import javax.ws.rs.container.ContainerRequestFilter;
 import javax.ws.rs.core.Context;
 import javax.ws.rs.core.HttpHeaders;
 import javax.ws.rs.core.UriInfo;
+import javax.xml.ws.spi.http.HttpContext;
 
+import org.glassfish.jersey.server.ContainerRequest;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Qualifier;
 
@@ -35,9 +39,6 @@ import org.apache.usergrid.services.ServiceManagerFactory;
 
 import org.apache.commons.lang.StringUtils;
 
-import com.sun.jersey.api.core.HttpContext;
-import com.sun.jersey.spi.container.ContainerRequest;
-import com.sun.jersey.spi.container.ContainerRequestFilter;
 
 import static org.apache.usergrid.utils.StringUtils.stringOrSubstringAfterFirst;
 import static org.apache.usergrid.utils.StringUtils.stringOrSubstringBeforeFirst;
@@ -118,8 +119,8 @@ public abstract class SecurityFilter implements ContainerRequestFilter {
     }
 
 
-    public static Map<String, String> getAuthTypes( ContainerRequest request ) {
-        String auth_header = request.getHeaderValue( HttpHeaders.AUTHORIZATION );
+    public static Map<String, String> getAuthTypes( ContainerRequestContext request ) {
+        String auth_header = request.getHeaderString( HttpHeaders.AUTHORIZATION );
         if ( auth_header == null ) {
             return null;
         }

http://git-wip-us.apache.org/repos/asf/usergrid/blob/0578d987/stack/rest/src/main/java/org/apache/usergrid/rest/utils/CORSUtils.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/utils/CORSUtils.java b/stack/rest/src/main/java/org/apache/usergrid/rest/utils/CORSUtils.java
index a082573..daaf5ab 100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/utils/CORSUtils.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/utils/CORSUtils.java
@@ -17,13 +17,15 @@
 package org.apache.usergrid.rest.utils;
 
 
+import org.glassfish.jersey.server.ContainerRequest;
+import org.glassfish.jersey.server.ContainerResponse;
+
 import java.util.Enumeration;
 
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
-
-import com.sun.jersey.spi.container.ContainerRequest;
-import com.sun.jersey.spi.container.ContainerResponse;
+import javax.ws.rs.container.ContainerRequestContext;
+import javax.ws.rs.container.ContainerResponseContext;
 
 
 /* Note: At one point there was a special case in this code that would
@@ -96,27 +98,27 @@ public class CORSUtils {
     }
 
 
-    public static ContainerResponse allowAllOrigins( ContainerRequest request, ContainerResponse response ) {
+    public static ContainerResponseContext allowAllOrigins( ContainerRequestContext request, ContainerResponseContext response ) {
 
-        if ( request.getRequestHeaders().containsKey( ACCESS_CONTROL_REQUEST_METHOD ) ) {
+        if ( request.getHeaders().containsKey( ACCESS_CONTROL_REQUEST_METHOD ) ) {
 
-            for ( String value : request.getRequestHeaders().get( ACCESS_CONTROL_REQUEST_METHOD ) ) {
-                response.getHttpHeaders().add( ACCESS_CONTROL_ALLOW_METHODS, value );
+            for ( String value : request.getHeaders().get( ACCESS_CONTROL_REQUEST_METHOD ) ) {
+                response.getHeaders().add( ACCESS_CONTROL_ALLOW_METHODS, value );
             }
         }
 
-        if ( request.getRequestHeaders().containsKey( ACCESS_CONTROL_REQUEST_HEADERS ) ) {
-            for ( String value : request.getRequestHeaders().get( ACCESS_CONTROL_REQUEST_HEADERS ) ) {
-                response.getHttpHeaders().add( ACCESS_CONTROL_ALLOW_HEADERS, value );
+        if ( request.getHeaders().containsKey( ACCESS_CONTROL_REQUEST_HEADERS ) ) {
+            for ( String value : request.getHeaders().get( ACCESS_CONTROL_REQUEST_HEADERS ) ) {
+                response.getHeaders().add( ACCESS_CONTROL_ALLOW_HEADERS, value );
             }
         }
 
         boolean origin_sent = false;
-        if ( request.getRequestHeaders().containsKey( ORIGIN_HEADER ) ) {
-            for ( String value : request.getRequestHeaders().get( ORIGIN_HEADER ) ) {
+        if ( request.getHeaders().containsKey( ORIGIN_HEADER ) ) {
+            for ( String value : request.getHeaders().get( ORIGIN_HEADER ) ) {
                 if ( value != null ) {
                     origin_sent = true;
-                    response.getHttpHeaders().add( ACCESS_CONTROL_ALLOW_ORIGIN, value );
+                    response.getHeaders().add( ACCESS_CONTROL_ALLOW_ORIGIN, value );
                 }
             }
         }
@@ -124,15 +126,15 @@ public class CORSUtils {
         if ( !origin_sent ) {
             String origin = getOrigin( request );
             if ( origin != null ) {
-                response.getHttpHeaders().add( ACCESS_CONTROL_ALLOW_CREDENTIALS, "true" );
-                response.getHttpHeaders().add( ACCESS_CONTROL_ALLOW_ORIGIN, origin );
+                response.getHeaders().add( ACCESS_CONTROL_ALLOW_CREDENTIALS, "true" );
+                response.getHeaders().add( ACCESS_CONTROL_ALLOW_ORIGIN, origin );
             }
             else {
-                response.getHttpHeaders().add( ACCESS_CONTROL_ALLOW_ORIGIN, "*" );
+                response.getHeaders().add( ACCESS_CONTROL_ALLOW_ORIGIN, "*" );
             }
         }
         else {
-            response.getHttpHeaders().add( ACCESS_CONTROL_ALLOW_CREDENTIALS, "true" );
+            response.getHeaders().add( ACCESS_CONTROL_ALLOW_CREDENTIALS, "true" );
         }
 
         return response;
@@ -166,9 +168,9 @@ public class CORSUtils {
     }
 
 
-    public static String getOrigin( ContainerRequest request ) {
-        String origin = request.getRequestHeaders().getFirst( ORIGIN_HEADER );
-        String referer = request.getRequestHeaders().getFirst( REFERER_HEADER );
+    public static String getOrigin( ContainerRequestContext request ) {
+        String origin = request.getHeaders().getFirst( ORIGIN_HEADER );
+        String referer = request.getHeaders().getFirst( REFERER_HEADER );
         return getOrigin( origin, referer );
     }
 }

http://git-wip-us.apache.org/repos/asf/usergrid/blob/0578d987/stack/rest/src/test/java/org/apache/usergrid/rest/BasicIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/BasicIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/BasicIT.java
index fc20147..edda5e5 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/BasicIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/BasicIT.java
@@ -17,23 +17,15 @@
 package org.apache.usergrid.rest;
 
 
-import java.io.IOException;
-
-import javax.ws.rs.core.MediaType;
-
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
 import org.apache.usergrid.persistence.index.utils.UUIDUtils;
 import org.apache.usergrid.rest.test.resource.AbstractRestIT;
-import org.apache.usergrid.rest.test.resource.model.Entity;
 import org.apache.usergrid.rest.test.resource.model.ApiResponse;
+import org.apache.usergrid.rest.test.resource.model.Entity;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
-import com.sun.jersey.api.client.UniformInterfaceException;
-import com.sun.jersey.api.client.WebResource;
-
-import org.junit.Ignore;
+import javax.ws.rs.client.ResponseProcessingException;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
@@ -82,8 +74,9 @@ public class BasicIT extends AbstractRestIT {
             try {
                 clientSetup.getRestClient().pathResource( getOrgAppPath( "users/JOE" ) ).get( ApiResponse.class );
                 fail("A get on a nonexistant object should fail");
-            }catch ( UniformInterfaceException e ) {
-                    assertEquals( "Guests should not be able to get a 404", 404, e.getResponse().getStatus() );
+            } catch ( ResponseProcessingException e ) {
+                assertEquals( "Guests should not be able to get a 404", 404,
+                    e.getResponse().getStatusInfo().getStatusCode());
             }
     }
 }

http://git-wip-us.apache.org/repos/asf/usergrid/blob/0578d987/stack/rest/src/test/java/org/apache/usergrid/rest/IndexResourceIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/IndexResourceIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/IndexResourceIT.java
index a84f91c..065cd10 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/IndexResourceIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/IndexResourceIT.java
@@ -20,25 +20,22 @@
 
 package org.apache.usergrid.rest;
 
-import com.sun.jersey.api.client.WebResource;
-import com.sun.jersey.api.client.filter.HTTPBasicAuthFilter;
 import org.apache.usergrid.rest.test.resource.AbstractRestIT;
 import org.apache.usergrid.rest.test.resource.model.ApiResponse;
 import org.apache.usergrid.rest.test.resource.model.QueryParameters;
 import org.apache.usergrid.rest.test.resource.model.Token;
+import org.glassfish.jersey.client.authentication.HttpAuthenticationFeature;
 import org.junit.Ignore;
-import org.junit.Rule;
 import org.junit.Test;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import javax.ws.rs.client.WebTarget;
 import javax.ws.rs.core.MediaType;
 import java.util.HashMap;
 import java.util.Map;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.fail;
+import static org.junit.Assert.*;
 
 
 /**
@@ -81,16 +78,20 @@ public class IndexResourceIT extends AbstractRestIT {
         result = clientSetup.getRestClient()
             .pathResource( "system/index/rebuild/"+clientSetup.getAppUuid()+"/storelatlons" )
             .post( false, ApiResponse.class,null,queryParameters,true);
+        String status = result.getProperties().get("jobId").toString();
 
         assertNotNull( result );
 
-        WebResource res = clientSetup.getRestClient()
-            .pathResource( "system/index/rebuild/"+result.getProperties().get("jobId").toString() ).getResource();
-        String status = result.getProperties().get("jobId").toString();
-        //added httpBasicauth filter to all setup calls because they all do verification this way.
-        HTTPBasicAuthFilter httpBasicAuthFilter = new HTTPBasicAuthFilter( clientSetup.getSuperuserName(),clientSetup.getSuperuserPassword() );
-        res.addFilter( httpBasicAuthFilter );
-        result = res.get(ApiResponse.class);
+        WebTarget res = clientSetup.getRestClient()
+            .pathResource( "system/index/rebuild/" + result.getProperties()
+                .get( "jobId" ).toString() )
+            .getTarget();
+
+        result = res.request()
+            .property( HttpAuthenticationFeature.HTTP_AUTHENTICATION_BASIC_USERNAME, "superuser")
+            .property( HttpAuthenticationFeature.HTTP_AUTHENTICATION_BASIC_PASSWORD, "superpassword" )
+            .get(ApiResponse.class);
+
         assertNotNull( result );
         assertEquals(status,result.getProperties().get("jobId").toString());
 
@@ -113,14 +114,14 @@ public class IndexResourceIT extends AbstractRestIT {
         org.apache.usergrid.rest.test.resource.model.ApiResponse node = null;
         try {
 
-            WebResource resource = this.clientSetup.getRestClient().pathResource("/system/index/" + appId).getResource();
-
-            //added httpBasicauth filter to all setup calls because they all do verification this way.
-            HTTPBasicAuthFilter httpBasicAuthFilter = new HTTPBasicAuthFilter( clientSetup.getSuperuserName(),clientSetup.getSuperuserPassword() );
-            resource.addFilter( httpBasicAuthFilter );
+            WebTarget resource = this.clientSetup.getRestClient().pathResource("/system/index/" + appId).getTarget();
 
-            node = resource.type( MediaType.APPLICATION_JSON_TYPE ).accept( MediaType.APPLICATION_JSON )
+            node = resource.request()
+                .property( HttpAuthenticationFeature.HTTP_AUTHENTICATION_BASIC_USERNAME, "superuser")
+                .property( HttpAuthenticationFeature.HTTP_AUTHENTICATION_BASIC_PASSWORD, "superpassword" )
+                .accept( MediaType.APPLICATION_JSON )
                 .get( org.apache.usergrid.rest.test.resource.model.ApiResponse.class);
+
         } catch (Exception e) {
             LOG.error("failed", e);
             fail(e.toString());

http://git-wip-us.apache.org/repos/asf/usergrid/blob/0578d987/stack/rest/src/test/java/org/apache/usergrid/rest/PartialUpdateTest.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/PartialUpdateTest.java b/stack/rest/src/test/java/org/apache/usergrid/rest/PartialUpdateTest.java
index 97a02fd..109c76d 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/PartialUpdateTest.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/PartialUpdateTest.java
@@ -17,7 +17,6 @@
 package org.apache.usergrid.rest;
 
 
-import com.sun.jersey.api.client.UniformInterfaceException;
 import org.apache.usergrid.rest.test.resource.AbstractRestIT;
 import org.apache.usergrid.rest.test.resource.model.Entity;
 import org.apache.usergrid.utils.MapUtils;
@@ -25,6 +24,7 @@ import org.junit.Test;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import javax.ws.rs.client.ResponseProcessingException;
 import java.io.IOException;
 import java.util.LinkedHashMap;
 import java.util.Map;
@@ -77,8 +77,8 @@ public class PartialUpdateTest extends AbstractRestIT {
             try {
                 // PUT the updates to the user and ensure they were saved
                 userNode = this.app().collection("users").entity(userNode).put(updateProps);
-            } catch (UniformInterfaceException uie) {
-                fail("Update failed due to: " + uie.getResponse().getEntity(String.class));
+            } catch (ResponseProcessingException uie) {
+                fail("Update failed due to: " + uie.getResponse().readEntity(String.class));
             }
 
             refreshIndex();
@@ -118,8 +118,8 @@ public class PartialUpdateTest extends AbstractRestIT {
         try { //  PUT /users/fred   put /users/uuid
             userNode = this.app().collection("users").entity(props.get("username").toString()).put(updateProps);
 
-        } catch (UniformInterfaceException uie) {
-            fail("Update failed due to: " + uie.getResponse().getEntity(String.class));
+        } catch (ResponseProcessingException uie) {
+            fail("Update failed due to: " + uie.getResponse().readEntity(String.class));
         }
         refreshIndex();
 

http://git-wip-us.apache.org/repos/asf/usergrid/blob/0578d987/stack/rest/src/test/java/org/apache/usergrid/rest/SystemResourceIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/SystemResourceIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/SystemResourceIT.java
index 7f09fa5..354589c 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/SystemResourceIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/SystemResourceIT.java
@@ -17,15 +17,10 @@
 package org.apache.usergrid.rest;
 
 
-import org.junit.Test;
-
 import org.apache.usergrid.rest.test.resource.AbstractRestIT;
 import org.apache.usergrid.rest.test.resource.model.Entity;
 import org.apache.usergrid.rest.test.resource.model.QueryParameters;
-import org.apache.usergrid.rest.test.resource.model.Token;
-
-import com.sun.jersey.api.client.UniformInterfaceException;
-import com.sun.jersey.api.client.filter.HTTPBasicAuthFilter;
+import org.junit.Test;
 
 import static org.junit.Assert.assertNotNull;
 

http://git-wip-us.apache.org/repos/asf/usergrid/blob/0578d987/stack/rest/src/test/java/org/apache/usergrid/rest/TomcatRuntime.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/TomcatRuntime.java b/stack/rest/src/test/java/org/apache/usergrid/rest/TomcatRuntime.java
index 498068a..4c09565 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/TomcatRuntime.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/TomcatRuntime.java
@@ -31,8 +31,10 @@ import org.apache.usergrid.cassandra.AvailablePortFinder;
 import org.apache.usergrid.setup.ConcurrentProcessSingleton;
 
 import com.google.common.io.Files;
-import com.sun.jersey.api.client.Client;
-import com.sun.jersey.api.client.WebResource;
+
+import javax.ws.rs.client.Client;
+import javax.ws.rs.client.ClientBuilder;
+import javax.ws.rs.client.WebTarget;
 
 
 /**
@@ -173,9 +175,9 @@ public class TomcatRuntime extends ExternalResource {
             while ( count++ < 30 ) {
                 try {
                     Thread.sleep( 1000 );
-                    Client c = Client.create();
-                    WebResource wr = c.resource( url );
-                    wr.get( String.class );
+                    Client c = ClientBuilder.newClient();
+                    WebTarget wr = c.target( url );
+                    wr.request().get( String.class );
                     log.info( "Tomcat is started." );
                     started = true;
                     break;

http://git-wip-us.apache.org/repos/asf/usergrid/blob/0578d987/stack/rest/src/test/java/org/apache/usergrid/rest/applications/ApplicationCreateIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/ApplicationCreateIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/ApplicationCreateIT.java
index d2ad7ba..cfcc91d 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/ApplicationCreateIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/ApplicationCreateIT.java
@@ -108,15 +108,15 @@ public class ApplicationCreateIT extends AbstractRestIT {
 
             final String entityName = "entity" + i;
             Entity entity = new Entity();
-            entity.setProperties(new HashMap<String, Object>() {{
-                put("name", entityName );
-            }});
+            entity.setProperties( new HashMap<String, Object>() {{
+                put( "name", entityName );
+            }} );
 
             ApiResponse createResponse = clientSetup.getRestClient()
-                .org(orgName).app( appName ).collection("things").getResource()
-                .queryParam("access_token", orgAdminToken.getAccessToken())
-                .type(MediaType.APPLICATION_JSON)
-                .post( ApiResponse.class, entity );
+                .org( orgName ).app( appName ).collection( "things" ).getTarget()
+                .queryParam( "access_token", orgAdminToken.getAccessToken() )
+                .request()
+                .post( javax.ws.rs.client.Entity.entity(entity, MediaType.APPLICATION_JSON_TYPE ), ApiResponse.class);
 
             entities.add( createResponse.getEntities().get(0) );
         }

http://git-wip-us.apache.org/repos/asf/usergrid/blob/0578d987/stack/rest/src/test/java/org/apache/usergrid/rest/applications/ApplicationDeleteIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/ApplicationDeleteIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/ApplicationDeleteIT.java
index cad0a37..b863a8e 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/ApplicationDeleteIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/ApplicationDeleteIT.java
@@ -18,27 +18,24 @@
 package org.apache.usergrid.rest.applications;
 
 
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.UUID;
-
-import javax.ws.rs.core.MediaType;
-
-import org.junit.Assert;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
+import com.fasterxml.jackson.databind.JsonNode;
 import org.apache.usergrid.rest.test.resource.AbstractRestIT;
 import org.apache.usergrid.rest.test.resource.endpoints.mgmt.ManagementResponse;
 import org.apache.usergrid.rest.test.resource.model.ApiResponse;
 import org.apache.usergrid.rest.test.resource.model.Application;
 import org.apache.usergrid.rest.test.resource.model.Entity;
 import org.apache.usergrid.rest.test.resource.model.Token;
+import org.junit.Assert;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
-import com.fasterxml.jackson.databind.JsonNode;
-import com.sun.jersey.api.client.UniformInterfaceException;
+import javax.ws.rs.client.ResponseProcessingException;
+import javax.ws.rs.core.MediaType;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.UUID;
 
 import static org.junit.Assert.fail;
 
@@ -77,52 +74,54 @@ public class ApplicationDeleteIT extends AbstractRestIT {
 
         try {
             clientSetup.getRestClient() .management().orgs()
-                .org(orgName).apps().app(appToDeleteId.toString()).getResource()
+                .org(orgName).apps().app(appToDeleteId.toString()).getTarget()
                 .queryParam("access_token", orgAdminToken.getAccessToken())
+                .request()
                 .delete();
 
             fail("Delete must fail without app_delete_confirm parameter");
 
-        } catch (  UniformInterfaceException expected  ) {
+        } catch (  ResponseProcessingException expected  ) {
             Assert.assertEquals("Error must be 400", 400, expected.getResponse().getStatus() );
-            JsonNode node = mapper.readTree( expected.getResponse().getEntity( String.class ));
+            JsonNode node = mapper.readTree( expected.getResponse().readEntity( String.class ));
             Assert.assertEquals("Cannot delete application without app_delete_confirm parameter", node.get("error_description").textValue());
         }
 
         clientSetup.getRestClient().management().orgs()
-            .org(orgName).apps().app(appToDeleteId.toString() ).getResource()
+            .org(orgName).apps().app(appToDeleteId.toString() ).getTarget()
             .queryParam("access_token", orgAdminToken.getAccessToken() )
             .queryParam("app_delete_confirm", "confirm_delete_of_application_and_data")
+            .request()
             .delete();
 
         // test that we can no longer get the app
 
         try {
             clientSetup.getRestClient().management().orgs()
-                .org(orgName).apps().app(appToDeleteName).getResource()
+                .org(orgName).apps().app(appToDeleteName).getTarget()
                 .queryParam("access_token", orgAdminToken.getAccessToken())
-                .type(MediaType.APPLICATION_JSON)
+                .request()
                 .get(ApiResponse.class);
 
             fail("Must not be able to get deleted app");
 
-        } catch ( UniformInterfaceException expected ) {
+        } catch ( ResponseProcessingException expected ) {
             Assert.assertEquals("Error must be 404", 404, expected.getResponse().getStatus() );
-            JsonNode node = mapper.readTree( expected.getResponse().getEntity( String.class ));
+            JsonNode node = mapper.readTree( expected.getResponse().readEntity( String.class ));
             Assert.assertEquals("entity_not_found", node.get("error").textValue());
         }
 
 
         try {
-            clientSetup.getRestClient().org( orgName ).app( appToDeleteName ).getResource()
-                       .queryParam( "access_token", orgAdminToken.getAccessToken() ).type( MediaType.APPLICATION_JSON )
+            clientSetup.getRestClient().org( orgName ).app( appToDeleteName ).getTarget()
+                       .queryParam( "access_token", orgAdminToken.getAccessToken() ).request()
                        .get( ApiResponse.class );
 
             fail( "Must not be able to get deleted app" );
         }
-        catch ( UniformInterfaceException expected ) {
+        catch ( ResponseProcessingException expected ) {
             Assert.assertEquals( "Error must be 404", 404, expected.getResponse().getStatus() );
-            JsonNode node = mapper.readTree( expected.getResponse().getEntity( String.class ) );
+            JsonNode node = mapper.readTree( expected.getResponse().readEntity( String.class ) );
             Assert.assertEquals( "organization_application_not_found", node.get( "error" ).textValue() );
         }
 
@@ -131,16 +130,16 @@ public class ApplicationDeleteIT extends AbstractRestIT {
 
         try {
             clientSetup.getRestClient()
-                .org(orgName).app(appToDeleteName).collection("things").getResource()
+                .org(orgName).app(appToDeleteName).collection("things").getTarget()
                 .queryParam("access_token", orgAdminToken.getAccessToken() )
-                .type(MediaType.APPLICATION_JSON )
-                .get(ApiResponse.class);
+                .request()
+                .get( ApiResponse.class );
 
             fail("Must not be able to get deleted app's collection");
 
-        } catch ( UniformInterfaceException expected ) {
+        } catch ( ResponseProcessingException expected ) {
             Assert.assertEquals("Error must be 400", 404, expected.getResponse().getStatus() );
-            JsonNode node = mapper.readTree( expected.getResponse().getEntity( String.class ));
+            JsonNode node = mapper.readTree( expected.getResponse().readEntity( String.class ));
             Assert.assertEquals("organization_application_not_found", node.get("error").textValue());
         }
 
@@ -149,17 +148,17 @@ public class ApplicationDeleteIT extends AbstractRestIT {
         try {
             UUID entityId = entities.get(0).getUuid();
             clientSetup.getRestClient()
-                .org(orgName).app(appToDeleteName).collection("things").entity( entityId ).getResource()
+                .org(orgName).app(appToDeleteName).collection("things").entity( entityId ).getTarget()
                 .queryParam( "access_token", orgAdminToken.getAccessToken())
-                .type( MediaType.APPLICATION_JSON)
-                .get(ApiResponse.class);
+                .request()
+                .get( ApiResponse.class );
 
             fail("Must not be able to get deleted app entity");
 
-        } catch ( UniformInterfaceException expected ) {
+        } catch ( ResponseProcessingException expected ) {
             // TODO: why not a 404?
             Assert.assertEquals("Error must be 400", 404, expected.getResponse().getStatus() );
-            JsonNode node = mapper.readTree( expected.getResponse().getEntity( String.class ));
+            JsonNode node = mapper.readTree( expected.getResponse().readEntity( String.class ));
             Assert.assertEquals("organization_application_not_found", node.get("error").textValue());
         }
 
@@ -181,24 +180,26 @@ public class ApplicationDeleteIT extends AbstractRestIT {
 
         try {
             clientSetup.getRestClient().management().orgs().org( orgName ).apps().app( appToDeleteId.toString() )
-                       .getResource().queryParam( "access_token", orgAdminToken.getAccessToken() )
-                       .queryParam( "app_delete_confirm", "confirm_delete_of_application_and_data" ).delete();
+                .getTarget().queryParam( "access_token", orgAdminToken.getAccessToken() )
+                .queryParam( "app_delete_confirm", "confirm_delete_of_application_and_data" )
+                .request()
+                .delete();
 
             fail("Can't delete a non existent app twice");
         }
-        catch ( UniformInterfaceException expected ) {
+        catch ( ResponseProcessingException expected ) {
             Assert.assertEquals( "Error must be 404", 404, expected.getResponse().getStatus() );
-            JsonNode node = mapper.readTree( expected.getResponse().getEntity( String.class ) );
+            JsonNode node = mapper.readTree( expected.getResponse().readEntity( String.class ) );
             Assert.assertEquals( "entity_not_found", node.get( "error" ).textValue() );
         }
 
         // test that we can create a new application with the same name
 
         ApiResponse appCreateAgainResponse = clientSetup.getRestClient()
-            .management().orgs().org( orgName ).app().getResource()
+            .management().orgs().org( orgName ).app().getTarget()
             .queryParam( "access_token", orgAdminToken.getAccessToken() )
-            .type( MediaType.APPLICATION_JSON )
-            .post( ApiResponse.class, new Application( appToDeleteName ) );
+            .request()
+            .post( javax.ws.rs.client.Entity.json( new Application( appToDeleteName ) ), ApiResponse.class );
 
         Assert.assertEquals("Must be able to create app with same name as deleted app",
             (orgName + "/" + appToDeleteName).toLowerCase(),
@@ -230,12 +231,13 @@ public class ApplicationDeleteIT extends AbstractRestIT {
 
         // delete the app
 
-        logger.debug("\n\nDeleting app\n");
+        logger.debug( "\n\nDeleting app\n" );
 
         clientSetup.getRestClient().management().orgs()
-            .org(orgName).apps().app( appToDeleteName ).getResource()
-            .queryParam("access_token", orgAdminToken.getAccessToken() )
+            .org( orgName ).apps().app( appToDeleteName ).getTarget()
+            .queryParam( "access_token", orgAdminToken.getAccessToken() )
             .queryParam("app_delete_confirm", "confirm_delete_of_application_and_data")
+            .request()
             .delete();
 
         refreshIndex();
@@ -246,9 +248,10 @@ public class ApplicationDeleteIT extends AbstractRestIT {
         logger.debug("\n\nRestoring app\n");
 
         clientSetup.getRestClient().management().orgs()
-            .org(orgName).apps().app( appToDeleteId.toString() ).getResource()
-            .queryParam("access_token", orgAdminToken.getAccessToken() )
-            .put();
+            .org( orgName ).apps().app( appToDeleteId.toString() ).getTarget()
+            .queryParam( "access_token", orgAdminToken.getAccessToken() )
+            .request()
+            .put( javax.ws.rs.client.Entity.json( null ));
 
         refreshIndex();
 
@@ -275,18 +278,18 @@ public class ApplicationDeleteIT extends AbstractRestIT {
 
         UUID entityId = entities.get(0).getUuid();
         ApiResponse entityResponse = clientSetup.getRestClient()
-            .org(orgName).app(appToDeleteName).collection("things").entity( entityId ).getResource()
-            .queryParam("access_token", orgAdminToken.getAccessToken())
-            .type(MediaType.APPLICATION_JSON)
-            .get(ApiResponse.class);
+            .org( orgName ).app( appToDeleteName ).collection( "things" ).entity( entityId ).getTarget()
+            .queryParam( "access_token", orgAdminToken.getAccessToken() )
+            .request()
+            .get( ApiResponse.class );
         Assert.assertEquals( entityId, entityResponse.getEntities().get(0).getUuid() );
 
         // test that we can get deleted app's collection
 
         ApiResponse collectionReponse = clientSetup.getRestClient()
-            .org(orgName).app(appToDeleteName).collection("things").getResource()
-            .queryParam("access_token", orgAdminToken.getAccessToken())
-            .type(MediaType.APPLICATION_JSON)
+            .org( orgName ).app( appToDeleteName ).collection( "things" ).getTarget()
+            .queryParam( "access_token", orgAdminToken.getAccessToken() )
+            .request()
             .get(ApiResponse.class);
         Assert.assertEquals( entities.size(), collectionReponse.getEntityCount() );
     }
@@ -311,9 +314,10 @@ public class ApplicationDeleteIT extends AbstractRestIT {
         // delete the app
 
         clientSetup.getRestClient().management().orgs()
-            .org( orgName ).apps().app(appToDeleteId.toString() ).getResource()
+            .org( orgName ).apps().app( appToDeleteId.toString() ).getTarget()
             .queryParam( "access_token", orgAdminToken.getAccessToken() )
             .queryParam("app_delete_confirm", "confirm_delete_of_application_and_data")
+            .request()
             .delete();
 
         // create new app with same name
@@ -325,13 +329,14 @@ public class ApplicationDeleteIT extends AbstractRestIT {
         try {
 
             clientSetup.getRestClient() .management().orgs()
-                .org(orgName).apps().app(appToDeleteId.toString()).getResource()
+                .org(orgName).apps().app(appToDeleteId.toString()).getTarget()
                 .queryParam("access_token", orgAdminToken.getAccessToken())
-                .put();
+                .request()
+                .put( javax.ws.rs.client.Entity.json(null) );
 
             fail("Must fail to restore app with same name as existing app");
 
-        } catch ( UniformInterfaceException e ) {
+        } catch ( ResponseProcessingException e ) {
             Assert.assertEquals(409, e.getResponse().getStatus());
         }
     }
@@ -356,9 +361,10 @@ public class ApplicationDeleteIT extends AbstractRestIT {
 
         // delete the app
 
-        clientSetup.getRestClient().management().orgs().org( orgName ).apps().app( appToDeleteId.toString() ).getResource()
+        clientSetup.getRestClient().management().orgs().org( orgName ).apps().app( appToDeleteId.toString() ).getTarget()
             .queryParam( "access_token", orgAdminToken.getAccessToken() )
             .queryParam( "app_delete_confirm", "confirm_delete_of_application_and_data" )
+            .request()
             .delete();
 
         // create new app with same name
@@ -369,14 +375,15 @@ public class ApplicationDeleteIT extends AbstractRestIT {
 
         try {
 
-            clientSetup.getRestClient().management().orgs().org( orgName ).apps().app( newAppId.toString() ).getResource()
-                .queryParam("access_token", orgAdminToken.getAccessToken())
+            clientSetup.getRestClient().management().orgs().org( orgName ).apps().app( newAppId.toString() ).getTarget()
+                .queryParam( "access_token", orgAdminToken.getAccessToken() )
                 .queryParam("app_delete_confirm", "confirm_delete_of_application_and_data")
+                .request()
                 .delete();
 
             fail("Must fail to delete app with same name as deleted app");
 
-        } catch ( UniformInterfaceException e ) {
+        } catch ( ResponseProcessingException e ) {
             Assert.assertEquals( 409, e.getResponse().getStatus() );
         }
     }
@@ -386,10 +393,10 @@ public class ApplicationDeleteIT extends AbstractRestIT {
         String orgName, String appName, Token orgAdminToken, List<Entity> entities) {
 
         ApiResponse appCreateResponse = clientSetup.getRestClient()
-            .management().orgs().org( orgName ).app().getResource()
+            .management().orgs().org( orgName ).app().getTarget()
             .queryParam( "access_token", orgAdminToken.getAccessToken() )
-            .type( MediaType.APPLICATION_JSON )
-            .post( ApiResponse.class, new Application( appName ) );
+            .request()
+            .post( javax.ws.rs.client.Entity.json(new Application( appName )), ApiResponse.class );
         UUID appId = appCreateResponse.getEntities().get(0).getUuid();
 
         try { Thread.sleep(INDEXING_WAIT); } catch (InterruptedException ignored ) { }
@@ -398,15 +405,15 @@ public class ApplicationDeleteIT extends AbstractRestIT {
 
             final String entityName = "entity" + i;
             Entity entity = new Entity();
-            entity.setProperties(new HashMap<String, Object>() {{
-                put("name", entityName );
-            }});
+            entity.setProperties( new HashMap<String, Object>() {{
+                put( "name", entityName );
+            }} );
 
             ApiResponse createResponse = clientSetup.getRestClient()
-                .org(orgName).app( appName ).collection("things").getResource()
+                .org(orgName).app( appName ).collection("things").getTarget()
                 .queryParam("access_token", orgAdminToken.getAccessToken())
-                .type(MediaType.APPLICATION_JSON)
-                .post( ApiResponse.class, entity );
+                .request()
+                .post( javax.ws.rs.client.Entity.json(entity), ApiResponse.class );
 
             entities.add( createResponse.getEntities().get(0) );
         }

http://git-wip-us.apache.org/repos/asf/usergrid/blob/0578d987/stack/rest/src/test/java/org/apache/usergrid/rest/applications/ApplicationResourceIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/ApplicationResourceIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/ApplicationResourceIT.java
index ec858f7..f071b5e 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/ApplicationResourceIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/ApplicationResourceIT.java
@@ -17,10 +17,6 @@
 package org.apache.usergrid.rest.applications;
 
 import com.fasterxml.jackson.databind.JsonNode;
-import com.sun.jersey.api.client.ClientResponse.Status;
-import com.sun.jersey.api.client.UniformInterfaceException;
-import com.sun.jersey.api.client.WebResource;
-import com.sun.jersey.api.representation.Form;
 import org.apache.commons.lang.RandomStringUtils;
 import org.apache.shiro.codec.Base64;
 import org.apache.usergrid.cassandra.SpringResource;
@@ -30,12 +26,17 @@ import org.apache.usergrid.rest.test.resource.endpoints.mgmt.OrganizationResourc
 import org.apache.usergrid.rest.test.resource.model.*;
 import org.apache.usergrid.setup.ConcurrentProcessSingleton;
 import org.apache.usergrid.utils.MapUtils;
+import org.glassfish.jersey.client.ClientProperties;
 import org.junit.Ignore;
 import org.junit.Test;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import javax.ws.rs.client.Invocation;
+import javax.ws.rs.client.ResponseProcessingException;
+import javax.ws.rs.core.Form;
 import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
 import java.io.IOException;
 import java.util.HashMap;
 import java.util.Map;
@@ -60,12 +61,12 @@ public class ApplicationResourceIT extends AbstractRestIT {
         Credentials orgCredentials = getOrgCredentials();
 
         //retrieve the app using only the org credentials
-        ApiResponse apiResponse = this.org().app(clientSetup.getAppName()).getResource(false)
+        ApiResponse apiResponse = this.org().app( clientSetup.getAppName() ).getTarget( false )
             .queryParam("grant_type", "client_credentials")
             .queryParam("client_id", orgCredentials.getClientId())
-            .queryParam("client_secret", orgCredentials.getClientSecret())
-            .accept(MediaType.APPLICATION_JSON)
-            .type(MediaType.APPLICATION_JSON_TYPE)
+            .queryParam( "client_secret", orgCredentials.getClientSecret() )
+            .request()
+            .accept( MediaType.APPLICATION_JSON )
             .get(ApiResponse.class);
         //assert that a valid response is returned without error
         assertNotNull(apiResponse);
@@ -82,12 +83,12 @@ public class ApplicationResourceIT extends AbstractRestIT {
         Credentials appCredentials = getAppCredentials();
 
         //retrieve the app using only the org credentials
-        ApiResponse apiResponse = this.app().getResource(false)
+        ApiResponse apiResponse = this.app().getTarget( false )
             .queryParam("grant_type", "client_credentials")
             .queryParam("client_id", appCredentials.getClientId())
             .queryParam("client_secret", appCredentials.getClientSecret())
+            .request()
             .accept(MediaType.APPLICATION_JSON)
-            .type(MediaType.APPLICATION_JSON_TYPE)
             .get(ApiResponse.class);
         //assert that a valid response is returned without error
         assertNotNull(apiResponse);
@@ -104,13 +105,13 @@ public class ApplicationResourceIT extends AbstractRestIT {
         Credentials appCredentials = getAppCredentials();
 
         //retrieve the app using only the org credentials
-        ApiResponse apiResponse = this.app().collection( "roles" ).getResource( false )
-                                      .queryParam( "grant_type", "client_credentials" )
-                                      .queryParam("client_id", appCredentials.getClientId())
-                                      .queryParam("client_secret", appCredentials.getClientSecret())
-                                      .accept(MediaType.APPLICATION_JSON)
-                                      .type(MediaType.APPLICATION_JSON_TYPE)
-                                      .get(ApiResponse.class);
+        ApiResponse apiResponse = this.app().collection( "roles" ).getTarget( false )
+            .queryParam( "grant_type", "client_credentials" )
+            .queryParam("client_id", appCredentials.getClientId())
+            .queryParam("client_secret", appCredentials.getClientSecret())
+            .request()
+            .accept(MediaType.APPLICATION_JSON)
+            .get(ApiResponse.class);
         //assert that a valid response is returned without error
         assertNotNull(apiResponse);
         assertNull(apiResponse.getError());
@@ -207,12 +208,12 @@ public class ApplicationResourceIT extends AbstractRestIT {
         Credentials orgCredentials = getOrgCredentials();
 
         //retrieve the users collection without setting the "Accept" header
-        WebResource.Builder builder = this.app().collection("users").getResource(false)
+        Invocation.Builder builder = this.app().collection( "users" ).getTarget( false )
             //Add the org credentials to the query
-            .queryParam("grant_type", "client_credentials")
-            .queryParam("client_id", orgCredentials.getClientId())
-            .queryParam("client_secret", orgCredentials.getClientSecret())
-            .type(MediaType.APPLICATION_JSON_TYPE);
+            .queryParam( "grant_type", "client_credentials" )
+            .queryParam("client_id", orgCredentials.getClientId() )
+            .queryParam( "client_secret", orgCredentials.getClientSecret() )
+            .request();
 
         ApiResponse apiResponse = builder.get(ApiResponse.class);
         Collection users = new Collection(apiResponse);
@@ -239,15 +240,17 @@ public class ApplicationResourceIT extends AbstractRestIT {
         String clientSecret = orgCredentials.getClientSecret();
 
         //retrieve the users collection, setting the "Accept" header to text/html
-        WebResource.Builder builder = this.app().collection("users").getResource(false)
+        Invocation.Builder builder = this.app().collection( "users" ).getTarget()
             //Add the org credentials to the query
-            .queryParam("grant_type", "client_credentials")
-            .queryParam("client_id", clientId)
-            .queryParam("client_secret", clientSecret)
+            .queryParam( "grant_type", "client_credentials" )
+            .queryParam( "client_id", clientId )
+            .queryParam( "client_secret", clientSecret )
+            .request();
+
+        ApiResponse apiResponse = builder
             .accept(MediaType.TEXT_HTML)
-            .type(MediaType.APPLICATION_JSON_TYPE);
+            .get(ApiResponse.class);
 
-        ApiResponse apiResponse = builder.get(ApiResponse.class);
         Collection users = new Collection(apiResponse);
         //make sure that a valid response is returned without error
         assertNotNull(users);
@@ -299,12 +302,12 @@ public class ApplicationResourceIT extends AbstractRestIT {
         //retrieve the credentials
         Credentials orgCredentials = getOrgCredentials();
 
-        ApiResponse apiResponse = this.app().getResource(false)
-            .queryParam("grant_type", "client_credentials")
+        ApiResponse apiResponse = this.app().getTarget( false )
+            .queryParam( "grant_type", "client_credentials" )
             .queryParam("client_id", orgCredentials.getClientId())
-            .queryParam("client_secret", orgCredentials.getClientSecret())
-            .accept(MediaType.APPLICATION_JSON)
-            .type(MediaType.APPLICATION_JSON_TYPE)
+            .queryParam( "client_secret", orgCredentials.getClientSecret() )
+            .request()
+            .accept( MediaType.APPLICATION_JSON )
             .get(ApiResponse.class);
 
         // assert that the response returns the correct URI
@@ -317,12 +320,12 @@ public class ApplicationResourceIT extends AbstractRestIT {
         assertEquals(String.format("%s/%s", orgName, appName), application.get("name"));
 
         //retrieve the application's roles collection
-        apiResponse = this.app().collection("roles").getResource(false)
-            .queryParam("grant_type", "client_credentials")
+        apiResponse = this.app().collection( "roles" ).getTarget( false )
+            .queryParam( "grant_type", "client_credentials" )
             .queryParam("client_id", orgCredentials.getClientId())
-            .queryParam("client_secret", orgCredentials.getClientSecret())
-            .accept(MediaType.APPLICATION_JSON)
-            .type(MediaType.APPLICATION_JSON_TYPE)
+            .queryParam( "client_secret", orgCredentials.getClientSecret() )
+            .request()
+            .accept( MediaType.APPLICATION_JSON )
             .get(ApiResponse.class);
         Collection roles = new Collection(apiResponse);
         //assert that we have the correct number of default roles
@@ -372,11 +375,11 @@ public class ApplicationResourceIT extends AbstractRestIT {
         String orgName = clientSetup.getOrganizationName().toLowerCase();
         String appName = clientSetup.getAppName().toLowerCase();
 
-        ApiResponse apiResponse = resource().path(String.format("/%s/%s", orgName, appName))
-            .queryParam("access_token", this.getAdminToken().getAccessToken())
-            .accept(MediaType.APPLICATION_JSON)
-            .type(MediaType.APPLICATION_JSON_TYPE)
-            .delete(ApiResponse.class);
+        ApiResponse apiResponse = target().path( String.format( "/%s/%s", orgName, appName ) )
+            .queryParam( "access_token", this.getAdminToken().getAccessToken() )
+            .request()
+            .accept( MediaType.APPLICATION_JSON )
+            .delete( ApiResponse.class );
 
         assertNotNull(apiResponse.getError());
     }
@@ -406,14 +409,14 @@ public class ApplicationResourceIT extends AbstractRestIT {
 
         try {
             //POST the updated TTL, anticipating an exception
-            resource().path(String.format("/%s/%s/token", orgName, appName))
+            target().path(String.format("/%s/%s/token", orgName, appName))
+                .request()
                 .accept(MediaType.APPLICATION_JSON)
-                .type(MediaType.APPLICATION_JSON_TYPE)
-                .post(ApiResponse.class, entity);
+                .post( javax.ws.rs.client.Entity.entity(entity, MediaType.APPLICATION_JSON_TYPE ), ApiResponse.class);
             fail("This should cause an exception");
-        } catch (UniformInterfaceException uie) {
+        } catch (ResponseProcessingException uie) {
             assertEquals(
-                String.valueOf(Status.BAD_REQUEST.getStatusCode()),
+                String.valueOf( Response.Status.BAD_REQUEST.getStatusCode()),
                 String.valueOf(uie.getResponse().getStatus()));
         }
     }
@@ -440,13 +443,13 @@ public class ApplicationResourceIT extends AbstractRestIT {
         refreshIndex();
 
         //Retrieve an authentication token for the user, setting the TTL
-        Token apiResponse = resource().path(String.format("/%s/%s/token", orgName, appName))
+        Token apiResponse = target().path( String.format( "/%s/%s/token", orgName, appName ) )
             .queryParam("grant_type", "password")
             .queryParam("username", username)
             .queryParam("password", "password")
-            .queryParam("ttl", String.valueOf(ttl))
-            .accept(MediaType.APPLICATION_JSON)
-            .type(MediaType.APPLICATION_JSON_TYPE)
+            .queryParam( "ttl", String.valueOf( ttl ) )
+            .request()
+            .accept( MediaType.APPLICATION_JSON )
             .get(Token.class);
 
         //Set a start time so we can calculate then the token should expire
@@ -477,8 +480,8 @@ public class ApplicationResourceIT extends AbstractRestIT {
             this.app().collection("users").entity(entity).get(
                 new QueryParameters().addParam("access_token", token), false);
             fail("The expired token should cause an exception");
-        } catch (UniformInterfaceException uie) {
-            assertEquals(Status.UNAUTHORIZED.getStatusCode(), uie.getResponse().getStatus());
+        } catch (ResponseProcessingException uie) {
+            assertEquals( Response.Status.UNAUTHORIZED.getStatusCode(), uie.getResponse().getStatus());
         }
 
     }
@@ -506,20 +509,20 @@ public class ApplicationResourceIT extends AbstractRestIT {
 
         try {
             //Retrieve a token for the new user, setting the TTL to an invalid value
-            resource().path(String.format("/%s/%s/token", orgName, appName))
-                .queryParam("grant_type", "password")
+            target().path( String.format( "/%s/%s/token", orgName, appName ) )
+                .queryParam( "grant_type", "password" )
                 .queryParam("username", username)
                 .queryParam("password", "password")
                 .queryParam("ttl", "derp")
-                .accept(MediaType.APPLICATION_JSON)
-                .type(MediaType.APPLICATION_JSON_TYPE)
-                .get(ApiResponse.class);
+                .request()
+                .accept( MediaType.APPLICATION_JSON )
+                .get( ApiResponse.class );
             fail("The invalid TTL should cause an exception");
 
-        } catch (UniformInterfaceException uie) {
+        } catch (ResponseProcessingException uie) {
             //TODO should this be handled and returned as a Status.BAD_REQUEST?
             //Status.INTERNAL_SERVER_ERROR is thrown because Jersey throws a NumberFormatException
-            assertEquals(Status.INTERNAL_SERVER_ERROR, uie.getResponse().getClientResponseStatus());
+            assertEquals( Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), uie.getResponse().getStatus());
         }
 
     }
@@ -543,12 +546,12 @@ public class ApplicationResourceIT extends AbstractRestIT {
         assertNotNull(entity);
         refreshIndex();
         //Retrieve an authentication token for the user
-        Token tokenResponse = this.app().getResource(false).path("token")
-            .queryParam("grant_type", "password")
-            .queryParam("username", username)
+        Token tokenResponse = this.app().getTarget( false ).path( "token" )
+            .queryParam( "grant_type", "password" )
+            .queryParam( "username", username )
             .queryParam("password", "password")
+            .request()
             .accept( MediaType.APPLICATION_JSON )
-            .type( MediaType.APPLICATION_JSON_TYPE )
             .get( Token.class );
 
         String token = tokenResponse.getAccessToken();
@@ -559,19 +562,21 @@ public class ApplicationResourceIT extends AbstractRestIT {
         assertEquals(604800, expires_in);
 
         //Set the default TTL of the application to a date far in the future
-        this.app().getResource(false)
-            .queryParam("access_token", token)
-            .accept(MediaType.APPLICATION_JSON)
-            .type(MediaType.APPLICATION_JSON_TYPE)
-            .put(Token.class, new MapUtils.HashMapBuilder<String, String>().map("accesstokenttl", "31536000000"));
+        final MapUtils.HashMapBuilder<String, String> map =
+            new MapUtils.HashMapBuilder<String, String>().map( "accesstokenttl", "31536000000" );
+        this.app().getTarget( false )
+            .queryParam( "access_token", token )
+            .request()
+            .accept( MediaType.APPLICATION_JSON )
+            .put( javax.ws.rs.client.Entity.entity( map, MediaType.APPLICATION_JSON_TYPE ), Token.class );
 
         //Create a new token for the user
-        tokenResponse = this.app().token().getResource(false)
+        tokenResponse = this.app().token().getTarget( false )
             .queryParam("grant_type", "password")
             .queryParam("username", username)
-            .queryParam("password", "password")
-            .accept(MediaType.APPLICATION_JSON)
-            .type(MediaType.APPLICATION_JSON_TYPE)
+            .queryParam( "password", "password" )
+            .request()
+            .accept( MediaType.APPLICATION_JSON )
             .get(Token.class);
 
         //assert that the new token has the new default TTL
@@ -587,15 +592,17 @@ public class ApplicationResourceIT extends AbstractRestIT {
     public void authorizationCodeWithWrongCredentials() throws Exception {
         //Create form input with bogus credentials
         Form payload = new Form();
-        payload.add("username", "wrong_user");
-        payload.add("password", "wrong_password");
-        payload.add("response_type", "code");
-        payload.add("scope", "none");
-        payload.add("redirect_uri", "http://www.my_test.com");
+        payload.param( "username", "wrong_user" );
+        payload.param( "password", "wrong_password" );
+        payload.param( "response_type", "code" );
+        payload.param( "scope", "none" );
+        payload.param( "redirect_uri", "http://www.my_test.com" );
 
         //POST the form to the authorization endpoint
-        String apiResponse = clientSetup.getRestClient().management().authorize().getResource()
-            .type( MediaType.APPLICATION_FORM_URLENCODED_TYPE ).accept(MediaType.TEXT_HTML).post(String.class, payload);
+        String apiResponse = clientSetup.getRestClient().management().authorize().getTarget()
+            .request()
+            .accept( MediaType.TEXT_HTML )
+            .post( javax.ws.rs.client.Entity.form( payload ), String.class );
 
         //Assert that an appropriate error message is returned
         assertTrue(apiResponse.contains("Username or password do not match"));
@@ -609,11 +616,12 @@ public class ApplicationResourceIT extends AbstractRestIT {
     //we have authorize response only with username/password - client_id/secret not considered
     public void authorizeWithInvalidClientIdRaisesError() throws Exception {
         //GET the application authorization endpoint using bogus client credentials
-        String apiResponse = clientSetup.getRestClient().management().authorize().getResource(true)
-            .queryParam("response_type", "code")
+        String apiResponse = clientSetup.getRestClient().management().authorize().getTarget( true )
+            .queryParam( "response_type", "code" )
             .queryParam("client_id", "invalid_client_id")
             .queryParam("redirect_uri", "http://www.my_test.com")
-            .accept(MediaType.TEXT_HTML)
+            .request()
+            .accept( MediaType.TEXT_HTML )
             .get(String.class);
         //Assert that an appropriate error message is returned
         //assertTrue(apiResponse.contains("Unable to authenticate (OAuth). Invalid client_id."));
@@ -630,22 +638,25 @@ public class ApplicationResourceIT extends AbstractRestIT {
 
         //Create form input with valid credentials
         Form payload = new Form();
-        payload.add("response_type", "code");
-        payload.add("grant_type", "client_credentials");
-        payload.add("client_id", orgCredentials.getClientId());
-        payload.add("client_secret", orgCredentials.getClientSecret());
-        payload.add("scope", "none");
-        payload.add("redirect_uri", "http://www.my_test.com");
+        payload.param( "response_type", "code" );
+        payload.param( "grant_type", "client_credentials" );
+        payload.param( "client_id", orgCredentials.getClientId() );
+        payload.param( "client_secret", orgCredentials.getClientSecret() );
+        payload.param( "scope", "none" );
+        payload.param( "redirect_uri", "http://www.my_test.com" );
 
         //Set the client to not follow the initial redirect returned by the stack
-        client().setFollowRedirects(false);
 
         try {
             //POST the form to the authorization endpoint
             clientSetup.getRestClient().management().authorize()
-                .getResource().accept(MediaType.TEXT_HTML).post(String.class, payload);
-        } catch (UniformInterfaceException uie) {
-            assertEquals(String.valueOf(Status.TEMPORARY_REDIRECT.getStatusCode()), uie.getResponse().getStatus());
+                .getTarget()
+                .property( ClientProperties.FOLLOW_REDIRECTS, Boolean.TRUE )
+                .request()
+                .accept( MediaType.TEXT_HTML )
+                .post( javax.ws.rs.client.Entity.form( payload ), String.class );
+        } catch (ResponseProcessingException uie) {
+            assertEquals(String.valueOf( Response.Status.TEMPORARY_REDIRECT.getStatusCode()), uie.getResponse().getStatus());
         }
 
     }
@@ -667,12 +678,12 @@ public class ApplicationResourceIT extends AbstractRestIT {
         Map<String, String> map = new HashMap<>(1);
         map.put("grant_type", "client_credentials");
         //GET the token endpoint, adding the basic auth header
-        Token apiResponse = clientSetup.getRestClient().management().token().getResource(false)
+        Token apiResponse = clientSetup.getRestClient().management().token().getTarget( false )
             //add the auth header
-            .header("Authorization", "Basic " + token)
+            .request()
+            .header( "Authorization", "Basic " + token )
             .accept(MediaType.APPLICATION_JSON)
-            .type(MediaType.APPLICATION_JSON_TYPE)
-            .post(Token.class, map);
+            .post( javax.ws.rs.client.Entity.entity(map, MediaType.APPLICATION_JSON_TYPE), Token.class );
 
         //Assert that a valid token with a valid TTL is returned
         assertNotNull("A valid response was returned.", apiResponse);
@@ -697,12 +708,13 @@ public class ApplicationResourceIT extends AbstractRestIT {
             .post(Token.class,new Token("client_credentials", clientId, clientSecret));
 
         //GET the token endpoint, adding authorization header
-        Token apiResponse = this.app().token().getResource(false)
+        Token apiResponse = this.app().token().getTarget( false )
             //add the auth header
-            .header("Authorization", "Bearer " + token.getAccessToken())
-            .accept(MediaType.APPLICATION_JSON)
-            .type(MediaType.APPLICATION_JSON_TYPE)
-            .post(Token.class, hashMap("grant_type", "client_credentials"));
+            .request()
+            .header( "Authorization", "Bearer " + token.getAccessToken() )
+            .accept( MediaType.APPLICATION_JSON )
+            .post(javax.ws.rs.client.Entity.entity(
+                hashMap( "grant_type", "client_credentials" ), MediaType.APPLICATION_JSON_TYPE ), Token.class );
 
         //Assert that a valid token with a valid TTL is returned
         assertNotNull("A valid response was returned.", apiResponse);
@@ -723,15 +735,14 @@ public class ApplicationResourceIT extends AbstractRestIT {
 
         //Create form input
         Form payload = new Form();
-        payload.add("grant_type", "client_credentials");
-        payload.add("client_id", clientId);
-        payload.add("client_secret", clientSecret);
+        payload.param( "grant_type", "client_credentials" );
+        payload.param( "client_id", clientId );
+        payload.param("client_secret", clientSecret);
 
         //POST the form to the application token endpoint
-        Token apiResponse = this.app().token().getResource(false)
+        Token apiResponse = this.app().token().getTarget( false).request()
             .accept(MediaType.APPLICATION_JSON)
-            .type(MediaType.APPLICATION_FORM_URLENCODED_TYPE)
-            .post(Token.class, payload);
+            .post( javax.ws.rs.client.Entity.form(payload), Token.class);
 
         //Assert that a valid token with a valid TTL is returned
         assertNotNull("It has access_token.", apiResponse.getAccessToken());
@@ -754,11 +765,11 @@ public class ApplicationResourceIT extends AbstractRestIT {
         String token = Base64.encodeToString(clientCredentials.getBytes());
 
         //POST the form to the application token endpoint along with the payload
-        Token apiResponse = this.app().token().getResource(false)
-            .header("Authorization", "Basic " + token)
-            .accept(MediaType.APPLICATION_JSON)
-            .type(MediaType.APPLICATION_JSON_TYPE)
-            .post(Token.class, hashMap("grant_type", "client_credentials"));
+        Token apiResponse = this.app().token().getTarget( false ).request()
+            .header( "Authorization", "Basic " + token )
+            .accept( MediaType.APPLICATION_JSON )
+            .post(javax.ws.rs.client.Entity.entity(
+                hashMap("grant_type", "client_credentials"), MediaType.APPLICATION_JSON_TYPE), Token.class);
 
         //Assert that a valid token with a valid TTL is returned
         assertNotNull("It has access_token.", apiResponse.getAccessToken());
@@ -775,18 +786,18 @@ public class ApplicationResourceIT extends AbstractRestIT {
 
         try {
             //GET the APM endpoint
-            String response = resource().path(String.format("/%s/%s/apm/apigeeMobileConfig", orgName, appName))
-                .accept(MediaType.APPLICATION_JSON)
-                .type(MediaType.APPLICATION_JSON_TYPE)
+            String response = target().path( String.format( "/%s/%s/apm/apigeeMobileConfig", orgName, appName ) )
+                .request()
+                .accept( MediaType.APPLICATION_JSON )
                 .get(String.class);
             //Parse the response
             JsonNode node = mapper.readTree(response);
 
             //if things are kosher then JSON should have value for instaOpsApplicationId
             assertTrue("it's valid json for APM", node.has("instaOpsApplicationId"));
-        } catch (UniformInterfaceException uie) {
+        } catch (ResponseProcessingException uie) {
             //Validate that APM config exists
-            assertNotEquals("APM Config API exists", Status.NOT_FOUND,
+            assertNotEquals("APM Config API exists", Response.Status.NOT_FOUND,
                 uie.getResponse().getStatus()); //i.e It should not be "Not Found"
         }
     }
@@ -813,7 +824,7 @@ public class ApplicationResourceIT extends AbstractRestIT {
         assertEquals(604800, ttl);
 
         //retrieve the users collection for the application using the new token
-        ApiResponse response = this.app().collection("users").getResource(true, token).get(ApiResponse.class);
+        ApiResponse response = this.app().collection("users").getTarget(true, token ).request().get(ApiResponse.class);
         //assert that we did not receive an error
         assertNull(response.getError());
     }
@@ -840,7 +851,7 @@ public class ApplicationResourceIT extends AbstractRestIT {
         assertEquals(604800, ttl);
 
         //retrieve the users collection for the application using the new token
-        ApiResponse response = this.app().collection("users").getResource(true, token).get(ApiResponse.class);
+        ApiResponse response = this.app().collection("users").getTarget( true, token ).request().get( ApiResponse.class);
         //assert that we did not receive an error
         assertNull(response.getError());
     }

http://git-wip-us.apache.org/repos/asf/usergrid/blob/0578d987/stack/rest/src/test/java/org/apache/usergrid/rest/applications/assets/AssetResourceIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/assets/AssetResourceIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/assets/AssetResourceIT.java
index 79a6957..92705b2 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/assets/AssetResourceIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/assets/AssetResourceIT.java
@@ -17,19 +17,16 @@
 package org.apache.usergrid.rest.applications.assets;
 
 
-import com.sun.jersey.multipart.FormDataMultiPart;
+import net.jcip.annotations.NotThreadSafe;
 import org.apache.commons.io.IOUtils;
-
-import org.apache.usergrid.rest.applications.ServiceResource;
 import org.apache.usergrid.rest.test.resource.AbstractRestIT;
 import org.apache.usergrid.rest.test.resource.model.ApiResponse;
 import org.apache.usergrid.rest.test.resource.model.Entity;
 import org.apache.usergrid.services.assets.data.AssetUtils;
-
+import org.glassfish.jersey.media.multipart.FormDataMultiPart;
 import org.junit.After;
 import org.junit.Assert;
 import org.junit.Before;
-import org.junit.Rule;
 import org.junit.Test;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -41,8 +38,6 @@ import java.util.HashMap;
 import java.util.Map;
 import java.util.UUID;
 
-import net.jcip.annotations.NotThreadSafe;
-
 import static org.apache.usergrid.management.AccountCreationProps.PROPERTIES_USERGRID_BINARY_UPLOADER;
 import static org.apache.usergrid.utils.MapUtils.hashMap;
 import static org.junit.Assert.*;

http://git-wip-us.apache.org/repos/asf/usergrid/blob/0578d987/stack/rest/src/test/java/org/apache/usergrid/rest/applications/assets/AwsAssetResourceIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/assets/AwsAssetResourceIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/assets/AwsAssetResourceIT.java
index 9cf719b..72d45de 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/assets/AwsAssetResourceIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/assets/AwsAssetResourceIT.java
@@ -17,51 +17,30 @@
 package org.apache.usergrid.rest.applications.assets;
 
 
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.UUID;
-
-import javax.ws.rs.core.MediaType;
-
-import org.jclouds.blobstore.BlobStoreContext;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.context.ApplicationContext;
-
-
+import com.amazonaws.SDKGlobalConfiguration;
+import net.jcip.annotations.NotThreadSafe;
 import org.apache.commons.io.IOUtils;
-
-import org.apache.usergrid.cassandra.SpringResource;
-import org.apache.usergrid.management.ManagementService;
 import org.apache.usergrid.rest.applications.assets.aws.NoAWSCredsRule;
 import org.apache.usergrid.rest.test.resource.AbstractRestIT;
 import org.apache.usergrid.rest.test.resource.model.ApiResponse;
 import org.apache.usergrid.rest.test.resource.model.Entity;
 import org.apache.usergrid.services.assets.data.AssetUtils;
-import org.apache.usergrid.services.assets.data.BinaryStore;
 import org.apache.usergrid.services.exceptions.AwsPropertiesNotFoundException;
-import org.apache.usergrid.setup.ConcurrentProcessSingleton;
-
-import com.amazonaws.SDKGlobalConfiguration;
-import com.sun.jersey.api.client.UniformInterfaceException;
-import com.sun.jersey.multipart.FormDataMultiPart;
+import org.glassfish.jersey.media.multipart.FormDataMultiPart;
+import org.junit.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
-import net.jcip.annotations.NotThreadSafe;
+import javax.ws.rs.client.ResponseProcessingException;
+import javax.ws.rs.core.MediaType;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Map;
+import java.util.UUID;
 
 import static org.apache.usergrid.management.AccountCreationProps.PROPERTIES_USERGRID_BINARY_UPLOADER;
 import static org.apache.usergrid.utils.MapUtils.hashMap;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import static org.junit.Assert.*;
 
 
 @NotThreadSafe
@@ -116,7 +95,7 @@ public class AwsAssetResourceIT extends AbstractRestIT {
         }catch ( AwsPropertiesNotFoundException e ){
             fail("Shouldn't interrupt runtime if access key isnt found.");
         }
-        catch( UniformInterfaceException uie){
+        catch( ResponseProcessingException uie){
             assertEquals(500,uie.getResponse().getStatus());
         }
         finally{
@@ -150,7 +129,7 @@ public class AwsAssetResourceIT extends AbstractRestIT {
         }catch ( AwsPropertiesNotFoundException e ){
             fail("Shouldn't interrupt runtime if access key isnt found.");
         }
-        catch( UniformInterfaceException uie){
+        catch( ResponseProcessingException uie){
             assertEquals( 500, uie.getResponse().getStatus() );
         }
         finally{
@@ -192,7 +171,7 @@ public class AwsAssetResourceIT extends AbstractRestIT {
         }catch ( AwsPropertiesNotFoundException e ){
             fail("Shouldn't interrupt runtime if access key isnt found.");
         }
-        catch( UniformInterfaceException uie){
+        catch( ResponseProcessingException uie){
             assertEquals( 500, uie.getResponse().getStatus() );
         }
         finally{

http://git-wip-us.apache.org/repos/asf/usergrid/blob/0578d987/stack/rest/src/test/java/org/apache/usergrid/rest/applications/assets/aws/NoAWSCredsRule.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/assets/aws/NoAWSCredsRule.java b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/assets/aws/NoAWSCredsRule.java
index 5f7779e..1dd00ff 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/assets/aws/NoAWSCredsRule.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/assets/aws/NoAWSCredsRule.java
@@ -20,9 +20,10 @@
 package org.apache.usergrid.rest.applications.assets.aws;
 
 
-import java.util.Map;
-import java.util.Properties;
-
+import com.amazonaws.AmazonClientException;
+import com.amazonaws.SDKGlobalConfiguration;
+import org.apache.usergrid.rest.test.resource.AbstractRestIT;
+import org.apache.usergrid.services.exceptions.AwsPropertiesNotFoundException;
 import org.junit.Assume;
 import org.junit.internal.runners.model.MultipleFailureException;
 import org.junit.rules.TestRule;
@@ -30,12 +31,8 @@ import org.junit.runner.Description;
 import org.junit.runners.model.Statement;
 import org.springframework.beans.factory.annotation.Autowired;
 
-import org.apache.usergrid.services.exceptions.AwsPropertiesNotFoundException;
-import org.apache.usergrid.rest.test.resource.AbstractRestIT;
-
-import com.amazonaws.AmazonClientException;
-import com.amazonaws.SDKGlobalConfiguration;
-import com.sun.jersey.api.client.UniformInterfaceException;
+import java.util.Map;
+import java.util.Properties;
 
 
 /**

http://git-wip-us.apache.org/repos/asf/usergrid/blob/0578d987/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/CollectionsResourceIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/CollectionsResourceIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/CollectionsResourceIT.java
index 3dadc5b..b2bab35 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/CollectionsResourceIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/CollectionsResourceIT.java
@@ -17,24 +17,20 @@
 package org.apache.usergrid.rest.applications.collection;
 
 
-import java.io.IOException;
 import com.fasterxml.jackson.databind.JsonNode;
-import com.sun.jersey.api.client.UniformInterfaceException;
 import org.apache.usergrid.rest.test.resource.AbstractRestIT;
-import org.apache.usergrid.rest.test.resource.model.ApiResponse;
 import org.apache.usergrid.rest.test.resource.model.Collection;
-
-import org.apache.usergrid.rest.test.resource.model.Credentials;
 import org.apache.usergrid.rest.test.resource.model.Entity;
 import org.apache.usergrid.rest.test.resource.model.QueryParameters;
 import org.apache.usergrid.rest.test.resource.model.Token;
-
 import org.junit.Ignore;
 import org.junit.Test;
-import org.mortbay.jetty.security.Credential;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import javax.ws.rs.client.ResponseProcessingException;
+import java.io.IOException;
+
 import static org.junit.Assert.*;
 
 
@@ -66,9 +62,9 @@ public class CollectionsResourceIT extends AbstractRestIT {
         try {
             this.clientSetup.getRestClient().org(org).app(app).collection("cities").get();
             fail("Call to bad path exists, but it should not");
-        } catch (UniformInterfaceException e) {
+        } catch (ResponseProcessingException e) {
             //verify the correct error was returned
-            JsonNode node = mapper.readTree( e.getResponse().getEntity( String.class ));
+            JsonNode node = mapper.readTree( e.getResponse().readEntity( String.class ));
             assertEquals( "organization_application_not_found", node.get( "error" ).textValue() );
         }
 
@@ -79,9 +75,9 @@ public class CollectionsResourceIT extends AbstractRestIT {
         try {
             this.clientSetup.getRestClient().org(org).app(app).collection("cities").post(payload);
             fail("Call to bad path exists, but it should not");
-        } catch (UniformInterfaceException e) {
+        } catch (ResponseProcessingException e) {
             //verify the correct error was returned
-            JsonNode node = mapper.readTree( e.getResponse().getEntity( String.class ));
+            JsonNode node = mapper.readTree( e.getResponse().readEntity( String.class ));
             assertEquals( "organization_application_not_found", node.get( "error" ).textValue() );
         }
 
@@ -89,9 +85,9 @@ public class CollectionsResourceIT extends AbstractRestIT {
         try {
             this.clientSetup.getRestClient().org(org).app(app).collection("cities").entity(entity).put(payload);
             fail("Call to bad path exists, but it should not");
-        } catch (UniformInterfaceException e) {
+        } catch (ResponseProcessingException e) {
             //verify the correct error was returned
-            JsonNode node = mapper.readTree( e.getResponse().getEntity( String.class ));
+            JsonNode node = mapper.readTree( e.getResponse().readEntity( String.class ));
             assertEquals( "organization_application_not_found", node.get( "error" ).textValue() );
         }
 
@@ -99,9 +95,9 @@ public class CollectionsResourceIT extends AbstractRestIT {
         try {
             this.clientSetup.getRestClient().org(org).app(app).collection("cities").entity(entity).delete();
             fail("Call to bad path exists, but it should not");
-        } catch (UniformInterfaceException e) {
+        } catch (ResponseProcessingException e) {
             //verify the correct error was returned
-            JsonNode node = mapper.readTree( e.getResponse().getEntity( String.class ));
+            JsonNode node = mapper.readTree( e.getResponse().readEntity( String.class ));
             assertEquals( "organization_application_not_found", node.get( "error" ).textValue() );
         }
 


[45/54] usergrid git commit: Merge branch 'two-dot-o-dev' of https://git-wip-us.apache.org/repos/asf/usergrid into 2.1-release

Posted by sn...@apache.org.
Merge branch 'two-dot-o-dev' of https://git-wip-us.apache.org/repos/asf/usergrid into 2.1-release


Project: http://git-wip-us.apache.org/repos/asf/usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/usergrid/commit/61dd5595
Tree: http://git-wip-us.apache.org/repos/asf/usergrid/tree/61dd5595
Diff: http://git-wip-us.apache.org/repos/asf/usergrid/diff/61dd5595

Branch: refs/heads/usergrid-1007-shiro-cache
Commit: 61dd5595a820ad5120e99523414050673e3d2cc4
Parents: fad32aa 9294af7
Author: Shawn Feldman <sf...@apache.org>
Authored: Thu Sep 17 11:54:17 2015 -0600
Committer: Shawn Feldman <sf...@apache.org>
Committed: Thu Sep 17 11:54:17 2015 -0600

----------------------------------------------------------------------
 .../management/AppInfoMigrationPlugin.java      | 234 +++++++++----------
 1 file changed, 116 insertions(+), 118 deletions(-)
----------------------------------------------------------------------



[51/54] usergrid git commit: Merge branch 'USERGRID-1018' into 2.1-release

Posted by sn...@apache.org.
Merge branch 'USERGRID-1018' into 2.1-release


Project: http://git-wip-us.apache.org/repos/asf/usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/usergrid/commit/0c12abb1
Tree: http://git-wip-us.apache.org/repos/asf/usergrid/tree/0c12abb1
Diff: http://git-wip-us.apache.org/repos/asf/usergrid/diff/0c12abb1

Branch: refs/heads/usergrid-1007-shiro-cache
Commit: 0c12abb154c85ea5ccfd936490a2f84b0ffe5d24
Parents: 61dd559 0d4dd11
Author: Todd Nine <tn...@apigee.com>
Authored: Fri Sep 18 10:48:34 2015 -0600
Committer: Todd Nine <tn...@apigee.com>
Committed: Fri Sep 18 10:48:34 2015 -0600

----------------------------------------------------------------------
 .../usergrid/corepersistence/CoreModule.java    |  51 +++-
 .../corepersistence/CpRelationManager.java      |  23 +-
 .../asyncevents/AsyncEventService.java          |   2 +
 .../migration/CoreMigration.java                |  45 +---
 .../migration/CoreMigrationPlugin.java          |  38 ++-
 .../migration/DeDupConnectionDataMigration.java |  93 ++++++++
 .../migration/EntityTypeMappingMigration.java   | 104 --------
 .../migration/MigrationModuleVersionPlugin.java |   5 -
 .../corepersistence/migration/Versions.java     |  31 ---
 .../builder/PipelineBuilderFactory.java         |   3 +
 .../service/ConnectionScope.java                |  53 +++++
 .../service/ConnectionService.java              |  10 +
 .../service/ConnectionServiceImpl.java          |  89 ++++++-
 .../corepersistence/util/CpNamingUtils.java     |  13 +-
 .../corepersistence/TestCoreModule.java         |  34 +++
 .../DeDupConnectionDataMigrationTest.java       | 145 ++++++++++++
 .../migration/EntityTypeMappingMigrationIT.java | 125 ----------
 .../service/ConnectionServiceImplTest.java      | 235 +++++++++++++++++++
 stack/core/src/test/resources/log4j.properties  |   6 +-
 .../serialization/impl/SerializationModule.java |   4 +-
 .../migration/CollectionMigrationPlugin.java    |   8 +-
 .../migration/MvccEntityDataMigrationImpl.java  |  10 +-
 ...ctMvccEntityDataMigrationV1ToV3ImplTest.java |  39 +--
 .../migration/data/AbstractMigrationPlugin.java |  17 +-
 .../core/migration/data/DataMigration.java      |  11 +-
 .../migration/data/MigrationDataProvider.java   |   2 +-
 .../core/migration/data/MigrationPlugin.java    |   4 +-
 .../migration/schema/MigrationManagerFig.java   |   1 +
 .../migration/data/TestProgressObserver.java    |  10 +-
 .../persistence/graph/guice/GraphModule.java    |   4 +-
 .../graph/impl/GraphManagerImpl.java            |   4 +-
 .../impl/stage/EdgeDeleteListenerImpl.java      |   4 +-
 .../graph/impl/stage/EdgeDeleteRepairImpl.java  |  61 ++---
 .../impl/TargetIdObservableImpl.java            |  13 +-
 .../impl/migration/EdgeDataMigrationImpl.java   |  12 +-
 .../impl/migration/GraphMigrationPlugin.java    |   8 +-
 .../impl/shard/impl/EdgeSearcher.java           |  14 +-
 .../impl/ShardedEdgeSerializationImpl.java      |  59 +++--
 .../shard/impl/serialize/EdgeSerializer.java    |  21 +-
 .../persistence/graph/GraphManagerIT.java       |  73 +++++-
 .../migration/EdgeDataMigrationImplTest.java    |  59 +++--
 .../persistence/index/guice/IndexModule.java    |   4 +-
 .../index/migration/EsIndexMigrationPlugin.java |   8 +-
 43 files changed, 1038 insertions(+), 517 deletions(-)
----------------------------------------------------------------------



[42/54] usergrid git commit: change mappings file

Posted by sn...@apache.org.
change mappings file


Project: http://git-wip-us.apache.org/repos/asf/usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/usergrid/commit/fad32aa2
Tree: http://git-wip-us.apache.org/repos/asf/usergrid/tree/fad32aa2
Diff: http://git-wip-us.apache.org/repos/asf/usergrid/diff/fad32aa2

Branch: refs/heads/usergrid-1007-shiro-cache
Commit: fad32aa271820a83d34d7fc1be162a9751ef6808
Parents: 65d2608
Author: Shawn Feldman <sf...@apache.org>
Authored: Thu Sep 17 11:23:49 2015 -0600
Committer: Shawn Feldman <sf...@apache.org>
Committed: Thu Sep 17 11:23:49 2015 -0600

----------------------------------------------------------------------
 .../index/migration/EsIndexMappingMigrationPlugin.java          | 2 +-
 .../apache/usergrid/persistence/index/usergrid-mappings.json    | 5 -----
 2 files changed, 1 insertion(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/usergrid/blob/fad32aa2/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/migration/EsIndexMappingMigrationPlugin.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/migration/EsIndexMappingMigrationPlugin.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/migration/EsIndexMappingMigrationPlugin.java
index 6d46beb..5c2e9c1 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/migration/EsIndexMappingMigrationPlugin.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/migration/EsIndexMappingMigrationPlugin.java
@@ -136,7 +136,7 @@ public class EsIndexMappingMigrationPlugin implements MigrationPlugin {
 
     @Override
     public int getMaxVersion() {
-        return 1;
+        return 2;//1->new storage format,2->remove uuid
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/usergrid/blob/fad32aa2/stack/corepersistence/queryindex/src/main/resources/org/apache/usergrid/persistence/index/usergrid-mappings.json
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/resources/org/apache/usergrid/persistence/index/usergrid-mappings.json b/stack/corepersistence/queryindex/src/main/resources/org/apache/usergrid/persistence/index/usergrid-mappings.json
index 1b6a7f3..3d2517c 100644
--- a/stack/corepersistence/queryindex/src/main/resources/org/apache/usergrid/persistence/index/usergrid-mappings.json
+++ b/stack/corepersistence/queryindex/src/main/resources/org/apache/usergrid/persistence/index/usergrid-mappings.json
@@ -90,11 +90,6 @@
                                 "ignore_above": 10922
                             }
                         }
-                    },
-                    "uuid": {
-                        "type": "string",
-                        "index": "not_analyzed",
-                        "doc_values": true
                     }
                 }
             }


[25/54] usergrid git commit: Give build a unique version number just during testing 2.1.0-JERSEY-TEST

Posted by sn...@apache.org.
Give build a unique version number just during testing 2.1.0-JERSEY-TEST


Project: http://git-wip-us.apache.org/repos/asf/usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/usergrid/commit/2888a7cf
Tree: http://git-wip-us.apache.org/repos/asf/usergrid/tree/2888a7cf
Diff: http://git-wip-us.apache.org/repos/asf/usergrid/diff/2888a7cf

Branch: refs/heads/usergrid-1007-shiro-cache
Commit: 2888a7cfebd9d7f13292dcf8c1de74b5278bf542
Parents: 3343e2d
Author: Dave Johnson <sn...@apache.org>
Authored: Thu Sep 10 16:34:05 2015 -0400
Committer: Dave Johnson <sn...@apache.org>
Committed: Thu Sep 10 16:34:05 2015 -0400

----------------------------------------------------------------------
 stack/build-tools/pom.xml                |  2 +-
 stack/config/pom.xml                     |  2 +-
 stack/core/pom.xml                       | 14 +++++++-------
 stack/corepersistence/collection/pom.xml |  2 +-
 stack/corepersistence/common/pom.xml     |  2 +-
 stack/corepersistence/graph/pom.xml      |  2 +-
 stack/corepersistence/map/pom.xml        |  2 +-
 stack/corepersistence/model/pom.xml      |  2 +-
 stack/corepersistence/pom.xml            |  2 +-
 stack/corepersistence/queryindex/pom.xml |  2 +-
 stack/corepersistence/queue/pom.xml      |  2 +-
 stack/pom.xml                            |  2 +-
 stack/rest/pom.xml                       |  2 +-
 stack/services/pom.xml                   |  2 +-
 stack/test-utils/pom.xml                 |  2 +-
 15 files changed, 21 insertions(+), 21 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/usergrid/blob/2888a7cf/stack/build-tools/pom.xml
----------------------------------------------------------------------
diff --git a/stack/build-tools/pom.xml b/stack/build-tools/pom.xml
index eb84fea..27c558a 100644
--- a/stack/build-tools/pom.xml
+++ b/stack/build-tools/pom.xml
@@ -22,7 +22,7 @@
   <parent>
     <groupId>org.apache.usergrid</groupId>
     <artifactId>usergrid</artifactId>
-    <version>2.1.0-SNAPSHOT</version>
+    <version>2.1.0-JERSEY-TEST</version>
     <relativePath>../</relativePath>
   </parent>
 

http://git-wip-us.apache.org/repos/asf/usergrid/blob/2888a7cf/stack/config/pom.xml
----------------------------------------------------------------------
diff --git a/stack/config/pom.xml b/stack/config/pom.xml
index 32de5aa..bc8f87a 100644
--- a/stack/config/pom.xml
+++ b/stack/config/pom.xml
@@ -21,7 +21,7 @@
   <parent>
     <groupId>org.apache.usergrid</groupId>
     <artifactId>usergrid</artifactId>
-    <version>2.1.0-SNAPSHOT</version>
+    <version>2.1.0-JERSEY-TEST</version>
     <relativePath>../</relativePath>
   </parent>
 

http://git-wip-us.apache.org/repos/asf/usergrid/blob/2888a7cf/stack/core/pom.xml
----------------------------------------------------------------------
diff --git a/stack/core/pom.xml b/stack/core/pom.xml
index be2d28c..a6eb5e8 100644
--- a/stack/core/pom.xml
+++ b/stack/core/pom.xml
@@ -21,7 +21,7 @@
   <parent>
     <groupId>org.apache.usergrid</groupId>
     <artifactId>usergrid</artifactId>
-    <version>2.1.0-SNAPSHOT</version>
+    <version>2.1.0-JERSEY-TEST</version>
     <relativePath>../</relativePath>
   </parent>
 
@@ -418,7 +418,7 @@
        <dependency>
         <groupId>org.apache.usergrid</groupId>
         <artifactId>common</artifactId>
-        <version>2.1.0-SNAPSHOT</version>
+        <version>2.1.0-JERSEY-TEST</version>
         <type>test-jar</type>
            <scope>test</scope>
        </dependency>
@@ -427,7 +427,7 @@
     <dependency>
 	    <groupId>org.apache.usergrid</groupId>
 	    <artifactId>collection</artifactId>
-	    <version>2.1.0-SNAPSHOT</version>
+	    <version>2.1.0-JERSEY-TEST</version>
 	    <type>jar</type>
       <exclusions>
         <exclusion>
@@ -445,28 +445,28 @@
     <dependency>
 	    <groupId>org.apache.usergrid</groupId>
 	    <artifactId>queryindex</artifactId>
-	    <version>2.1.0-SNAPSHOT</version>
+	    <version>2.1.0-JERSEY-TEST</version>
 	    <type>jar</type>
     </dependency>
 
     <dependency>
 	    <groupId>org.apache.usergrid</groupId>
 	    <artifactId>graph</artifactId>
-	    <version>2.1.0-SNAPSHOT</version>
+	    <version>2.1.0-JERSEY-TEST</version>
 	    <type>jar</type>
     </dependency>
 
     <dependency>
       <groupId>org.apache.usergrid</groupId>
       <artifactId>map</artifactId>
-      <version>2.1.0-SNAPSHOT</version>
+      <version>2.1.0-JERSEY-TEST</version>
       <type>jar</type>
     </dependency>
 
     <dependency>
       <groupId>org.apache.usergrid</groupId>
       <artifactId>queue</artifactId>
-      <version>2.1.0-SNAPSHOT</version>
+      <version>2.1.0-JERSEY-TEST</version>
       <type>jar</type>
     </dependency>
 

http://git-wip-us.apache.org/repos/asf/usergrid/blob/2888a7cf/stack/corepersistence/collection/pom.xml
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/pom.xml b/stack/corepersistence/collection/pom.xml
index 4eaa393..ccb5fc5 100644
--- a/stack/corepersistence/collection/pom.xml
+++ b/stack/corepersistence/collection/pom.xml
@@ -6,7 +6,7 @@
   <parent>
     <artifactId>persistence</artifactId>
     <groupId>org.apache.usergrid</groupId>
-    <version>2.1.0-SNAPSHOT</version>
+    <version>2.1.0-JERSEY-TEST</version>
   </parent>
 
   <modelVersion>4.0.0</modelVersion>

http://git-wip-us.apache.org/repos/asf/usergrid/blob/2888a7cf/stack/corepersistence/common/pom.xml
----------------------------------------------------------------------
diff --git a/stack/corepersistence/common/pom.xml b/stack/corepersistence/common/pom.xml
index 84f09de..d7ac1ee 100644
--- a/stack/corepersistence/common/pom.xml
+++ b/stack/corepersistence/common/pom.xml
@@ -5,7 +5,7 @@
   <parent>
     <artifactId>persistence</artifactId>
     <groupId>org.apache.usergrid</groupId>
-    <version>2.1.0-SNAPSHOT</version>
+    <version>2.1.0-JERSEY-TEST</version>
   </parent>
   <modelVersion>4.0.0</modelVersion>
 

http://git-wip-us.apache.org/repos/asf/usergrid/blob/2888a7cf/stack/corepersistence/graph/pom.xml
----------------------------------------------------------------------
diff --git a/stack/corepersistence/graph/pom.xml b/stack/corepersistence/graph/pom.xml
index 3dde8bb..460bdca 100644
--- a/stack/corepersistence/graph/pom.xml
+++ b/stack/corepersistence/graph/pom.xml
@@ -24,7 +24,7 @@
   <parent>
     <artifactId>persistence</artifactId>
     <groupId>org.apache.usergrid</groupId>
-    <version>2.1.0-SNAPSHOT</version>
+    <version>2.1.0-JERSEY-TEST</version>
   </parent>
 
   <modelVersion>4.0.0</modelVersion>

http://git-wip-us.apache.org/repos/asf/usergrid/blob/2888a7cf/stack/corepersistence/map/pom.xml
----------------------------------------------------------------------
diff --git a/stack/corepersistence/map/pom.xml b/stack/corepersistence/map/pom.xml
index 7b367ba..c84db70 100644
--- a/stack/corepersistence/map/pom.xml
+++ b/stack/corepersistence/map/pom.xml
@@ -22,7 +22,7 @@ limitations under the License.
   <parent>
     <artifactId>persistence</artifactId>
     <groupId>org.apache.usergrid</groupId>
-    <version>2.1.0-SNAPSHOT</version>
+    <version>2.1.0-JERSEY-TEST</version>
   </parent>
 
   <modelVersion>4.0.0</modelVersion>

http://git-wip-us.apache.org/repos/asf/usergrid/blob/2888a7cf/stack/corepersistence/model/pom.xml
----------------------------------------------------------------------
diff --git a/stack/corepersistence/model/pom.xml b/stack/corepersistence/model/pom.xml
index 142bca1..5429a49 100644
--- a/stack/corepersistence/model/pom.xml
+++ b/stack/corepersistence/model/pom.xml
@@ -5,7 +5,7 @@
     <parent>
         <artifactId>persistence</artifactId>
         <groupId>org.apache.usergrid</groupId>
-        <version>2.1.0-SNAPSHOT</version>
+        <version>2.1.0-JERSEY-TEST</version>
     </parent>
     <modelVersion>4.0.0</modelVersion>
 

http://git-wip-us.apache.org/repos/asf/usergrid/blob/2888a7cf/stack/corepersistence/pom.xml
----------------------------------------------------------------------
diff --git a/stack/corepersistence/pom.xml b/stack/corepersistence/pom.xml
index 4b47bc0..8fb1d25 100644
--- a/stack/corepersistence/pom.xml
+++ b/stack/corepersistence/pom.xml
@@ -26,7 +26,7 @@ limitations under the License.
     <artifactId>persistence</artifactId>
     <name>Usergrid Persistence</name>
     <packaging>pom</packaging>
-    <version>2.1.0-SNAPSHOT</version>
+    <version>2.1.0-JERSEY-TEST</version>
 
   <profiles>
     <!-- better to have keep this sonar profile in your maven settings.xml -->

http://git-wip-us.apache.org/repos/asf/usergrid/blob/2888a7cf/stack/corepersistence/queryindex/pom.xml
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/pom.xml b/stack/corepersistence/queryindex/pom.xml
index 2484cfd..97732ff 100644
--- a/stack/corepersistence/queryindex/pom.xml
+++ b/stack/corepersistence/queryindex/pom.xml
@@ -6,7 +6,7 @@
     <parent>
         <artifactId>persistence</artifactId>
         <groupId>org.apache.usergrid</groupId>
-        <version>2.1.0-SNAPSHOT</version>
+        <version>2.1.0-JERSEY-TEST</version>
     </parent>
 
     <modelVersion>4.0.0</modelVersion>

http://git-wip-us.apache.org/repos/asf/usergrid/blob/2888a7cf/stack/corepersistence/queue/pom.xml
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queue/pom.xml b/stack/corepersistence/queue/pom.xml
index 2d46dc8..86d387d 100644
--- a/stack/corepersistence/queue/pom.xml
+++ b/stack/corepersistence/queue/pom.xml
@@ -24,7 +24,7 @@
   <parent>
     <artifactId>persistence</artifactId>
     <groupId>org.apache.usergrid</groupId>
-    <version>2.1.0-SNAPSHOT</version>
+    <version>2.1.0-JERSEY-TEST</version>
   </parent>
 
   <modelVersion>4.0.0</modelVersion>

http://git-wip-us.apache.org/repos/asf/usergrid/blob/2888a7cf/stack/pom.xml
----------------------------------------------------------------------
diff --git a/stack/pom.xml b/stack/pom.xml
index 93733aa..c05eae7 100644
--- a/stack/pom.xml
+++ b/stack/pom.xml
@@ -27,7 +27,7 @@
 
   <groupId>org.apache.usergrid</groupId>
   <artifactId>usergrid</artifactId>
-  <version>2.1.0-SNAPSHOT</version>
+  <version>2.1.0-JERSEY-TEST</version>
   <name>Usergrid Parent</name>
   <description>Parent module for the Apache Usergrid Project</description>
   <packaging>pom</packaging>

http://git-wip-us.apache.org/repos/asf/usergrid/blob/2888a7cf/stack/rest/pom.xml
----------------------------------------------------------------------
diff --git a/stack/rest/pom.xml b/stack/rest/pom.xml
index ebbc375..2aee114 100644
--- a/stack/rest/pom.xml
+++ b/stack/rest/pom.xml
@@ -21,7 +21,7 @@
     <parent>
         <groupId>org.apache.usergrid</groupId>
         <artifactId>usergrid</artifactId>
-        <version>2.1.0-SNAPSHOT</version>
+        <version>2.1.0-JERSEY-TEST</version>
     </parent>
 
     <artifactId>usergrid-rest</artifactId>

http://git-wip-us.apache.org/repos/asf/usergrid/blob/2888a7cf/stack/services/pom.xml
----------------------------------------------------------------------
diff --git a/stack/services/pom.xml b/stack/services/pom.xml
index a771b34..82f7373 100644
--- a/stack/services/pom.xml
+++ b/stack/services/pom.xml
@@ -21,7 +21,7 @@
   <parent>
     <groupId>org.apache.usergrid</groupId>
     <artifactId>usergrid</artifactId>
-    <version>2.1.0-SNAPSHOT</version>
+    <version>2.1.0-JERSEY-TEST</version>
     <relativePath>../</relativePath>
   </parent>
 

http://git-wip-us.apache.org/repos/asf/usergrid/blob/2888a7cf/stack/test-utils/pom.xml
----------------------------------------------------------------------
diff --git a/stack/test-utils/pom.xml b/stack/test-utils/pom.xml
index b28d170..bb80546 100644
--- a/stack/test-utils/pom.xml
+++ b/stack/test-utils/pom.xml
@@ -21,7 +21,7 @@
     <parent>
         <groupId>org.apache.usergrid</groupId>
         <artifactId>usergrid</artifactId>
-        <version>2.1.0-SNAPSHOT</version>
+        <version>2.1.0-JERSEY-TEST</version>
     </parent>
 
     <artifactId>usergrid-test-utils</artifactId>


[06/54] usergrid git commit: Switch to Jersey 2, fix all compilation errors. TODO: new MeteringFilter, new JSON-HTMP swap logic and correct use of dependency management.

Posted by sn...@apache.org.
http://git-wip-us.apache.org/repos/asf/usergrid/blob/0578d987/stack/rest/src/main/java/org/apache/usergrid/rest/applications/queues/QueueResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/applications/queues/QueueResource.java b/stack/rest/src/main/java/org/apache/usergrid/rest/applications/queues/QueueResource.java
index 67498cd..9b9207b 100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/applications/queues/QueueResource.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/applications/queues/QueueResource.java
@@ -17,39 +17,23 @@
 package org.apache.usergrid.rest.applications.queues;
 
 
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import javax.ws.rs.Consumes;
-import javax.ws.rs.DELETE;
-import javax.ws.rs.DefaultValue;
-import javax.ws.rs.GET;
-import javax.ws.rs.POST;
-import javax.ws.rs.PUT;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.Produces;
-import javax.ws.rs.QueryParam;
-import javax.ws.rs.core.Context;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.UriInfo;
-
+import com.fasterxml.jackson.jaxrs.json.annotation.JSONP;
+import org.apache.commons.lang.StringUtils;
+import org.apache.usergrid.exception.NotImplementedException;
+import org.apache.usergrid.mq.*;
+import org.apache.usergrid.rest.AbstractContextResource;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.context.annotation.Scope;
 import org.springframework.stereotype.Component;
-import org.apache.usergrid.exception.NotImplementedException;
-import org.apache.usergrid.mq.Message;
-import org.apache.usergrid.mq.QueueManager;
-import org.apache.usergrid.mq.QueueQuery;
-import org.apache.usergrid.mq.QueueResults;
-import org.apache.usergrid.rest.AbstractContextResource;
-
-import org.apache.commons.lang.StringUtils;
 
-import com.sun.jersey.api.json.JSONWithPadding;
-import com.sun.jersey.core.provider.EntityHolder;
+import javax.ws.rs.*;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.UriInfo;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
 
 
 @Component
@@ -106,31 +90,37 @@ public class QueueResource extends AbstractContextResource {
 
     @Path("properties")
     @GET
-    public JSONWithPadding getProperties( @Context UriInfo ui,
+    @JSONP
+    @Produces({"application/json", "application/javascript"})
+    public Queue getProperties( @Context UriInfo ui,
                                           @QueryParam("callback") @DefaultValue("callback") String callback )
             throws Exception {
 
         logger.info( "QueueResource.getProperties" );
 
-        return new JSONWithPadding( mq.getQueue( queuePath ), callback );
+        return mq.getQueue( queuePath );
     }
 
 
     @Path("properties")
     @PUT
     @Consumes(MediaType.APPLICATION_JSON)
-    public JSONWithPadding putProperties( @Context UriInfo ui, Map<String, Object> json,
+    @JSONP
+    @Produces({"application/json", "application/javascript"})
+    public Queue putProperties( @Context UriInfo ui, Map<String, Object> json,
                                           @QueryParam("callback") @DefaultValue("callback") String callback )
             throws Exception {
 
         logger.info( "QueueResource.putProperties" );
 
-        return new JSONWithPadding( mq.updateQueue( queuePath, json ), callback );
+        return mq.updateQueue( queuePath, json );
     }
 
 
     @GET
-    public JSONWithPadding executeGet( @Context UriInfo ui, @QueryParam("start") String firstQueuePath,
+    @JSONP
+    @Produces({"application/json", "application/javascript"})
+    public Object executeGet( @Context UriInfo ui, @QueryParam("start") String firstQueuePath,
                                        @QueryParam("limit") @DefaultValue("10") int limit,
                                        @QueryParam("callback") @DefaultValue("callback") String callback )
             throws Exception {
@@ -140,33 +130,32 @@ public class QueueResource extends AbstractContextResource {
 
             QueueQuery query = QueueQuery.fromQueryParams( ui.getQueryParameters() );
             QueueResults results = mq.getFromQueue( queuePath, query );
-            return new JSONWithPadding( results, callback );
+            return results;
         }
 
         logger.info( "QueueResource.executeGet" );
 
-        return new JSONWithPadding( mq.getQueues( firstQueuePath, limit ), callback );
+        return  mq.getQueues( firstQueuePath, limit );
     }
 
 
     @SuppressWarnings("unchecked")
     @POST
     @Consumes(MediaType.APPLICATION_JSON)
-    public JSONWithPadding executePost( @Context UriInfo ui, EntityHolder<Object> body,
+    @JSONP
+    @Produces({"application/json", "application/javascript"})
+    public QueueResults executePost( @Context UriInfo ui, Object body,
                                         @QueryParam("callback") @DefaultValue("callback") String callback )
             throws Exception {
 
         logger.info( "QueueResource.executePost: " + queuePath );
-        Object json = body.getEntity();
+        Object json = body;
 
         if ( json instanceof Map ) {
-            return new JSONWithPadding(
-                    new QueueResults( mq.postToQueue( queuePath, new Message( ( Map<String, Object> ) json ) ) ),
-                    callback );
+            return new QueueResults( mq.postToQueue( queuePath, new Message( ( Map<String, Object> ) json ) ));
         }
         else if ( json instanceof List ) {
-            return new JSONWithPadding( new QueueResults(
-                    mq.postToQueue( queuePath, Message.fromList( ( List<Map<String, Object>> ) json ) ) ), callback );
+            return new QueueResults( mq.postToQueue( queuePath, Message.fromList( ( List<Map<String, Object>> ) json ) ) );
         }
 
         return null;
@@ -175,7 +164,9 @@ public class QueueResource extends AbstractContextResource {
 
     @PUT
     @Consumes(MediaType.APPLICATION_JSON)
-    public JSONWithPadding executePut( @Context UriInfo ui, Map<String, Object> json,
+    @JSONP
+    @Produces({"application/json", "application/javascript"})
+    public Map<String, Object> executePut( @Context UriInfo ui, Map<String, Object> json,
                                        @QueryParam("callback") @DefaultValue("callback") String callback )
             throws Exception {
 
@@ -183,14 +174,15 @@ public class QueueResource extends AbstractContextResource {
 
         Map<String, Object> results = new HashMap<String, Object>();
 
-        return new JSONWithPadding( results, callback );
+        return results;
     }
 
 
     @DELETE
-    public JSONWithPadding executeDelete( @Context UriInfo ui,
-                                          @QueryParam("callback") @DefaultValue("callback") String callback )
-            throws Exception {
+    @JSONP
+    @Produces({"application/json", "application/javascript"})
+    public Queue executeDelete(
+            @Context UriInfo ui, @QueryParam("callback") @DefaultValue("callback") String callback ) throws Exception {
         throw new NotImplementedException( "Queue delete is not implemented yet" );
     }
 

http://git-wip-us.apache.org/repos/asf/usergrid/blob/0578d987/stack/rest/src/main/java/org/apache/usergrid/rest/applications/queues/QueueSubscriberResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/applications/queues/QueueSubscriberResource.java b/stack/rest/src/main/java/org/apache/usergrid/rest/applications/queues/QueueSubscriberResource.java
index 12db937..5e6b57d 100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/applications/queues/QueueSubscriberResource.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/applications/queues/QueueSubscriberResource.java
@@ -17,35 +17,22 @@
 package org.apache.usergrid.rest.applications.queues;
 
 
-import java.util.List;
-import java.util.Map;
-
-import javax.ws.rs.Consumes;
-import javax.ws.rs.DELETE;
-import javax.ws.rs.DefaultValue;
-import javax.ws.rs.GET;
-import javax.ws.rs.POST;
-import javax.ws.rs.PUT;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.Produces;
-import javax.ws.rs.QueryParam;
-import javax.ws.rs.core.Context;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.UriInfo;
-
+import com.fasterxml.jackson.jaxrs.json.annotation.JSONP;
+import org.apache.commons.lang.StringUtils;
+import org.apache.usergrid.mq.QueueManager;
+import org.apache.usergrid.mq.QueueSet;
+import org.apache.usergrid.rest.AbstractContextResource;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.context.annotation.Scope;
 import org.springframework.stereotype.Component;
-import org.apache.usergrid.mq.QueueManager;
-import org.apache.usergrid.mq.QueueSet;
-import org.apache.usergrid.rest.AbstractContextResource;
-
-import org.apache.commons.lang.StringUtils;
 
-import com.sun.jersey.api.json.JSONWithPadding;
-import com.sun.jersey.core.provider.EntityHolder;
+import javax.ws.rs.*;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.UriInfo;
+import java.util.List;
+import java.util.Map;
 
 
 @Component
@@ -93,7 +80,9 @@ public class QueueSubscriberResource extends AbstractContextResource {
 
 
     @GET
-    public JSONWithPadding executeGet( @Context UriInfo ui, @QueryParam("start") String firstSubscriberQueuePath,
+    @JSONP
+    @Produces({"application/json", "application/javascript"})
+    public QueueSet executeGet( @Context UriInfo ui, @QueryParam("start") String firstSubscriberQueuePath,
                                        @QueryParam("limit") @DefaultValue("10") int limit,
                                        @QueryParam("callback") @DefaultValue("callback") String callback )
             throws Exception {
@@ -102,13 +91,15 @@ public class QueueSubscriberResource extends AbstractContextResource {
 
         QueueSet results = mq.getSubscribers( queuePath, firstSubscriberQueuePath, limit );
 
-        return new JSONWithPadding( results, callback );
+        return results;
     }
 
 
     @POST
     @Consumes(MediaType.APPLICATION_JSON)
-    public JSONWithPadding executePost( @Context UriInfo ui, EntityHolder<Map<String, Object>> body,
+    @JSONP
+    @Produces({"application/json", "application/javascript"})
+    public QueueSet executePost( @Context UriInfo ui, Map<String, Object> body,
                                         @QueryParam("callback") @DefaultValue("callback") String callback )
             throws Exception {
 
@@ -120,23 +111,25 @@ public class QueueSubscriberResource extends AbstractContextResource {
 
     @PUT
     @Consumes(MediaType.APPLICATION_JSON)
-    public JSONWithPadding executePut( @Context UriInfo ui, EntityHolder<Map<String, Object>> body,
+    @JSONP
+    @Produces({"application/json", "application/javascript"})
+    public QueueSet executePut( @Context UriInfo ui, Map<String, Object> body,
                                        @QueryParam("callback") @DefaultValue("callback") String callback )
             throws Exception {
 
         logger.info( "QueueSubscriberResource.executePut: " + queuePath );
 
-        Map<String, Object> json = body.getEntity();
+        Map<String, Object> json = body;
         if ( StringUtils.isNotBlank( subscriberPath ) ) {
-            return new JSONWithPadding( mq.subscribeToQueue( queuePath, subscriberPath ), callback );
+            return mq.subscribeToQueue( queuePath, subscriberPath );
         }
         else if ( ( json != null ) && ( json.containsKey( "subscriber" ) ) ) {
             String subscriber = ( String ) json.get( "subscriber" );
-            return new JSONWithPadding( mq.subscribeToQueue( queuePath, subscriber ), callback );
+            return mq.subscribeToQueue( queuePath, subscriber );
         }
         else if ( ( json != null ) && ( json.containsKey( "subscribers" ) ) ) {
             @SuppressWarnings("unchecked") List<String> subscribers = ( List<String> ) json.get( "subscribers" );
-            return new JSONWithPadding( mq.addSubscribersToQueue( queuePath, subscribers ), callback );
+            return mq.addSubscribersToQueue( queuePath, subscribers );
         }
 
         return null;
@@ -144,14 +137,16 @@ public class QueueSubscriberResource extends AbstractContextResource {
 
 
     @DELETE
-    public JSONWithPadding executeDelete( @Context UriInfo ui,
+    @JSONP
+    @Produces({"application/json", "application/javascript"})
+    public QueueSet executeDelete( @Context UriInfo ui,
                                           @QueryParam("callback") @DefaultValue("callback") String callback )
             throws Exception {
 
         logger.info( "QueueSubscriberResource.executeDelete: " + queuePath );
 
         if ( StringUtils.isNotBlank( subscriberPath ) ) {
-            return new JSONWithPadding( mq.unsubscribeFromQueue( queuePath, subscriberPath ), callback );
+            return mq.unsubscribeFromQueue( queuePath, subscriberPath );
         }
 
         return null;

http://git-wip-us.apache.org/repos/asf/usergrid/blob/0578d987/stack/rest/src/main/java/org/apache/usergrid/rest/applications/queues/QueueSubscriptionResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/applications/queues/QueueSubscriptionResource.java b/stack/rest/src/main/java/org/apache/usergrid/rest/applications/queues/QueueSubscriptionResource.java
index a822b1e..b99ecad 100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/applications/queues/QueueSubscriptionResource.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/applications/queues/QueueSubscriptionResource.java
@@ -17,35 +17,22 @@
 package org.apache.usergrid.rest.applications.queues;
 
 
-import java.util.List;
-import java.util.Map;
-
-import javax.ws.rs.Consumes;
-import javax.ws.rs.DELETE;
-import javax.ws.rs.DefaultValue;
-import javax.ws.rs.GET;
-import javax.ws.rs.POST;
-import javax.ws.rs.PUT;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.Produces;
-import javax.ws.rs.QueryParam;
-import javax.ws.rs.core.Context;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.UriInfo;
-
+import com.fasterxml.jackson.jaxrs.json.annotation.JSONP;
+import org.apache.commons.lang.StringUtils;
+import org.apache.usergrid.mq.QueueManager;
+import org.apache.usergrid.mq.QueueSet;
+import org.apache.usergrid.rest.AbstractContextResource;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.context.annotation.Scope;
 import org.springframework.stereotype.Component;
-import org.apache.usergrid.mq.QueueManager;
-import org.apache.usergrid.mq.QueueSet;
-import org.apache.usergrid.rest.AbstractContextResource;
-
-import org.apache.commons.lang.StringUtils;
 
-import com.sun.jersey.api.json.JSONWithPadding;
-import com.sun.jersey.core.provider.EntityHolder;
+import javax.ws.rs.*;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.UriInfo;
+import java.util.List;
+import java.util.Map;
 
 
 @Component
@@ -95,7 +82,9 @@ public class QueueSubscriptionResource extends AbstractContextResource {
 
 
     @GET
-    public JSONWithPadding executeGet( @Context UriInfo ui, @QueryParam("start") String firstSubscriptionQueuePath,
+    @JSONP
+    @Produces({"application/json", "application/javascript"})
+    public QueueSet executeGet( @Context UriInfo ui, @QueryParam("start") String firstSubscriptionQueuePath,
                                        @QueryParam("limit") @DefaultValue("10") int limit,
                                        @QueryParam("callback") @DefaultValue("callback") String callback )
             throws Exception {
@@ -104,13 +93,15 @@ public class QueueSubscriptionResource extends AbstractContextResource {
 
         QueueSet results = mq.getSubscriptions( queuePath, firstSubscriptionQueuePath, limit );
 
-        return new JSONWithPadding( results, callback );
+        return results;
     }
 
 
     @POST
     @Consumes(MediaType.APPLICATION_JSON)
-    public JSONWithPadding executePost( @Context UriInfo ui, EntityHolder<Map<String, Object>> body,
+    @JSONP
+    @Produces({"application/json", "application/javascript"})
+    public QueueSet executePost( @Context UriInfo ui, Map<String, Object> body,
                                         @QueryParam("callback") @DefaultValue("callback") String callback )
             throws Exception {
 
@@ -122,23 +113,25 @@ public class QueueSubscriptionResource extends AbstractContextResource {
 
     @PUT
     @Consumes(MediaType.APPLICATION_JSON)
-    public JSONWithPadding executePut( @Context UriInfo ui, EntityHolder<Map<String, Object>> body,
+    @JSONP
+    @Produces({"application/json", "application/javascript"})
+    public QueueSet executePut( @Context UriInfo ui, Map<String, Object> body,
                                        @QueryParam("callback") @DefaultValue("callback") String callback )
             throws Exception {
 
         logger.info( "QueueSubscriptionResource.executePut: " + queuePath );
 
-        Map<String, Object> json = body.getEntity();
+        Map<String, Object> json = body;
         if ( StringUtils.isNotBlank( subscriptionPath ) ) {
-            return new JSONWithPadding( mq.subscribeToQueue( subscriptionPath, queuePath ), callback );
+            return mq.subscribeToQueue( subscriptionPath, queuePath );
         }
         else if ( ( json != null ) && ( json.containsKey( "subscriber" ) ) ) {
             String supscription = ( String ) json.get( "supscription" );
-            return new JSONWithPadding( mq.subscribeToQueue( supscription, queuePath ), callback );
+            return mq.subscribeToQueue( supscription, queuePath );
         }
         else if ( ( json != null ) && ( json.containsKey( "subscribers" ) ) ) {
             @SuppressWarnings("unchecked") List<String> supscriptions = ( List<String> ) json.get( "supscriptions" );
-            return new JSONWithPadding( mq.unsubscribeFromQueues( queuePath, supscriptions ), callback );
+            return  mq.unsubscribeFromQueues( queuePath, supscriptions );
         }
 
         return null;
@@ -146,14 +139,16 @@ public class QueueSubscriptionResource extends AbstractContextResource {
 
 
     @DELETE
-    public JSONWithPadding executeDelete( @Context UriInfo ui,
+    @JSONP
+    @Produces({"application/json", "application/javascript"})
+    public QueueSet executeDelete( @Context UriInfo ui,
                                           @QueryParam("callback") @DefaultValue("callback") String callback )
             throws Exception {
 
         logger.info( "QueueSubscriptionResource.executeDelete: " + queuePath );
 
         if ( StringUtils.isNotBlank( subscriptionPath ) ) {
-            return new JSONWithPadding( mq.unsubscribeFromQueue( subscriptionPath, queuePath ), callback );
+            return  mq.unsubscribeFromQueue( subscriptionPath, queuePath );
         }
 
         return null;

http://git-wip-us.apache.org/repos/asf/usergrid/blob/0578d987/stack/rest/src/main/java/org/apache/usergrid/rest/applications/queues/QueueTransactionsResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/applications/queues/QueueTransactionsResource.java b/stack/rest/src/main/java/org/apache/usergrid/rest/applications/queues/QueueTransactionsResource.java
index 2f9819d..1e7e304 100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/applications/queues/QueueTransactionsResource.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/applications/queues/QueueTransactionsResource.java
@@ -17,29 +17,21 @@
 package org.apache.usergrid.rest.applications.queues;
 
 
-import java.util.UUID;
-
-import javax.ws.rs.DELETE;
-import javax.ws.rs.DefaultValue;
-import javax.ws.rs.PUT;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.Produces;
-import javax.ws.rs.QueryParam;
-import javax.ws.rs.core.Context;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.UriInfo;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.context.annotation.Scope;
-import org.springframework.stereotype.Component;
+import com.fasterxml.jackson.jaxrs.json.annotation.JSONP;
 import org.apache.usergrid.mq.QueueManager;
 import org.apache.usergrid.mq.QueueQuery;
 import org.apache.usergrid.persistence.Results;
 import org.apache.usergrid.rest.AbstractContextResource;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Component;
 
-import com.sun.jersey.api.json.JSONWithPadding;
+import javax.ws.rs.*;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.UriInfo;
+import java.util.UUID;
 
 import static org.apache.usergrid.utils.MapUtils.hashMap;
 
@@ -72,7 +64,9 @@ public class QueueTransactionsResource extends AbstractContextResource {
 
     @Path("{id}")
     @PUT
-    public JSONWithPadding updateTransaction( @Context UriInfo ui, @PathParam("id") UUID transactionId,
+    @JSONP
+    @Produces({"application/json", "application/javascript"})
+    public Results updateTransaction( @Context UriInfo ui, @PathParam("id") UUID transactionId,
                                               @QueryParam("callback") @DefaultValue("callback") String callback )
             throws Exception {
 
@@ -80,13 +74,15 @@ public class QueueTransactionsResource extends AbstractContextResource {
 
         UUID newTransactionId = mq.renewTransaction( queuePath, transactionId, query );
 
-        return new JSONWithPadding( Results.fromData( hashMap( "transaction", newTransactionId ) ), callback );
+        return Results.fromData( hashMap( "transaction", newTransactionId ) );
     }
 
 
     @Path("{id}")
     @DELETE
-    public JSONWithPadding removeTransaction( @Context UriInfo ui, @PathParam("id") UUID transactionId,
+    @JSONP
+    @Produces({"application/json", "application/javascript"})
+    public Results removeTransaction( @Context UriInfo ui, @PathParam("id") UUID transactionId,
                                               @QueryParam("callback") @DefaultValue("callback") String callback )
             throws Exception {
 
@@ -95,6 +91,6 @@ public class QueueTransactionsResource extends AbstractContextResource {
 
         mq.deleteTransaction( this.queuePath, transactionId, query );
 
-        return new JSONWithPadding( Results.fromData( hashMap( "transaction", transactionId ) ), callback );
+        return Results.fromData( hashMap( "transaction", transactionId ) );
     }
 }

http://git-wip-us.apache.org/repos/asf/usergrid/blob/0578d987/stack/rest/src/main/java/org/apache/usergrid/rest/applications/users/UserResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/applications/users/UserResource.java b/stack/rest/src/main/java/org/apache/usergrid/rest/applications/users/UserResource.java
index a8b0f81..95adfc4 100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/applications/users/UserResource.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/applications/users/UserResource.java
@@ -19,33 +19,16 @@ package org.apache.usergrid.rest.applications.users;
 
 import com.fasterxml.jackson.databind.JsonNode;
 import com.fasterxml.jackson.databind.ObjectMapper;
-import java.util.Map;
-import java.util.UUID;
-
-import javax.ws.rs.Consumes;
-import javax.ws.rs.DefaultValue;
-import javax.ws.rs.FormParam;
-import javax.ws.rs.GET;
-import javax.ws.rs.POST;
-import javax.ws.rs.PUT;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.Produces;
-import javax.ws.rs.QueryParam;
-import javax.ws.rs.core.Context;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.PathSegment;
-import javax.ws.rs.core.Response;
-import javax.ws.rs.core.UriInfo;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.context.annotation.Scope;
-import org.springframework.stereotype.Component;
+import com.fasterxml.jackson.jaxrs.json.annotation.JSONP;
+import net.tanesha.recaptcha.ReCaptchaImpl;
+import net.tanesha.recaptcha.ReCaptchaResponse;
+import org.apache.amber.oauth2.common.exception.OAuthProblemException;
+import org.apache.amber.oauth2.common.message.OAuthResponse;
+import org.apache.commons.lang.StringUtils;
 import org.apache.usergrid.management.ActivationState;
 import org.apache.usergrid.persistence.EntityManager;
-import org.apache.usergrid.persistence.index.query.Identifier;
 import org.apache.usergrid.persistence.entities.User;
+import org.apache.usergrid.persistence.index.query.Identifier;
 import org.apache.usergrid.rest.AbstractContextResource;
 import org.apache.usergrid.rest.ApiResponse;
 import org.apache.usergrid.rest.applications.ServiceResource;
@@ -53,24 +36,19 @@ import org.apache.usergrid.rest.exceptions.RedirectionException;
 import org.apache.usergrid.rest.security.annotations.RequireApplicationAccess;
 import org.apache.usergrid.security.oauth.AccessInfo;
 import org.apache.usergrid.security.tokens.exceptions.TokenException;
+import org.glassfish.jersey.server.mvc.Viewable;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Component;
 
-import org.apache.amber.oauth2.common.exception.OAuthProblemException;
-import org.apache.amber.oauth2.common.message.OAuthResponse;
-import org.apache.commons.lang.StringUtils;
-
-import com.sun.jersey.api.json.JSONWithPadding;
-import com.sun.jersey.api.view.Viewable;
-
-import net.tanesha.recaptcha.ReCaptchaImpl;
-import net.tanesha.recaptcha.ReCaptchaResponse;
-
-import static javax.servlet.http.HttpServletResponse.SC_BAD_REQUEST;
-import static javax.servlet.http.HttpServletResponse.SC_FORBIDDEN;
-import static javax.servlet.http.HttpServletResponse.SC_OK;
+import javax.ws.rs.*;
+import javax.ws.rs.core.*;
+import java.util.Map;
+import java.util.UUID;
 
-import static org.apache.usergrid.security.shiro.utils.SubjectUtils.getSubjectUserId;
-import static org.apache.usergrid.security.shiro.utils.SubjectUtils.isApplicationAdmin;
-import static org.apache.usergrid.security.shiro.utils.SubjectUtils.isApplicationUser;
+import static javax.servlet.http.HttpServletResponse.*;
+import static org.apache.usergrid.security.shiro.utils.SubjectUtils.*;
 import static org.apache.usergrid.utils.ConversionUtils.string;
 
 
@@ -105,7 +83,9 @@ public class UserResource extends ServiceResource {
     @PUT
     @RequireApplicationAccess
     @Consumes(MediaType.APPLICATION_JSON)
-    public JSONWithPadding executePut( @Context UriInfo ui, String body,
+    @JSONP
+    @Produces({"application/json", "application/javascript"})
+    public ApiResponse executePut( @Context UriInfo ui, String body,
                                        @QueryParam("callback") @DefaultValue("callback") String callback )
             throws Exception {
 
@@ -123,7 +103,9 @@ public class UserResource extends ServiceResource {
 
     @PUT
     @Path("password")
-    public JSONWithPadding setUserPasswordPut( @Context UriInfo ui, Map<String, Object> json,
+    @JSONP
+    @Produces({"application/json", "application/javascript"})
+    public ApiResponse setUserPasswordPut( @Context UriInfo ui, Map<String, Object> json,
                                                @QueryParam("callback") @DefaultValue("callback") String callback )
             throws Exception {
 
@@ -147,7 +129,7 @@ public class UserResource extends ServiceResource {
 
         if ( targetUserId == null ) {
             response.setError( "User not found" );
-            return new JSONWithPadding( response, callback );
+            return response;
         }
 
 
@@ -161,13 +143,15 @@ public class UserResource extends ServiceResource {
             management.setAppUserPassword( getApplicationId(), targetUserId, oldPassword, newPassword );
         }
 
-        return new JSONWithPadding( response, callback );
+        return response;
     }
 
 
     @POST
     @Path("password")
-    public JSONWithPadding setUserPasswordPost( @Context UriInfo ui, Map<String, Object> json,
+    @JSONP
+    @Produces({"application/json", "application/javascript"})
+    public ApiResponse setUserPasswordPost( @Context UriInfo ui, Map<String, Object> json,
                                                 @QueryParam("callback") @DefaultValue("callback") String callback )
             throws Exception {
         return setUserPasswordPut( ui, json, callback );
@@ -176,7 +160,9 @@ public class UserResource extends ServiceResource {
 
     @POST
     @Path("deactivate")
-    public JSONWithPadding deactivate( @Context UriInfo ui, Map<String, Object> json,
+    @JSONP
+    @Produces({"application/json", "application/javascript"})
+    public ApiResponse deactivate( @Context UriInfo ui, Map<String, Object> json,
                                        @QueryParam("callback") @DefaultValue("") String callback ) throws Exception {
 
         ApiResponse response = createApiResponse();
@@ -186,13 +172,15 @@ public class UserResource extends ServiceResource {
 
         response.withEntity( user );
 
-        return new JSONWithPadding( response, callback );
+        return response;
     }
 
 
     @GET
     @Path("sendpin")
-    public JSONWithPadding sendPin( @Context UriInfo ui,
+    @JSONP
+    @Produces({"application/json", "application/javascript"})
+    public ApiResponse sendPin( @Context UriInfo ui,
                                     @QueryParam("callback") @DefaultValue("callback") String callback )
             throws Exception {
 
@@ -208,13 +196,15 @@ public class UserResource extends ServiceResource {
             response.setError( "User not found" );
         }
 
-        return new JSONWithPadding( response, callback );
+        return response;
     }
 
 
     @POST
     @Path("sendpin")
-    public JSONWithPadding postSendPin( @Context UriInfo ui,
+    @JSONP
+    @Produces({"application/json", "application/javascript"})
+    public ApiResponse postSendPin( @Context UriInfo ui,
                                         @QueryParam("callback") @DefaultValue("callback") String callback )
             throws Exception {
         return sendPin( ui, callback );
@@ -224,7 +214,9 @@ public class UserResource extends ServiceResource {
     @GET
     @Path("setpin")
     @RequireApplicationAccess
-    public JSONWithPadding setPin( @Context UriInfo ui, @QueryParam("pin") String pin,
+    @JSONP
+    @Produces({"application/json", "application/javascript"})
+    public ApiResponse setPin( @Context UriInfo ui, @QueryParam("pin") String pin,
                                    @QueryParam("callback") @DefaultValue("callback") String callback )
             throws Exception {
 
@@ -240,7 +232,7 @@ public class UserResource extends ServiceResource {
             response.setError( "User not found" );
         }
 
-        return new JSONWithPadding( response, callback );
+        return response;
     }
 
 
@@ -248,7 +240,9 @@ public class UserResource extends ServiceResource {
     @Path("setpin")
     @Consumes("application/x-www-form-urlencoded")
     @RequireApplicationAccess
-    public JSONWithPadding postPin( @Context UriInfo ui, @FormParam("pin") String pin,
+    @JSONP
+    @Produces({"application/json", "application/javascript"})
+    public ApiResponse postPin( @Context UriInfo ui, @FormParam("pin") String pin,
                                     @QueryParam("callback") @DefaultValue("callback") String callback )
             throws Exception {
 
@@ -264,7 +258,7 @@ public class UserResource extends ServiceResource {
             response.setError( "User not found" );
         }
 
-        return new JSONWithPadding( response, callback );
+        return response;
     }
 
 
@@ -272,7 +266,9 @@ public class UserResource extends ServiceResource {
     @Path("setpin")
     @Consumes(MediaType.APPLICATION_JSON)
     @RequireApplicationAccess
-    public JSONWithPadding jsonPin( @Context UriInfo ui, JsonNode json,
+    @JSONP
+    @Produces({"application/json", "application/javascript"})
+    public ApiResponse jsonPin( @Context UriInfo ui, JsonNode json,
                                     @QueryParam("callback") @DefaultValue("callback") String callback )
             throws Exception {
 
@@ -288,7 +284,7 @@ public class UserResource extends ServiceResource {
             response.setError( "User not found" );
         }
 
-        return new JSONWithPadding( response, callback );
+        return response;
     }
 
 
@@ -460,7 +456,9 @@ public class UserResource extends ServiceResource {
 
     @GET
     @Path("reactivate")
-    public JSONWithPadding reactivate( @Context UriInfo ui,
+    @JSONP
+    @Produces({"application/json", "application/javascript"})
+    public ApiResponse reactivate( @Context UriInfo ui,
                                        @QueryParam("callback") @DefaultValue("callback") String callback )
             throws Exception {
 
@@ -471,13 +469,15 @@ public class UserResource extends ServiceResource {
         management.startAppUserActivationFlow( getApplicationId(), user );
 
         response.setAction( "reactivate user" );
-        return new JSONWithPadding( response, callback );
+        return response;
     }
 
 
     @POST
     @Path("revoketokens")
-    public JSONWithPadding revokeTokensPost( @Context UriInfo ui,
+    @JSONP
+    @Produces({"application/json", "application/javascript"})
+    public ApiResponse revokeTokensPost( @Context UriInfo ui,
                                              @QueryParam("callback") @DefaultValue("callback") String callback )
             throws Exception {
 
@@ -488,13 +488,15 @@ public class UserResource extends ServiceResource {
         management.revokeAccessTokensForAppUser( getApplicationId(), getUserUuid() );
 
         response.setAction( "revoked user tokens" );
-        return new JSONWithPadding( response, callback );
+        return response;
     }
 
 
     @PUT
     @Path("revoketokens")
-    public JSONWithPadding revokeTokensPut( @Context UriInfo ui,
+    @JSONP
+    @Produces({"application/json", "application/javascript"})
+    public ApiResponse revokeTokensPut( @Context UriInfo ui,
                                             @QueryParam("callback") @DefaultValue("callback") String callback )
             throws Exception {
         return revokeTokensPost( ui, callback );
@@ -503,7 +505,9 @@ public class UserResource extends ServiceResource {
 
     @POST
     @Path("revoketoken")
-    public JSONWithPadding revokeTokenPost( @Context UriInfo ui,
+    @JSONP
+    @Produces({"application/json", "application/javascript"})
+    public ApiResponse revokeTokenPost( @Context UriInfo ui,
                                             @QueryParam("callback") @DefaultValue("callback") String callback,
                                             @QueryParam("token") String token ) throws Exception {
 
@@ -514,13 +518,15 @@ public class UserResource extends ServiceResource {
         management.revokeAccessTokenForAppUser( token );
 
         response.setAction( "revoked user token" );
-        return new JSONWithPadding( response, callback );
+        return response;
     }
 
 
     @PUT
     @Path("revoketoken")
-    public JSONWithPadding revokeTokenPut( @Context UriInfo ui,
+    @JSONP
+    @Produces({"application/json", "application/javascript"})
+    public ApiResponse revokeTokenPut( @Context UriInfo ui,
                                            @QueryParam("callback") @DefaultValue("callback") String callback,
                                            @QueryParam("token") String token ) throws Exception {
         return revokeTokenPost( ui, callback, token );

http://git-wip-us.apache.org/repos/asf/usergrid/blob/0578d987/stack/rest/src/main/java/org/apache/usergrid/rest/applications/users/UsersResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/applications/users/UsersResource.java b/stack/rest/src/main/java/org/apache/usergrid/rest/applications/users/UsersResource.java
index c3f0283..e39a311 100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/applications/users/UsersResource.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/applications/users/UsersResource.java
@@ -18,45 +18,38 @@ package org.apache.usergrid.rest.applications.users;
 
 
 import com.fasterxml.jackson.databind.ObjectMapper;
-import com.sun.jersey.api.json.JSONWithPadding;
-import com.sun.jersey.api.view.Viewable;
-import java.util.List;
-import java.util.Map;
-import java.util.UUID;
-import javax.ws.rs.Consumes;
-import javax.ws.rs.DefaultValue;
-import javax.ws.rs.FormParam;
-import javax.ws.rs.GET;
-import javax.ws.rs.POST;
-import javax.ws.rs.PUT;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.Produces;
-import javax.ws.rs.QueryParam;
-import javax.ws.rs.core.Context;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.PathSegment;
-import javax.ws.rs.core.UriInfo;
+import com.fasterxml.jackson.jaxrs.json.annotation.JSONP;
 import net.tanesha.recaptcha.ReCaptchaImpl;
 import net.tanesha.recaptcha.ReCaptchaResponse;
-import static org.apache.commons.lang.StringUtils.isBlank;
-import static org.apache.commons.lang.StringUtils.isNotBlank;
 import org.apache.usergrid.persistence.Entity;
+import org.apache.usergrid.persistence.Query;
 import org.apache.usergrid.persistence.entities.User;
 import org.apache.usergrid.persistence.index.query.Identifier;
-import org.apache.usergrid.persistence.Query;
 import org.apache.usergrid.rest.AbstractContextResource;
 import org.apache.usergrid.rest.ApiResponse;
 import org.apache.usergrid.rest.RootResource;
 import org.apache.usergrid.rest.applications.ServiceResource;
 import org.apache.usergrid.rest.exceptions.RedirectionException;
 import org.apache.usergrid.rest.security.annotations.RequireApplicationAccess;
-import static org.apache.usergrid.services.ServiceParameter.addParameter;
+import org.glassfish.jersey.server.mvc.Viewable;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.context.annotation.Scope;
 import org.springframework.stereotype.Component;
 
+import javax.ws.rs.*;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.PathSegment;
+import javax.ws.rs.core.UriInfo;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+
+import static org.apache.commons.lang.StringUtils.isBlank;
+import static org.apache.commons.lang.StringUtils.isNotBlank;
+import static org.apache.usergrid.services.ServiceParameter.addParameter;
+
 
 @Component("org.apache.usergrid.rest.applications.users.UsersResource")
 @Scope("prototype")
@@ -186,7 +179,9 @@ public class UsersResource extends ServiceResource {
     @PUT
     @Override
     @RequireApplicationAccess
-    public JSONWithPadding executePut( @Context UriInfo ui, String body,
+    @JSONP
+    @Produces({"application/json", "application/javascript"})
+    public ApiResponse executePut( @Context UriInfo ui, String body,
                                        @QueryParam("callback") @DefaultValue("callback") String callback )
             throws Exception {
 
@@ -208,7 +203,9 @@ public class UsersResource extends ServiceResource {
     @POST
     @Override
     @RequireApplicationAccess
-    public JSONWithPadding executePost( @Context UriInfo ui, String body,
+    @JSONP
+    @Produces({"application/json", "application/javascript"})
+    public ApiResponse executePost( @Context UriInfo ui, String body,
                                         @QueryParam("callback") @DefaultValue("callback") String callback )
             throws Exception {
 
@@ -245,7 +242,7 @@ public class UsersResource extends ServiceResource {
             }
         }
 
-        ApiResponse response = ( ApiResponse ) super.executePostWithObject( ui, json, callback ).getJsonSource();
+        ApiResponse response = ( ApiResponse ) super.executePostWithObject( ui, json, callback );
 
         if ( ( response.getEntities() != null ) && ( response.getEntities().size() == 1 ) ) {
 
@@ -264,6 +261,6 @@ public class UsersResource extends ServiceResource {
                 management.startAppUserActivationFlow( getApplicationId(), user );
             }
         }
-        return new JSONWithPadding( response, callback );
+        return response;
     }
 }

http://git-wip-us.apache.org/repos/asf/usergrid/blob/0578d987/stack/rest/src/main/java/org/apache/usergrid/rest/exceptions/NotFoundExceptionMapper.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/exceptions/NotFoundExceptionMapper.java b/stack/rest/src/main/java/org/apache/usergrid/rest/exceptions/NotFoundExceptionMapper.java
index 165a8d3..557be08 100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/exceptions/NotFoundExceptionMapper.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/exceptions/NotFoundExceptionMapper.java
@@ -17,8 +17,7 @@
 package org.apache.usergrid.rest.exceptions;
 
 
-import com.sun.jersey.api.NotFoundException;
-
+import javax.ws.rs.NotFoundException;
 import javax.ws.rs.core.Response;
 import javax.ws.rs.ext.Provider;
 

http://git-wip-us.apache.org/repos/asf/usergrid/blob/0578d987/stack/rest/src/main/java/org/apache/usergrid/rest/exceptions/SecurityException.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/exceptions/SecurityException.java b/stack/rest/src/main/java/org/apache/usergrid/rest/exceptions/SecurityException.java
index 93be148..6b0d232 100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/exceptions/SecurityException.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/exceptions/SecurityException.java
@@ -19,7 +19,7 @@ package org.apache.usergrid.rest.exceptions;
 
 import org.apache.usergrid.rest.ApiResponse;
 
-import com.sun.jersey.api.container.MappableContainerException;
+import javax.ws.rs.ext.ExceptionMapper;
 
 import static org.apache.usergrid.utils.JsonUtils.mapToJsonString;
 
@@ -36,12 +36,14 @@ public class SecurityException extends RuntimeException {
 
     private String realm = null;
     private String type = null;
+    private Exception root = null;
 
 
-    private SecurityException( String type, String message, String realm ) {
+    private SecurityException( String type, String message, String realm, Exception root ) {
         super( message );
         this.type = type;
         this.realm = realm;
+        this.root = root;
     }
 
 
@@ -54,6 +56,9 @@ public class SecurityException extends RuntimeException {
         return type;
     }
 
+    public Exception getRoot() {
+        return root;
+    }
 
     public String getJsonResponse() {
         ApiResponse response = new ApiResponse();
@@ -62,28 +67,28 @@ public class SecurityException extends RuntimeException {
     }
 
 
-    public static MappableContainerException mappableSecurityException( AuthErrorInfo errorInfo ) {
+    public static RuntimeException mappableSecurityException( AuthErrorInfo errorInfo ) {
         return mappableSecurityException( errorInfo.getType(), errorInfo.getMessage() );
     }
 
-
-    public static MappableContainerException mappableSecurityException( AuthErrorInfo errorInfo, String message ) {
+    public static RuntimeException mappableSecurityException( AuthErrorInfo errorInfo, String message ) {
         return mappableSecurityException( errorInfo.getType(), message );
     }
 
-
-    public static MappableContainerException mappableSecurityException( String type, String message ) {
-        return new MappableContainerException( new SecurityException( type, message, null ) );
+    public static RuntimeException mappableSecurityException( String type, String message ) {
+        return new SecurityException( type, message, null, null );
     }
 
-
-    public static MappableContainerException mappableSecurityException( AuthErrorInfo errorInfo, String message,
-                                                                        String realm ) {
+    public static RuntimeException mappableSecurityException( AuthErrorInfo errorInfo, String message, String realm ) {
         return mappableSecurityException( errorInfo.getType(), message, realm );
     }
 
+    public static RuntimeException mappableSecurityException( String type, String message, String realm ) {
+        return new SecurityException( type, message, realm, null );
+    }
 
-    public static MappableContainerException mappableSecurityException( String type, String message, String realm ) {
-        return new MappableContainerException( new SecurityException( type, message, realm ) );
+    public static RuntimeException mappableSecurityException( Exception e, AuthErrorInfo errorInfo ) {
+        return new SecurityException( errorInfo.getType(), e.getMessage(), null, e );
     }
+
 }

http://git-wip-us.apache.org/repos/asf/usergrid/blob/0578d987/stack/rest/src/main/java/org/apache/usergrid/rest/filters/JSONPCallbackFilter.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/filters/JSONPCallbackFilter.java b/stack/rest/src/main/java/org/apache/usergrid/rest/filters/JSONPCallbackFilter.java
index 5eca8c9..bc2bdc7d 100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/filters/JSONPCallbackFilter.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/filters/JSONPCallbackFilter.java
@@ -17,15 +17,15 @@
 package org.apache.usergrid.rest.filters;
 
 
-import javax.servlet.http.HttpServletRequest;
-import javax.ws.rs.core.Context;
-
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.stereotype.Component;
 
-import com.sun.jersey.spi.container.ContainerRequest;
-import com.sun.jersey.spi.container.ContainerRequestFilter;
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.container.ContainerRequestContext;
+import javax.ws.rs.container.ContainerRequestFilter;
+import javax.ws.rs.core.Context;
+import java.io.IOException;
 
 import static org.apache.commons.lang.StringUtils.isNotBlank;
 
@@ -45,23 +45,15 @@ public class JSONPCallbackFilter implements ContainerRequestFilter {
 
 
     @Override
-    public ContainerRequest filter( ContainerRequest request ) {
+    public void filter(ContainerRequestContext crc) throws IOException {
         String callback = null;
         try {
             callback = httpServletRequest.getParameter( "callback" );
         }
         catch ( IllegalStateException e ) {
         }
-        if ( callback == null ) {
-            try {
-                callback = request.getQueryParameters().getFirst( "callback" );
-            }
-            catch ( IllegalStateException e ) {
-            }
-        }
         if ( isNotBlank( callback ) ) {
-            request.getRequestHeaders().putSingle( "Accept", "application/javascript" );
+            crc.getHeaders().putSingle( "Accept", "application/javascript" );
         }
-        return request;
     }
 }

http://git-wip-us.apache.org/repos/asf/usergrid/blob/0578d987/stack/rest/src/main/java/org/apache/usergrid/rest/filters/MeteringFilter.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/filters/MeteringFilter.java b/stack/rest/src/main/java/org/apache/usergrid/rest/filters/MeteringFilter.java
index b483f5f..24051ad 100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/filters/MeteringFilter.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/filters/MeteringFilter.java
@@ -17,330 +17,348 @@
 package org.apache.usergrid.rest.filters;
 
 
+import com.yammer.metrics.Metrics;
+import com.yammer.metrics.core.Counter;
+import com.yammer.metrics.core.Timer;
+import com.yammer.metrics.core.TimerContext;
+import org.apache.usergrid.management.ManagementService;
+import org.apache.usergrid.persistence.EntityManager;
+import org.apache.usergrid.persistence.EntityManagerFactory;
+import org.apache.usergrid.services.ServiceManagerFactory;
+import org.apache.usergrid.system.UsergridSystemMonitor;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.stereotype.Component;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.container.ContainerRequestContext;
+import javax.ws.rs.container.ContainerRequestFilter;
+import javax.ws.rs.container.ContainerResponseContext;
+import javax.ws.rs.container.ContainerResponseFilter;
+import javax.ws.rs.core.Context;
 import java.io.FilterInputStream;
-import java.io.FilterOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
-import java.io.OutputStream;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.Properties;
 import java.util.UUID;
 import java.util.concurrent.TimeUnit;
 
-import javax.servlet.http.HttpServletRequest;
-import javax.ws.rs.core.Context;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Qualifier;
-import org.springframework.stereotype.Component;
-import org.apache.usergrid.management.ManagementService;
-import org.apache.usergrid.persistence.EntityManager;
-import org.apache.usergrid.persistence.EntityManagerFactory;
-import org.apache.usergrid.services.ServiceManagerFactory;
-import org.apache.usergrid.system.UsergridSystemMonitor;
-
-import com.sun.jersey.spi.container.ContainerRequest;
-import com.sun.jersey.spi.container.ContainerRequestFilter;
-import com.sun.jersey.spi.container.ContainerResponse;
-import com.sun.jersey.spi.container.ContainerResponseFilter;
-import com.sun.jersey.spi.container.ContainerResponseWriter;
-import com.yammer.metrics.Metrics;
-import com.yammer.metrics.core.Counter;
-import com.yammer.metrics.core.Timer;
-import com.yammer.metrics.core.TimerContext;
-
 
+// TODO: Metering for Jersey 2
 @Component
 public class MeteringFilter implements ContainerRequestFilter, ContainerResponseFilter {
 
-    @Context
-    protected HttpServletRequest httpServletRequest;
-
-    EntityManagerFactory emf;
-    ServiceManagerFactory smf;
-    Properties properties;
-    ManagementService management;
-    UsergridSystemMonitor usergridSystemMonitor;
-    final Counter activeRequests;
-    final Timer requestTimer;
-
-    private static final Logger logger = LoggerFactory.getLogger( MeteringFilter.class );
-
-
-    public MeteringFilter() {
-        logger.info( "MeteringFilter installed" );
-        this.activeRequests = Metrics.newCounter( MeteringFilter.class, "activeRequests" );
-        this.requestTimer =
-                Metrics.newTimer( MeteringFilter.class, "requests", TimeUnit.MILLISECONDS, TimeUnit.SECONDS );
-    }
-
-
-    @Autowired
-    public void setEntityManagerFactory( EntityManagerFactory emf ) {
-        this.emf = emf;
-    }
-
-
-    @Autowired
-    public void setServiceManagerFactory( ServiceManagerFactory smf ) {
-        this.smf = smf;
-    }
-
-
-    @Autowired
-    @Qualifier("properties")
-    public void setProperties( Properties properties ) {
-        this.properties = properties;
-    }
-
-
-    @Autowired
-    public void setManagementService( ManagementService management ) {
-        this.management = management;
-    }
-
-
-    @Autowired
-    public void setUsergridSystemMonitor( UsergridSystemMonitor usergridSystemMonitor ) {
-        this.usergridSystemMonitor = usergridSystemMonitor;
-    }
-
-
     @Override
-    public ContainerRequest filter( ContainerRequest request ) {
-
-        try {
-            activeRequests.inc();
-            request.setEntityInputStream( new InputStreamAdapter( request.getEntityInputStream() ) );
-            httpServletRequest.setAttribute( "application.request.timetamp", System.currentTimeMillis() );
-            httpServletRequest.setAttribute( "application.request.requestTimer", requestTimer.time() );
-        }
-        catch ( Exception e ) {
-            logger.error( "Unable to capture request", e );
-        }
-        return request;
-    }
-
-
-    public void countDataWritten( long written ) {
-        TimerContext timer = ( TimerContext ) httpServletRequest.getAttribute( "application.request.requestTimer" );
-        try {
-            UUID applicationId = ( UUID ) httpServletRequest.getAttribute( "applicationId" );
-            Long timestamp = ( Long ) httpServletRequest.getAttribute( "application.request.timetamp" );
-            long time;
-            if ( ( timestamp != null ) && ( timestamp > 0 ) ) {
-                time = System.currentTimeMillis() - timestamp;
-            }
-            else {
-                time = -1;
-            }
-            usergridSystemMonitor.maybeLogPayload( time, "path", httpServletRequest.getRequestURI(), "applicationId",
-                    applicationId );
-            if ( applicationId != null ) {
-
-                Map<String, Long> counters = new HashMap<String, Long>();
-
-
-                if ( time > 0 ) {
-                    logger.trace( "Application: {}, spent {} milliseconds of CPU time", applicationId, time );
-                    counters.put( "application.request.time", time );
-                }
-
-                Long read = ( Long ) httpServletRequest.getAttribute( "application.request.upload" );
-                if ( ( read != null ) && ( read > 0 ) ) {
-                    logger.trace( "Application: {}, received {} bytes", applicationId, written );
-                    counters.put( "application.request.upload", read );
-                }
-
-                if ( written > 0 ) {
-                    logger.trace( "Application: {}, sending {} bytes", applicationId, written );
-                    counters.put( "application.request.download", written );
-                }
-
-                if ( emf != null ) {
-                    EntityManager em = emf.getEntityManager( applicationId );
-                    em.incrementAggregateCounters( null, null, null, counters );
-                }
-                else {
-                    logger.error( "No EntityManagerFactory configured" );
-                }
-            }
-        }
-        catch ( Exception e ) {
-            logger.error( "Unable to capture output", e );
-        }
-        finally {
-            if ( timer != null ) {
-                timer.stop();
-            }
-            activeRequests.dec();
-        }
-    }
-
-
-    public void countDataRead( long read ) {
-        try {
-            if ( read > 0 ) {
-                httpServletRequest.setAttribute( "application.request.upload", read );
-            }
-        }
-        catch ( Exception e ) {
-            logger.error( "Unable to capture input", e );
-        }
-    }
-
-
-    private final class InputStreamAdapter extends FilterInputStream {
-
-        long total = 0;
-
-
-        protected InputStreamAdapter( InputStream in ) {
-            super( in );
-        }
-
-
-        @Override
-        public int available() throws IOException {
-            int i = super.available();
-            return i;
-        }
-
-
-        @Override
-        public int read() throws IOException {
-            int b = super.read();
-            if ( b != -1 ) {
-                total++;
-            }
-            else {
-                countDataRead( total );
-                total = 0;
-            }
-            return b;
-        }
-
-
-        @Override
-        public int read( byte[] b, int off, int len ) throws IOException {
-            int l = super.read( b, off, len );
-            if ( l != -1 ) {
-                total += l;
-            }
-            if ( ( l == -1 ) || ( l < len ) ) {
-                countDataRead( total );
-                total = 0;
-            }
-            return l;
-        }
-
-
-        @Override
-        public int read( byte[] b ) throws IOException {
-            int l = super.read( b );
-            if ( l != -1 ) {
-                total += l;
-            }
-            if ( ( l == -1 ) || ( l < b.length ) ) {
-                countDataRead( total );
-                total = 0;
-            }
-            return l;
-        }
-
+    public void filter(ContainerRequestContext containerRequestContext) throws IOException {
 
-        @Override
-        public void close() throws IOException {
-            super.close();
-            countDataRead( total );
-        }
     }
 
-
-    private final class ContainerResponseWriterAdapter implements ContainerResponseWriter {
-
-        private final ContainerResponseWriter crw;
-        private OutputStreamAdapter out = null;
-
-
-        ContainerResponseWriterAdapter( ContainerResponseWriter crw ) {
-            this.crw = crw;
-        }
-
-
-        @Override
-        public OutputStream writeStatusAndHeaders( long contentLength, ContainerResponse response ) throws IOException {
-
-            // logger.info("Wrapping output stream");
-            OutputStream o = crw.writeStatusAndHeaders( contentLength, response );
-
-            if ( out == null ) {
-                out = new OutputStreamAdapter( o );
-            }
-
-            return out;
-        }
-
-
-        @Override
-        public void finish() throws IOException {
-            crw.finish();
-            if ( out != null ) {
-                countDataWritten( out.getTotal() );
-            }
-        }
-
-
-        private final class OutputStreamAdapter extends FilterOutputStream {
-
-            long total = 0;
-
-
-            public OutputStreamAdapter( OutputStream out ) {
-                super( out );
-            }
-
-
-            public long getTotal() {
-                return total;
-            }
-
-
-            @Override
-            public void write( byte[] b, int off, int len ) throws IOException {
-                out.write( b, off, len );
-                total += len;
-            }
-
-
-            @Override
-            public void write( byte[] b ) throws IOException {
-                out.write( b );
-                total += b.length;
-            }
-
-
-            @Override
-            public void write( int b ) throws IOException {
-                out.write( b );
-                total += 1;
-            }
-        }
-    }
-
-
     @Override
-    public ContainerResponse filter( ContainerRequest request, ContainerResponse response ) {
-        try {
-            response.setContainerResponseWriter(
-                    new ContainerResponseWriterAdapter( response.getContainerResponseWriter() ) );
-        }
-        catch ( Exception e ) {
-            logger.error( "Unable to capture response", e );
-        }
-        return response;
+    public void filter(ContainerRequestContext containerRequestContext, ContainerResponseContext containerResponseContext) throws IOException {
+
     }
+//
+//    @Context
+//    protected HttpServletRequest httpServletRequest;
+//
+//    EntityManagerFactory emf;
+//    ServiceManagerFactory smf;
+//    Properties properties;
+//    ManagementService management;
+//    UsergridSystemMonitor usergridSystemMonitor;
+//    final Counter activeRequests;
+//    final Timer requestTimer;
+//
+//    private static final Logger logger = LoggerFactory.getLogger( MeteringFilter.class );
+//
+//
+//    public MeteringFilter() {
+//        logger.info( "MeteringFilter installed" );
+//        this.activeRequests = Metrics.newCounter( MeteringFilter.class, "activeRequests" );
+//        this.requestTimer =
+//                Metrics.newTimer( MeteringFilter.class, "requests", TimeUnit.MILLISECONDS, TimeUnit.SECONDS );
+//    }
+//
+//
+//    @Autowired
+//    public void setEntityManagerFactory( EntityManagerFactory emf ) {
+//        this.emf = emf;
+//    }
+//
+//
+//    @Autowired
+//    public void setServiceManagerFactory( ServiceManagerFactory smf ) {
+//        this.smf = smf;
+//    }
+//
+//
+//    @Autowired
+//    @Qualifier("properties")
+//    public void setProperties( Properties properties ) {
+//        this.properties = properties;
+//    }
+//
+//
+//    @Autowired
+//    public void setManagementService( ManagementService management ) {
+//        this.management = management;
+//    }
+//
+//
+//    @Autowired
+//    public void setUsergridSystemMonitor( UsergridSystemMonitor usergridSystemMonitor ) {
+//        this.usergridSystemMonitor = usergridSystemMonitor;
+//    }
+//
+//
+//    @Override
+//    public void filter(ContainerRequestContext creq) throws IOException {
+//
+//        try {
+//            activeRequests.inc();
+//            creq.setEntityStream( new InputStreamAdapter( creq.getEntityStream() ) );
+//            httpServletRequest.setAttribute( "application.request.timetamp", System.currentTimeMillis() );
+//            httpServletRequest.setAttribute( "application.request.requestTimer", requestTimer.time() );
+//        }
+//        catch ( Exception e ) {
+//            logger.error( "Unable to capture request", e );
+//        }
+//    }
+//
+//    public void countDataWritten( long written ) {
+//        TimerContext timer = ( TimerContext ) httpServletRequest.getAttribute( "application.request.requestTimer" );
+//        try {
+//            UUID applicationId = ( UUID ) httpServletRequest.getAttribute( "applicationId" );
+//            Long timestamp = ( Long ) httpServletRequest.getAttribute( "application.request.timetamp" );
+//            long time;
+//            if ( ( timestamp != null ) && ( timestamp > 0 ) ) {
+//                time = System.currentTimeMillis() - timestamp;
+//            }
+//            else {
+//                time = -1;
+//            }
+//            usergridSystemMonitor.maybeLogPayload( time, "path", httpServletRequest.getRequestURI(), "applicationId",
+//                    applicationId );
+//            if ( applicationId != null ) {
+//
+//                Map<String, Long> counters = new HashMap<String, Long>();
+//
+//
+//                if ( time > 0 ) {
+//                    logger.trace( "Application: {}, spent {} milliseconds of CPU time", applicationId, time );
+//                    counters.put( "application.request.time", time );
+//                }
+//
+//                Long read = ( Long ) httpServletRequest.getAttribute( "application.request.upload" );
+//                if ( ( read != null ) && ( read > 0 ) ) {
+//                    logger.trace( "Application: {}, received {} bytes", applicationId, written );
+//                    counters.put( "application.request.upload", read );
+//                }
+//
+//                if ( written > 0 ) {
+//                    logger.trace( "Application: {}, sending {} bytes", applicationId, written );
+//                    counters.put( "application.request.download", written );
+//                }
+//
+//                if ( emf != null ) {
+//                    EntityManager em = emf.getEntityManager( applicationId );
+//                    em.incrementAggregateCounters( null, null, null, counters );
+//                }
+//                else {
+//                    logger.error( "No EntityManagerFactory configured" );
+//                }
+//            }
+//        }
+//        catch ( Exception e ) {
+//            logger.error( "Unable to capture output", e );
+//        }
+//        finally {
+//            if ( timer != null ) {
+//                timer.stop();
+//            }
+//            activeRequests.dec();
+//        }
+//    }
+//
+//
+//    public void countDataRead( long read ) {
+//        try {
+//            if ( read > 0 ) {
+//                httpServletRequest.setAttribute( "application.request.upload", read );
+//            }
+//        }
+//        catch ( Exception e ) {
+//            logger.error( "Unable to capture input", e );
+//        }
+//    }
+//
+//
+//    private final class InputStreamAdapter extends FilterInputStream {
+//
+//        long total = 0;
+//
+//
+//        protected InputStreamAdapter( InputStream in ) {
+//            super( in );
+//        }
+//
+//
+//        @Override
+//        public int available() throws IOException {
+//            int i = super.available();
+//            return i;
+//        }
+//
+//
+//        @Override
+//        public int read() throws IOException {
+//            int b = super.read();
+//            if ( b != -1 ) {
+//                total++;
+//            }
+//            else {
+//                countDataRead( total );
+//                total = 0;
+//            }
+//            return b;
+//        }
+//
+//
+//        @Override
+//        public int read( byte[] b, int off, int len ) throws IOException {
+//            int l = super.read( b, off, len );
+//            if ( l != -1 ) {
+//                total += l;
+//            }
+//            if ( ( l == -1 ) || ( l < len ) ) {
+//                countDataRead( total );
+//                total = 0;
+//            }
+//            return l;
+//        }
+//
+//
+//        @Override
+//        public int read( byte[] b ) throws IOException {
+//            int l = super.read( b );
+//            if ( l != -1 ) {
+//                total += l;
+//            }
+//            if ( ( l == -1 ) || ( l < b.length ) ) {
+//                countDataRead( total );
+//                total = 0;
+//            }
+//            return l;
+//        }
+//
+//
+//        @Override
+//        public void close() throws IOException {
+//            super.close();
+//            countDataRead( total );
+//        }
+//    }
+//
+//
+//    private final class ContainerResponseWriterAdapter implements ContainerResponseWriter {
+//
+//        private final ContainerResponseWriter crw;
+//        private OutputStreamAdapter out = null;
+//
+//
+//        ContainerResponseWriterAdapter( ContainerResponseWriter crw ) {
+//            this.crw = crw;
+//        }
+//
+//
+//        @Override
+//        public OutputStream writeResponseStatusAndHeaders(
+//            long contentLength, ContainerResponse response) throws ContainerException {
+//
+//            // logger.info("Wrapping output stream");
+//            OutputStream o = crw.writeResponseStatusAndHeaders( contentLength, response );
+//
+//            if ( out == null ) {
+//                out = new OutputStreamAdapter( o );
+//            }
+//
+//            return out;
+//        }
+//
+//        @Override
+//        public boolean suspend(long l, TimeUnit timeUnit, TimeoutHandler timeoutHandler) {
+//            return crw.suspend( l, timeUnit, timeoutHandler );
+//        }
+//
+//        @Override
+//        public void setSuspendTimeout(long l, TimeUnit timeUnit) throws IllegalStateException {
+//            crw.setSuspendTimeout( l, timeUnit );
+//        }
+//
+//        @Override
+//        public void commit() {
+//            crw.commit();
+//        }
+//
+//        @Override
+//        public void failure(Throwable throwable) {
+//            crw.failure( throwable );
+//        }
+//
+//        @Override
+//        public boolean enableResponseBuffering() {
+//            return false;
+//        }
+//
+//
+//        private final class OutputStreamAdapter extends FilterOutputStream {
+//
+//            long total = 0;
+//
+//
+//            public OutputStreamAdapter( OutputStream out ) {
+//                super( out );
+//            }
+//
+//
+//            public long getTotal() {
+//                return total;
+//            }
+//
+//
+//            @Override
+//            public void write( byte[] b, int off, int len ) throws IOException {
+//                out.write( b, off, len );
+//                total += len;
+//            }
+//
+//
+//            @Override
+//            public void write( byte[] b ) throws IOException {
+//                out.write( b );
+//                total += b.length;
+//            }
+//
+//
+//            @Override
+//            public void write( int b ) throws IOException {
+//                out.write( b );
+//                total += 1;
+//            }
+//        }
+//    }
+//
+//    @Override
+//    public void filter(ContainerRequestContext req, ContainerResponseContext res) throws IOException {
+//        try {
+//            res.setEntityStream( res.getEntityStream() );
+//        }
+//        catch ( Exception e ) {
+//            logger.error( "Unable to capture response", e );
+//        }
+//    }
 }

http://git-wip-us.apache.org/repos/asf/usergrid/blob/0578d987/stack/rest/src/main/java/org/apache/usergrid/rest/filters/TracingFilter.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/filters/TracingFilter.java b/stack/rest/src/main/java/org/apache/usergrid/rest/filters/TracingFilter.java
index cc28028..fcff69d 100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/filters/TracingFilter.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/filters/TracingFilter.java
@@ -17,22 +17,21 @@
 package org.apache.usergrid.rest.filters;
 
 
-import javax.servlet.http.HttpServletRequest;
-import javax.ws.rs.core.Context;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
 import org.apache.usergrid.persistence.cassandra.util.TraceTag;
 import org.apache.usergrid.persistence.cassandra.util.TraceTagManager;
 import org.apache.usergrid.persistence.cassandra.util.TraceTagReporter;
 import org.apache.usergrid.utils.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
 
-import com.sun.jersey.spi.container.ContainerRequest;
-import com.sun.jersey.spi.container.ContainerRequestFilter;
-import com.sun.jersey.spi.container.ContainerResponse;
-import com.sun.jersey.spi.container.ContainerResponseFilter;
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.container.ContainerRequestContext;
+import javax.ws.rs.container.ContainerRequestFilter;
+import javax.ws.rs.container.ContainerResponseContext;
+import javax.ws.rs.container.ContainerResponseFilter;
+import javax.ws.rs.core.Context;
 
 
 /**
@@ -56,35 +55,33 @@ public class TracingFilter implements ContainerRequestFilter, ContainerResponseF
 
 
     @Override
-    public ContainerRequest filter( ContainerRequest request ) {
+    public void filter( ContainerRequestContext request ) {
         if ( !traceTagManager.getTraceEnabled() && !traceTagManager.getExplicitOnly() ) {
-            return request;
+            return;
         }
         String traceId;
         if ( traceTagManager.getExplicitOnly() ) {
             // if we are set in explicit mode and the header is not present, leave.
             String id = httpServletRequest.getHeader( "XX-TRACE-ID" );
             if ( StringUtils.isBlank( id ) ) {
-                return request;
+                return;
             }
-            traceId = id.concat( "-REST-" ).concat( request.getPath( true ) );
+            traceId = id.concat( "-REST-" ).concat( request.getUriInfo().getPath( true ) );
         }
         else {
-            traceId = "TRACE-".concat( request.getPath( true ) );
+            traceId = "TRACE-".concat( request.getUriInfo().getPath( true ) );
         }
         TraceTag traceTag = traceTagManager.create( traceId );
         traceTagManager.attach( traceTag );
-
-        return request;
     }
 
 
     @Override
-    public ContainerResponse filter( ContainerRequest request, ContainerResponse response ) {
+    public void filter( ContainerRequestContext request, ContainerResponseContext response ) {
         if ( traceTagManager.isActive() ) {
             TraceTag traceTag = traceTagManager.detach();
             traceTagReporter.report( traceTag );
         }
-        return response;
     }
+
 }

http://git-wip-us.apache.org/repos/asf/usergrid/blob/0578d987/stack/rest/src/main/java/org/apache/usergrid/rest/management/ManagementResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/management/ManagementResource.java b/stack/rest/src/main/java/org/apache/usergrid/rest/management/ManagementResource.java
index caed361..e79e521 100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/management/ManagementResource.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/management/ManagementResource.java
@@ -21,13 +21,6 @@ import com.codahale.metrics.Counter;
 import com.codahale.metrics.Timer;
 import com.fasterxml.jackson.databind.JsonNode;
 import com.google.inject.Injector;
-import com.sun.jersey.api.client.Client;
-import com.sun.jersey.api.client.config.ClientConfig;
-import com.sun.jersey.api.client.config.DefaultClientConfig;
-import com.sun.jersey.api.json.JSONConfiguration;
-import com.sun.jersey.api.view.Viewable;
-import com.sun.jersey.client.apache.ApacheHttpClient;
-import com.sun.jersey.client.apache.ApacheHttpClientHandler;
 import org.apache.amber.oauth2.common.error.OAuthError;
 import org.apache.amber.oauth2.common.exception.OAuthProblemException;
 import org.apache.amber.oauth2.common.message.OAuthResponse;
@@ -37,6 +30,9 @@ import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager;
 import org.apache.commons.httpclient.params.HttpConnectionManagerParams;
 import org.apache.commons.lang.RandomStringUtils;
 import org.apache.commons.lang.StringUtils;
+import org.apache.http.HttpHost;
+import org.apache.http.conn.routing.HttpRoute;
+import org.apache.http.impl.conn.PoolingClientConnectionManager;
 import org.apache.shiro.codec.Base64;
 import org.apache.usergrid.exception.NotImplementedException;
 import org.apache.usergrid.management.ApplicationCreator;
@@ -54,6 +50,14 @@ import org.apache.usergrid.rest.management.organizations.OrganizationsResource;
 import org.apache.usergrid.rest.management.users.UsersResource;
 import org.apache.usergrid.security.oauth.AccessInfo;
 import org.apache.usergrid.security.shiro.utils.SubjectUtils;
+import org.glassfish.jersey.apache.connector.ApacheClientProperties;
+import org.glassfish.jersey.apache.connector.ApacheConnectorProvider;
+import org.glassfish.jersey.client.ClientConfig;
+import org.glassfish.jersey.client.ClientProperties;
+import org.glassfish.jersey.client.spi.Connector;
+import org.glassfish.jersey.client.spi.ConnectorProvider;
+import org.glassfish.jersey.jackson.JacksonFeature;
+import org.glassfish.jersey.server.mvc.Viewable;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -61,10 +65,9 @@ import org.springframework.context.annotation.Scope;
 import org.springframework.stereotype.Component;
 
 import javax.ws.rs.*;
-import javax.ws.rs.core.Context;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-import javax.ws.rs.core.UriInfo;
+import javax.ws.rs.client.Client;
+import javax.ws.rs.client.ClientBuilder;
+import javax.ws.rs.core.*;
 import java.net.URLEncoder;
 import java.util.Collections;
 import java.util.Iterator;
@@ -707,8 +710,8 @@ public class ManagementResource extends AbstractContextResource {
         Client client = getJerseyClient();
         final JsonNode accessInfoNode;
         try {
-            accessInfoNode = client.resource( me )
-                    .type( MediaType.APPLICATION_JSON_TYPE)
+            accessInfoNode = client.target( me ).request()
+                    .accept( MediaType.APPLICATION_JSON_TYPE )
                     .get(JsonNode.class);
 
             tokensValidatedCounter.inc();
@@ -738,12 +741,8 @@ public class ManagementResource extends AbstractContextResource {
                     poolSize = Integer.parseInt( poolSizeStr );
                 }
 
-                MultiThreadedHttpConnectionManager cm = new MultiThreadedHttpConnectionManager();
-                HttpConnectionManagerParams cmParams = cm.getParams();
-                cmParams.setMaxTotalConnections( poolSize );
-                HttpClient httpClient = new HttpClient( cm );
-
-                // create Jersey Client using that HTTPClient and with configured timeouts
+                PoolingClientConnectionManager connectionManager = new PoolingClientConnectionManager();
+                connectionManager.setMaxTotal(poolSize);
 
                 int timeout = 20000; // ms
                 final String timeoutStr = properties.getProperty( CENTRAL_CONNECTION_TIMEOUT );
@@ -757,14 +756,14 @@ public class ManagementResource extends AbstractContextResource {
                     readTimeout = Integer.parseInt( readTimeoutStr );
                 }
 
-                ClientConfig clientConfig = new DefaultClientConfig();
-                clientConfig.getFeatures().put( JSONConfiguration.FEATURE_POJO_MAPPING, Boolean.TRUE );
-                clientConfig.getProperties().put( ClientConfig.PROPERTY_CONNECT_TIMEOUT, timeout ); // ms
-                clientConfig.getProperties().put( ClientConfig.PROPERTY_READ_TIMEOUT, readTimeout ); // ms
-
-                ApacheHttpClientHandler handler = new ApacheHttpClientHandler( httpClient, clientConfig );
-                jerseyClient = new ApacheHttpClient( handler );
+                ClientConfig clientConfig = new ClientConfig();
+                clientConfig.register( new JacksonFeature() );
+                clientConfig.property( ApacheClientProperties.CONNECTION_MANAGER, connectionManager );
+                clientConfig.connectorProvider( new ApacheConnectorProvider() );
 
+                jerseyClient = ClientBuilder.newClient( clientConfig );
+                jerseyClient.property( ClientProperties.CONNECT_TIMEOUT, timeout);
+                jerseyClient.property( ClientProperties.READ_TIMEOUT, readTimeout );
             }
         }
 

http://git-wip-us.apache.org/repos/asf/usergrid/blob/0578d987/stack/rest/src/main/java/org/apache/usergrid/rest/management/metrics/MetricsResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/management/metrics/MetricsResource.java b/stack/rest/src/main/java/org/apache/usergrid/rest/management/metrics/MetricsResource.java
index 7072ae6..af4e3ad 100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/management/metrics/MetricsResource.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/management/metrics/MetricsResource.java
@@ -24,13 +24,12 @@ import javax.ws.rs.core.Context;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.UriInfo;
 
+import com.fasterxml.jackson.jaxrs.json.annotation.JSONP;
 import org.springframework.context.annotation.Scope;
 import org.springframework.stereotype.Component;
 import org.apache.usergrid.rest.AbstractContextResource;
 import org.apache.usergrid.rest.ApiResponse;
 
-import com.sun.jersey.api.json.JSONWithPadding;
-
 
 /** @author zznate */
 @Component("org.apache.usergrid.rest.management.metrics.MetricsResource")
@@ -45,11 +44,13 @@ public class MetricsResource extends AbstractContextResource {
 
     @GET
     @Path("all")
-    public JSONWithPadding getDeveloperMetrics( @Context UriInfo ui ) {
+    @JSONP
+    @Produces({MediaType.APPLICATION_JSON, "application/javascript"})
+    public ApiResponse getDeveloperMetrics( @Context UriInfo ui ) {
 
         ApiResponse response = createApiResponse();
         response.setAction( "get developer metrics" );
 
-        return new JSONWithPadding( response );
+        return response;
     }
 }

http://git-wip-us.apache.org/repos/asf/usergrid/blob/0578d987/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/OrganizationResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/OrganizationResource.java b/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/OrganizationResource.java
index afd4d26..287b5a7 100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/OrganizationResource.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/OrganizationResource.java
@@ -17,20 +17,13 @@
 package org.apache.usergrid.rest.management.organizations;
 
 
-import com.sun.jersey.api.json.JSONWithPadding;
-import com.sun.jersey.api.view.Viewable;
+import com.fasterxml.jackson.jaxrs.json.annotation.JSONP;
 import org.apache.amber.oauth2.common.exception.OAuthSystemException;
 import org.apache.commons.lang.NullArgumentException;
-
-import org.apache.usergrid.corepersistence.util.CpNamingUtils;
 import org.apache.usergrid.management.ActivationState;
 import org.apache.usergrid.management.OrganizationInfo;
 import org.apache.usergrid.management.export.ExportService;
-import org.apache.usergrid.management.importer.ImportService;
-import org.apache.usergrid.persistence.EntityRef;
-import org.apache.usergrid.persistence.SimpleEntityRef;
 import org.apache.usergrid.persistence.entities.Export;
-import org.apache.usergrid.persistence.entities.Import;
 import org.apache.usergrid.persistence.queue.impl.UsergridAwsCredentials;
 import org.apache.usergrid.rest.AbstractContextResource;
 import org.apache.usergrid.rest.ApiResponse;
@@ -43,6 +36,7 @@ import org.apache.usergrid.rest.utils.JSONPUtils;
 import org.apache.usergrid.security.oauth.ClientCredentialsInfo;
 import org.apache.usergrid.security.tokens.exceptions.TokenException;
 import org.apache.usergrid.services.ServiceResults;
+import org.glassfish.jersey.server.mvc.Viewable;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -54,16 +48,12 @@ import javax.ws.rs.core.Context;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.Response;
 import javax.ws.rs.core.UriInfo;
-
 import java.util.HashMap;
-import java.util.List;
 import java.util.Map;
 import java.util.UUID;
 
 import static javax.servlet.http.HttpServletResponse.*;
 import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
-import org.apache.usergrid.persistence.Entity;
-import org.apache.usergrid.persistence.Query.Level;
 
 
 @Component("org.apache.usergrid.rest.management.organizations.OrganizationResource")
@@ -116,7 +106,9 @@ public class OrganizationResource extends AbstractContextResource {
 
 
     @GET
-    public JSONWithPadding getOrganizationDetails( @Context UriInfo ui,
+    @JSONP
+    @Produces({"application/json", "application/javascript"})
+    public ApiResponse getOrganizationDetails( @Context UriInfo ui,
                                                    @QueryParam("callback") @DefaultValue("callback") String callback )
             throws Exception {
 
@@ -125,7 +117,7 @@ public class OrganizationResource extends AbstractContextResource {
         ApiResponse response = createApiResponse();
         response.setProperty( "organization", management.getOrganizationData( organization ) );
 
-        return new JSONWithPadding( response, callback );
+        return response;
     }
 
 
@@ -176,7 +168,9 @@ public class OrganizationResource extends AbstractContextResource {
 
     @GET
     @Path("reactivate")
-    public JSONWithPadding reactivate( @Context UriInfo ui,
+    @JSONP
+    @Produces({"application/json", "application/javascript"})
+    public ApiResponse reactivate( @Context UriInfo ui,
                                        @QueryParam("callback") @DefaultValue("callback") String callback )
             throws Exception {
 
@@ -187,14 +181,16 @@ public class OrganizationResource extends AbstractContextResource {
         management.startOrganizationActivationFlow( organization );
 
         response.setAction( "reactivate organization" );
-        return new JSONWithPadding( response, callback );
+        return response;
     }
 
 
     @RequireOrganizationAccess
     @GET
     @Path("feed")
-    public JSONWithPadding getFeed( @Context UriInfo ui,
+    @JSONP
+    @Produces({"application/json", "application/javascript"})
+    public ApiResponse getFeed( @Context UriInfo ui,
                                     @QueryParam("callback") @DefaultValue("callback") String callback )
             throws Exception {
 
@@ -205,14 +201,16 @@ public class OrganizationResource extends AbstractContextResource {
         response.setEntities( results.getEntities() );
         response.setSuccess();
 
-        return new JSONWithPadding( response, callback );
+        return response;
     }
 
 
     @RequireOrganizationAccess
     @GET
     @Path("credentials")
-    public JSONWithPadding getCredentials( @Context UriInfo ui,
+    @JSONP
+    @Produces({"application/json", "application/javascript"})
+    public ApiResponse getCredentials( @Context UriInfo ui,
                                            @QueryParam("callback") @DefaultValue("callback") String callback )
             throws Exception {
 
@@ -224,14 +222,16 @@ public class OrganizationResource extends AbstractContextResource {
                         management.getClientSecretForOrganization( organization.getUuid() ) );
 
         response.setCredentials( keys );
-        return new JSONWithPadding( response, callback );
+        return response;
     }
 
 
     @RequireOrganizationAccess
     @POST
     @Path("credentials")
-    public JSONWithPadding generateCredentials( @Context UriInfo ui,
+    @JSONP
+    @Produces({"application/json", "application/javascript"})
+    public ApiResponse generateCredentials( @Context UriInfo ui,
                                                 @QueryParam("callback") @DefaultValue("callback") String callback )
             throws Exception {
 
@@ -243,7 +243,7 @@ public class OrganizationResource extends AbstractContextResource {
                         management.newClientSecretForOrganization( organization.getUuid() ) );
 
         response.setCredentials( credentials );
-        return new JSONWithPadding( response, callback );
+        return response;
     }
 
 
@@ -255,7 +255,9 @@ public class OrganizationResource extends AbstractContextResource {
     @RequireOrganizationAccess
     @Consumes(MediaType.APPLICATION_JSON)
     @PUT
-    public JSONWithPadding executePut( @Context UriInfo ui, Map<String, Object> json,
+    @JSONP
+    @Produces({"application/json", "application/javascript"})
+    public ApiResponse executePut( @Context UriInfo ui, Map<String, Object> json,
                                        @QueryParam("callback") @DefaultValue("callback") String callback )
             throws Exception {
 
@@ -270,7 +272,7 @@ public class OrganizationResource extends AbstractContextResource {
         organization.setProperties( customProperties );
         management.updateOrganization( organization );
 
-        return new JSONWithPadding( response, callback );
+        return response;
     }
 
     @POST


[05/54] usergrid git commit: Switch to Jersey 2, fix all compilation errors. TODO: new MeteringFilter, new JSON-HTMP swap logic and correct use of dependency management.

Posted by sn...@apache.org.
http://git-wip-us.apache.org/repos/asf/usergrid/blob/0578d987/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/OrganizationsResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/OrganizationsResource.java b/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/OrganizationsResource.java
index 13489a3..9398f0e 100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/OrganizationsResource.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/OrganizationsResource.java
@@ -17,40 +17,30 @@
 package org.apache.usergrid.rest.management.organizations;
 
 
-import java.util.Map;
-import java.util.UUID;
-
-import javax.ws.rs.Consumes;
-import javax.ws.rs.DefaultValue;
-import javax.ws.rs.FormParam;
-import javax.ws.rs.POST;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.Produces;
-import javax.ws.rs.QueryParam;
-import javax.ws.rs.core.Context;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.UriInfo;
-
-import org.apache.usergrid.rest.RootResource;
-import org.apache.usergrid.rest.management.ManagementResource;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.context.annotation.Scope;
-import org.springframework.stereotype.Component;
+import com.fasterxml.jackson.jaxrs.json.annotation.JSONP;
+import com.google.common.base.Preconditions;
+import org.apache.commons.lang.StringUtils;
 import org.apache.usergrid.management.ApplicationCreator;
 import org.apache.usergrid.management.OrganizationInfo;
 import org.apache.usergrid.management.OrganizationOwnerInfo;
 import org.apache.usergrid.management.exceptions.ManagementException;
 import org.apache.usergrid.rest.AbstractContextResource;
 import org.apache.usergrid.rest.ApiResponse;
+import org.apache.usergrid.rest.RootResource;
+import org.apache.usergrid.rest.management.ManagementResource;
 import org.apache.usergrid.rest.security.annotations.RequireOrganizationAccess;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Component;
 
-import org.apache.commons.lang.StringUtils;
-
-import com.google.common.base.Preconditions;
-import com.sun.jersey.api.json.JSONWithPadding;
+import javax.ws.rs.*;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.UriInfo;
+import java.util.Map;
+import java.util.UUID;
 
 
 @Component( "org.apache.usergrid.rest.management.organizations.OrganizationsResource" )
@@ -101,7 +91,9 @@ public class OrganizationsResource extends AbstractContextResource {
 
     @POST
     @Consumes( MediaType.APPLICATION_JSON )
-    public JSONWithPadding newOrganization( @Context UriInfo ui, Map<String, Object> json,
+    @JSONP
+    @Produces({"application/json", "application/javascript"})
+    public ApiResponse newOrganization( @Context UriInfo ui, Map<String, Object> json,
                                             @QueryParam( "callback" ) @DefaultValue( "" ) String callback )
             throws Exception {
 
@@ -126,7 +118,9 @@ public class OrganizationsResource extends AbstractContextResource {
 
     @POST
     @Consumes( MediaType.APPLICATION_FORM_URLENCODED )
-    public JSONWithPadding newOrganizationFromForm( @Context UriInfo ui,
+    @JSONP
+    @Produces({"application/json", "application/javascript"})
+    public ApiResponse newOrganizationFromForm( @Context UriInfo ui,
                                                     @FormParam( "organization" ) String organizationNameForm,
                                                     @QueryParam( "organization" ) String organizationNameQuery,
                                                     @FormParam( "username" ) String usernameForm,
@@ -153,7 +147,9 @@ public class OrganizationsResource extends AbstractContextResource {
 
 
     /** Create a new organization */
-    private JSONWithPadding newOrganization( @Context UriInfo ui, String organizationName, String username, String name,
+    @JSONP
+    @Produces({"application/json", "application/javascript"})
+    private ApiResponse newOrganization( @Context UriInfo ui, String organizationName, String username, String name,
                                              String email, String password, Map<String, Object> userProperties,
                                              Map<String, Object> orgProperties, String callback ) throws Exception {
 
@@ -191,7 +187,7 @@ public class OrganizationsResource extends AbstractContextResource {
         response.setSuccess();
 
         logger.info( "New organization complete: {}", organizationName );
-        return new JSONWithPadding( response, callback );
+        return response;
     }
 
     /*

http://git-wip-us.apache.org/repos/asf/usergrid/blob/0578d987/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/applications/ApplicationResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/applications/ApplicationResource.java b/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/applications/ApplicationResource.java
index bcec775..ae60123 100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/applications/ApplicationResource.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/applications/ApplicationResource.java
@@ -17,16 +17,17 @@
 package org.apache.usergrid.rest.management.organizations.applications;
 
 
+import com.fasterxml.jackson.jaxrs.json.annotation.JSONP;
 import com.google.common.base.Preconditions;
-import com.sun.jersey.api.json.JSONWithPadding;
 import org.apache.amber.oauth2.common.exception.OAuthSystemException;
 import org.apache.amber.oauth2.common.message.OAuthResponse;
 import org.apache.commons.lang.NullArgumentException;
 import org.apache.commons.lang.StringUtils;
-
 import org.apache.usergrid.management.ApplicationInfo;
 import org.apache.usergrid.management.OrganizationInfo;
 import org.apache.usergrid.management.export.ExportService;
+import org.apache.usergrid.persistence.EntityManager;
+import org.apache.usergrid.persistence.core.util.Health;
 import org.apache.usergrid.persistence.queue.impl.UsergridAwsCredentials;
 import org.apache.usergrid.rest.AbstractContextResource;
 import org.apache.usergrid.rest.ApiResponse;
@@ -38,7 +39,6 @@ import org.apache.usergrid.security.oauth.ClientCredentialsInfo;
 import org.apache.usergrid.security.providers.SignInAsProvider;
 import org.apache.usergrid.security.providers.SignInProviderFactory;
 import org.apache.usergrid.services.ServiceManager;
-
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -55,14 +55,8 @@ import java.util.Map;
 import java.util.Properties;
 import java.util.UUID;
 
-import static javax.servlet.http.HttpServletResponse.SC_ACCEPTED;
-import static javax.servlet.http.HttpServletResponse.SC_BAD_REQUEST;
-import static javax.servlet.http.HttpServletResponse.SC_INTERNAL_SERVER_ERROR;
-import static javax.servlet.http.HttpServletResponse.SC_NOT_FOUND;
-import static javax.servlet.http.HttpServletResponse.SC_OK;
+import static javax.servlet.http.HttpServletResponse.*;
 import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
-import org.apache.usergrid.persistence.EntityManager;
-import org.apache.usergrid.persistence.core.util.Health;
 
 
 @Component("org.apache.usergrid.rest.management.organizations.applications.ApplicationResource")
@@ -112,7 +106,9 @@ public class ApplicationResource extends AbstractContextResource {
 
     @RequireOrganizationAccess
     @GET
-    public JSONWithPadding getApplication(
+    @JSONP
+    @Produces({"application/json", "application/javascript"})
+    public ApiResponse getApplication(
             @Context UriInfo ui, @QueryParam("callback") @DefaultValue("callback") String callback )
         throws Exception {
 
@@ -122,14 +118,16 @@ public class ApplicationResource extends AbstractContextResource {
         response.setApplication( sm.getApplication() );
         response.setParams( ui.getQueryParameters() );
         response.setResults( management.getApplicationMetadata( applicationId ) );
-        return new JSONWithPadding( response, callback );
+        return response;
     }
 
 
     @RequireOrganizationAccess
     @GET
     @Path("credentials")
-    public JSONWithPadding getCredentials(
+    @JSONP
+    @Produces({"application/json", "application/javascript"})
+    public ApiResponse getCredentials(
             @Context UriInfo ui, @QueryParam("callback") @DefaultValue("callback") String callback )
         throws Exception {
 
@@ -141,14 +139,16 @@ public class ApplicationResource extends AbstractContextResource {
                         management.getClientSecretForApplication( applicationId ) );
 
         response.setCredentials( credentials );
-        return new JSONWithPadding( response, callback );
+        return response;
     }
 
 
     @RequireOrganizationAccess
     @POST
     @Path("credentials")
-    public JSONWithPadding generateCredentials( @Context UriInfo ui,
+    @JSONP
+    @Produces({"application/json", "application/javascript"})
+    public ApiResponse generateCredentials( @Context UriInfo ui,
             @QueryParam("callback") @DefaultValue("callback") String callback )
         throws Exception {
 
@@ -160,7 +160,7 @@ public class ApplicationResource extends AbstractContextResource {
                         management.newClientSecretForApplication( applicationId ) );
 
         response.setCredentials( credentials );
-        return new JSONWithPadding( response, callback );
+        return response;
     }
 
 
@@ -168,7 +168,9 @@ public class ApplicationResource extends AbstractContextResource {
     @Path("sia-provider")
     @Consumes(APPLICATION_JSON)
     @RequireOrganizationAccess
-    public JSONWithPadding configureProvider(
+    @JSONP
+    @Produces({"application/json", "application/javascript"})
+    public ApiResponse configureProvider(
             @Context UriInfo ui,
             @QueryParam("provider_key") String siaProvider,
             Map<String, Object> json,
@@ -200,7 +202,7 @@ public class ApplicationResource extends AbstractContextResource {
 
         signInAsProvider.saveToConfiguration( json );
 
-        return new JSONWithPadding( response, callback );
+        return response;
     }
 
     @POST
@@ -393,7 +395,9 @@ public class ApplicationResource extends AbstractContextResource {
      */
     @PUT
     @RequireOrganizationAccess
-    public JSONWithPadding executePut(  @Context UriInfo ui, String body,
+    @JSONP
+    @Produces({"application/json", "application/javascript"})
+    public ApiResponse executePut(  @Context UriInfo ui, String body,
         @QueryParam("callback") @DefaultValue("callback") String callback ) throws Exception {
 
         if ( applicationId == null ) {
@@ -407,13 +411,15 @@ public class ApplicationResource extends AbstractContextResource {
         response.setApplication( emf.getEntityManager( applicationId ).getApplication() );
         response.setParams( ui.getQueryParameters() );
 
-        return new JSONWithPadding( response, callback );
+        return response;
     }
 
 
     @DELETE
     @RequireOrganizationAccess
-    public JSONWithPadding executeDelete(  @Context UriInfo ui,
+    @JSONP
+    @Produces({"application/json", "application/javascript"})
+    public ApiResponse executeDelete(  @Context UriInfo ui,
         @QueryParam("callback") @DefaultValue("callback") String callback,
         @QueryParam("app_delete_confirm") String confirmDelete) throws Exception {
 
@@ -445,7 +451,7 @@ public class ApplicationResource extends AbstractContextResource {
 
         logger.debug( "ApplicationResource.delete() sending response ");
 
-        return new JSONWithPadding( response, callback );
+        return response;
     }
 
 }

http://git-wip-us.apache.org/repos/asf/usergrid/blob/0578d987/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/applications/ApplicationsResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/applications/ApplicationsResource.java b/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/applications/ApplicationsResource.java
index 28eff4e..ef9a5f4 100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/applications/ApplicationsResource.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/applications/ApplicationsResource.java
@@ -17,30 +17,28 @@
 package org.apache.usergrid.rest.management.organizations.applications;
 
 
-import java.util.LinkedHashMap;
-import java.util.Map;
-import java.util.UUID;
-
-import javax.ws.rs.*;
-import javax.ws.rs.core.Context;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.UriInfo;
-
-import org.apache.usergrid.rest.RootResource;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.context.annotation.Scope;
-import org.springframework.stereotype.Component;
+import com.fasterxml.jackson.jaxrs.json.annotation.JSONP;
+import com.google.common.base.Preconditions;
+import com.google.common.collect.BiMap;
 import org.apache.usergrid.management.ApplicationInfo;
 import org.apache.usergrid.management.OrganizationInfo;
 import org.apache.usergrid.persistence.exceptions.EntityNotFoundException;
 import org.apache.usergrid.rest.AbstractContextResource;
 import org.apache.usergrid.rest.ApiResponse;
+import org.apache.usergrid.rest.RootResource;
 import org.apache.usergrid.rest.security.annotations.RequireOrganizationAccess;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Component;
 
-import com.google.common.base.Preconditions;
-import com.google.common.collect.BiMap;
-import com.sun.jersey.api.json.JSONWithPadding;
+import javax.ws.rs.*;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.UriInfo;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.UUID;
 
 import static org.apache.commons.lang.StringUtils.isEmpty;
 
@@ -70,7 +68,9 @@ public class ApplicationsResource extends AbstractContextResource {
 
     @RequireOrganizationAccess
     @GET
-    public JSONWithPadding getOrganizationApplications(
+    @JSONP
+    @Produces({"application/json", "application/javascript"})
+    public ApiResponse getOrganizationApplications(
         @Context UriInfo ui,
         @QueryParam( "deleted" ) @DefaultValue( "false" ) Boolean deleted, // only return deleted apps if true
         @QueryParam( "callback" ) @DefaultValue( "callback" ) String callback ) throws Exception {
@@ -81,14 +81,16 @@ public class ApplicationsResource extends AbstractContextResource {
         BiMap<UUID, String> applications = management.getApplicationsForOrganization( organization.getUuid() );
         response.setData( applications.inverse() );
 
-        return new JSONWithPadding( response, callback );
+        return response;
     }
 
 
     @RequireOrganizationAccess
     @POST
     @Consumes( MediaType.APPLICATION_JSON )
-    public JSONWithPadding newApplicationForOrganization( @Context UriInfo ui, Map<String, Object> json,
+    @JSONP
+    @Produces({"application/json", "application/javascript"})
+    public ApiResponse newApplicationForOrganization( @Context UriInfo ui, Map<String, Object> json,
                                                           @QueryParam( "callback" ) @DefaultValue( "callback" )
                                                           String callback ) throws Exception {
         String applicationName = ( String ) json.get( "name" );
@@ -99,7 +101,9 @@ public class ApplicationsResource extends AbstractContextResource {
     @RequireOrganizationAccess
     @POST
     @Consumes( MediaType.APPLICATION_FORM_URLENCODED )
-    public JSONWithPadding newApplicationForOrganizationFromForm( @Context UriInfo ui, Map<String, Object> json,
+    @JSONP
+    @Produces({"application/json", "application/javascript"})
+    public ApiResponse newApplicationForOrganizationFromForm( @Context UriInfo ui, Map<String, Object> json,
                                                                   @QueryParam( "callback" ) @DefaultValue( "callback" )
                                                                   String callback,
                                                                   @FormParam( "name" ) String applicationName )
@@ -119,7 +123,7 @@ public class ApplicationsResource extends AbstractContextResource {
         applications.put( applicationInfo.getName(), applicationInfo.getId() );
         response.setData( applications );
         response.setResults( management.getApplicationMetadata( applicationInfo.getId() ) );
-        return new JSONWithPadding( response, callback );
+        return response;
 
     }
 

http://git-wip-us.apache.org/repos/asf/usergrid/blob/0578d987/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/applications/imports/FileErrorsResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/applications/imports/FileErrorsResource.java b/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/applications/imports/FileErrorsResource.java
index a72a8f0..d9fc009 100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/applications/imports/FileErrorsResource.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/applications/imports/FileErrorsResource.java
@@ -20,23 +20,7 @@
 package org.apache.usergrid.rest.management.organizations.applications.imports;
 
 
-import java.util.Collections;
-import java.util.UUID;
-
-import javax.ws.rs.GET;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.Produces;
-import javax.ws.rs.QueryParam;
-import javax.ws.rs.core.Context;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.PathSegment;
-import javax.ws.rs.core.UriInfo;
-
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.context.annotation.Scope;
-import org.springframework.stereotype.Component;
-
+import com.fasterxml.jackson.jaxrs.json.annotation.JSONP;
 import org.apache.usergrid.management.ApplicationInfo;
 import org.apache.usergrid.management.importer.ImportService;
 import org.apache.usergrid.persistence.Entity;
@@ -46,8 +30,17 @@ import org.apache.usergrid.persistence.exceptions.EntityNotFoundException;
 import org.apache.usergrid.rest.AbstractContextResource;
 import org.apache.usergrid.rest.ApiResponse;
 import org.apache.usergrid.rest.RootResource;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Component;
 
-import com.sun.jersey.api.json.JSONWithPadding;
+import javax.ws.rs.*;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.PathSegment;
+import javax.ws.rs.core.UriInfo;
+import java.util.Collections;
+import java.util.UUID;
 
 
 @Component("org.apache.usergrid.rest.management.organizations.applications.imports.FileErrorsResource")
@@ -82,7 +75,9 @@ public class FileErrorsResource extends AbstractContextResource {
 
 
     @GET
-    public JSONWithPadding getFileIncludes( @Context UriInfo ui, @QueryParam( "ql" ) String query, @QueryParam( "cursor" ) String cursor )
+    @JSONP
+    @Produces({"application/json", "application/javascript"})
+    public ApiResponse getFileIncludes( @Context UriInfo ui, @QueryParam( "ql" ) String query, @QueryParam( "cursor" ) String cursor )
           throws Exception {
 
 
@@ -103,13 +98,15 @@ public class FileErrorsResource extends AbstractContextResource {
 
           response.withResults( importResults );
 
-          return new JSONWithPadding( response );
+          return response;
 
       }
 
     @GET
     @Path( RootResource.ENTITY_ID_PATH )
-    public JSONWithPadding getFileIncludeById( @Context UriInfo ui, @PathParam( "entityId" ) PathSegment entityId )
+    @JSONP
+    @Produces({"application/json", "application/javascript"})
+    public ApiResponse getFileIncludeById( @Context UriInfo ui, @PathParam( "entityId" ) PathSegment entityId )
         throws Exception {
 
         final UUID failedEntity = UUID.fromString( entityId.getPath() );
@@ -131,7 +128,7 @@ public class FileErrorsResource extends AbstractContextResource {
 
         response.setEntities( Collections.<Entity>singletonList( importEntity ) );
 
-        return new JSONWithPadding( response );
+        return response;
 
     }
 

http://git-wip-us.apache.org/repos/asf/usergrid/blob/0578d987/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/applications/imports/FileIncludesResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/applications/imports/FileIncludesResource.java b/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/applications/imports/FileIncludesResource.java
index 1cb44d0..708aa80 100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/applications/imports/FileIncludesResource.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/applications/imports/FileIncludesResource.java
@@ -33,6 +33,7 @@ import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.PathSegment;
 import javax.ws.rs.core.UriInfo;
 
+import com.fasterxml.jackson.jaxrs.json.annotation.JSONP;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.annotation.Scope;
 import org.springframework.stereotype.Component;
@@ -47,8 +48,6 @@ import org.apache.usergrid.rest.AbstractContextResource;
 import org.apache.usergrid.rest.ApiResponse;
 import org.apache.usergrid.rest.RootResource;
 
-import com.sun.jersey.api.json.JSONWithPadding;
-
 
 @Component("org.apache.usergrid.rest.management.organizations.applications.imports.FileIncludesResource")
 @Scope("prototype")
@@ -80,7 +79,9 @@ public class FileIncludesResource extends AbstractContextResource {
 
 
     @GET
-    public JSONWithPadding getFileIncludes( @Context UriInfo ui, @QueryParam( "ql" ) String query, @QueryParam( "cursor" ) String cursor )
+    @JSONP
+    @Produces({"application/json", "application/javascript"})
+    public ApiResponse getFileIncludes( @Context UriInfo ui, @QueryParam( "ql" ) String query, @QueryParam( "cursor" ) String cursor )
           throws Exception {
 
 
@@ -100,13 +101,15 @@ public class FileIncludesResource extends AbstractContextResource {
 
           response.withResults( importResults );
 
-          return new JSONWithPadding( response );
+        return response;
 
       }
 
     @GET
     @Path( RootResource.ENTITY_ID_PATH )
-    public JSONWithPadding getFileIncludeById( @Context UriInfo ui, @PathParam( "entityId" ) PathSegment entityId )
+    @JSONP
+    @Produces({"application/json", "application/javascript"})
+    public ApiResponse getFileIncludeById( @Context UriInfo ui, @PathParam( "entityId" ) PathSegment entityId )
         throws Exception {
 
         final UUID fileIncludeId = UUID.fromString( entityId.getPath() );
@@ -126,7 +129,7 @@ public class FileIncludesResource extends AbstractContextResource {
 
         response.setEntities( Collections.<Entity>singletonList( importEntity ) );
 
-        return new JSONWithPadding( response );
+        return response;
 
     }
 

http://git-wip-us.apache.org/repos/asf/usergrid/blob/0578d987/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/applications/imports/ImportsResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/applications/imports/ImportsResource.java b/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/applications/imports/ImportsResource.java
index 5755c8e..d829f80 100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/applications/imports/ImportsResource.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/applications/imports/ImportsResource.java
@@ -20,31 +20,8 @@
 package org.apache.usergrid.rest.management.organizations.applications.imports;
 
 
-import java.util.Collections;
-import java.util.Map;
-import java.util.UUID;
-
-import javax.ws.rs.Consumes;
-import javax.ws.rs.DefaultValue;
-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;
-import javax.ws.rs.QueryParam;
-import javax.ws.rs.core.Context;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.PathSegment;
-import javax.ws.rs.core.UriInfo;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.context.annotation.Scope;
-import org.springframework.stereotype.Component;
-
+import com.fasterxml.jackson.jaxrs.json.annotation.JSONP;
 import org.apache.commons.lang.NullArgumentException;
-
 import org.apache.usergrid.management.ApplicationInfo;
 import org.apache.usergrid.management.OrganizationInfo;
 import org.apache.usergrid.management.importer.ImportService;
@@ -56,8 +33,20 @@ import org.apache.usergrid.rest.AbstractContextResource;
 import org.apache.usergrid.rest.ApiResponse;
 import org.apache.usergrid.rest.RootResource;
 import org.apache.usergrid.rest.security.annotations.RequireOrganizationAccess;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Component;
 
-import com.sun.jersey.api.json.JSONWithPadding;
+import javax.ws.rs.*;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.PathSegment;
+import javax.ws.rs.core.UriInfo;
+import java.util.Collections;
+import java.util.Map;
+import java.util.UUID;
 
 
 @Component( "org.apache.usergrid.rest.management.organizations.applications.imports.ImportsResource" )
@@ -93,7 +82,9 @@ public class ImportsResource extends AbstractContextResource {
     @POST
     @RequireOrganizationAccess
     @Consumes( MediaType.APPLICATION_JSON )
-    public JSONWithPadding executePost( @Context UriInfo ui, String body,
+    @JSONP
+    @Produces({"application/json", "application/javascript"})
+    public ApiResponse executePost( @Context UriInfo ui, String body,
                                         @QueryParam( "callback" ) @DefaultValue( "callback" ) String callback )
         throws Exception {
 
@@ -142,12 +133,14 @@ public class ImportsResource extends AbstractContextResource {
 
         response.setEntities( Collections.<Entity>singletonList( importEntity ) );
 
-        return new JSONWithPadding( response, callback );
+        return response;
     }
 
 
     @GET
-    public JSONWithPadding getImports( @Context UriInfo ui, @QueryParam( "ql" ) String query,  @QueryParam( "cursor" ) String cursor ) throws Exception {
+    @JSONP
+    @Produces({"application/json", "application/javascript"})
+    public ApiResponse getImports( @Context UriInfo ui, @QueryParam( "ql" ) String query,  @QueryParam( "cursor" ) String cursor ) throws Exception {
 
         final Results importResults = importService.getImports( application.getId(), query, cursor );
 
@@ -161,13 +154,15 @@ public class ImportsResource extends AbstractContextResource {
         response.setParams( ui.getQueryParameters() );
         response.withResults( importResults );
 
-        return new JSONWithPadding( response );
+        return response;
     }
 
 
     @GET
     @Path( RootResource.ENTITY_ID_PATH )
-    public JSONWithPadding getImportById( @Context UriInfo ui, @PathParam( "entityId" ) PathSegment entityId )
+    @JSONP
+    @Produces({"application/json", "application/javascript"})
+    public ApiResponse getImportById( @Context UriInfo ui, @PathParam( "entityId" ) PathSegment entityId )
         throws Exception {
 
         final UUID importId = UUID.fromString( entityId.getPath() );
@@ -186,7 +181,7 @@ public class ImportsResource extends AbstractContextResource {
         response.setParams( ui.getQueryParameters() );
         response.setEntities( Collections.<Entity>singletonList( importEntity ) );
 
-        return new JSONWithPadding( response );
+        return response;
     }
 
 

http://git-wip-us.apache.org/repos/asf/usergrid/blob/0578d987/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/users/UsersResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/users/UsersResource.java b/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/users/UsersResource.java
index 036c3fb..a4e3f40 100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/users/UsersResource.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/users/UsersResource.java
@@ -17,42 +17,34 @@
 package org.apache.usergrid.rest.management.organizations.users;
 
 
-import com.sun.jersey.api.json.JSONWithPadding;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.UUID;
-import javax.ws.rs.Consumes;
-import javax.ws.rs.DELETE;
-import javax.ws.rs.DefaultValue;
-import javax.ws.rs.FormParam;
-import javax.ws.rs.GET;
-import javax.ws.rs.POST;
-import javax.ws.rs.PUT;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.Produces;
-import javax.ws.rs.QueryParam;
-import javax.ws.rs.core.Context;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.UriInfo;
-import static org.apache.commons.collections.MapUtils.getObject;
+import com.fasterxml.jackson.jaxrs.json.annotation.JSONP;
 import org.apache.usergrid.management.OrganizationInfo;
 import org.apache.usergrid.management.UserInfo;
 import org.apache.usergrid.management.exceptions.ManagementException;
 import org.apache.usergrid.rest.AbstractContextResource;
 import org.apache.usergrid.rest.ApiResponse;
 import org.apache.usergrid.rest.RootResource;
-import static org.apache.usergrid.rest.exceptions.SecurityException.mappableSecurityException;
 import org.apache.usergrid.rest.security.annotations.RequireOrganizationAccess;
 import org.apache.usergrid.security.shiro.utils.SubjectUtils;
-import static org.apache.usergrid.utils.ConversionUtils.getBoolean;
-import static org.apache.usergrid.utils.ConversionUtils.string;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.context.annotation.Scope;
 import org.springframework.stereotype.Component;
 
+import javax.ws.rs.*;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.UriInfo;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+
+import static org.apache.commons.collections.MapUtils.getObject;
+import static org.apache.usergrid.rest.exceptions.SecurityException.mappableSecurityException;
+import static org.apache.usergrid.utils.ConversionUtils.getBoolean;
+import static org.apache.usergrid.utils.ConversionUtils.string;
+
 
 @Component("org.apache.usergrid.rest.management.organizations.users.UsersResource")
 @Scope("prototype")
@@ -79,7 +71,9 @@ public class UsersResource extends AbstractContextResource {
 
     @RequireOrganizationAccess
     @GET
-    public JSONWithPadding getOrganizationUsers( @Context UriInfo ui,
+    @JSONP
+    @Produces({"application/json", "application/javascript"})
+    public ApiResponse getOrganizationUsers( @Context UriInfo ui,
                                                  @QueryParam("callback") @DefaultValue("callback") String callback )
             throws Exception {
 
@@ -88,14 +82,16 @@ public class UsersResource extends AbstractContextResource {
 
         List<UserInfo> users = management.getAdminUsersForOrganization( organization.getUuid() );
         response.setData( users );
-        return new JSONWithPadding( response, callback );
+        return response;
     }
 
 
     @RequireOrganizationAccess
     @POST
     @Consumes(MediaType.APPLICATION_JSON)
-    public JSONWithPadding newUserForOrganization( @Context UriInfo ui, Map<String, Object> json,
+    @JSONP
+    @Produces({"application/json", "application/javascript"})
+    public ApiResponse newUserForOrganization( @Context UriInfo ui, Map<String, Object> json,
                                                    @QueryParam("callback") @DefaultValue("callback") String callback )
             throws Exception {
 
@@ -112,7 +108,9 @@ public class UsersResource extends AbstractContextResource {
     @RequireOrganizationAccess
     @POST
     @Consumes(MediaType.APPLICATION_FORM_URLENCODED)
-    public JSONWithPadding newUserForOrganizationFromForm( @Context UriInfo ui, @FormParam("username") String username,
+    @JSONP
+    @Produces({"application/json", "application/javascript"})
+    public ApiResponse newUserForOrganizationFromForm( @Context UriInfo ui, @FormParam("username") String username,
                                                            @FormParam("name") String name,
                                                            @FormParam("email") String email,
                                                            @FormParam("password") String password,
@@ -150,7 +148,7 @@ public class UsersResource extends AbstractContextResource {
         response.setData( result );
         response.setSuccess();
 
-        return new JSONWithPadding( response, callback );
+        return response;
     }
 
 	/*
@@ -177,7 +175,9 @@ public class UsersResource extends AbstractContextResource {
     @RequireOrganizationAccess
     @PUT
     @Path(RootResource.USER_ID_PATH)
-    public JSONWithPadding addUserToOrganization( @Context UriInfo ui, @PathParam("userId") String userIdStr,
+    @JSONP
+    @Produces({"application/json", "application/javascript"})
+    public ApiResponse addUserToOrganization( @Context UriInfo ui, @PathParam("userId") String userIdStr,
                                                   @QueryParam("callback") @DefaultValue("callback") String callback )
             throws Exception {
 
@@ -195,14 +195,16 @@ public class UsersResource extends AbstractContextResource {
         response.setData( result );
         response.setSuccess();
 
-        return new JSONWithPadding( response, callback );
+        return response;
     }
 
 
     @RequireOrganizationAccess
     @PUT
     @Path(RootResource.EMAIL_PATH)
-    public JSONWithPadding addUserToOrganizationByEmail( @Context UriInfo ui, @PathParam("email") String email,
+    @JSONP
+    @Produces({"application/json", "application/javascript"})
+    public ApiResponse addUserToOrganizationByEmail( @Context UriInfo ui, @PathParam("email") String email,
                                                          @QueryParam("callback") @DefaultValue("callback")
                                                          String callback ) throws Exception {
 
@@ -220,14 +222,16 @@ public class UsersResource extends AbstractContextResource {
         response.setData( result );
         response.setSuccess();
 
-        return new JSONWithPadding( response, callback );
+        return response;
     }
 
 
     @RequireOrganizationAccess
     @PUT
     @Path("{username}")
-    public JSONWithPadding addUserToOrganizationByUsername( @Context UriInfo ui, @PathParam("username") String username,
+    @JSONP
+    @Produces({"application/json", "application/javascript"})
+    public ApiResponse addUserToOrganizationByUsername( @Context UriInfo ui, @PathParam("username") String username,
                                                             @QueryParam("callback") @DefaultValue("callback")
                                                             String callback ) throws Exception {
 
@@ -253,14 +257,14 @@ public class UsersResource extends AbstractContextResource {
         response.setData( result );
         response.setSuccess();
 
-        return new JSONWithPadding( response, callback );
+        return response;
     }
 
 
     @RequireOrganizationAccess
     @DELETE
     @Path(RootResource.USER_ID_PATH)
-    public JSONWithPadding removeUserFromOrganizationByUserId( @Context UriInfo ui,
+    public ApiResponse removeUserFromOrganizationByUserId( @Context UriInfo ui,
                                                                @PathParam("userId") String userIdStr,
                                                                @QueryParam("callback") @DefaultValue("callback")
                                                                String callback ) throws Exception {
@@ -279,14 +283,16 @@ public class UsersResource extends AbstractContextResource {
         response.setData( result );
         response.setSuccess();
 
-        return new JSONWithPadding( response, callback );
+        return response;
     }
 
 
     @RequireOrganizationAccess
     @DELETE
     @Path("{username}")
-    public JSONWithPadding removeUserFromOrganizationByUsername( @Context UriInfo ui,
+    @JSONP
+    @Produces({"application/json", "application/javascript"})
+    public ApiResponse removeUserFromOrganizationByUsername( @Context UriInfo ui,
                                                                  @PathParam("username") String username,
                                                                  @QueryParam("callback") @DefaultValue("callback")
                                                                  String callback ) throws Exception {
@@ -313,14 +319,16 @@ public class UsersResource extends AbstractContextResource {
         response.setData( result );
         response.setSuccess();
 
-        return new JSONWithPadding( response, callback );
+        return response;
     }
 
 
     @RequireOrganizationAccess
     @DELETE
     @Path(RootResource.EMAIL_PATH)
-    public JSONWithPadding removeUserFromOrganizationByEmail( @Context UriInfo ui, @PathParam("email") String email,
+    @JSONP
+    @Produces({"application/json", "application/javascript"})
+    public ApiResponse removeUserFromOrganizationByEmail( @Context UriInfo ui, @PathParam("email") String email,
                                                               @QueryParam("callback") @DefaultValue("callback")
                                                               String callback ) throws Exception {
 
@@ -338,6 +346,6 @@ public class UsersResource extends AbstractContextResource {
         response.setData( result );
         response.setSuccess();
 
-        return new JSONWithPadding( response, callback );
+        return response;
     }
 }

http://git-wip-us.apache.org/repos/asf/usergrid/blob/0578d987/stack/rest/src/main/java/org/apache/usergrid/rest/management/users/UserResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/management/users/UserResource.java b/stack/rest/src/main/java/org/apache/usergrid/rest/management/users/UserResource.java
index 7ea4eec..1741db6 100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/management/users/UserResource.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/management/users/UserResource.java
@@ -17,44 +17,33 @@
 package org.apache.usergrid.rest.management.users;
 
 
-import java.util.Map;
-import java.util.UUID;
-
-import javax.ws.rs.Consumes;
-import javax.ws.rs.DefaultValue;
-import javax.ws.rs.FormParam;
-import javax.ws.rs.GET;
-import javax.ws.rs.POST;
-import javax.ws.rs.PUT;
-import javax.ws.rs.Path;
-import javax.ws.rs.Produces;
-import javax.ws.rs.QueryParam;
-import javax.ws.rs.core.Context;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.UriInfo;
-
+import com.fasterxml.jackson.jaxrs.json.annotation.JSONP;
+import net.tanesha.recaptcha.ReCaptchaImpl;
+import net.tanesha.recaptcha.ReCaptchaResponse;
 import org.apache.commons.lang.StringUtils;
-import org.apache.usergrid.rest.management.ManagementResource;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.context.annotation.Scope;
-import org.springframework.stereotype.Component;
 import org.apache.usergrid.management.ActivationState;
 import org.apache.usergrid.management.UserInfo;
 import org.apache.usergrid.rest.AbstractContextResource;
 import org.apache.usergrid.rest.ApiResponse;
 import org.apache.usergrid.rest.exceptions.RedirectionException;
+import org.apache.usergrid.rest.management.ManagementResource;
 import org.apache.usergrid.rest.management.users.organizations.OrganizationsResource;
 import org.apache.usergrid.rest.security.annotations.RequireAdminUserAccess;
 import org.apache.usergrid.security.shiro.utils.SubjectUtils;
 import org.apache.usergrid.security.tokens.exceptions.TokenException;
 import org.apache.usergrid.services.ServiceResults;
+import org.glassfish.jersey.server.mvc.Viewable;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Component;
 
-import com.sun.jersey.api.json.JSONWithPadding;
-import com.sun.jersey.api.view.Viewable;
-
-import net.tanesha.recaptcha.ReCaptchaImpl;
-import net.tanesha.recaptcha.ReCaptchaResponse;
+import javax.ws.rs.*;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.UriInfo;
+import java.util.Map;
+import java.util.UUID;
 
 import static org.apache.usergrid.security.shiro.utils.SubjectUtils.isServiceAdmin;
 import static org.apache.usergrid.utils.ConversionUtils.string;
@@ -102,7 +91,9 @@ public class UserResource extends AbstractContextResource {
 
 
     @PUT
-    public JSONWithPadding setUserInfo( @Context UriInfo ui, Map<String, Object> json,
+    @JSONP
+    @Produces({"application/json", "application/javascript"})
+    public ApiResponse setUserInfo( @Context UriInfo ui, Map<String, Object> json,
                                         @QueryParam( "callback" ) @DefaultValue( "callback" ) String callback )
             throws Exception {
 
@@ -124,13 +115,15 @@ public class UserResource extends AbstractContextResource {
         ApiResponse response = createApiResponse();
         response.setAction( "update user info" );
 
-        return new JSONWithPadding( response, callback );
+        return response;
     }
 
 
     @PUT
     @Path( "password" )
-    public JSONWithPadding setUserPasswordPut( @Context UriInfo ui, Map<String, Object> json,
+    @JSONP
+    @Produces({"application/json", "application/javascript"})
+    public ApiResponse setUserPasswordPut( @Context UriInfo ui, Map<String, Object> json,
                                                @QueryParam( "callback" ) @DefaultValue( "callback" ) String callback )
             throws Exception {
 
@@ -151,13 +144,15 @@ public class UserResource extends AbstractContextResource {
         ApiResponse response = createApiResponse();
         response.setAction( "set user password" );
 
-        return new JSONWithPadding( response, callback );
+        return response;
     }
 
 
     @POST
     @Path( "password" )
-    public JSONWithPadding setUserPasswordPost( @Context UriInfo ui, Map<String, Object> json,
+    @JSONP
+    @Produces({"application/json", "application/javascript"})
+    public ApiResponse setUserPasswordPost( @Context UriInfo ui, Map<String, Object> json,
                                                 @QueryParam( "callback" ) @DefaultValue( "callback" ) String callback )
             throws Exception {
         return setUserPasswordPut( ui, json, callback );
@@ -167,7 +162,9 @@ public class UserResource extends AbstractContextResource {
     @RequireAdminUserAccess
     @GET
     @Path( "feed" )
-    public JSONWithPadding getFeed( @Context UriInfo ui,
+    @JSONP
+    @Produces({"application/json", "application/javascript"})
+    public ApiResponse getFeed( @Context UriInfo ui,
                                     @QueryParam( "callback" ) @DefaultValue( "callback" ) String callback )
             throws Exception {
 
@@ -178,13 +175,15 @@ public class UserResource extends AbstractContextResource {
         response.setEntities( results.getEntities() );
         response.setSuccess();
 
-        return new JSONWithPadding( response, callback );
+        return response;
     }
 
 
     @RequireAdminUserAccess
     @GET
-    public JSONWithPadding getUserData( @Context UriInfo ui, @QueryParam( "ttl" ) long ttl,
+    @JSONP
+    @Produces({"application/json", "application/javascript"})
+    public ApiResponse getUserData( @Context UriInfo ui, @QueryParam( "ttl" ) long ttl,
                                         @QueryParam( "shallow" ) boolean shallow,
                                         @QueryParam( "callback" ) @DefaultValue( "callback" ) String callback )
             throws Exception {
@@ -198,7 +197,7 @@ public class UserResource extends AbstractContextResource {
         response.setData( userOrganizationData );
         response.setSuccess();
 
-        return new JSONWithPadding( response, callback );
+        return response;
     }
 
 
@@ -387,7 +386,9 @@ public class UserResource extends AbstractContextResource {
 
     @GET
     @Path( "reactivate" )
-    public JSONWithPadding reactivate( @Context UriInfo ui,
+    @JSONP
+    @Produces({"application/json", "application/javascript"})
+    public ApiResponse reactivate( @Context UriInfo ui,
                                        @QueryParam( "callback" ) @DefaultValue( "callback" ) String callback )
             throws Exception {
 
@@ -406,13 +407,15 @@ public class UserResource extends AbstractContextResource {
         management.startAdminUserActivationFlow( user );
 
         response.setAction( "reactivate user" );
-        return new JSONWithPadding( response, callback );
+        return response;
     }
 
 
     @POST
     @Path( "revoketokens" )
-    public JSONWithPadding revokeTokensPost( @Context UriInfo ui,
+    @JSONP
+    @Produces({"application/json", "application/javascript"})
+    public ApiResponse revokeTokensPost( @Context UriInfo ui,
                                              @QueryParam( "callback" ) @DefaultValue( "callback" ) String callback )
             throws Exception {
 
@@ -425,13 +428,15 @@ public class UserResource extends AbstractContextResource {
         management.revokeAccessTokensForAdminUser( adminId );
 
         response.setAction( "revoked user tokens" );
-        return new JSONWithPadding( response, callback );
+        return response;
     }
 
 
     @PUT
     @Path( "revoketokens" )
-    public JSONWithPadding revokeTokensPut( @Context UriInfo ui,
+    @JSONP
+    @Produces({"application/json", "application/javascript"})
+    public ApiResponse revokeTokensPut( @Context UriInfo ui,
                                             @QueryParam( "callback" ) @DefaultValue( "callback" ) String callback )
             throws Exception {
         return revokeTokensPost( ui, callback );
@@ -440,7 +445,9 @@ public class UserResource extends AbstractContextResource {
 
     @POST
     @Path( "revoketoken" )
-    public JSONWithPadding revokeTokenPost( @Context UriInfo ui,
+    @JSONP
+    @Produces({"application/json", "application/javascript"})
+    public ApiResponse revokeTokenPost( @Context UriInfo ui,
                                             @QueryParam( "callback" ) @DefaultValue( "callback" ) String callback,
                                             @QueryParam( "token" ) String token ) throws Exception {
 
@@ -454,13 +461,15 @@ public class UserResource extends AbstractContextResource {
         management.revokeAccessTokenForAdminUser( adminId, token );
 
         response.setAction( "revoked user tokens" );
-        return new JSONWithPadding( response, callback );
+        return response;
     }
 
 
     @PUT
     @Path( "revoketoken" )
-    public JSONWithPadding revokeTokenPut( @Context UriInfo ui,
+    @JSONP
+    @Produces({"application/json", "application/javascript"})
+    public ApiResponse revokeTokenPut( @Context UriInfo ui,
                                            @QueryParam( "callback" ) @DefaultValue( "callback" ) String callback,
                                            @QueryParam( "token" ) String token ) throws Exception {
         return revokeTokenPost( ui, callback, token );

http://git-wip-us.apache.org/repos/asf/usergrid/blob/0578d987/stack/rest/src/main/java/org/apache/usergrid/rest/management/users/UsersResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/management/users/UsersResource.java b/stack/rest/src/main/java/org/apache/usergrid/rest/management/users/UsersResource.java
index 7165d08..6136139 100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/management/users/UsersResource.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/management/users/UsersResource.java
@@ -17,14 +17,12 @@
 package org.apache.usergrid.rest.management.users;
 
 
-import com.sun.jersey.api.json.JSONWithPadding;
-import com.sun.jersey.api.view.Viewable;
+import com.fasterxml.jackson.jaxrs.json.annotation.JSONP;
 import net.tanesha.recaptcha.ReCaptchaImpl;
 import net.tanesha.recaptcha.ReCaptchaResponse;
 import org.apache.commons.lang.StringUtils;
 import org.apache.usergrid.management.UserInfo;
 import org.apache.usergrid.management.exceptions.ManagementException;
-
 import org.apache.usergrid.rest.AbstractContextResource;
 import org.apache.usergrid.rest.ApiResponse;
 import org.apache.usergrid.rest.RootResource;
@@ -32,6 +30,7 @@ import org.apache.usergrid.rest.exceptions.AuthErrorInfo;
 import org.apache.usergrid.rest.exceptions.RedirectionException;
 import org.apache.usergrid.rest.management.ManagementResource;
 import org.apache.usergrid.security.shiro.utils.SubjectUtils;
+import org.glassfish.jersey.server.mvc.Viewable;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.stereotype.Component;
@@ -105,7 +104,9 @@ public class UsersResource extends AbstractContextResource {
 
     @POST
     @Consumes( MediaType.APPLICATION_FORM_URLENCODED )
-    public JSONWithPadding createUser( @Context UriInfo ui, @FormParam( "username" ) String username,
+    @JSONP
+    @Produces( {MediaType.APPLICATION_JSON, "application/javascript" })
+    public ApiResponse createUser( @Context UriInfo ui, @FormParam( "username" ) String username,
                                        @FormParam( "name" ) String name, @FormParam( "email" ) String email,
                                        @FormParam( "password" ) String password,
                                        @QueryParam( "callback" ) @DefaultValue( "callback" ) String callback )
@@ -135,7 +136,7 @@ public class UsersResource extends AbstractContextResource {
             throw mappableSecurityException( AuthErrorInfo.BAD_CREDENTIALS_SYNTAX_ERROR );
         }
 
-        return new JSONWithPadding( response, callback );
+        return response;
     }
 
 	/*

http://git-wip-us.apache.org/repos/asf/usergrid/blob/0578d987/stack/rest/src/main/java/org/apache/usergrid/rest/management/users/organizations/OrganizationsResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/management/users/organizations/OrganizationsResource.java b/stack/rest/src/main/java/org/apache/usergrid/rest/management/users/organizations/OrganizationsResource.java
index 71eccbf..186ccd3 100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/management/users/organizations/OrganizationsResource.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/management/users/organizations/OrganizationsResource.java
@@ -17,38 +17,26 @@
 package org.apache.usergrid.rest.management.users.organizations;
 
 
-import java.util.Map;
-import java.util.UUID;
-
-import javax.ws.rs.Consumes;
-import javax.ws.rs.DELETE;
-import javax.ws.rs.DefaultValue;
-import javax.ws.rs.FormParam;
-import javax.ws.rs.GET;
-import javax.ws.rs.POST;
-import javax.ws.rs.PUT;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.Produces;
-import javax.ws.rs.QueryParam;
-import javax.ws.rs.core.Context;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.UriInfo;
-
-import org.apache.usergrid.rest.RootResource;
-import org.springframework.context.annotation.Scope;
-import org.springframework.stereotype.Component;
+import com.fasterxml.jackson.jaxrs.json.annotation.JSONP;
+import com.google.common.collect.BiMap;
 import org.apache.usergrid.management.OrganizationInfo;
 import org.apache.usergrid.management.UserInfo;
 import org.apache.usergrid.management.exceptions.ManagementException;
 import org.apache.usergrid.rest.AbstractContextResource;
 import org.apache.usergrid.rest.ApiResponse;
+import org.apache.usergrid.rest.RootResource;
 import org.apache.usergrid.rest.security.annotations.RequireAdminUserAccess;
 import org.apache.usergrid.rest.security.annotations.RequireOrganizationAccess;
 import org.apache.usergrid.security.shiro.utils.SubjectUtils;
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Component;
 
-import com.google.common.collect.BiMap;
-import com.sun.jersey.api.json.JSONWithPadding;
+import javax.ws.rs.*;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.UriInfo;
+import java.util.Map;
+import java.util.UUID;
 
 
 @Component( "org.apache.usergrid.rest.management.users.organizations.OrganizationsResource" )
@@ -74,7 +62,9 @@ public class OrganizationsResource extends AbstractContextResource {
 
     @RequireAdminUserAccess
     @GET
-    public JSONWithPadding getUserOrganizations( @Context UriInfo ui,
+    @JSONP
+    @Produces({"application/json", "application/javascript"})
+    public ApiResponse getUserOrganizations( @Context UriInfo ui,
                                                  @QueryParam( "callback" ) @DefaultValue( "callback" ) String callback )
             throws Exception {
 
@@ -84,13 +74,15 @@ public class OrganizationsResource extends AbstractContextResource {
         BiMap<UUID, String> userOrganizations = SubjectUtils.getOrganizations();
         response.setData( userOrganizations.inverse() );
 
-        return new JSONWithPadding( response, callback );
+        return response;
     }
 
 
     @RequireAdminUserAccess
     @POST
-    public JSONWithPadding newOrganizationForUser( @Context UriInfo ui, Map<String, Object> json,
+    @JSONP
+    @Produces({"application/json", "application/javascript"})
+    public ApiResponse newOrganizationForUser( @Context UriInfo ui, Map<String, Object> json,
                                                    @QueryParam( "callback" ) @DefaultValue( "callback" )
                                                    String callback ) throws Exception {
 
@@ -103,14 +95,16 @@ public class OrganizationsResource extends AbstractContextResource {
 
         management.activateOrganization( organization );
 
-        return new JSONWithPadding( response, callback );
+        return response;
     }
 
 
     @RequireAdminUserAccess
     @POST
     @Consumes( MediaType.APPLICATION_FORM_URLENCODED )
-    public JSONWithPadding newOrganizationForUserFromForm( @Context UriInfo ui, Map<String, Object> json,
+    @JSONP
+    @Produces({"application/json", "application/javascript"})
+    public ApiResponse newOrganizationForUserFromForm( @Context UriInfo ui, Map<String, Object> json,
                                                            @QueryParam( "callback" ) @DefaultValue( "callback" )
                                                            String callback,
                                                            @FormParam( "organization" ) String organizationName )
@@ -128,14 +122,16 @@ public class OrganizationsResource extends AbstractContextResource {
 
         management.activateOrganization( organization );
 
-        return new JSONWithPadding( response, callback );
+        return response;
     }
 
 
     @RequireOrganizationAccess
     @PUT
     @Path( "{organizationName}" )
-    public JSONWithPadding addUserToOrganizationByOrganizationName( @Context UriInfo ui,
+    @JSONP
+    @Produces({"application/json", "application/javascript"})
+    public ApiResponse addUserToOrganizationByOrganizationName( @Context UriInfo ui,
                                                                     @PathParam( "organizationName" )
                                                                     String organizationName, @QueryParam( "callback" )
                                                                     @DefaultValue( "callback" ) String callback )
@@ -147,14 +143,16 @@ public class OrganizationsResource extends AbstractContextResource {
         OrganizationInfo organization = management.getOrganizationByName( organizationName );
         management.addAdminUserToOrganization( user, organization, true );
         response.setData( organization );
-        return new JSONWithPadding( response, callback );
+        return response;
     }
 
 
     @RequireOrganizationAccess
     @PUT
     @Path(RootResource.ORGANIZATION_ID_PATH)
-    public JSONWithPadding addUserToOrganizationByOrganizationId( @Context UriInfo ui, @PathParam( "organizationId" )
+    @JSONP
+    @Produces({"application/json", "application/javascript"})
+    public ApiResponse addUserToOrganizationByOrganizationId( @Context UriInfo ui, @PathParam( "organizationId" )
     String organizationIdStr, @QueryParam( "callback" ) @DefaultValue( "callback" ) String callback ) throws Exception {
 
         ApiResponse response = createApiResponse();
@@ -163,14 +161,16 @@ public class OrganizationsResource extends AbstractContextResource {
         OrganizationInfo organization = management.getOrganizationByUuid( UUID.fromString( organizationIdStr ) );
         management.addAdminUserToOrganization( user, organization, true );
         response.setData( organization );
-        return new JSONWithPadding( response, callback );
+        return response;
     }
 
 
     @RequireOrganizationAccess
     @DELETE
     @Path( RootResource.ORGANIZATION_ID_PATH )
-    public JSONWithPadding removeUserFromOrganizationByOrganizationId( @Context UriInfo ui,
+    @JSONP
+    @Produces({"application/json", "application/javascript"})
+    public ApiResponse removeUserFromOrganizationByOrganizationId( @Context UriInfo ui,
                                                                        @PathParam( "organizationId" )
                                                                        String organizationIdStr,
                                                                        @QueryParam( "callback" )
@@ -183,14 +183,16 @@ public class OrganizationsResource extends AbstractContextResource {
         OrganizationInfo organization = management.getOrganizationByUuid( UUID.fromString( organizationIdStr ) );
         management.removeAdminUserFromOrganization( user.getUuid(), organization.getUuid() );
         response.setData( organization );
-        return new JSONWithPadding( response, callback );
+        return response;
     }
 
 
     @RequireOrganizationAccess
     @DELETE
     @Path( "{organizationName}" )
-    public JSONWithPadding removeUserFromOrganizationByOrganizationName( @Context UriInfo ui,
+    @JSONP
+    @Produces({"application/json", "application/javascript"})
+    public ApiResponse removeUserFromOrganizationByOrganizationName( @Context UriInfo ui,
                                                                          @PathParam( "organizationName" )
                                                                          String organizationName,
                                                                          @QueryParam( "callback" )
@@ -203,6 +205,6 @@ public class OrganizationsResource extends AbstractContextResource {
         management.removeAdminUserFromOrganization( user.getUuid(), organization.getUuid() );
         response.setData( organization );
 
-        return new JSONWithPadding( response, callback );
+        return response;
     }
 }

http://git-wip-us.apache.org/repos/asf/usergrid/blob/0578d987/stack/rest/src/main/java/org/apache/usergrid/rest/organizations/OrganizationResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/organizations/OrganizationResource.java b/stack/rest/src/main/java/org/apache/usergrid/rest/organizations/OrganizationResource.java
index 5e1d1f7..6ac7366 100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/organizations/OrganizationResource.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/organizations/OrganizationResource.java
@@ -19,22 +19,9 @@ package org.apache.usergrid.rest.organizations;
 
 import com.google.common.base.Optional;
 import com.google.common.collect.BiMap;
-import com.sun.jersey.api.json.JSONWithPadding;
-import java.util.UUID;
-import java.util.regex.Pattern;
-import javax.ws.rs.DELETE;
-import javax.ws.rs.DefaultValue;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.Produces;
-import javax.ws.rs.QueryParam;
-import javax.ws.rs.core.Context;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.UriInfo;
 import org.apache.shiro.authz.UnauthorizedException;
 import org.apache.usergrid.exception.NotImplementedException;
 import org.apache.usergrid.management.OrganizationInfo;
-import org.apache.usergrid.persistence.index.query.Identifier;
 import org.apache.usergrid.rest.AbstractContextResource;
 import org.apache.usergrid.rest.RootResource;
 import org.apache.usergrid.rest.applications.ApplicationResource;
@@ -49,6 +36,12 @@ import org.slf4j.LoggerFactory;
 import org.springframework.context.annotation.Scope;
 import org.springframework.stereotype.Component;
 
+import javax.ws.rs.*;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.UriInfo;
+import java.util.UUID;
+
 
 @Component("org.apache.usergrid.rest.organizations.OrganizationResource")
 @Scope("prototype")
@@ -106,7 +99,7 @@ public class OrganizationResource extends AbstractContextResource {
         }
 
         // don't look up app if request is a PUT because a PUT can be used to restore a deleted app
-        if ( !hc.getRequest().getMethod().equalsIgnoreCase("PUT") ) {
+        if ( httpServletRequest.getMethod().equalsIgnoreCase("PUT") ) {
 
             BiMap<UUID, String> apps = management.getApplicationsForOrganization(organizationId);
             if (apps.get(applicationId) == null) {
@@ -184,11 +177,8 @@ public class OrganizationResource extends AbstractContextResource {
 
     @DELETE
     @RequireOrganizationAccess
-    public JSONWithPadding executeDelete( @Context UriInfo ui,
-                                          @QueryParam("callback") @DefaultValue("callback") String callback )
-            throws Exception {
-
-
+    public void executeDelete(
+        @Context UriInfo ui, @QueryParam("callback") @DefaultValue("callback") String callback ) throws Exception {
         throw new NotImplementedException( "Organization delete is not allowed yet" );
     }
 }

http://git-wip-us.apache.org/repos/asf/usergrid/blob/0578d987/stack/rest/src/main/java/org/apache/usergrid/rest/security/CrossOriginRequestFilter.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/security/CrossOriginRequestFilter.java b/stack/rest/src/main/java/org/apache/usergrid/rest/security/CrossOriginRequestFilter.java
index e975463..be6c3e9 100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/security/CrossOriginRequestFilter.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/security/CrossOriginRequestFilter.java
@@ -17,23 +17,21 @@
 package org.apache.usergrid.rest.security;
 
 
+import org.apache.usergrid.rest.utils.CORSUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import org.apache.usergrid.rest.utils.CORSUtils;
 
-import com.sun.jersey.spi.container.ContainerRequest;
-import com.sun.jersey.spi.container.ContainerResponse;
-import com.sun.jersey.spi.container.ContainerResponseFilter;
+import javax.ws.rs.container.ContainerRequestContext;
+import javax.ws.rs.container.ContainerResponseContext;
+import javax.ws.rs.container.ContainerResponseFilter;
+import java.io.IOException;
 
 
 public class CrossOriginRequestFilter implements ContainerResponseFilter {
-
     public static final Logger logger = LoggerFactory.getLogger( CrossOriginRequestFilter.class );
 
-
     @Override
-    public ContainerResponse filter( ContainerRequest request, ContainerResponse response ) {
-
-        return CORSUtils.allowAllOrigins( request, response );
+    public void filter(ContainerRequestContext request, ContainerResponseContext response) throws IOException {
+        CORSUtils.allowAllOrigins( request, response );
     }
 }

http://git-wip-us.apache.org/repos/asf/usergrid/blob/0578d987/stack/rest/src/main/java/org/apache/usergrid/rest/security/SecuredResourceFilterFactory.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/security/SecuredResourceFilterFactory.java b/stack/rest/src/main/java/org/apache/usergrid/rest/security/SecuredResourceFilterFactory.java
index 551c687..6e4fc1e 100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/security/SecuredResourceFilterFactory.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/security/SecuredResourceFilterFactory.java
@@ -17,20 +17,6 @@
 package org.apache.usergrid.rest.security;
 
 
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-
-import javax.ws.rs.core.Context;
-import javax.ws.rs.core.MultivaluedMap;
-import javax.ws.rs.core.UriInfo;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Qualifier;
-import org.springframework.stereotype.Component;
 import org.apache.usergrid.management.ApplicationInfo;
 import org.apache.usergrid.management.ManagementService;
 import org.apache.usergrid.persistence.EntityManager;
@@ -44,24 +30,32 @@ import org.apache.usergrid.rest.security.annotations.RequireSystemAccess;
 import org.apache.usergrid.rest.utils.PathingUtils;
 import org.apache.usergrid.security.shiro.utils.SubjectUtils;
 import org.apache.usergrid.services.ServiceManagerFactory;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.stereotype.Component;
 
-import com.sun.jersey.api.model.AbstractMethod;
-import com.sun.jersey.spi.container.ContainerRequest;
-import com.sun.jersey.spi.container.ContainerRequestFilter;
-import com.sun.jersey.spi.container.ContainerResponseFilter;
-import com.sun.jersey.spi.container.ResourceFilter;
-import com.sun.jersey.spi.container.ResourceFilterFactory;
+import javax.ws.rs.container.ContainerRequestContext;
+import javax.ws.rs.container.ContainerRequestFilter;
+import javax.ws.rs.container.DynamicFeature;
+import javax.ws.rs.container.ResourceInfo;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.FeatureContext;
+import javax.ws.rs.core.MultivaluedMap;
+import javax.ws.rs.core.UriInfo;
+import java.io.IOException;
+import java.lang.reflect.Method;
+import java.util.Map;
+import java.util.Properties;
 
 import static org.apache.commons.lang.StringUtils.isNotEmpty;
 import static org.apache.usergrid.rest.exceptions.SecurityException.mappableSecurityException;
-import static org.apache.usergrid.security.shiro.utils.SubjectUtils.isPermittedAccessToApplication;
-import static org.apache.usergrid.security.shiro.utils.SubjectUtils.isPermittedAccessToOrganization;
-import static org.apache.usergrid.security.shiro.utils.SubjectUtils.isUser;
-import static org.apache.usergrid.security.shiro.utils.SubjectUtils.loginApplicationGuest;
+import static org.apache.usergrid.security.shiro.utils.SubjectUtils.*;
 
 
 @Component
-public class SecuredResourceFilterFactory implements ResourceFilterFactory {
+public class SecuredResourceFilterFactory implements DynamicFeature {
 
     private static final Logger logger = LoggerFactory.getLogger( SecuredResourceFilterFactory.class );
 
@@ -118,58 +112,45 @@ public class SecuredResourceFilterFactory implements ResourceFilterFactory {
 
 
     @Override
-    public List<ResourceFilter> create( AbstractMethod am ) {
+    public void configure(ResourceInfo resourceInfo, FeatureContext featureContext) {
+        Method am = resourceInfo.getResourceMethod();
+
         if ( am.isAnnotationPresent( RequireApplicationAccess.class ) ) {
-            return Collections.<ResourceFilter>singletonList( new ApplicationFilter() );
+            featureContext.register( ApplicationFilter.class );
         }
         else if ( am.isAnnotationPresent( RequireOrganizationAccess.class ) ) {
-            return Collections.<ResourceFilter>singletonList( new OrganizationFilter() );
+            featureContext.register( OrganizationFilter.class );
         }
         else if ( am.isAnnotationPresent( RequireSystemAccess.class ) ) {
-            return Collections.<ResourceFilter>singletonList( new SystemFilter() );
+            featureContext.register( SystemFilter.class );
         }
         else if ( am.isAnnotationPresent( RequireAdminUserAccess.class ) ) {
-            return Collections.<ResourceFilter>singletonList( new AdminUserFilter() );
+            featureContext.register( AdminUserFilter.class );
         }
-        return null;
-    }
 
+    }
 
-    public abstract class AbstractFilter implements ResourceFilter, ContainerRequestFilter {
+    public abstract class AbstractFilter implements ContainerRequestFilter {
         public AbstractFilter() {
         }
 
-
         @Override
-        public ContainerRequestFilter getRequestFilter() {
-            return this;
-        }
-
-
-        @Override
-        public ContainerResponseFilter getResponseFilter() {
-            return null;
-        }
+        public void filter(ContainerRequestContext request) throws IOException {
 
-
-        @Override
-        public ContainerRequest filter( ContainerRequest request ) {
-            logger.debug( "Filtering {}", request.getRequestUri().toString() );
+            logger.debug( "Filtering {}", request.getUriInfo().getRequestUri().toString() );
 
             if ( request.getMethod().equalsIgnoreCase( "OPTIONS" ) ) {
                 logger.debug( "Skipping option request" );
-                return request;
             }
 
             MultivaluedMap<java.lang.String, java.lang.String> params = uriInfo.getPathParameters();
             logger.debug( "Params: {}", params.keySet() );
 
             authorize( request );
-            return request;
         }
 
 
-        public abstract void authorize( ContainerRequest request );
+        public abstract void authorize( ContainerRequestContext request );
 
 
         public Identifier getApplicationIdentifier() {
@@ -236,7 +217,7 @@ public class SecuredResourceFilterFactory implements ResourceFilterFactory {
 
 
         @Override
-        public void authorize( ContainerRequest request ) {
+        public void authorize( ContainerRequestContext request ) {
             logger.debug( "OrganizationFilter.authorize" );
 
             if ( !isPermittedAccessToOrganization( getOrganizationIdentifier() ) ) {
@@ -256,7 +237,7 @@ public class SecuredResourceFilterFactory implements ResourceFilterFactory {
 
 
         @Override
-        public void authorize( ContainerRequest request ) {
+        public void authorize( ContainerRequestContext request ) {
             logger.debug( "ApplicationFilter.authorize" );
             if ( SubjectUtils.isAnonymous() ) {
                 ApplicationInfo application = null;
@@ -296,21 +277,21 @@ public class SecuredResourceFilterFactory implements ResourceFilterFactory {
 
 
         @Override
-        public void authorize( ContainerRequest request ) {
+        public void authorize( ContainerRequestContext request ) {
             logger.debug( "SystemFilter.authorize" );
             try {
-                if ( !request.isUserInRole( "sysadmin" ) ) {
+                if ( !request.getSecurityContext().isUserInRole( "sysadmin" ) ) {
                     logger.debug( "You are not the system admin." );
                     throw mappableSecurityException( "unauthorized", "No system access authorized",
-                            SecurityException.REALM );
+                        SecurityException.REALM );
                 }
             }
             catch ( IllegalStateException e ) {
                 logger.debug( "This is an invalid state",e );
-                if ( ( request.getUserPrincipal() == null ) || !"sysadmin"
-                        .equals( request.getUserPrincipal().getName() ) ) {
+                if ( ( request.getSecurityContext().getUserPrincipal() == null ) || !"sysadmin"
+                    .equals( request.getSecurityContext().getUserPrincipal().getName() ) ) {
                     throw mappableSecurityException( "unauthorized", "No system access authorized",
-                            SecurityException.REALM );
+                        SecurityException.REALM );
                 }
             }
         }
@@ -323,7 +304,7 @@ public class SecuredResourceFilterFactory implements ResourceFilterFactory {
 
 
         @Override
-        public void authorize( ContainerRequest request ) {
+        public void authorize( ContainerRequestContext request ) {
             logger.debug( "AdminUserFilter.authorize" );
             if ( !isUser( getUserIdentifier() ) ) {
                 throw mappableSecurityException( "unauthorized", "No admin user access authorized" );

http://git-wip-us.apache.org/repos/asf/usergrid/blob/0578d987/stack/rest/src/main/java/org/apache/usergrid/rest/security/shiro/filters/BasicAuthSecurityFilter.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/security/shiro/filters/BasicAuthSecurityFilter.java b/stack/rest/src/main/java/org/apache/usergrid/rest/security/shiro/filters/BasicAuthSecurityFilter.java
index 5f03809..6bf825f 100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/security/shiro/filters/BasicAuthSecurityFilter.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/security/shiro/filters/BasicAuthSecurityFilter.java
@@ -17,18 +17,15 @@
 package org.apache.usergrid.rest.security.shiro.filters;
 
 
-import java.security.Principal;
-import java.util.Map;
-
-import javax.ws.rs.core.SecurityContext;
-
+import org.apache.shiro.codec.Base64;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.stereotype.Component;
 
-import org.apache.shiro.codec.Base64;
-
-import com.sun.jersey.spi.container.ContainerRequest;
+import javax.ws.rs.container.ContainerRequestContext;
+import javax.ws.rs.core.SecurityContext;
+import java.security.Principal;
+import java.util.Map;
 
 
 @Component
@@ -43,15 +40,14 @@ public class BasicAuthSecurityFilter extends SecurityFilter {
 
 
     @Override
-    public ContainerRequest filter( ContainerRequest request ) {
+    public void filter( ContainerRequestContext request ) {
         Map<String, String> auth_types = getAuthTypes( request );
         if ( ( auth_types == null ) || !auth_types.containsKey( AUTH_BASIC_TYPE ) ) {
-            return request;
+            return;
         }
-
         String[] values = Base64.decodeToString( auth_types.get( AUTH_BASIC_TYPE ) ).split( ":" );
         if ( values.length < 2 ) {
-            return request;
+            return;
         }
         String name = values[0].toLowerCase();
         String password = values[1];
@@ -64,13 +60,9 @@ public class BasicAuthSecurityFilter extends SecurityFilter {
                 && sysadmin_login_allowed ) {
             request.setSecurityContext( new SysAdminRoleAuthenticator() );
             logger.info( "System administrator access allowed" );
-            return request;
         }
-
-        return request;
     }
 
-
     private static class SysAdminRoleAuthenticator implements SecurityContext {
 
         private final Principal principal;

http://git-wip-us.apache.org/repos/asf/usergrid/blob/0578d987/stack/rest/src/main/java/org/apache/usergrid/rest/security/shiro/filters/ClientCredentialsSecurityFilter.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/security/shiro/filters/ClientCredentialsSecurityFilter.java b/stack/rest/src/main/java/org/apache/usergrid/rest/security/shiro/filters/ClientCredentialsSecurityFilter.java
index cdb7f50..c4ee3e7 100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/security/shiro/filters/ClientCredentialsSecurityFilter.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/security/shiro/filters/ClientCredentialsSecurityFilter.java
@@ -17,18 +17,16 @@
 package org.apache.usergrid.rest.security.shiro.filters;
 
 
-import javax.servlet.http.HttpServletRequest;
-import javax.ws.rs.core.Context;
-
+import org.apache.shiro.subject.Subject;
+import org.apache.usergrid.security.shiro.PrincipalCredentialsToken;
+import org.apache.usergrid.security.shiro.utils.SubjectUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.stereotype.Component;
-import org.apache.usergrid.security.shiro.PrincipalCredentialsToken;
-import org.apache.usergrid.security.shiro.utils.SubjectUtils;
-
-import org.apache.shiro.subject.Subject;
 
-import com.sun.jersey.spi.container.ContainerRequest;
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.container.ContainerRequestContext;
+import javax.ws.rs.core.Context;
 
 import static org.apache.commons.lang.StringUtils.isNotBlank;
 import static org.apache.usergrid.rest.exceptions.AuthErrorInfo.OAUTH2_INVALID_CLIENT;
@@ -50,7 +48,7 @@ public class ClientCredentialsSecurityFilter extends SecurityFilter {
 
 
     @Override
-    public ContainerRequest filter( ContainerRequest request ) {
+    public void filter( ContainerRequestContext request ) {
         String clientId = httpServletRequest.getParameter( "client_id" );
         String clientSecret = httpServletRequest.getParameter( "client_secret" );
 
@@ -65,6 +63,5 @@ public class ClientCredentialsSecurityFilter extends SecurityFilter {
                 throw mappableSecurityException( OAUTH2_INVALID_CLIENT );
             }
         }
-        return request;
     }
 }


[18/54] usergrid git commit: SystemResourceIT tests pass only when run separately.

Posted by sn...@apache.org.
SystemResourceIT tests pass only when run separately.


Project: http://git-wip-us.apache.org/repos/asf/usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/usergrid/commit/31bacc8d
Tree: http://git-wip-us.apache.org/repos/asf/usergrid/tree/31bacc8d
Diff: http://git-wip-us.apache.org/repos/asf/usergrid/diff/31bacc8d

Branch: refs/heads/usergrid-1007-shiro-cache
Commit: 31bacc8d1083337b0eac82c2f094282cd2d864a9
Parents: 1f77ca1
Author: Dave Johnson <sn...@apache.org>
Authored: Wed Sep 9 10:00:27 2015 -0400
Committer: Dave Johnson <sn...@apache.org>
Committed: Wed Sep 9 10:00:27 2015 -0400

----------------------------------------------------------------------
 .../test/java/org/apache/usergrid/rest/NotificationsIT.java    | 6 ++++--
 .../test/java/org/apache/usergrid/rest/PartialUpdateTest.java  | 6 ++++--
 .../test/java/org/apache/usergrid/rest/SystemResourceIT.java   | 3 ++-
 .../org/apache/usergrid/rest/test/resource/ClientSetup.java    | 5 ++++-
 .../usergrid/rest/test/resource/endpoints/SetupResource.java   | 2 +-
 .../usergrid/rest/test/resource/endpoints/SystemResource.java  | 2 +-
 6 files changed, 16 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/usergrid/blob/31bacc8d/stack/rest/src/test/java/org/apache/usergrid/rest/NotificationsIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/NotificationsIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/NotificationsIT.java
index 07ec796..22785dc 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/NotificationsIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/NotificationsIT.java
@@ -188,7 +188,8 @@ public class NotificationsIT extends org.apache.usergrid.rest.test.resource.Abst
 
     private int pageThroughAllNotifications( String state ) throws IOException, InterruptedException {
 
-        Collection initialNode = this.app().collection("notifications").get(new QueryParameters().setQuery("select * where state='" + state + "'"));
+        Collection initialNode = this.app().collection("notifications")
+            .get(new QueryParameters().setQuery("select * where state='" + state + "'"));
 
         int count = initialNode.getNumOfEntities();
 
@@ -202,7 +203,8 @@ public class NotificationsIT extends org.apache.usergrid.rest.test.resource.Abst
 
             while (cursor != null) {
 
-                Collection anotherNode = this.app().collection("notifications").get(new QueryParameters().setQuery("select * where state='" + state + "'").setCursor(cursor));
+                Collection anotherNode = this.app().collection("notifications")
+                    .get(new QueryParameters().setQuery("select * where state='" + state + "'").setCursor(cursor));
 
 
                 int returnCount = anotherNode.getNumOfEntities();

http://git-wip-us.apache.org/repos/asf/usergrid/blob/31bacc8d/stack/rest/src/test/java/org/apache/usergrid/rest/PartialUpdateTest.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/PartialUpdateTest.java b/stack/rest/src/test/java/org/apache/usergrid/rest/PartialUpdateTest.java
index bc66467..5ce3c2d 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/PartialUpdateTest.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/PartialUpdateTest.java
@@ -98,8 +98,10 @@ public class PartialUpdateTest extends AbstractRestIT {
 
             // Verify that the location was updated correctly AND that
             // it is not the same object reference from the original POST
-            log.info(geolocation.get("latitude") + " != " + Double.parseDouble(((Map<String, Object>) userNode.get("location")).get("latitude").toString()));
-            log.info(geolocation.get("longitude") + " != " + Double.parseDouble(((Map<String, Object>) userNode.get("location")).get("longitude").toString()));
+            log.info(geolocation.get("latitude") + " != "
+                + Double.parseDouble(((Map<String, Object>) userNode.get("location")).get("latitude").toString()));
+            log.info(geolocation.get("longitude") + " != "
+                + Double.parseDouble(((Map<String, Object>) userNode.get("location")).get("longitude").toString()));
             assertNotSame(geolocation.get("latitude"),
                 Double.parseDouble(((Map<String, Object>) userNode.get("location")).get("latitude").toString()));
             assertEquals(geolocation.get("latitude").doubleValue(),

http://git-wip-us.apache.org/repos/asf/usergrid/blob/31bacc8d/stack/rest/src/test/java/org/apache/usergrid/rest/SystemResourceIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/SystemResourceIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/SystemResourceIT.java
index e70d1b2..a278358 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/SystemResourceIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/SystemResourceIT.java
@@ -60,7 +60,8 @@ public class SystemResourceIT extends AbstractRestIT {
         queryParameters.addParam( "access_token", clientSetup.getSuperuserToken().getAccessToken() );
         queryParameters.addParam("confirmApplicationName", this.clientSetup.getAppName());
 
-        org.apache.usergrid.rest.test.resource.model.ApiResponse result = clientSetup.getRestClient().system().applications(this.clientSetup.getAppUuid()).delete( queryParameters);
+        org.apache.usergrid.rest.test.resource.model.ApiResponse result =
+            clientSetup.getRestClient().system().applications(this.clientSetup.getAppUuid()).delete( queryParameters);
 
         assertNotNull( result );
         assertNotNull( "ok",result.getStatus() );

http://git-wip-us.apache.org/repos/asf/usergrid/blob/31bacc8d/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/ClientSetup.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/ClientSetup.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/ClientSetup.java
index f13e215..57cb7e8 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/ClientSetup.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/ClientSetup.java
@@ -94,8 +94,9 @@ public class ClientSetup implements TestRule {
         String name = testClass + "." + methodName;
 
         try {
+
             restClient.superuserSetup();
-            superuserToken = restClient.management().token().get(superuserName, superuserPassword);
+
         } catch ( BadRequestException e ) {
             if ( logger.isDebugEnabled() ) {
                 logger.debug( "Error creating superuser, may already exist", e );
@@ -104,6 +105,8 @@ public class ClientSetup implements TestRule {
             }
         }
 
+        superuserToken = restClient.management().token().get(superuserName, superuserPassword);
+
         username = "user_"+name + UUIDUtils.newTimeUUID();
         password = username;
         orgName = "org_"+name+UUIDUtils.newTimeUUID();

http://git-wip-us.apache.org/repos/asf/usergrid/blob/31bacc8d/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/SetupResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/SetupResource.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/SetupResource.java
index 2b2b1b4..6897e86 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/SetupResource.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/SetupResource.java
@@ -43,6 +43,6 @@ public class SetupResource extends NamedResource {
             .credentials( "superuser", "superpassword" ).build();
 
         return resource.register( feature ).request()
-            .accept( MediaType.APPLICATION_JSON ).get( Entity.class );
+            .accept( MediaType.APPLICATION_JSON ).put( javax.ws.rs.client.Entity.json(""), Entity.class );
     }
 }

http://git-wip-us.apache.org/repos/asf/usergrid/blob/31bacc8d/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/SystemResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/SystemResource.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/SystemResource.java
index 4dd6dbc..6d89fa9 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/SystemResource.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/SystemResource.java
@@ -70,7 +70,7 @@ public class SystemResource extends NamedResource {
             response = getTarget(true)
                 .request()
                 .accept(MediaType.APPLICATION_JSON)
-                .put( javax.ws.rs.client.Entity.json(null), ApiResponse.class);
+                .put( javax.ws.rs.client.Entity.json(""), ApiResponse.class);
         return response;
     }
 }


[03/54] usergrid git commit: Switch to Jersey 2, fix all compilation errors. TODO: new MeteringFilter, new JSON-HTMP swap logic and correct use of dependency management.

Posted by sn...@apache.org.
http://git-wip-us.apache.org/repos/asf/usergrid/blob/0578d987/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/DuplicateNameIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/DuplicateNameIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/DuplicateNameIT.java
index ec69405..4e21ca7 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/DuplicateNameIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/DuplicateNameIT.java
@@ -16,11 +16,12 @@
 
 package org.apache.usergrid.rest.applications.collection;
 
-import com.sun.jersey.api.client.UniformInterfaceException;
 import org.apache.usergrid.rest.test.resource.AbstractRestIT;
 import org.apache.usergrid.rest.test.resource.model.Entity;
 import org.junit.Test;
 
+import javax.ws.rs.client.ResponseProcessingException;
+
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.fail;
 
@@ -46,7 +47,7 @@ public class DuplicateNameIT extends AbstractRestIT {
             this.app().collection(collectionName).post(entity);
             // fail if the POST did not return an exception
             fail("Should not have created duplicate entity");
-        } catch (UniformInterfaceException uie) {
+        } catch (ResponseProcessingException uie) {
             //Check for an exception
             assertEquals(400, uie.getResponse().getStatus());
         }

http://git-wip-us.apache.org/repos/asf/usergrid/blob/0578d987/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/activities/ActivityResourceIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/activities/ActivityResourceIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/activities/ActivityResourceIT.java
index 94a1bb3..239bb13 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/activities/ActivityResourceIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/activities/ActivityResourceIT.java
@@ -17,7 +17,6 @@
 package org.apache.usergrid.rest.applications.collection.activities;
 
 
-import com.sun.jersey.api.client.UniformInterfaceException;
 import org.apache.usergrid.persistence.index.utils.MapUtils;
 import org.apache.usergrid.rest.test.resource.AbstractRestIT;
 import org.apache.usergrid.rest.test.resource.endpoints.CollectionEndpoint;
@@ -29,6 +28,8 @@ import org.slf4j.LoggerFactory;
 
 import org.apache.usergrid.utils.UUIDUtils;
 
+import javax.ws.rs.client.ResponseProcessingException;
+
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
 
@@ -87,7 +88,7 @@ public class ActivityResourceIT extends AbstractRestIT {
         // don't populate the user, it will use the currently authenticated user.
         try {
             groupActivityResource.post(activity);
-        }catch (UniformInterfaceException e)
+        }catch (ResponseProcessingException e)
         {
             throw e;
         }

http://git-wip-us.apache.org/repos/asf/usergrid/blob/0578d987/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/devices/DevicesResourceIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/devices/DevicesResourceIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/devices/DevicesResourceIT.java
index ee18c62..6e44e39 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/devices/DevicesResourceIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/devices/DevicesResourceIT.java
@@ -29,7 +29,6 @@ import org.apache.usergrid.rest.test.resource.model.Entity;
 import org.junit.Test;
 
 
-import com.sun.jersey.api.client.UniformInterfaceException;
 import java.io.IOException;
 
 import static org.junit.Assert.assertEquals;
@@ -37,6 +36,7 @@ import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.fail;
 import org.junit.Ignore;
 
+import javax.ws.rs.client.ResponseProcessingException;
 
 
 public class DevicesResourceIT extends AbstractRestIT {
@@ -68,7 +68,7 @@ public class DevicesResourceIT extends AbstractRestIT {
             entity = devicesResource.entity(uuid).get();
             fail( "should get 404 error" );
         }
-        catch ( UniformInterfaceException e ) {
+        catch ( ResponseProcessingException e ) {
             assertEquals( 404, e.getResponse().getStatus() );
         }
         refreshIndex();

http://git-wip-us.apache.org/repos/asf/usergrid/blob/0578d987/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/groups/GroupResourceIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/groups/GroupResourceIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/groups/GroupResourceIT.java
index a52792a..787306c 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/groups/GroupResourceIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/groups/GroupResourceIT.java
@@ -17,19 +17,15 @@
 package org.apache.usergrid.rest.applications.collection.groups;
 
 
-import java.io.IOException;
-import java.util.NoSuchElementException;
 import com.fasterxml.jackson.databind.JsonNode;
-import com.sun.jersey.api.client.UniformInterfaceException;
 import org.apache.usergrid.rest.test.resource.AbstractRestIT;
 import org.apache.usergrid.rest.test.resource.model.Collection;
 import org.apache.usergrid.rest.test.resource.model.Entity;
-
 import org.junit.Ignore;
 import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
+import javax.ws.rs.client.ResponseProcessingException;
+import java.io.IOException;
 
 import static org.junit.Assert.*;
 
@@ -153,9 +149,9 @@ public class GroupResourceIT extends AbstractRestIT {
         try {
             this.createGroup(groupName, groupSpacePath);
             fail("Should not be able to create a group with a space in the path");
-        } catch (UniformInterfaceException e) {
+        } catch (ResponseProcessingException e) {
             //verify the correct error was returned
-            JsonNode node = mapper.readTree( e.getResponse().getEntity( String.class ));
+            JsonNode node = mapper.readTree( e.getResponse().readEntity( String.class ));
             assertEquals( "illegal_argument", node.get( "error" ).textValue() );
         }
 
@@ -196,9 +192,9 @@ public class GroupResourceIT extends AbstractRestIT {
         try {
             this.app().collection("groups").uniqueID(groupName).get();
             fail("Entity still exists");
-        } catch (UniformInterfaceException e) {
+        } catch (ResponseProcessingException e) {
             //verify the correct error was returned
-            JsonNode node = mapper.readTree( e.getResponse().getEntity( String.class ));
+            JsonNode node = mapper.readTree( e.getResponse().readEntity( String.class ));
             assertEquals( "entity_not_found", node.get( "error" ).textValue() );
         }
 
@@ -302,9 +298,9 @@ public class GroupResourceIT extends AbstractRestIT {
         try {
             this.app().collection("role").entity(role).get();
             fail("Entity still exists");
-        } catch (UniformInterfaceException e) {
+        } catch (ResponseProcessingException e) {
             //verify the correct error was returned
-            JsonNode node = mapper.readTree( e.getResponse().getEntity( String.class ));
+            JsonNode node = mapper.readTree( e.getResponse().readEntity( String.class ));
             assertEquals( "entity_not_found", node.get( "error" ).textValue() );
         }
 
@@ -371,9 +367,9 @@ public class GroupResourceIT extends AbstractRestIT {
         try {
             this.app().collection("cats").uniqueID(catName).put(fluffy);
             fail("permissions should not allow this");
-        } catch (UniformInterfaceException e) {
+        } catch (ResponseProcessingException e) {
             //verify the correct error was returned
-            JsonNode node = mapper.readTree( e.getResponse().getEntity( String.class ));
+            JsonNode node = mapper.readTree( e.getResponse().readEntity( String.class ) );
             assertEquals( "unauthorized", node.get( "error" ).textValue() );
         }
 
@@ -381,9 +377,9 @@ public class GroupResourceIT extends AbstractRestIT {
         try {
             this.app().collection("cats").uniqueID(catName).delete();
             fail("permissions should not allow this");
-        } catch (UniformInterfaceException e) {
+        } catch (ResponseProcessingException e) {
             //verify the correct error was returned
-            JsonNode node = mapper.readTree( e.getResponse().getEntity( String.class ));
+            JsonNode node = mapper.readTree( e.getResponse().readEntity( String.class ));
             assertEquals( "unauthorized", node.get( "error" ).textValue() );
         }
 

http://git-wip-us.apache.org/repos/asf/usergrid/blob/0578d987/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/users/ConnectionResourceTest.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/users/ConnectionResourceTest.java b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/users/ConnectionResourceTest.java
index 22a6165..af3ce9b 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/users/ConnectionResourceTest.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/users/ConnectionResourceTest.java
@@ -17,7 +17,6 @@
 package org.apache.usergrid.rest.applications.collection.users;
 
 
-import com.sun.jersey.api.client.UniformInterfaceException;
 import org.apache.usergrid.rest.test.resource.AbstractRestIT;
 import org.apache.usergrid.rest.test.resource.endpoints.CollectionEndpoint;
 import org.apache.usergrid.rest.test.resource.model.Collection;
@@ -26,6 +25,7 @@ import org.junit.Test;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import javax.ws.rs.client.ResponseProcessingException;
 import java.io.IOException;
 import java.util.Map;
 
@@ -71,7 +71,7 @@ public class ConnectionResourceTest extends AbstractRestIT {
 
             this.app().collection("users").entity(scott).collection("likes").collection("peeps").entity(peep).get();
             fail("This should throw an exception");
-        } catch (UniformInterfaceException uie) {
+        } catch (ResponseProcessingException uie) {
             // Should return a 404 Not Found
             assertEquals(404, uie.getResponse().getStatus());
         }
@@ -162,7 +162,7 @@ public class ConnectionResourceTest extends AbstractRestIT {
             //attempt to retrieve thing1
             thing2 = this.app().collection("things").entity(thing2).get();
             fail("This should throw an exception");
-        } catch (UniformInterfaceException uie) {
+        } catch (ResponseProcessingException uie) {
             // Should return a 404 Not Found
             assertEquals(404, uie.getResponse().getStatus());
         }
@@ -198,7 +198,7 @@ public class ConnectionResourceTest extends AbstractRestIT {
             //attempt to retrieve thing1
             thing1 = this.app().collection("things").entity(thing1).get();
             fail("This should throw an exception");
-        } catch (UniformInterfaceException uie) {
+        } catch (ResponseProcessingException uie) {
             // Should return a 404 Not Found
             assertEquals(404, uie.getResponse().getStatus());
         }

http://git-wip-us.apache.org/repos/asf/usergrid/blob/0578d987/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/users/OwnershipResourceIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/users/OwnershipResourceIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/users/OwnershipResourceIT.java
index 8667757..f90b6ae 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/users/OwnershipResourceIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/users/OwnershipResourceIT.java
@@ -20,7 +20,6 @@ package org.apache.usergrid.rest.applications.collection.users;
 import com.fasterxml.jackson.databind.JsonNode;
 import java.io.IOException;
 
-import com.sun.jersey.api.client.UniformInterfaceException;
 import org.apache.usergrid.rest.test.resource.AbstractRestIT;
 import org.apache.usergrid.rest.test.resource.endpoints.CollectionEndpoint;
 import org.apache.usergrid.rest.test.resource.model.*;
@@ -31,6 +30,8 @@ import org.junit.Test;
 
 import org.apache.usergrid.utils.MapUtils;
 
+import javax.ws.rs.client.ResponseProcessingException;
+
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
@@ -151,7 +152,7 @@ public class OwnershipResourceIT extends AbstractRestIT {
         int status = 0;
         try {
             data = devices.entity("device2").get();
-        }catch (UniformInterfaceException e){
+        }catch (ResponseProcessingException e){
             status = e.getResponse().getStatus();
         }
         assertEquals( status,404 );
@@ -175,7 +176,7 @@ public class OwnershipResourceIT extends AbstractRestIT {
         status = 0;
         try{
         data = devices.entity("device1").get();
-        }catch (UniformInterfaceException e){
+        }catch (ResponseProcessingException e){
             status = e.getResponse().getStatus();
         }
         assertEquals( status,404 );
@@ -282,7 +283,7 @@ public class OwnershipResourceIT extends AbstractRestIT {
         int status = 200;
         try {
             likeRestaurants.entity("arrogantbutcher").get();
-        }catch (UniformInterfaceException e){
+        }catch (ResponseProcessingException e){
             status = e.getResponse().getStatus();
         }
         assertEquals(status, 404);
@@ -290,7 +291,7 @@ public class OwnershipResourceIT extends AbstractRestIT {
         status = 200;
         try {
             likeRestaurants.entity( arrogantButcherId ).get();
-        }catch (UniformInterfaceException e){
+        }catch (ResponseProcessingException e){
             status = e.getResponse().getStatus();
         }
         assertEquals(status, 404);
@@ -319,7 +320,7 @@ public class OwnershipResourceIT extends AbstractRestIT {
          status = 200;
         try {
             data = likeRestaurants.entity( "4peaks" ).get();
-        }catch (UniformInterfaceException e){
+        }catch (ResponseProcessingException e){
             status = e.getResponse().getStatus();
         }
         assertEquals( status,404 );
@@ -330,7 +331,7 @@ public class OwnershipResourceIT extends AbstractRestIT {
         try {
             likeRestaurants.entity( peaksId ).get();
 
-        }catch (UniformInterfaceException e){
+        }catch (ResponseProcessingException e){
             status = e.getResponse().getStatus();
         }
         assertEquals( status,404 );

http://git-wip-us.apache.org/repos/asf/usergrid/blob/0578d987/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/users/PermissionsResourceIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/users/PermissionsResourceIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/users/PermissionsResourceIT.java
index e0e852a..f9f1743 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/users/PermissionsResourceIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/users/PermissionsResourceIT.java
@@ -28,8 +28,8 @@ import org.apache.usergrid.utils.UUIDUtils;
 import org.junit.Before;
 import org.junit.Test;
 
-import com.sun.jersey.api.client.ClientResponse.Status;
-import com.sun.jersey.api.client.UniformInterfaceException;
+import javax.ws.rs.client.ResponseProcessingException;
+import javax.ws.rs.core.Response;
 import java.io.IOException;
 
 import static org.junit.Assert.*;
@@ -106,7 +106,7 @@ public class PermissionsResourceIT extends AbstractRestIT {
         int status = 0;
         try {
             node = this.app().collection("users").entity(USER).collection("roles").entity(ROLE).get();
-        }catch (UniformInterfaceException e){
+        }catch (ResponseProcessingException e){
             status = e.getResponse().getStatus();
         }
 
@@ -158,7 +158,7 @@ public class PermissionsResourceIT extends AbstractRestIT {
         try {
             this.app().collection("users").entity(user).collection("groups").entity( groupPath ).collection( "users" ).entity( user ).get();
             fail("Should not have been able to retrieve the user as it was deleted");
-        }catch (UniformInterfaceException e){
+        }catch (ResponseProcessingException e){
             status=e.getResponse().getStatus();
             assertEquals( 404,status );
         }
@@ -198,7 +198,7 @@ public class PermissionsResourceIT extends AbstractRestIT {
         //Call a get on a existing entity with no access token and check if we get a 401
         try {
             this.app().collection( "roles" ).entity( "guest" ).get( false );
-        }catch(UniformInterfaceException uie){
+        }catch(ResponseProcessingException uie){
             assertEquals( 401,uie.getResponse().getStatus() );
         }
 
@@ -209,13 +209,13 @@ public class PermissionsResourceIT extends AbstractRestIT {
         //Call a get on a non existing entity that doesn't need permissions and check it we get a 404.
         try {
             this.app().collection( "roles" ).entity( "banana" ).get( false );
-        }catch(UniformInterfaceException uie){
+        }catch(ResponseProcessingException uie){
             assertEquals( 404,uie.getResponse().getStatus() );
         }
 
         try {
             this.app().collection( "roles" ).entity( UUIDUtils.newTimeUUID() ).get( false );
-        }catch(UniformInterfaceException uie){
+        }catch(ResponseProcessingException uie){
             assertEquals( 404,uie.getResponse().getStatus() );
         }
     }
@@ -302,11 +302,11 @@ public class PermissionsResourceIT extends AbstractRestIT {
             this.app().collection("reviews").entity("noca").delete();
             fail( "this should have failed due to having insufficient permissions" );
         }
-        catch ( UniformInterfaceException uie ) {
+        catch ( ResponseProcessingException uie ) {
             status = uie.getResponse().getStatus();
         }
 
-        assertEquals( Status.UNAUTHORIZED.getStatusCode(), status );
+        assertEquals( Response.Status.UNAUTHORIZED.getStatusCode(), status );
 
         status = 0;
 
@@ -315,11 +315,11 @@ public class PermissionsResourceIT extends AbstractRestIT {
             this.app().collection("reviews").entity("4peaks").delete();
             fail( "this should have failed due to having insufficient permissions" );
         }
-        catch ( UniformInterfaceException uie ) {
+        catch ( ResponseProcessingException uie ) {
             status = uie.getResponse().getStatus();
         }
 
-        assertEquals( Status.UNAUTHORIZED.getStatusCode(), status );
+        assertEquals( Response.Status.UNAUTHORIZED.getStatusCode(), status );
 
         refreshIndex();
 
@@ -355,11 +355,11 @@ public class PermissionsResourceIT extends AbstractRestIT {
             this.app().collection("reviews").entity("cowboyciao").delete();
             fail( "this should have failed due to having insufficient permissions" );
         }
-        catch ( UniformInterfaceException uie ) {
+        catch ( ResponseProcessingException uie ) {
             status = uie.getResponse().getStatus();
         }
 
-        assertEquals( Status.UNAUTHORIZED.getStatusCode(), status );
+        assertEquals( Response.Status.UNAUTHORIZED.getStatusCode(), status );
 
         refreshIndex();
 
@@ -369,11 +369,11 @@ public class PermissionsResourceIT extends AbstractRestIT {
             this.app().collection("reviews").entity("currycorner").delete();
             fail( "this should have failed due to having insufficient permissions" );
         }
-        catch ( UniformInterfaceException uie ) {
+        catch ( ResponseProcessingException uie ) {
             status = uie.getResponse().getStatus();
         }
 
-        assertEquals( Status.UNAUTHORIZED.getStatusCode(), status );
+        assertEquals( Response.Status.UNAUTHORIZED.getStatusCode(), status );
     }
 
 
@@ -472,10 +472,10 @@ public class PermissionsResourceIT extends AbstractRestIT {
             this.app().collection("books").post(book);
 
         }
-        catch ( UniformInterfaceException uie ) {
+        catch ( ResponseProcessingException uie ) {
             status = uie.getResponse().getStatus();
         }
-        assertEquals( Status.UNAUTHORIZED.getStatusCode(), status );
+        assertEquals( Response.Status.UNAUTHORIZED.getStatusCode(), status );
 
         //Gets all books that user1 reviewed\
         this.app().collection("users").entity("me").connection("reviewed").collection("books").get();

http://git-wip-us.apache.org/repos/asf/usergrid/blob/0578d987/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/users/UserResourceIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/users/UserResourceIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/users/UserResourceIT.java
index a387436..71a8447 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/users/UserResourceIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/users/UserResourceIT.java
@@ -36,8 +36,8 @@ import org.slf4j.LoggerFactory;
 import org.apache.usergrid.rest.applications.utils.UserRepo;
 import org.apache.usergrid.utils.UUIDUtils;
 
-import com.sun.jersey.api.client.ClientResponse.Status;
-import com.sun.jersey.api.client.UniformInterfaceException;
+import javax.ws.rs.client.ResponseProcessingException;
+import javax.ws.rs.core.Response;
 import java.io.IOException;
 
 import static org.junit.Assert.assertEquals;
@@ -381,7 +381,8 @@ public class UserResourceIT extends AbstractRestIT {
 
         refreshIndex();
 
-        Collection results = usersResource.get(new QueryParameters().setQuery(String.format("username = '%s'", username)));
+        Collection results = usersResource.get(
+            new QueryParameters().setQuery(String.format("username = '%s'", username)));
         assertEquals(0, results.getResponse().getEntities().size());
 
         // now create that same user again, it should work
@@ -422,14 +423,16 @@ public class UserResourceIT extends AbstractRestIT {
 
         // plural collection name
 
-        Entity conn1 = usersResource.entity(firstCreatedId.toString()).connection("conn1").entity(secondCreatedId.toString()).post();
+        Entity conn1 = usersResource.entity(
+            firstCreatedId.toString()).connection("conn1").entity(secondCreatedId.toString()).post();
 
         assertEquals(secondCreatedId.toString(), conn1.getUuid().toString());
 
         refreshIndex();
 
 
-        Entity conn2 = usersResource.entity(firstCreatedId.toString()).connection("conn2").entity(secondCreatedId.toString()).post();
+        Entity conn2 = usersResource.entity(
+            firstCreatedId.toString()).connection("conn2").entity(secondCreatedId.toString()).post();
 
         assertEquals(secondCreatedId.toString(), conn2.getUuid().toString());
 
@@ -437,19 +440,23 @@ public class UserResourceIT extends AbstractRestIT {
 
         Collection conn1Connections = usersResource.entity(firstCreatedId.toString()).connection("conn1").get();
 
-        assertEquals(secondCreatedId.toString(), ((Entity) conn1Connections.getResponse().getEntities().get(0)).getUuid().toString());
+        assertEquals(secondCreatedId.toString(),
+            ((Entity) conn1Connections.getResponse().getEntities().get(0)).getUuid().toString());
 
         conn1Connections = userResource.entity(firstCreatedId.toString()).connection("conn1").get();
 
-        assertEquals(secondCreatedId.toString(), ((Entity) conn1Connections.getResponse().getEntities().get(0)).getUuid().toString());
+        assertEquals(secondCreatedId.toString(),
+            ((Entity) conn1Connections.getResponse().getEntities().get(0)).getUuid().toString());
 
         Collection conn2Connections = usersResource.entity(firstCreatedId.toString()).connection("conn1").get();
 
-        assertEquals(secondCreatedId.toString(), ((Entity) conn2Connections.getResponse().getEntities().get(0)).getUuid().toString());
+        assertEquals(secondCreatedId.toString(),
+            ((Entity) conn2Connections.getResponse().getEntities().get(0)).getUuid().toString());
 
         conn2Connections = userResource.entity(firstCreatedId.toString()).connection("conn1").get();
 
-        assertEquals(secondCreatedId.toString(), ((Entity) conn2Connections.getResponse().getEntities().get(0)).getUuid().toString());
+        assertEquals(secondCreatedId.toString(),
+            ((Entity) conn2Connections.getResponse().getEntities().get(0)).getUuid().toString());
     }
 
 
@@ -482,7 +489,8 @@ public class UserResourceIT extends AbstractRestIT {
         refreshIndex();
 
         // named entity in collection name
-        Entity conn1 = usersResource.entity(firstCreatedId.toString()).connection("conn1", "users").entity(secondCreatedId.toString()).post();
+        Entity conn1 = usersResource.entity(firstCreatedId.toString()).connection("conn1", "users")
+            .entity(secondCreatedId.toString()).post();
 
         assertEquals(secondCreatedId.toString(), conn1.getUuid().toString());
 
@@ -523,7 +531,8 @@ public class UserResourceIT extends AbstractRestIT {
         perms.put("permission", "get:/stuff/**");
 
 
-        Entity perms1 = this.app().collection("roles").entity(roleId1.toString()).connection("permissions").post(new Entity(perms));
+        Entity perms1 = this.app().collection("roles").entity(roleId1.toString()).connection("permissions")
+            .post(new Entity(perms));
 
 
         //Create the second role
@@ -538,10 +547,12 @@ public class UserResourceIT extends AbstractRestIT {
 
         perms = new HashMap<>();
         perms.put("permission", "get:/stuff/**");
-        Entity perms2 = this.app().collection("roles").entity(roleId2.toString()).connection("permissions").post(new Entity(perms));
+        Entity perms2 = this.app().collection("roles").entity(roleId2.toString()).connection("permissions")
+            .post(new Entity(perms));
         refreshIndex();
         //connect the entities where role is the root
-        Entity perms3 = this.app().collection("roles").entity(roleId1.toString()).connection("users").entity(userId.toString()).post();
+        Entity perms3 = this.app().collection("roles").entity(roleId1.toString()).connection("users")
+            .entity(userId.toString()).post();
 
         // now create a connection of "likes" between the first user and the
         // second using pluralized form
@@ -557,12 +568,14 @@ public class UserResourceIT extends AbstractRestIT {
 
         refreshIndex();
         //query the second role, it should work
-        Collection userRoles = this.app().collection("roles").entity(roleId2).connection("users").get(new QueryParameters().setQuery("select%20*%20where%20username%20=%20'" + email + "'"));
+        Collection userRoles = this.app().collection("roles").entity(roleId2).connection("users")
+            .get(new QueryParameters().setQuery("select%20*%20where%20username%20=%20'" + email + "'"));
         assertEquals(userId.toString(), ((Entity) userRoles.iterator().next()).getUuid().toString());
 
 
         //query the first role, it should work
-        userRoles = this.app().collection("roles").entity(roleId1).connection("users").get(new QueryParameters().setQuery("select%20*%20where%20username%20=%20'" + email + "'"));
+        userRoles = this.app().collection("roles").entity(roleId1).connection("users")
+            .get(new QueryParameters().setQuery("select%20*%20where%20username%20=%20'" + email + "'"));
         assertEquals(userId.toString(), ((Entity) userRoles.iterator().next()).getUuid().toString());
 
 
@@ -572,14 +585,16 @@ public class UserResourceIT extends AbstractRestIT {
 
         //query the first role, it should 404
         try {
-            userRoles = this.app().collection("roles").entity(roleId1).connection("users").get(new QueryParameters().setQuery("select%20*%20where%20username%20=%20'" + email + "'"));
+            userRoles = this.app().collection("roles").entity(roleId1).connection("users")
+                .get(new QueryParameters().setQuery("select%20*%20where%20username%20=%20'" + email + "'"));
             assertNull(userRoles);
-        } catch (UniformInterfaceException e) {
-            assertEquals(Status.NOT_FOUND.getStatusCode(), e.getResponse().getStatus());
+        } catch (ResponseProcessingException e) {
+            assertEquals( Response.Status.NOT_FOUND.getStatusCode(), e.getResponse().getStatus());
         }
 
         //query the second role, it should work
-        userRoles = this.app().collection("roles").entity(roleId2).connection("users").get(new QueryParameters().setQuery("select%20*%20where%20username%20=%20'" + email + "'"));
+        userRoles = this.app().collection("roles").entity(roleId2).connection("users")
+            .get(new QueryParameters().setQuery("select%20*%20where%20username%20=%20'" + email + "'"));
 
         assertEquals(userId.toString(), userRoles.getResponse().getEntities().get(0).getUuid().toString());
     }
@@ -613,7 +628,8 @@ public class UserResourceIT extends AbstractRestIT {
         // second using pluralized form
 
         // named entity in collection name
-        Entity conn1 = usersResource.entity(firstCreatedId).connection("conn1").collection("pizzas").entity(secondCreatedId).post();
+        Entity conn1 = usersResource.entity(firstCreatedId).connection("conn1").collection("pizzas")
+            .entity(secondCreatedId).post();
 
         assertEquals(secondCreatedId.toString(), conn1.getUuid().toString());
 
@@ -706,7 +722,8 @@ public class UserResourceIT extends AbstractRestIT {
         String userName = String.format("test%s", newUserUuid);
 
         User entity =
-                (User) new User(userName, "Ed Anuff", String.format("%s@anuff.com", newUserUuid), "sesame").chainPut("pin", "1234");
+                (User) new User(userName, "Ed Anuff", String.format("%s@anuff.com", newUserUuid), "sesame")
+                    .chainPut("pin", "1234");
 
         usersResource.post(entity);
         refreshIndex();
@@ -728,7 +745,8 @@ public class UserResourceIT extends AbstractRestIT {
         refreshIndex();
         boolean fail = false;
         try {
-            Entity changeResponse = usersResource.entity("edanuff").collection("password").post(new ChangePasswordEntity("foo", "bar"));
+            Entity changeResponse = usersResource.entity("edanuff").collection("password")
+                .post(new ChangePasswordEntity("foo", "bar"));
         } catch (Exception e) {
             fail = true;
         }
@@ -762,7 +780,8 @@ public class UserResourceIT extends AbstractRestIT {
 
         // if this was successful, we need to re-set the password for other
         // tests
-        Entity changeResponse = usersResource.entity("edanuff").collection("password").post(new ChangePasswordEntity("sesame1", "sesame"));
+        Entity changeResponse = usersResource.entity("edanuff").collection("password")
+            .post(new ChangePasswordEntity("sesame1", "sesame"));
         refreshIndex();
         assertNotNull(changeResponse);
 
@@ -776,7 +795,8 @@ public class UserResourceIT extends AbstractRestIT {
         refreshIndex();
 
         // change the password as admin. The old password isn't required
-        Entity node = usersResource.entity("edanuff").connection("password").post(new ChangePasswordEntity(newPassword));
+        Entity node = usersResource.entity("edanuff").connection("password")
+            .post(new ChangePasswordEntity(newPassword));
         assertNotNull(node);
 
         refreshIndex();
@@ -797,7 +817,7 @@ public class UserResourceIT extends AbstractRestIT {
         int responseStatus = 0;
         try {
             usersResource.entity("edanuff").connection("password").post(data);
-        } catch (UniformInterfaceException uie) {
+        } catch (ResponseProcessingException uie) {
             responseStatus = uie.getResponse().getStatus();
         }
 
@@ -849,8 +869,8 @@ public class UserResourceIT extends AbstractRestIT {
             role = usersResource.entity(createdId).collection("roles").entity(roleName).get();
 
             assertNull(role);
-        } catch (UniformInterfaceException e) {
-            assertEquals(e.getResponse().getStatus(), Status.NOT_FOUND.getStatusCode());
+        } catch (ResponseProcessingException e) {
+            assertEquals(e.getResponse().getStatus(), Response.Status.NOT_FOUND.getStatusCode());
         }
     }
 
@@ -871,7 +891,8 @@ public class UserResourceIT extends AbstractRestIT {
         assertNotNull(entity1);
 
         assertNotNull(entity2);
-        Token adminToken = this.clientSetup.getRestClient().management().token().post(false,Token.class,new Token(clientSetup.getUsername(), clientSetup.getUsername()),null);
+        Token adminToken = this.clientSetup.getRestClient().management().token()
+            .post( false, Token.class, new Token( clientSetup.getUsername(), clientSetup.getUsername() ), null );
         // now revoke the tokens
         this.app().token().setToken(adminToken);
 
@@ -886,11 +907,11 @@ public class UserResourceIT extends AbstractRestIT {
 
             usersResource.entity("edanuff").get();
             assertFalse(true);
-        } catch (UniformInterfaceException uie) {
+        } catch (ResponseProcessingException uie) {
             status = uie.getResponse().getStatus();
         }
 
-        assertEquals(Status.UNAUTHORIZED.getStatusCode(), status);
+        assertEquals(Response.Status.UNAUTHORIZED.getStatusCode(), status);
 
         status = 0;
 
@@ -898,11 +919,11 @@ public class UserResourceIT extends AbstractRestIT {
             this.app().token().setToken(token2);
 
             usersResource.entity("edanuff").get();
-        } catch (UniformInterfaceException uie) {
+        } catch (ResponseProcessingException uie) {
             status = uie.getResponse().getStatus();
         }
 
-        assertEquals(Status.UNAUTHORIZED.getStatusCode(), status);
+        assertEquals(Response.Status.UNAUTHORIZED.getStatusCode(), status);
 
         Token token3 = this.app().token().post(new Token("edanuff", "sesame"));
         Token token4 = this.app().token().post(new Token("edanuff", "sesame"));
@@ -919,7 +940,8 @@ public class UserResourceIT extends AbstractRestIT {
         assertNotNull(entity2);
 
         // now revoke the token3
-        adminToken = this.clientSetup.getRestClient().management().token().post(false,Token.class,new Token(clientSetup.getUsername(), clientSetup.getUsername()),null);
+        adminToken = this.clientSetup.getRestClient().management().token()
+            .post( false, Token.class, new Token( clientSetup.getUsername(), clientSetup.getUsername() ), null );
         // now revoke the tokens
         this.app().token().setToken(adminToken);
         usersResource.entity("edanuff").connection("revoketokens").post();
@@ -933,11 +955,11 @@ public class UserResourceIT extends AbstractRestIT {
             this.app().token().setToken(token3);
             usersResource.entity("edanuff").get();
 
-        } catch (UniformInterfaceException uie) {
+        } catch (ResponseProcessingException uie) {
             status = uie.getResponse().getStatus();
         }
 
-        assertEquals(Status.UNAUTHORIZED.getStatusCode(), status);
+        assertEquals(Response.Status.UNAUTHORIZED.getStatusCode(), status);
 
         status = 0;
 
@@ -946,12 +968,12 @@ public class UserResourceIT extends AbstractRestIT {
             usersResource.entity("edanuff").get();
 
 
-            status = Status.OK.getStatusCode();
-        } catch (UniformInterfaceException uie) {
+            status = Response.Status.OK.getStatusCode();
+        } catch (ResponseProcessingException uie) {
             status = uie.getResponse().getStatus();
         }
 
-        assertEquals(Status.UNAUTHORIZED.getStatusCode(), status);
+        assertEquals(Response.Status.UNAUTHORIZED.getStatusCode(), status);
     }
 
 
@@ -977,33 +999,37 @@ public class UserResourceIT extends AbstractRestIT {
 
         // bad access token
         try {
-            userResource.entity("test_1").connection("token").get(new QueryParameters().addParam("access_token", "blah"), false);
+            userResource.entity("test_1").connection("token").get(
+                new QueryParameters().addParam("access_token", "blah"), false);
             assertTrue(false);
-        } catch (UniformInterfaceException uie) {
+        } catch (ResponseProcessingException uie) {
             status = uie.getResponse().getStatus();
-            log.info("Error Response Body: " + uie.getResponse().getEntity(String.class));
+            log.info("Error Response Body: " + uie.getResponse().readEntity(String.class));
         }
 
-        assertEquals(Status.UNAUTHORIZED.getStatusCode(), status);
+        assertEquals(Response.Status.UNAUTHORIZED.getStatusCode(), status);
 
         try {
-            userResource.entity("test_2").connection("token").get(new QueryParameters().addParam("access_token", token.getAccessToken()), false);
+            userResource.entity("test_2").connection("token").get(
+                new QueryParameters().addParam("access_token", token.getAccessToken()), false);
             assertTrue(false);
-        } catch (UniformInterfaceException uie) {
+        } catch (ResponseProcessingException uie) {
             status = uie.getResponse().getStatus();
-            log.info("Error Response Body: " + uie.getResponse().getEntity(String.class));
+            log.info("Error Response Body: " + uie.getResponse().readEntity(String.class));
         }
 
-        assertEquals(Status.FORBIDDEN.getStatusCode(), status);
+        assertEquals(Response.Status.FORBIDDEN.getStatusCode(), status);
 
 
         String adminToken = this.getAdminToken().getAccessToken();
-        Collection tokens = userResource.entity("test_1").connection("token").get(new QueryParameters().addParam("access_token", adminToken), false);
+        Collection tokens = userResource.entity("test_1").connection("token").get(
+            new QueryParameters().addParam("access_token", adminToken), false);
 
 
         assertTrue(tokens.getResponse().getProperties().get("user") != null);
 
-        tokens = userResource.entity("test_1").connection("token").get(new QueryParameters().addParam("access_token", adminToken), false);
+        tokens = userResource.entity("test_1").connection("token").get(
+            new QueryParameters().addParam("access_token", adminToken), false);
 
         assertTrue(tokens.getResponse().getProperties().get("user") != null);
 
@@ -1015,9 +1041,9 @@ public class UserResourceIT extends AbstractRestIT {
         try {
             this.app().token().post(new Token("test_1", "test123"));
             fail("request for deactivated user should fail");
-        } catch (UniformInterfaceException uie) {
+        } catch (ResponseProcessingException uie) {
             status = uie.getResponse().getStatus();
-            JsonNode body = mapper.readTree(uie.getResponse().getEntity(String.class));
+            JsonNode body = mapper.readTree(uie.getResponse().readEntity(String.class));
             assertEquals("user not activated", body.findPath("error_description").textValue());
         }
     }

http://git-wip-us.apache.org/repos/asf/usergrid/blob/0578d987/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/BadGrammarQueryTest.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/BadGrammarQueryTest.java b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/BadGrammarQueryTest.java
index 5a2134d..c4b24b4 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/BadGrammarQueryTest.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/BadGrammarQueryTest.java
@@ -17,12 +17,11 @@
 package org.apache.usergrid.rest.applications.queries;
 
 
-import com.sun.jersey.api.client.UniformInterfaceException;
 import org.apache.usergrid.rest.test.resource.model.Collection;
-import org.apache.usergrid.rest.test.resource.model.Entity;
 import org.apache.usergrid.rest.test.resource.model.QueryParameters;
 import org.junit.Test;
 
+import javax.ws.rs.client.ResponseProcessingException;
 import java.io.IOException;
 
 import static org.junit.Assert.assertEquals;
@@ -55,7 +54,7 @@ public class BadGrammarQueryTest extends QueryTestBase {
             QueryParameters params = new QueryParameters().setQuery(query);
             this.app().collection(collectionName).get(params);
             fail("This should throw an exception");
-        } catch (UniformInterfaceException uie) {
+        } catch (ResponseProcessingException uie) {
             //Check for an exception
             assertEquals(400, uie.getResponse().getStatus());
         }
@@ -81,7 +80,7 @@ public class BadGrammarQueryTest extends QueryTestBase {
             QueryParameters params = new QueryParameters().setQuery(query);
             this.app().collection(collectionName).get(params);
             fail("This should throw an exception");
-        } catch (UniformInterfaceException uie) {
+        } catch (ResponseProcessingException uie) {
             //Check for an exception
             assertEquals(400, uie.getResponse().getStatus());
         }
@@ -107,7 +106,7 @@ public class BadGrammarQueryTest extends QueryTestBase {
             QueryParameters params = new QueryParameters().setQuery(query);
             this.app().collection(collectionName).get(params);
             fail("This should throw an exception");
-        } catch (UniformInterfaceException uie) {
+        } catch (ResponseProcessingException uie) {
             //Check for an exception
             assertEquals(400, uie.getResponse().getStatus());
         }
@@ -133,7 +132,7 @@ public class BadGrammarQueryTest extends QueryTestBase {
             QueryParameters params = new QueryParameters().setQuery(query);
             this.app().collection(collectionName).get(params);
             fail("This should throw an exception");
-        } catch (UniformInterfaceException uie) {
+        } catch (ResponseProcessingException uie) {
             //Check for an exception
             assertEquals(400, uie.getResponse().getStatus());
         }
@@ -159,7 +158,7 @@ public class BadGrammarQueryTest extends QueryTestBase {
             QueryParameters params = new QueryParameters().setQuery(query);
             this.app().collection(collectionName).get(params);
             fail("This should throw an exception");
-        } catch (UniformInterfaceException uie) {
+        } catch (ResponseProcessingException uie) {
             //Check for an exception
             assertEquals(400, uie.getResponse().getStatus());
         }
@@ -185,7 +184,7 @@ public class BadGrammarQueryTest extends QueryTestBase {
             QueryParameters params = new QueryParameters().setQuery(query);
             this.app().collection(collectionName).get(params);
             fail("This should throw an exception");
-        } catch (UniformInterfaceException uie) {
+        } catch (ResponseProcessingException uie) {
             //Check for an exception
             assertEquals(400, uie.getResponse().getStatus());
         }

http://git-wip-us.apache.org/repos/asf/usergrid/blob/0578d987/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/BasicGeoTests.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/BasicGeoTests.java b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/BasicGeoTests.java
index 2246e17..fba7c66 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/BasicGeoTests.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/BasicGeoTests.java
@@ -17,23 +17,18 @@
 package org.apache.usergrid.rest.applications.queries;
 
 
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.Map;
-
+import com.fasterxml.jackson.databind.JsonNode;
 import org.apache.usergrid.rest.test.resource.AbstractRestIT;
 import org.apache.usergrid.rest.test.resource.model.Entity;
-import org.junit.Rule;
 import org.junit.Test;
 
-
-import com.fasterxml.jackson.databind.JsonNode;
-import com.sun.jersey.api.client.UniformInterfaceException;
+import javax.ws.rs.client.ResponseProcessingException;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
 
 import static org.apache.usergrid.utils.MapUtils.hashMap;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.fail;
+import static org.junit.Assert.*;
 
 
 /**
@@ -67,8 +62,8 @@ public class BasicGeoTests extends AbstractRestIT {
         try {
             node = this.app().collection( collectionType ).post( entityData ).getEntity();
         }
-        catch ( UniformInterfaceException e ) {
-            JsonNode nodeError = mapper.readTree( e.getResponse().getEntity( String.class ) );
+        catch ( ResponseProcessingException e ) {
+            JsonNode nodeError = mapper.readTree( e.getResponse().readEntity( String.class ) );
             fail( nodeError.get( "error" ).textValue() );
         }
 
@@ -105,8 +100,8 @@ public class BasicGeoTests extends AbstractRestIT {
         try {
             entity = this.app().collection( collectionType ).post( entityData ).getEntities().get(0);
         }
-        catch ( UniformInterfaceException e ) {
-            JsonNode nodeError = mapper.readTree( e.getResponse().getEntity( String.class ) );
+        catch ( ResponseProcessingException e ) {
+            JsonNode nodeError = mapper.readTree( e.getResponse().readEntity( String.class ) );
             fail( nodeError.get( "error" ).textValue() );
         }
 
@@ -121,7 +116,7 @@ public class BasicGeoTests extends AbstractRestIT {
         try {
             node = context.collection( collectionType ).get(entityName);
         }
-        catch ( UniformInterfaceException e ) {
+        catch ( ResponseProcessingException e ) {
             JsonNode nodeError = mapper.readTree( e.getResponse().getEntity( String.class ) );
             fail( nodeError.get( "error" ).textValue() );
         }
@@ -139,7 +134,7 @@ public class BasicGeoTests extends AbstractRestIT {
             //entity.put(entityData);
 
         }
-        catch ( UniformInterfaceException e ) {
+        catch ( ResponseProcessingException e ) {
             JsonNode nodeError = mapper.readTree( e.getResponse().getEntity( String.class ) );
             fail( nodeError.get( "error" ).textValue() );
         }
@@ -182,9 +177,9 @@ public class BasicGeoTests extends AbstractRestIT {
             node = this.app().collection( collectionType ).post( misspelledLatitudeEntityData ).getEntity();
             fail("System allowed misspelled location property - latitudee, which it should not");
         }
-        catch ( UniformInterfaceException e ) {
+        catch ( ResponseProcessingException e ) {
             //verify the correct error was returned
-            JsonNode nodeError = mapper.readTree( e.getResponse().getEntity( String.class ));
+            JsonNode nodeError = mapper.readTree( e.getResponse().readEntity( String.class ) );
             assertEquals( "illegal_argument", nodeError.get( "error" ).textValue() );
         }
 
@@ -198,9 +193,9 @@ public class BasicGeoTests extends AbstractRestIT {
             node = this.app().collection( collectionType ).post( misspelledLongitudeEntityData ).getEntity();
             fail("System allowed misspelled location property - longitudee, which it should not");
         }
-        catch ( UniformInterfaceException e ) {
+        catch ( ResponseProcessingException e ) {
             //verify the correct error was returned
-            JsonNode nodeError = mapper.readTree( e.getResponse().getEntity( String.class ));
+            JsonNode nodeError = mapper.readTree( e.getResponse().readEntity( String.class ));
             assertEquals( "illegal_argument", nodeError.get( "error" ).textValue() );
         }
 
@@ -229,9 +224,9 @@ public class BasicGeoTests extends AbstractRestIT {
             node = this.app().collection( collectionType ).post( latitudeOnlyEntityData ).getEntity();
             fail("System allowed location with only one point, latitude, which it should not");
         }
-        catch ( UniformInterfaceException e ) {
+        catch ( ResponseProcessingException e ) {
             //verify the correct error was returned
-            JsonNode nodeError = mapper.readTree( e.getResponse().getEntity( String.class ));
+            JsonNode nodeError = mapper.readTree( e.getResponse().readEntity( String.class ));
             assertEquals( "illegal_argument", nodeError.get( "error" ).textValue() );
         }
 
@@ -245,9 +240,9 @@ public class BasicGeoTests extends AbstractRestIT {
             node = this.app().collection( collectionType ).post( notDoubleLatLonEntityData ).getEntity();
             fail("System allowed misspelled location values that are not doubles for latitude and longitude, which it should not");
         }
-        catch ( UniformInterfaceException e ) {
+        catch ( ResponseProcessingException e ) {
             //verify the correct error was returned
-            JsonNode nodeError = mapper.readTree( e.getResponse().getEntity( String.class ));
+            JsonNode nodeError = mapper.readTree( e.getResponse().readEntity( String.class ));
             assertEquals( "illegal_argument", nodeError.get( "error" ).textValue() );
         }
 

http://git-wip-us.apache.org/repos/asf/usergrid/blob/0578d987/stack/rest/src/test/java/org/apache/usergrid/rest/filters/ContentTypeResourceIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/filters/ContentTypeResourceIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/filters/ContentTypeResourceIT.java
index c1dce29..31ceb8c 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/filters/ContentTypeResourceIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/filters/ContentTypeResourceIT.java
@@ -16,10 +16,6 @@
  */
 package org.apache.usergrid.rest.filters;
 
-
-import com.sun.jersey.api.client.ClientResponse;
-import com.sun.jersey.api.client.WebResource;
-import com.sun.jersey.api.representation.Form;
 import org.apache.http.Header;
 import org.apache.http.HttpEntity;
 import org.apache.http.HttpHost;
@@ -28,15 +24,17 @@ import org.apache.http.client.methods.HttpPost;
 import org.apache.http.entity.StringEntity;
 import org.apache.http.impl.client.DefaultHttpClient;
 import org.apache.http.util.EntityUtils;
-
+import org.apache.usergrid.rest.test.resource.AbstractRestIT;
 import org.apache.usergrid.rest.test.resource.model.Organization;
 import org.apache.usergrid.rest.test.resource.model.Token;
 import org.apache.usergrid.rest.test.resource.model.User;
 import org.apache.usergrid.utils.JsonUtils;
 import org.apache.usergrid.utils.UUIDUtils;
-import org.junit.Ignore;
+import org.glassfish.jersey.client.ClientResponse;
 import org.junit.Test;
 
+import javax.ws.rs.client.Invocation;
+import javax.ws.rs.core.Form;
 import javax.ws.rs.core.HttpHeaders;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.MultivaluedMap;
@@ -49,8 +47,6 @@ import static org.apache.usergrid.utils.MapUtils.hashMap;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 
-import org.apache.usergrid.rest.test.resource.AbstractRestIT;
-
 
 /**
  * @author tnine
@@ -80,7 +76,8 @@ public class ContentTypeResourceIT extends AbstractRestIT {
 
         HttpHost host = new HttpHost( super.getBaseURI().getHost(), super.getBaseURI().getPort() );
 
-        HttpPost post = new HttpPost( String.format("/%s/%s/games", this.clientSetup.getOrganization().getName(), this.clientSetup.getAppName()) );
+        HttpPost post = new HttpPost( String.format("/%s/%s/games",
+            this.clientSetup.getOrganization().getName(), this.clientSetup.getAppName()) );
         post.setEntity(new StringEntity(json));
         post.setHeader(HttpHeaders.AUTHORIZATION, "Bearer " + token.getAccessToken());
         post.setHeader(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON);
@@ -118,7 +115,8 @@ public class ContentTypeResourceIT extends AbstractRestIT {
 
         HttpHost host = new HttpHost( super.getBaseURI().getHost(), super.getBaseURI().getPort() );
 
-        HttpPost post = new HttpPost( String.format("/%s/%s/games", this.clientSetup.getOrganization().getName(), this.clientSetup.getAppName()) );
+        HttpPost post = new HttpPost( String.format("/%s/%s/games",
+            this.clientSetup.getOrganization().getName(), this.clientSetup.getAppName()) );
 
         post.setEntity( new StringEntity( json ) );
         post.setHeader( HttpHeaders.AUTHORIZATION, "Bearer " + token.getAccessToken() );
@@ -142,11 +140,11 @@ public class ContentTypeResourceIT extends AbstractRestIT {
 
 
         Form payload = new Form();
-        payload.add( "organization", "formContentOrg" + UUIDUtils.newTimeUUID() );
-        payload.add( "username", "formContentOrg" + UUIDUtils.newTimeUUID() );
-        payload.add( "name", "Test User" + UUIDUtils.newTimeUUID() );
-        payload.add( "email", UUIDUtils.newTimeUUID() + "@usergrid.org" );
-        payload.add( "password", "foobar" );
+        payload.param( "organization", "formContentOrg" + UUIDUtils.newTimeUUID() );
+        payload.param( "username", "formContentOrg" + UUIDUtils.newTimeUUID() );
+        payload.param( "name", "Test User" + UUIDUtils.newTimeUUID() );
+        payload.param( "email", UUIDUtils.newTimeUUID() + "@usergrid.org" );
+        payload.param( "password", "foobar" );
 
         //checks that the organization was created using a form encoded content type, this is checked else where so
         //this test should be depreciated eventually.
@@ -209,7 +207,8 @@ public class ContentTypeResourceIT extends AbstractRestIT {
 
         HttpHost host = new HttpHost( super.getBaseURI().getHost(), super.getBaseURI().getPort() );
 
-        HttpPost post = new HttpPost( String.format("/%s/%s/games", this.clientSetup.getOrganization().getName(), this.clientSetup.getAppName()) );
+        HttpPost post = new HttpPost( String.format("/%s/%s/games",
+            this.clientSetup.getOrganization().getName(), this.clientSetup.getAppName()) );
 
         post.setEntity( new StringEntity( json ) );
         post.setHeader( HttpHeaders.AUTHORIZATION, "Bearer " + token.getAccessToken() );
@@ -219,11 +218,12 @@ public class ContentTypeResourceIT extends AbstractRestIT {
         HttpResponse rsp = client.execute( host, post );
 
 
-        WebResource.Builder builder = app().collection("games").getResource(true)
-            .queryParam("access_token", this.getAdminToken().getAccessToken())
-            .type(MediaType.APPLICATION_JSON_TYPE);
+        Invocation.Builder builder = app().collection( "games" ).getTarget()
+            .queryParam( "access_token", this.getAdminToken().getAccessToken() )
+            .request();
 
-        ClientResponse clientResponse = builder.post(ClientResponse.class, JsonUtils.mapToJsonString(hashMap("name", "bar2")));
+        ClientResponse clientResponse = builder.post(
+            javax.ws.rs.client.Entity.json( hashMap( "name", "bar2" ) ), ClientResponse.class );
 
         assertEquals(200, clientResponse.getStatus());
 
@@ -234,7 +234,8 @@ public class ContentTypeResourceIT extends AbstractRestIT {
         assertEquals(MediaType.APPLICATION_JSON, contentType.get(0));
 
         //do the get with no content type, it should get set to application/json
-        HttpPost get = new HttpPost( String.format("/%s/%s/games", this.clientSetup.getOrganization().getName(), this.clientSetup.getAppName()) );
+        HttpPost get = new HttpPost( String.format("/%s/%s/games",
+            this.clientSetup.getOrganization().getName(), this.clientSetup.getAppName()) );
 
         get.setHeader( HttpHeaders.AUTHORIZATION, "Bearer " + token.getAccessToken() );
         clientResponse = builder.get(ClientResponse.class);

http://git-wip-us.apache.org/repos/asf/usergrid/blob/0578d987/stack/rest/src/test/java/org/apache/usergrid/rest/management/AccessTokenIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/management/AccessTokenIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/management/AccessTokenIT.java
index d9089ca..7edc2a7 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/management/AccessTokenIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/management/AccessTokenIT.java
@@ -27,9 +27,9 @@ import org.apache.usergrid.rest.test.resource.model.Entity;
 import org.apache.usergrid.rest.test.resource.model.QueryParameters;
 import org.apache.usergrid.rest.test.resource.model.Token;
 
-import com.sun.jersey.api.client.ClientResponse;
-import com.sun.jersey.api.client.UniformInterfaceException;
-import com.sun.jersey.api.representation.Form;
+import javax.ws.rs.client.ResponseProcessingException;
+import javax.ws.rs.core.Form;
+import javax.ws.rs.core.Response;
 
 import static org.apache.usergrid.utils.MapUtils.hashMap;
 import static org.junit.Assert.assertEquals;
@@ -62,14 +62,14 @@ public class AccessTokenIT extends AbstractRestIT {
         // wait for the token to expire
         Thread.sleep(ttl - (System.currentTimeMillis() - startTime) + 1000);
 
-        ClientResponse.Status responseStatus = null;
+        Response.Status responseStatus = null;
         try {
             management().users().user( clientSetup.getUsername() ).get( ApiResponse.class);
-        } catch (UniformInterfaceException uie) {
-            responseStatus = uie.getResponse().getClientResponseStatus();
+        } catch (ResponseProcessingException uie) {
+            responseStatus = Response.Status.fromStatusCode( uie.getResponse().getStatus() );
         }
 
-        assertEquals(ClientResponse.Status.UNAUTHORIZED, responseStatus);
+        assertEquals(Response.Status.UNAUTHORIZED, responseStatus);
     }
 
 
@@ -168,9 +168,9 @@ public class AccessTokenIT extends AbstractRestIT {
     public void meTokenPostForm() throws IOException {
 
         Form form = new Form();
-        form.add("grant_type", "password");
-        form.add("username", clientSetup.getUsername());
-        form.add("password", clientSetup.getPassword());
+        form.param( "grant_type", "password" );
+        form.param( "username", clientSetup.getUsername() );
+        form.param( "password", clientSetup.getPassword() );
 
         Token adminToken = management().me().post( Token.class,form );
 
@@ -198,8 +198,8 @@ public class AccessTokenIT extends AbstractRestIT {
 
         try {
             management().token().post( Token.class,payload );
-        } catch (UniformInterfaceException uie) {
-            assertEquals(ClientResponse.Status.BAD_REQUEST, uie.getResponse().getClientResponseStatus());
+        } catch (ResponseProcessingException uie) {
+            assertEquals(Response.Status.BAD_REQUEST, uie.getResponse().getStatus());
         }
 
     }
@@ -218,8 +218,8 @@ public class AccessTokenIT extends AbstractRestIT {
 
         try {
             management().token().post( Token.class, payload );
-        } catch (UniformInterfaceException uie) {
-            assertEquals(ClientResponse.Status.BAD_REQUEST, uie.getResponse().getClientResponseStatus());
+        } catch (ResponseProcessingException uie) {
+            assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), uie.getResponse().getStatus());
         }
 
     }
@@ -246,8 +246,8 @@ public class AccessTokenIT extends AbstractRestIT {
             management().users().user( clientSetup.getUsername() ).get();
             fail( "Token1 should have been revoked" );
         }
-        catch ( UniformInterfaceException uie ) {
-            assertEquals( ClientResponse.Status.UNAUTHORIZED, uie.getResponse().getClientResponseStatus());
+        catch ( ResponseProcessingException uie ) {
+            assertEquals(Response.Status.UNAUTHORIZED.getStatusCode(), uie.getResponse().getStatus());
         }
 
 
@@ -257,8 +257,8 @@ public class AccessTokenIT extends AbstractRestIT {
             management().users().user( clientSetup.getUsername() ).get();
             fail( "Token2 should have been revoked" );
         }
-        catch ( UniformInterfaceException uie ) {
-            assertEquals( ClientResponse.Status.UNAUTHORIZED, uie.getResponse().getClientResponseStatus());
+        catch ( ResponseProcessingException uie ) {
+            assertEquals( Response.Status.UNAUTHORIZED.getStatusCode(), uie.getResponse().getStatus());
         }
     }
 
@@ -287,8 +287,8 @@ public class AccessTokenIT extends AbstractRestIT {
             management().users().user( clientSetup.getUsername() ).get();
             fail( "Token1 should have been revoked" );
         }
-        catch ( UniformInterfaceException uie ) {
-            assertEquals( ClientResponse.Status.UNAUTHORIZED, uie.getResponse().getClientResponseStatus());
+        catch ( ResponseProcessingException uie ) {
+            assertEquals( Response.Status.UNAUTHORIZED.getStatusCode(), uie.getResponse().getStatus());
         }
 
 
@@ -297,7 +297,7 @@ public class AccessTokenIT extends AbstractRestIT {
             management().token().setToken( token2 );
             management().users().user( clientSetup.getUsername() ).get();
         }
-        catch ( UniformInterfaceException uie ) {
+        catch ( ResponseProcessingException uie ) {
             fail( "Token2 shouldn't have been revoked" );
 
         }

http://git-wip-us.apache.org/repos/asf/usergrid/blob/0578d987/stack/rest/src/test/java/org/apache/usergrid/rest/management/AdminUsersIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/management/AdminUsersIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/management/AdminUsersIT.java
index 286f893..09c49e1 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/management/AdminUsersIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/management/AdminUsersIT.java
@@ -17,9 +17,6 @@
 
 package org.apache.usergrid.rest.management;
 
-import com.sun.jersey.api.client.ClientResponse;
-import com.sun.jersey.api.client.UniformInterfaceException;
-import com.sun.jersey.api.representation.Form;
 import org.apache.usergrid.management.MockImapClient;
 import org.apache.usergrid.persistence.core.util.StringUtils;
 import org.apache.usergrid.persistence.index.utils.UUIDUtils;
@@ -34,6 +31,9 @@ import org.jvnet.mock_javamail.Mailbox;
 import javax.mail.Message;
 import javax.mail.MessagingException;
 import javax.mail.internet.MimeMultipart;
+import javax.ws.rs.client.ResponseProcessingException;
+import javax.ws.rs.core.Form;
+import javax.ws.rs.core.Response;
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.HashMap;
@@ -83,7 +83,7 @@ public class AdminUsersIT extends AbstractRestIT {
         try {
             management.token().post(false, Token.class, new Token( username, password ),null);
             fail( "We shouldn't be able to get a token using the old password" );
-        }catch(UniformInterfaceException uie) {
+        }catch(ResponseProcessingException uie) {
             errorParse( 400,"invalid_grant",uie );
         }
     }
@@ -120,8 +120,8 @@ public class AdminUsersIT extends AbstractRestIT {
             management.users().user( username ).password().post( Entity.class ,passwordPayload );
             fail("We shouldn't be able to change the password with the same payload");
         }
-        catch ( UniformInterfaceException uie ) {
-            errorParse( ClientResponse.Status.BAD_REQUEST.getStatusCode(),"auth_invalid_username_or_password",uie );
+        catch ( ResponseProcessingException uie ) {
+            errorParse( Response.Status.BAD_REQUEST.getStatusCode(),"auth_invalid_username_or_password",uie );
         }
 
     }
@@ -153,7 +153,7 @@ public class AdminUsersIT extends AbstractRestIT {
         try {
             management.token().post( false,Token.class, new Token( username, password) ,null);
             fail( "We shouldn't be able to get a token using the old password" );
-        }catch(UniformInterfaceException uie) {
+        }catch(ResponseProcessingException uie) {
             errorParse( 400,"invalid_grant",uie );
         }
     }
@@ -236,7 +236,7 @@ public class AdminUsersIT extends AbstractRestIT {
                 management().token().get( queryParameters );
                 fail( "Admin user should not be able to log in." );
             }
-            catch ( UniformInterfaceException uie ) {
+            catch ( ResponseProcessingException uie ) {
                 assertEquals( "Admin user should have failed with 403", 403, uie.getResponse().getStatus() );
             }
 
@@ -417,11 +417,12 @@ public class AdminUsersIT extends AbstractRestIT {
         String token = getTokenFromMessage( confirmation );
 
         Form formData = new Form();
-        formData.add( "token", token );
-        formData.add( "password1", "sesame" );
-        formData.add( "password2", "sesame" );
+        formData.param( "token", token );
+        formData.param( "password1", "sesame" );
+        formData.param( "password2", "sesame" );
 
-        String html = management().users().user( clientSetup.getUsername() ).resetpw().post( formData );
+        String html = management().users().user( clientSetup.getUsername() ).resetpw().getTarget().request()
+            .post( javax.ws.rs.client.Entity.form(formData), String.class );
 
         assertTrue( html.contains( "password set" ) );
 
@@ -493,7 +494,7 @@ public class AdminUsersIT extends AbstractRestIT {
 
             fail( "should fail with conflict" );
         }
-        catch ( UniformInterfaceException e ) {
+        catch ( ResponseProcessingException e ) {
             assertEquals( 409, e.getResponse().getStatus() );
         }
 
@@ -512,7 +513,7 @@ public class AdminUsersIT extends AbstractRestIT {
 
             fail( "should fail with conflict" );
         }
-        catch ( UniformInterfaceException e ) {
+        catch ( ResponseProcessingException e ) {
             assertEquals( 409, e.getResponse().getStatus() );
         }
     }
@@ -628,7 +629,7 @@ public class AdminUsersIT extends AbstractRestIT {
 
             fail( "Should have thrown unique exception on org name" );
         }
-        catch ( UniformInterfaceException uie ) {
+        catch ( ResponseProcessingException uie ) {
             assertEquals(500,uie.getResponse().getStatus());
         }
     }

http://git-wip-us.apache.org/repos/asf/usergrid/blob/0578d987/stack/rest/src/test/java/org/apache/usergrid/rest/management/ExportResourceIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/management/ExportResourceIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/management/ExportResourceIT.java
index 33bf360..a4f5f2d 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/management/ExportResourceIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/management/ExportResourceIT.java
@@ -18,23 +18,18 @@
 package org.apache.usergrid.rest.management;
 
 
-import java.util.HashMap;
-import java.util.Map;
-import java.util.UUID;
-
-import org.junit.Ignore;
-import org.junit.Rule;
-import org.junit.Test;
-
 import org.apache.usergrid.rest.test.resource.AbstractRestIT;
 import org.apache.usergrid.rest.test.resource.model.ApiResponse;
+import org.junit.Ignore;
+import org.junit.Test;
 
-import com.sun.jersey.api.client.ClientResponse;
-import com.sun.jersey.api.client.UniformInterfaceException;
+import javax.ws.rs.client.ResponseProcessingException;
+import javax.ws.rs.core.Response;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.UUID;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.fail;
+import static org.junit.Assert.*;
 
 
 public class ExportResourceIT extends AbstractRestIT {
@@ -53,8 +48,8 @@ public class ExportResourceIT extends AbstractRestIT {
             management().orgs().org( clientSetup.getOrganizationName() )
                         .app().addToPath( clientSetup.getAppUuid() ).addToPath( "export" );
         }
-        catch ( UniformInterfaceException uie ) {
-            fail("We got back " + uie.getResponse().getClientResponseStatus() + " instead of having a successful call" );
+        catch ( ResponseProcessingException uie ) {
+            fail("We got back " + uie.getResponse().getStatus() + " instead of having a successful call" );
         }
 
     }
@@ -73,8 +68,8 @@ public class ExportResourceIT extends AbstractRestIT {
                         .app().addToPath( clientSetup.getAppUuid()).addToPath( "collection" )
                         .addToPath( "users" ).addToPath( "export" ).post(ApiResponse.class,payloadBuilder() );
         }
-        catch ( UniformInterfaceException uie ) {
-            fail( "We got back "+uie.getResponse().getClientResponseStatus()+" instead of having a successful call" );
+        catch ( ResponseProcessingException uie ) {
+            fail( "We got back "+uie.getResponse().getStatus()+" instead of having a successful call" );
         }
 
         assertNotNull( exportEntity );
@@ -97,8 +92,8 @@ public class ExportResourceIT extends AbstractRestIT {
             exportEntity = management().orgs().org( clientSetup.getOrganizationName() )
                                        .addToPath( "export" ).post( ApiResponse.class, payloadBuilder() );
         }
-        catch ( UniformInterfaceException uie ) {
-            fail( "We got back "+uie.getResponse().getClientResponseStatus()+" instead of having a successful call" );
+        catch ( ResponseProcessingException uie ) {
+            fail( "We got back "+uie.getResponse().getStatus()+" instead of having a successful call" );
         }
 
         assertNotNull( exportEntity );
@@ -111,8 +106,8 @@ public class ExportResourceIT extends AbstractRestIT {
             exportEntity = management().orgs().org( clientSetup.getOrganizationName() )
                                        .addToPath( "export" ).addToPath( uuid ).get( ApiResponse.class );
         }
-        catch ( UniformInterfaceException uie ) {
-            fail( "We got back "+uie.getResponse().getClientResponseStatus()+" instead of having a successful call" );
+        catch ( ResponseProcessingException uie ) {
+            fail( "We got back "+uie.getResponse().getStatus()+" instead of having a successful call" );
         }
 
         assertNotNull( exportEntity );
@@ -140,8 +135,8 @@ public class ExportResourceIT extends AbstractRestIT {
                                        .app().addToPath( clientSetup.getAppUuid() )
                                        .addToPath( "export" ).post( ApiResponse.class, payloadBuilder() );
         }
-        catch ( UniformInterfaceException uie ) {
-            fail( "We got back "+uie.getResponse().getClientResponseStatus()+" instead of having a successful call" );
+        catch ( ResponseProcessingException uie ) {
+            fail( "We got back "+uie.getResponse().getStatus()+" instead of having a successful call" );
         }
 
         assertNotNull( exportEntity );
@@ -155,8 +150,8 @@ public class ExportResourceIT extends AbstractRestIT {
             exportEntity = management().orgs().org( clientSetup.getOrganizationName() )
                                        .addToPath( "export" ).addToPath( uuid ).get( ApiResponse.class );
         }
-        catch ( UniformInterfaceException uie ) {
-            fail( "We got back "+uie.getResponse().getClientResponseStatus()+" instead of having a successful call" );
+        catch ( ResponseProcessingException uie ) {
+            fail( "We got back "+uie.getResponse().getStatus()+" instead of having a successful call" );
         }
 
         assertNotNull( exportEntity );
@@ -185,8 +180,8 @@ public class ExportResourceIT extends AbstractRestIT {
             exportEntity = management().orgs().org( clientSetup.getOrganizationName() )
                                        .addToPath( "export" ).addToPath( uuid ).get( ApiResponse.class );
         }
-        catch ( UniformInterfaceException uie ) {
-            fail( "We got back "+uie.getResponse().getClientResponseStatus()+" instead of having a successful call" );
+        catch ( ResponseProcessingException uie ) {
+            fail( "We got back "+uie.getResponse().getStatus()+" instead of having a successful call" );
         }
 
 
@@ -206,8 +201,8 @@ public class ExportResourceIT extends AbstractRestIT {
                                        .addToPath( "export" ).addToPath( fake.toString() ).get( ApiResponse.class );
             fail( "Should not have been able to get fake uuid" );
         }
-        catch ( UniformInterfaceException uie ) {
-            assertEquals( ClientResponse.Status.BAD_REQUEST, uie.getResponse().getClientResponseStatus() );
+        catch ( ResponseProcessingException uie ) {
+            assertEquals( Response.Status.BAD_REQUEST.getStatusCode(), uie.getResponse().getStatus() );
 
         }
     }
@@ -224,8 +219,8 @@ public class ExportResourceIT extends AbstractRestIT {
                 new HashMap<String, Object>() );
             fail( "Should not have passed, The payload is empty." );
         }
-        catch ( UniformInterfaceException uie ) {
-            assertEquals( ClientResponse.Status.BAD_REQUEST, uie.getResponse().getClientResponseStatus() );
+        catch ( ResponseProcessingException uie ) {
+            assertEquals( Response.Status.BAD_REQUEST.getStatusCode(), uie.getResponse().getStatus() );
         }
     }
 
@@ -238,8 +233,8 @@ public class ExportResourceIT extends AbstractRestIT {
                         .addToPath( "export" ).post( ApiResponse.class, new HashMap<String, Object>()  );
             fail( "Should not have passed, The payload is empty." );
         }
-        catch ( UniformInterfaceException uie ) {
-            assertEquals( ClientResponse.Status.BAD_REQUEST, uie.getResponse().getClientResponseStatus() );
+        catch ( ResponseProcessingException uie ) {
+            assertEquals( Response.Status.BAD_REQUEST.getStatusCode(), uie.getResponse().getStatus() );
         }
     }
 
@@ -255,8 +250,8 @@ public class ExportResourceIT extends AbstractRestIT {
 
             fail( "Should not have passed, The payload is empty." );
         }
-        catch ( UniformInterfaceException uie ) {
-            assertEquals( ClientResponse.Status.BAD_REQUEST, uie.getResponse().getClientResponseStatus() );
+        catch ( ResponseProcessingException uie ) {
+            assertEquals( Response.Status.BAD_REQUEST.getStatusCode(), uie.getResponse().getStatus() );
         }
     }
 
@@ -272,8 +267,8 @@ public class ExportResourceIT extends AbstractRestIT {
                         .addToPath( "export" ).addToPath( fake.toString() ).get(ApiResponse.class ,false);
             fail( "Should not have passed as we didn't have an access token." );
         }
-        catch ( UniformInterfaceException uie ) {
-            assertEquals( ClientResponse.Status.UNAUTHORIZED, uie.getResponse().getClientResponseStatus() );
+        catch ( ResponseProcessingException uie ) {
+            assertEquals( Response.Status.UNAUTHORIZED.getStatusCode(), uie.getResponse().getStatus() );
         }
     }
 
@@ -288,8 +283,8 @@ public class ExportResourceIT extends AbstractRestIT {
                         .addToPath( "export" ).addToPath( fake.toString() ).get(ApiResponse.class ,false);
             fail( "Should not have passed as we didn't have an access token." );
         }
-        catch ( UniformInterfaceException uie ) {
-            assertEquals( ClientResponse.Status.UNAUTHORIZED, uie.getResponse().getClientResponseStatus() );
+        catch ( ResponseProcessingException uie ) {
+            assertEquals( Response.Status.UNAUTHORIZED.getStatusCode(), uie.getResponse().getStatus() );
         }
     }
 
@@ -303,8 +298,8 @@ public class ExportResourceIT extends AbstractRestIT {
                         .addToPath( "export" ).addToPath( fake.toString() ).get(ApiResponse.class ,false);
             fail( "Should not have passed as we didn't have an access token." );
         }
-        catch ( UniformInterfaceException uie ) {
-            assertEquals( ClientResponse.Status.UNAUTHORIZED, uie.getResponse().getClientResponseStatus() );
+        catch ( ResponseProcessingException uie ) {
+            assertEquals( Response.Status.UNAUTHORIZED.getStatusCode(), uie.getResponse().getStatus() );
         }
     }
 
@@ -322,8 +317,8 @@ public class ExportResourceIT extends AbstractRestIT {
             fail( "Should not have passed as we were missing an important part of the payload" );
 
         }
-        catch ( UniformInterfaceException uie ) {
-            assertEquals( ClientResponse.Status.BAD_REQUEST, uie.getResponse().getClientResponseStatus() );
+        catch ( ResponseProcessingException uie ) {
+            assertEquals( Response.Status.BAD_REQUEST.getStatusCode(), uie.getResponse().getStatus() );
         }
     }
 
@@ -344,8 +339,8 @@ public class ExportResourceIT extends AbstractRestIT {
             fail( "Should not have passed as we were missing an important part of the payload" );
 
         }
-        catch ( UniformInterfaceException uie ) {
-            assertEquals( ClientResponse.Status.BAD_REQUEST, uie.getResponse().getClientResponseStatus() );
+        catch ( ResponseProcessingException uie ) {
+            assertEquals( Response.Status.BAD_REQUEST.getStatusCode(), uie.getResponse().getStatus() );
         }
     }
 
@@ -366,8 +361,8 @@ public class ExportResourceIT extends AbstractRestIT {
             fail( "Should not have passed as we were missing an important part of the payload" );
 
         }
-        catch ( UniformInterfaceException uie ) {
-            assertEquals( ClientResponse.Status.BAD_REQUEST, uie.getResponse().getClientResponseStatus() );
+        catch ( ResponseProcessingException uie ) {
+            assertEquals( Response.Status.BAD_REQUEST.getStatusCode(), uie.getResponse().getStatus() );
         }
     }
 
@@ -385,8 +380,8 @@ public class ExportResourceIT extends AbstractRestIT {
             fail( "Should not have passed as we were missing an important part of the payload" );
 
         }
-        catch ( UniformInterfaceException uie ) {
-            assertEquals( ClientResponse.Status.BAD_REQUEST, uie.getResponse().getClientResponseStatus() );
+        catch ( ResponseProcessingException uie ) {
+            assertEquals( Response.Status.BAD_REQUEST.getStatusCode(), uie.getResponse().getStatus() );
         }
     }
 
@@ -407,8 +402,8 @@ public class ExportResourceIT extends AbstractRestIT {
             fail( "Should not have passed as we were missing an important part of the payload" );
 
         }
-        catch ( UniformInterfaceException uie ) {
-            assertEquals( ClientResponse.Status.BAD_REQUEST, uie.getResponse().getClientResponseStatus() );
+        catch ( ResponseProcessingException uie ) {
+            assertEquals( Response.Status.BAD_REQUEST.getStatusCode(), uie.getResponse().getStatus() );
         }
     }
 
@@ -429,8 +424,8 @@ public class ExportResourceIT extends AbstractRestIT {
             fail( "Should not have passed as we were missing an important part of the payload" );
 
         }
-        catch ( UniformInterfaceException uie ) {
-            assertEquals( ClientResponse.Status.BAD_REQUEST, uie.getResponse().getClientResponseStatus() );
+        catch ( ResponseProcessingException uie ) {
+            assertEquals( Response.Status.BAD_REQUEST.getStatusCode(), uie.getResponse().getStatus() );
         }
     }
 
@@ -450,8 +445,8 @@ public class ExportResourceIT extends AbstractRestIT {
             fail( "Should not have passed as we were missing an important part of the payload" );
 
         }
-        catch ( UniformInterfaceException uie ) {
-            assertEquals( ClientResponse.Status.BAD_REQUEST, uie.getResponse().getClientResponseStatus() );
+        catch ( ResponseProcessingException uie ) {
+            assertEquals( Response.Status.BAD_REQUEST.getStatusCode(), uie.getResponse().getStatus() );
         }
 
         payload = payloadBuilder();
@@ -466,8 +461,8 @@ public class ExportResourceIT extends AbstractRestIT {
             fail( "Should not have passed as we were missing an important part of the payload" );
 
         }
-        catch ( UniformInterfaceException uie ) {
-            assertEquals( ClientResponse.Status.BAD_REQUEST, uie.getResponse().getClientResponseStatus() );
+        catch ( ResponseProcessingException uie ) {
+            assertEquals( Response.Status.BAD_REQUEST.getStatusCode(), uie.getResponse().getStatus() );
         }
 
         payload = payloadBuilder();
@@ -482,8 +477,8 @@ public class ExportResourceIT extends AbstractRestIT {
             fail( "Should not have passed as we were missing an important part of the payload" );
 
         }
-        catch ( UniformInterfaceException uie ) {
-            assertEquals( ClientResponse.Status.BAD_REQUEST, uie.getResponse().getClientResponseStatus() );
+        catch ( ResponseProcessingException uie ) {
+            assertEquals( Response.Status.BAD_REQUEST.getStatusCode(), uie.getResponse().getStatus() );
         }
     }
 
@@ -503,8 +498,8 @@ public class ExportResourceIT extends AbstractRestIT {
             fail( "Should not have passed as we were missing an important part of the payload" );
 
         }
-        catch ( UniformInterfaceException uie ) {
-            assertEquals( ClientResponse.Status.BAD_REQUEST, uie.getResponse().getClientResponseStatus() );
+        catch ( ResponseProcessingException uie ) {
+            assertEquals( Response.Status.BAD_REQUEST.getStatusCode(), uie.getResponse().getStatus() );
         }
 
         payload = payloadBuilder();
@@ -520,8 +515,8 @@ public class ExportResourceIT extends AbstractRestIT {
             fail( "Should not have passed as we were missing an important part of the payload" );
 
         }
-        catch ( UniformInterfaceException uie ) {
-            assertEquals( ClientResponse.Status.BAD_REQUEST, uie.getResponse().getClientResponseStatus() );
+        catch ( ResponseProcessingException uie ) {
+            assertEquals( Response.Status.BAD_REQUEST.getStatusCode(), uie.getResponse().getStatus() );
         }
 
         payload = payloadBuilder();
@@ -537,8 +532,8 @@ public class ExportResourceIT extends AbstractRestIT {
             fail( "Should not have passed as we were missing an important part of the payload" );
 
         }
-        catch ( UniformInterfaceException uie ) {
-            assertEquals( ClientResponse.Status.BAD_REQUEST, uie.getResponse().getClientResponseStatus() );
+        catch ( ResponseProcessingException uie ) {
+            assertEquals( Response.Status.BAD_REQUEST.getStatusCode(), uie.getResponse().getStatus() );
         }
     }
 
@@ -559,8 +554,8 @@ public class ExportResourceIT extends AbstractRestIT {
             fail( "Should not have passed as we were missing an important part of the payload" );
 
         }
-        catch ( UniformInterfaceException uie ) {
-            assertEquals( ClientResponse.Status.BAD_REQUEST, uie.getResponse().getClientResponseStatus() );
+        catch ( ResponseProcessingException uie ) {
+            assertEquals( Response.Status.BAD_REQUEST.getStatusCode(), uie.getResponse().getStatus() );
         }
 
         payload = payloadBuilder();
@@ -577,8 +572,8 @@ public class ExportResourceIT extends AbstractRestIT {
             fail( "Should not have passed as we were missing an important part of the payload" );
 
         }
-        catch ( UniformInterfaceException uie ) {
-            assertEquals( ClientResponse.Status.BAD_REQUEST, uie.getResponse().getClientResponseStatus() );
+        catch ( ResponseProcessingException uie ) {
+            assertEquals( Response.Status.BAD_REQUEST.getStatusCode(), uie.getResponse().getStatus() );
         }
 
         payload = payloadBuilder();
@@ -595,8 +590,8 @@ public class ExportResourceIT extends AbstractRestIT {
             fail( "Should not have passed as we were missing an important part of the payload" );
 
         }
-        catch ( UniformInterfaceException uie ) {
-            assertEquals( ClientResponse.Status.BAD_REQUEST, uie.getResponse().getClientResponseStatus() );
+        catch ( ResponseProcessingException uie ) {
+            assertEquals( Response.Status.BAD_REQUEST.getStatusCode(), uie.getResponse().getStatus() );
         }
     }
 


[32/54] usergrid git commit: Reduces logging and adds filter into delete listener

Posted by sn...@apache.org.
Reduces logging and adds filter into delete listener


Project: http://git-wip-us.apache.org/repos/asf/usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/usergrid/commit/b7a22c2d
Tree: http://git-wip-us.apache.org/repos/asf/usergrid/tree/b7a22c2d
Diff: http://git-wip-us.apache.org/repos/asf/usergrid/diff/b7a22c2d

Branch: refs/heads/usergrid-1007-shiro-cache
Commit: b7a22c2d51602e32692b22ad584ce128b1592ed0
Parents: 6233bf0
Author: Todd Nine <tn...@apigee.com>
Authored: Tue Sep 15 17:27:14 2015 -0600
Committer: Todd Nine <tn...@apigee.com>
Committed: Tue Sep 15 17:27:14 2015 -0600

----------------------------------------------------------------------
 stack/core/src/test/resources/log4j.properties                   | 4 ++--
 .../persistence/graph/impl/stage/EdgeDeleteRepairImpl.java       | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/usergrid/blob/b7a22c2d/stack/core/src/test/resources/log4j.properties
----------------------------------------------------------------------
diff --git a/stack/core/src/test/resources/log4j.properties b/stack/core/src/test/resources/log4j.properties
index 93951fe..4267293 100644
--- a/stack/core/src/test/resources/log4j.properties
+++ b/stack/core/src/test/resources/log4j.properties
@@ -19,7 +19,7 @@
 
 # output messages into a rolling log file as well as stdout
 #log4j.rootLogger=ERROR,stdout\
-log4j.rootLogger=DEBUG,stdout
+log4j.rootLogger=INFO,stdout
 
 # stdout
 log4j.appender.stdout=org.apache.log4j.ConsoleAppender
@@ -48,7 +48,7 @@ log4j.logger.org.apache.usergrid.corepersistence.migration=WARN
 
 #Debug our queries
 #log4j.logger.org.apache.usergrid.persistence.index.impl.EsApplicationEntityIndexImpl=DEBUG
-log4j.logger.org.apache.usergrid.corepersistence.service.ConnectionServiceImpl=DEBUG
+#log4j.logger.org.apache.usergrid.corepersistence.service.ConnectionServiceImpl=DEBUG
 
 #log4j.logger.org.apache.usergrid.persistence.index.impl=DEBUG
 #log4j.logger.org.apache.usergrid.corepersistence.CpSetup=INFO

http://git-wip-us.apache.org/repos/asf/usergrid/blob/b7a22c2d/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/impl/stage/EdgeDeleteRepairImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/impl/stage/EdgeDeleteRepairImpl.java b/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/impl/stage/EdgeDeleteRepairImpl.java
index 643dcc1..a87a079 100644
--- a/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/impl/stage/EdgeDeleteRepairImpl.java
+++ b/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/impl/stage/EdgeDeleteRepairImpl.java
@@ -79,7 +79,7 @@ public class EdgeDeleteRepairImpl implements EdgeDeleteRepair {
 
 
         //merge source and target then deal with the distinct values
-        return Observable.just( edge )
+        return Observable.just( edge ).filter( markedEdge-> markedEdge.isDeleted() )
                 .doOnNext( markedEdge -> {
                     //it's still in the same state as it was when we queued it. Remove it
                         LOG.info( "Removing edge {} ", markedEdge );


[20/54] usergrid git commit: Merge branch 'two-dot-o-dev' into usergrid-103-upgrade-jersey

Posted by sn...@apache.org.
Merge branch 'two-dot-o-dev' into usergrid-103-upgrade-jersey

Conflicts:
	stack/rest/src/main/java/org/apache/usergrid/rest/ApplicationsResource.java
	stack/rest/src/main/java/org/apache/usergrid/rest/applications/ApplicationResource.java
	stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/applications/ApplicationsResource.java
	stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/SystemResource.java


Project: http://git-wip-us.apache.org/repos/asf/usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/usergrid/commit/0db86225
Tree: http://git-wip-us.apache.org/repos/asf/usergrid/tree/0db86225
Diff: http://git-wip-us.apache.org/repos/asf/usergrid/diff/0db86225

Branch: refs/heads/usergrid-1007-shiro-cache
Commit: 0db8622540987e951748ca1c01f7f609fe39ee3d
Parents: 2aaa37f a1be2fd
Author: Dave Johnson <sn...@apache.org>
Authored: Wed Sep 9 13:11:35 2015 -0400
Committer: Dave Johnson <sn...@apache.org>
Committed: Wed Sep 9 13:11:35 2015 -0400

----------------------------------------------------------------------
 .../usergrid/corepersistence/CoreModule.java    | 25 ++---
 .../service/ApplicationService.java             |  2 +-
 .../service/ApplicationServiceImpl.java         | 38 +++++---
 .../corepersistence/service/StatusService.java  | 81 ++++++++++++++++
 .../service/StatusServiceImpl.java              | 98 ++++++++++++++++++++
 .../corepersistence/CpEntityMapUtilsTest.java   | 26 +++---
 .../persistence/ApplicationServiceIT.java       |  8 +-
 .../usergrid/rest/ApplicationsResource.java     | 94 ++++++++++++++++---
 .../rest/applications/ApplicationResource.java  | 43 +++------
 .../applications/ApplicationResource.java       |  5 +-
 .../apache/usergrid/rest/SystemResourceIT.java  | 23 ++++-
 .../test/resource/endpoints/SystemResource.java | 22 ++++-
 .../usergrid/management/ManagementService.java  |  2 +-
 .../cassandra/ManagementServiceImpl.java        | 45 +++++----
 14 files changed, 391 insertions(+), 121 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/usergrid/blob/0db86225/stack/rest/src/main/java/org/apache/usergrid/rest/ApplicationsResource.java
----------------------------------------------------------------------
diff --cc stack/rest/src/main/java/org/apache/usergrid/rest/ApplicationsResource.java
index b702276,8d36acb..74827e9
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/ApplicationsResource.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/ApplicationsResource.java
@@@ -19,8 -19,12 +19,10 @@@
   */
  package org.apache.usergrid.rest;
  
 -import com.sun.jersey.api.json.JSONWithPadding;
 +import com.fasterxml.jackson.jaxrs.json.annotation.JSONP;
+ import org.apache.usergrid.corepersistence.service.StatusService;
 -import org.apache.usergrid.persistence.Entity;
  import org.apache.usergrid.persistence.EntityManager;
 -import org.apache.usergrid.persistence.core.util.StringUtils;
+ import org.apache.usergrid.persistence.model.util.UUIDGenerator;
  import org.apache.usergrid.rest.security.annotations.RequireSystemAccess;
  import org.slf4j.Logger;
  import org.slf4j.LoggerFactory;
@@@ -56,13 -64,12 +59,15 @@@ public class ApplicationsResource exten
  
      @RequireSystemAccess
      @DELETE
 +    @JSONP
      @Path( "{applicationId}" )
-     public ApiResponse clearApplication( @Context UriInfo ui,
 -    public JSONWithPadding clearApplication( @Context UriInfo ui,
 -                                             @PathParam("applicationId") UUID applicationId,
 -                                             @QueryParam( "confirmApplicationName" ) String confirmApplicationName,
 -                                             @QueryParam( "limit" ) int limit,
 -                                             @QueryParam( "callback" ) @DefaultValue( "callback" ) String callback )
++    public ApiResponse clearApplication(
++        @Context UriInfo ui,
 +        @PathParam("applicationId") UUID applicationId,
 +        @QueryParam( "confirmApplicationName" ) String confirmApplicationName,
++        @QueryParam( "limit" ) int limit,
 +        @QueryParam( "callback" ) @DefaultValue( "callback" ) String callback )
 +
          throws Exception {
  
          if(confirmApplicationName == null){
@@@ -72,28 -81,89 +79,89 @@@
          final EntityManager em =  emf.getEntityManager(applicationId);
          final String name =  em.getApplication().getApplicationName();
          if(!name.toLowerCase().equals(confirmApplicationName.toLowerCase())){
 -            throw new IllegalArgumentException("confirmApplicationName: " + confirmApplicationName + " does not equal " + name);
 +            throw new IllegalArgumentException(
 +                "confirmApplicationName: " + confirmApplicationName + " does not equal " + name);
          }
+         final StatusService statusService = injector.getInstance(StatusService.class);
+ 
          final ApiResponse response = createApiResponse();
+ 
          response.setAction( "clear application" );
  
-         logger.info( "clearing up application" );
-         final AtomicInteger itemsDeleted = new AtomicInteger(0);
-         try {
-             management.deleteAllEntities(applicationId)
-                 .count()
-                 .doOnNext(count -> itemsDeleted.set(count))
-                 .toBlocking().lastOrDefault(0);
-         }
-         catch ( Exception e ) {
-             logger.error( "Unable to delete all items, deleted: " + itemsDeleted.get(), e );
-         }
+         logger.info("clearing up application");
+ 
 -
+         final Thread delete = new Thread() {
+ 
+             @Override
+             public void run() {
+                 final AtomicInteger itemsDeleted = new AtomicInteger(0);
+                 try {
+                     management.deleteAllEntities(applicationId, limit)
+                         .count()
+                         .doOnNext(count -> itemsDeleted.set(count))
+                         .doOnNext(count -> {
+                             if( count % 100 == 0 ){
+                                 Map<String,Object> map = new LinkedHashMap<>();
+                                 map.put("count",itemsDeleted.intValue());
+                                 final StatusService statusService = injector.getInstance(StatusService.class);
+                                 statusService.setStatus(applicationId, jobId, StatusService.Status.INPROGRESS,map).subscribe();
+                             }
+                         })
+                         .doOnCompleted(() ->{
+                             Map<String,Object> map = new LinkedHashMap<>();
+                             map.put("count",itemsDeleted.intValue());
+                             final StatusService statusService = injector.getInstance(StatusService.class);
+                             statusService.setStatus(applicationId,jobId, StatusService.Status.COMPLETE,map).subscribe();
+                         })
+                         .subscribe();
+ 
+                 } catch ( Exception e ) {
+                     Map<String,Object> map = new LinkedHashMap<>();
+                     map.put("exception",e);
+                     statusService.setStatus(applicationId,jobId, StatusService.Status.FAILED,map).subscribe();
+                     logger.error( "Failed to delete appid:"+applicationId + " jobid:"+jobId+" count:"+itemsDeleted, e );
+                 }
+             }
+         };
+ 
+         delete.setName("Delete for app : " + applicationId + " job: " + jobId);
+         delete.setDaemon(true);
+         delete.start();
+ 
+         statusService.setStatus(applicationId,jobId, StatusService.Status.STARTED,new LinkedHashMap<>()).subscribe();
+ 
+         Map<String,Object> data = new HashMap<>();
+         data.put("jobId",jobId);
+         data.put("status",StatusService.Status.STARTED);
+         response.setData(data);
+         response.setSuccess();
 -        return new JSONWithPadding( response, callback );
++        return response;
+     }
+ 
+     @RequireSystemAccess
+     @GET
+     @Path( "{applicationId}/job/{jobId}" )
 -    public JSONWithPadding getStatus( @Context UriInfo ui,
 -                                             @PathParam("applicationId") UUID applicationId,
 -                                            @PathParam("jobId") UUID jobId,
 -                                             @QueryParam( "callback" ) @DefaultValue( "callback" ) String callback ) throws Exception{
++    public ApiResponse getStatus(
++        @Context UriInfo ui,
++        @PathParam("applicationId") UUID applicationId,
++        @PathParam("jobId") UUID jobId,
++        @QueryParam( "callback" ) @DefaultValue( "callback" ) String callback ) throws Exception{
++
+         final StatusService statusService = injector.getInstance(StatusService.class);
+ 
+         final ApiResponse response = createApiResponse();
+ 
+         response.setAction( "clear application" );
+ 
+         StatusService.JobStatus jobStatus = statusService.getStatus(applicationId, jobId).toBlocking().lastOrDefault(null);
+ 
          Map<String,Object> data = new HashMap<>();
-         data.put("count",itemsDeleted.get());
+         data.put("jobId",jobId);
+         data.put( "status", jobStatus.getStatus().toString() );
+         data.put( "metadata", jobStatus.getData() );
          response.setData(data);
          response.setSuccess();
 -
 -        return new JSONWithPadding( response, callback );
 -
 +        return response;
      }
  
  }

http://git-wip-us.apache.org/repos/asf/usergrid/blob/0db86225/stack/rest/src/main/java/org/apache/usergrid/rest/applications/ApplicationResource.java
----------------------------------------------------------------------
diff --cc stack/rest/src/main/java/org/apache/usergrid/rest/applications/ApplicationResource.java
index 7dc6717,52a0f99..afcbbaf
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/applications/ApplicationResource.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/applications/ApplicationResource.java
@@@ -17,35 -17,8 +17,7 @@@
  package org.apache.usergrid.rest.applications;
  
  
- import java.io.UnsupportedEncodingException;
- import java.net.URLEncoder;
- import java.util.Map;
- import java.util.UUID;
- 
- import javax.ws.rs.Consumes;
- import javax.ws.rs.DELETE;
- import javax.ws.rs.DefaultValue;
- import javax.ws.rs.FormParam;
- import javax.ws.rs.GET;
- import javax.ws.rs.HeaderParam;
- import javax.ws.rs.POST;
- import javax.ws.rs.Path;
- import javax.ws.rs.Produces;
- import javax.ws.rs.QueryParam;
- import javax.ws.rs.core.Context;
- import javax.ws.rs.core.MediaType;
- import javax.ws.rs.core.PathSegment;
- import javax.ws.rs.core.Response;
- import javax.ws.rs.core.UriInfo;
- 
 -import com.sun.jersey.api.json.JSONWithPadding;
 -import com.sun.jersey.api.view.Viewable;
 +import com.fasterxml.jackson.jaxrs.json.annotation.JSONP;
- import org.apache.usergrid.rest.ApiResponse;
- import org.glassfish.jersey.server.mvc.Viewable;
- import org.slf4j.Logger;
- import org.slf4j.LoggerFactory;
- import org.springframework.context.annotation.Scope;
- import org.springframework.stereotype.Component;
- 
  import org.apache.amber.oauth2.common.error.OAuthError;
  import org.apache.amber.oauth2.common.exception.OAuthProblemException;
  import org.apache.amber.oauth2.common.message.OAuthResponse;
@@@ -65,6 -37,6 +36,7 @@@ import org.apache.usergrid.persistence.
  import org.apache.usergrid.persistence.entities.User;
  import org.apache.usergrid.persistence.index.query.Identifier;
  import org.apache.usergrid.rest.AbstractContextResource;
++import org.apache.usergrid.rest.ApiResponse;
  import org.apache.usergrid.rest.applications.assets.AssetsResource;
  import org.apache.usergrid.rest.applications.events.EventsResource;
  import org.apache.usergrid.rest.applications.queues.QueueResource;
@@@ -75,6 -47,17 +47,18 @@@ import org.apache.usergrid.rest.securit
  import org.apache.usergrid.rest.security.annotations.RequireOrganizationAccess;
  import org.apache.usergrid.security.oauth.AccessInfo;
  import org.apache.usergrid.security.oauth.ClientCredentialsInfo;
++import org.glassfish.jersey.server.mvc.Viewable;
+ import org.slf4j.Logger;
+ import org.slf4j.LoggerFactory;
+ import org.springframework.context.annotation.Scope;
+ import org.springframework.stereotype.Component;
+ 
+ import javax.ws.rs.*;
+ import javax.ws.rs.core.*;
+ import java.io.UnsupportedEncodingException;
+ import java.net.URLEncoder;
+ import java.util.Map;
+ import java.util.UUID;
  
  import static javax.servlet.http.HttpServletResponse.SC_BAD_REQUEST;
  import static javax.servlet.http.HttpServletResponse.SC_OK;

http://git-wip-us.apache.org/repos/asf/usergrid/blob/0db86225/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/applications/ApplicationResource.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/usergrid/blob/0db86225/stack/rest/src/test/java/org/apache/usergrid/rest/SystemResourceIT.java
----------------------------------------------------------------------
diff --cc stack/rest/src/test/java/org/apache/usergrid/rest/SystemResourceIT.java
index a278358,55623dd..ae9a2c2
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/SystemResourceIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/SystemResourceIT.java
@@@ -20,9 -20,11 +20,10 @@@ package org.apache.usergrid.rest
  import org.apache.usergrid.rest.test.resource.AbstractRestIT;
  import org.apache.usergrid.rest.test.resource.model.Entity;
  import org.apache.usergrid.rest.test.resource.model.QueryParameters;
 +import org.junit.Test;
  
  import java.util.LinkedHashMap;
+ import java.util.UUID;
  
  import static org.junit.Assert.assertEquals;
  import static org.junit.Assert.assertNotNull;
@@@ -60,12 -63,25 +61,26 @@@ public class SystemResourceIT extends A
          queryParameters.addParam( "access_token", clientSetup.getSuperuserToken().getAccessToken() );
          queryParameters.addParam("confirmApplicationName", this.clientSetup.getAppName());
  
 -        org.apache.usergrid.rest.test.resource.model.ApiResponse result = clientSetup.getRestClient().system().applications(this.clientSetup.getAppUuid()).delete( queryParameters);
 +        org.apache.usergrid.rest.test.resource.model.ApiResponse result =
 +            clientSetup.getRestClient().system().applications(this.clientSetup.getAppUuid()).delete( queryParameters);
  
-         assertNotNull( result );
-         assertNotNull( "ok",result.getStatus() );
-         assertEquals(((LinkedHashMap) result.getData()).get("count"), count);
+         assertNotNull(result);
+         assertNotNull("ok", result.getStatus());
+         assertNotNull(((LinkedHashMap) result.getData()).get("jobId"));
+ 
+         String jobId = (String)((LinkedHashMap) result.getData()).get("jobId");
+         queryParameters = new QueryParameters();
+         for(int i = 0;i<10;i++ ) {
+             result = clientSetup.getRestClient().system().applications(this.clientSetup.getAppUuid(), "job/" + jobId).get(queryParameters);
+             String status = (String) ((LinkedHashMap) result.getData()).get("status");
+             if(status.equals("COMPLETE")){
+                 break;
+             }else{
+                 Thread.sleep(100);
+             }
+         }
+         assertEquals(((LinkedHashMap)((LinkedHashMap) result.getData()).get("metadata")).get("count"), 10);
+ 
      }
  
  

http://git-wip-us.apache.org/repos/asf/usergrid/blob/0db86225/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/SystemResource.java
----------------------------------------------------------------------
diff --cc stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/SystemResource.java
index 6d89fa9,1a7b594..96e8fa5
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/SystemResource.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/SystemResource.java
@@@ -45,32 -48,37 +45,46 @@@ public class SystemResource extends Nam
      public ApplicationsResource applications(String appid) {
          return new ApplicationsResource(appid,context,this);
      }
 +
+     public ApplicationsResource applications(String appid, String additionalPath) {
+         return new ApplicationsResource(appid+"/"+additionalPath,context,this);
+     }
++
      public class ApplicationsResource extends NamedResource {
 -        public ApplicationsResource(final String appid, final ClientContext context, final UrlResource parent ) {
 -            super( "applications/"+appid,context, parent );
 +
 +        public ApplicationsResource(final String appid, final ClientContext context, final UrlResource parent) {
 +            super( "applications/" + appid, context, parent );
          }
  
+         public ApiResponse get(QueryParameters queryParameters){
+ 
 -            WebResource resource = getResource();
++            WebTarget resource = getTarget();
+             resource = addParametersToResource( resource, queryParameters );
+ 
 -            //added httpBasicauth filter to all setup calls because they all do verification this way.
 -            HTTPBasicAuthFilter httpBasicAuthFilter = new HTTPBasicAuthFilter( "superuser","superpassword" );
 -            resource.addFilter(httpBasicAuthFilter);
++            HttpAuthenticationFeature feature = HttpAuthenticationFeature.basicBuilder()
++                .credentials( "superuser", "superpassword" ).build();
+ 
 -            return resource.type( MediaType.APPLICATION_JSON_TYPE ).accept( MediaType.APPLICATION_JSON )
++            return resource.register( feature ).request().accept( MediaType.APPLICATION_JSON )
+                 .get(ApiResponse.class);
+         }
 -        public ApiResponse delete(QueryParameters queryParameters){
+ 
 -            WebResource resource = getResource();
++
 +        public ApiResponse delete(QueryParameters queryParameters) {
 +
 +            WebTarget resource = getTarget();
              resource = addParametersToResource( resource, queryParameters );
  
 -            //added httpBasicauth filter to all setup calls because they all do verification this way.
 -            HTTPBasicAuthFilter httpBasicAuthFilter = new HTTPBasicAuthFilter( "superuser","superpassword" );
 -            resource.addFilter(httpBasicAuthFilter);
 +            HttpAuthenticationFeature feature = HttpAuthenticationFeature.basicBuilder()
 +                .credentials( "superuser", "superpassword" ).build();
 +
 +            return resource.register( feature ).request().delete( ApiResponse.class );
  
 -            return resource.type( MediaType.APPLICATION_JSON_TYPE ).accept( MediaType.APPLICATION_JSON )
 -                .delete(ApiResponse.class);
          }
      }
 +
 +    public ApiResponse put(){
-         ApiResponse
-             response = getTarget(true)
-                 .request()
-                 .accept(MediaType.APPLICATION_JSON)
++        ApiResponse response = getTarget(true).request().accept(MediaType.APPLICATION_JSON)
 +                .put( javax.ws.rs.client.Entity.json(""), ApiResponse.class);
 +        return response;
 +    }
  }


[35/54] usergrid git commit: change parsing logic to parse uuid as string

Posted by sn...@apache.org.
change parsing logic to parse uuid as string


Project: http://git-wip-us.apache.org/repos/asf/usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/usergrid/commit/968496d0
Tree: http://git-wip-us.apache.org/repos/asf/usergrid/tree/968496d0
Diff: http://git-wip-us.apache.org/repos/asf/usergrid/diff/968496d0

Branch: refs/heads/usergrid-1007-shiro-cache
Commit: 968496d0e66327339b7122af271f86edc4e18e9d
Parents: e2fe939
Author: Shawn Feldman <sf...@apache.org>
Authored: Tue Sep 15 18:42:19 2015 -0600
Committer: Shawn Feldman <sf...@apache.org>
Committed: Tue Sep 15 18:42:19 2015 -0600

----------------------------------------------------------------------
 .../usergrid/persistence/index/impl/EntityToMapConverterTest.java  | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/usergrid/blob/968496d0/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EntityToMapConverterTest.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EntityToMapConverterTest.java b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EntityToMapConverterTest.java
index 2fb32cd..5ebe14e 100644
--- a/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EntityToMapConverterTest.java
+++ b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EntityToMapConverterTest.java
@@ -170,7 +170,7 @@ public class EntityToMapConverterTest {
     @Test
     public void testUUIDField() {
         testSingleField( new UUIDField( "Name", UUIDGenerator.newTimeUUID() ),
-            ( field, entityField ) -> assertEquals( field.getValue().toString(), entityField.get( IndexingUtils.FIELD_UUID ) ) );
+            ( field, entityField ) -> assertEquals( field.getValue().toString(), entityField.get( IndexingUtils.FIELD_STRING ) ) );
     }
 
 


[13/54] usergrid git commit: Jersey 2 fixes for ContentTypeFilter and associated test, down to 1 failing test now.

Posted by sn...@apache.org.
Jersey 2 fixes for ContentTypeFilter and associated test, down to 1 failing test now.


Project: http://git-wip-us.apache.org/repos/asf/usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/usergrid/commit/c8b84305
Tree: http://git-wip-us.apache.org/repos/asf/usergrid/tree/c8b84305
Diff: http://git-wip-us.apache.org/repos/asf/usergrid/diff/c8b84305

Branch: refs/heads/usergrid-1007-shiro-cache
Commit: c8b84305910f8916991a9c3f50c4d9d97a3572ec
Parents: dfa65d6
Author: Dave Johnson <sn...@apache.org>
Authored: Fri Sep 4 11:12:32 2015 -0400
Committer: Dave Johnson <sn...@apache.org>
Committed: Fri Sep 4 11:12:32 2015 -0400

----------------------------------------------------------------------
 .../exceptions/UnsupportedMediaTypeMapper.java  | 43 ++++++++++++++++++
 .../rest/filters/ContentTypeFilter.java         | 48 ++++++++------------
 stack/rest/src/main/webapp/WEB-INF/web.xml      |  3 +-
 .../rest/filters/ContentTypeResourceIT.java     | 35 ++++++++------
 4 files changed, 82 insertions(+), 47 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/usergrid/blob/c8b84305/stack/rest/src/main/java/org/apache/usergrid/rest/exceptions/UnsupportedMediaTypeMapper.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/exceptions/UnsupportedMediaTypeMapper.java b/stack/rest/src/main/java/org/apache/usergrid/rest/exceptions/UnsupportedMediaTypeMapper.java
new file mode 100644
index 0000000..99ae992
--- /dev/null
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/exceptions/UnsupportedMediaTypeMapper.java
@@ -0,0 +1,43 @@
+/*
+ * 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.usergrid.rest.exceptions;
+
+
+import javax.ws.rs.NotSupportedException;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.ext.Provider;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import static javax.ws.rs.core.Response.Status.UNSUPPORTED_MEDIA_TYPE;
+
+
+@Provider
+public class UnsupportedMediaTypeMapper extends AbstractExceptionMapper<NotSupportedException> {
+
+    private static final Logger logger = LoggerFactory.getLogger(UnsupportedMediaTypeMapper.class);
+
+    @Override
+    public Response toResponse( NotSupportedException e ) {
+
+        logger.error( "Unsupported media type", e );
+
+        return toResponse( UNSUPPORTED_MEDIA_TYPE, e );
+    }
+}
+

http://git-wip-us.apache.org/repos/asf/usergrid/blob/c8b84305/stack/rest/src/main/java/org/apache/usergrid/rest/filters/ContentTypeFilter.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/filters/ContentTypeFilter.java b/stack/rest/src/main/java/org/apache/usergrid/rest/filters/ContentTypeFilter.java
index 93048db..d79451c 100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/filters/ContentTypeFilter.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/filters/ContentTypeFilter.java
@@ -133,26 +133,24 @@ public class ContentTypeFilter implements Filter {
          */
         private void adapt() throws IOException {
 
-            //check if the accept header was set
-            @SuppressWarnings( "rawtypes" ) Enumeration contentType = origRequest.getHeaders( HttpHeaders.ACCEPT );
-
-            if ( !contentType.hasMoreElements() ) {
-                setHeader( HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON );
-            }
-
-
             String path = origRequest.getRequestURI();
-
+            String method = origRequest.getMethod();
             logger.debug( "Content path is '{}'", path );
 
-            int initial = inputStream.read();
 
-            String method = origRequest.getMethod();
+            // first ensure that an Accept header is set
+
+            @SuppressWarnings( "rawtypes" ) Enumeration acceptHeaders = origRequest.getHeaders( HttpHeaders.ACCEPT );
+            if ( !acceptHeaders.hasMoreElements() ) {
+                setHeader( HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON );
+            }
 
+            // next, ensure that one and only one content-type is set
 
-            // nothing to read, check if it's a put or a post. If so set the
-            // content type to json to create an empty json request
+            int initial = inputStream.read();
             if ( initial == -1 ) {
+
+                // request has no body, set type to application/json
                 if ( ( HttpMethod.POST.equals( method ) || HttpMethod.PUT.equals( method ) )
                     && !MediaType.APPLICATION_FORM_URLENCODED.equals( getContentType() ) ) {
                     logger.debug("Setting content type to application/json " +
@@ -166,14 +164,12 @@ public class ContentTypeFilter implements Filter {
             }
 
             char firstChar = ( char ) initial;
+            if ( ( firstChar == '{' || firstChar == '[' )
+                 && !MediaType.APPLICATION_JSON.equals( getContentType() )) {
 
-            // its json, make it so
-            if ( firstChar == '{' || firstChar == '['
-                && !MediaType.APPLICATION_JSON.equals( getContentType() )) {
-
+                // request appears to be JSON so set type to application/json
                 logger.debug( "Setting content type to application/json " +
                         "for POST or PUT with json content at path '{}'", path );
-
                 setHeader( HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON );
                 setHeader( HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON );
             }
@@ -182,12 +178,8 @@ public class ContentTypeFilter implements Filter {
         }
 
 
-        /**
-         * @throws IOException
-         *
-         */
         public void setHeader( String name, String value ) {
-            newHeaders.put( name, value );
+            newHeaders.put( name.toLowerCase(), value );
         }
 
 
@@ -219,20 +211,16 @@ public class ContentTypeFilter implements Filter {
          */
         @Override
         public Enumeration getHeaders( String name ) {
-            Set<String> headers = new LinkedHashSet<String>();
 
+            Set<String> headers = new LinkedHashSet<String>();
             String overridden = newHeaders.get( name );
 
             if ( overridden != null ) {
                 headers.add( overridden );
-            }
-            else {
-                for ( Enumeration e = super.getHeaders( name ); e.hasMoreElements(); ) {
-                    headers.add( e.nextElement().toString() );
-                }
+                return Collections.enumeration( headers );
             }
 
-            return Collections.enumeration( headers );
+            return super.getHeaders( name );
         }
 
 

http://git-wip-us.apache.org/repos/asf/usergrid/blob/c8b84305/stack/rest/src/main/webapp/WEB-INF/web.xml
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/webapp/WEB-INF/web.xml b/stack/rest/src/main/webapp/WEB-INF/web.xml
index 0c46fe4..a7ca5b8 100644
--- a/stack/rest/src/main/webapp/WEB-INF/web.xml
+++ b/stack/rest/src/main/webapp/WEB-INF/web.xml
@@ -53,7 +53,7 @@
         <url-pattern>/management.json</url-pattern>
     </filter-mapping>
 
-    <!--  filter for setting default accept and Content-Type as application/json when undefined by client
+    <!--  filter for setting default accept and Content-Type as application/json when undefined by client -->
     <filter>
         <filter-name>contentTypeFilter</filter-name>
         <filter-class>org.apache.usergrid.rest.filters.ContentTypeFilter</filter-class>
@@ -62,7 +62,6 @@
         <filter-name>contentTypeFilter</filter-name>
         <url-pattern>/*</url-pattern>
     </filter-mapping>
-    -->
 
     <filter>
         <filter-name>shiroFilter</filter-name>

http://git-wip-us.apache.org/repos/asf/usergrid/blob/c8b84305/stack/rest/src/test/java/org/apache/usergrid/rest/filters/ContentTypeResourceIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/filters/ContentTypeResourceIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/filters/ContentTypeResourceIT.java
index 31ceb8c..47afb8c 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/filters/ContentTypeResourceIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/filters/ContentTypeResourceIT.java
@@ -20,6 +20,7 @@ import org.apache.http.Header;
 import org.apache.http.HttpEntity;
 import org.apache.http.HttpHost;
 import org.apache.http.HttpResponse;
+import org.apache.http.client.methods.HttpGet;
 import org.apache.http.client.methods.HttpPost;
 import org.apache.http.entity.StringEntity;
 import org.apache.http.impl.client.DefaultHttpClient;
@@ -34,12 +35,10 @@ import org.glassfish.jersey.client.ClientResponse;
 import org.junit.Test;
 
 import javax.ws.rs.client.Invocation;
-import javax.ws.rs.core.Form;
-import javax.ws.rs.core.HttpHeaders;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.MultivaluedMap;
+import javax.ws.rs.core.*;
 import java.io.IOException;
 import java.text.ParseException;
+import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
@@ -80,7 +79,7 @@ public class ContentTypeResourceIT extends AbstractRestIT {
             this.clientSetup.getOrganization().getName(), this.clientSetup.getAppName()) );
         post.setEntity(new StringEntity(json));
         post.setHeader(HttpHeaders.AUTHORIZATION, "Bearer " + token.getAccessToken());
-        post.setHeader(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON);
+        post.setHeader( HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON );
         post.setHeader(HttpHeaders.CONTENT_TYPE, "*/*");
 
         HttpResponse rsp = client.execute( host, post );
@@ -105,7 +104,7 @@ public class ContentTypeResourceIT extends AbstractRestIT {
     @Test
     public void textPlainContentType() throws Exception {
         User user = new User("shawn","shawn","shawn@email.com","aliensquirrel");
-        this.app().collection("users").post(user);
+        this.app().collection("users").post( user );
         Token token = this.app().token().post(new Token("shawn","aliensquirrel"));
         Map<String, String> data = hashMap( "name", "Solitaire2" );
 
@@ -171,7 +170,8 @@ public class ContentTypeResourceIT extends AbstractRestIT {
 
         HttpHost host = new HttpHost( super.getBaseURI().getHost(), super.getBaseURI().getPort() );
 
-        HttpPost post = new HttpPost( String.format("/%s/%s/games", this.clientSetup.getOrganization().getName(), this.clientSetup.getAppName()) );
+        HttpPost post = new HttpPost( String.format("/%s/%s/games",
+            this.clientSetup.getOrganization().getName(), this.clientSetup.getAppName()) );
 
         post.setEntity( new StringEntity( json ) );
         post.setHeader( HttpHeaders.AUTHORIZATION, "Bearer " + token.getAccessToken() );
@@ -191,8 +191,8 @@ public class ContentTypeResourceIT extends AbstractRestIT {
 
 
     /**
-     * Creates a simple entity of type game. Does not set the Accepts header. The type should be set to json to match the
-     * body.  Then does a get without Accept type, it should return application/json, not text/csv
+     * Creates a simple entity of type game. Does not set the Accepts header. The type should be set to json
+     * to match the body.  Then does a get without Accept type, it should return application/json, not text/csv
      */
     @Test
     public void noAcceptGet() throws Exception {
@@ -222,23 +222,28 @@ public class ContentTypeResourceIT extends AbstractRestIT {
             .queryParam( "access_token", this.getAdminToken().getAccessToken() )
             .request();
 
-        ClientResponse clientResponse = builder.post(
-            javax.ws.rs.client.Entity.json( hashMap( "name", "bar2" ) ), ClientResponse.class );
+        Response clientResponse = builder.post(
+            javax.ws.rs.client.Entity.json( new HashMap() {{ put( "name", "bar2" ); }} ), Response.class );
 
         assertEquals(200, clientResponse.getStatus());
 
-        MultivaluedMap<String, String> headers = clientResponse.getHeaders();
+        MultivaluedMap<String, Object> headers = clientResponse.getHeaders();
 
-        List<String> contentType = headers.get("Content-Type");
+        List contentType = headers.get( "Content-Type" );
         assertEquals(1, contentType.size());
         assertEquals(MediaType.APPLICATION_JSON, contentType.get(0));
 
         //do the get with no content type, it should get set to application/json
-        HttpPost get = new HttpPost( String.format("/%s/%s/games",
+
+        builder = app().collection( "games" ).getTarget()
+            .queryParam( "access_token", this.getAdminToken().getAccessToken() )
+            .request();
+
+        HttpGet get = new HttpGet( String.format("/%s/%s/games",
             this.clientSetup.getOrganization().getName(), this.clientSetup.getAppName()) );
 
         get.setHeader( HttpHeaders.AUTHORIZATION, "Bearer " + token.getAccessToken() );
-        clientResponse = builder.get(ClientResponse.class);
+        clientResponse = builder.get( Response.class );
 
         assertEquals(200, clientResponse.getStatus());
 


[14/54] usergrid git commit: In Jersey 2 need the security annotation on the very last resource method that is called.

Posted by sn...@apache.org.
In Jersey 2 need the security annotation on the very last resource method that is called.


Project: http://git-wip-us.apache.org/repos/asf/usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/usergrid/commit/cdf7c293
Tree: http://git-wip-us.apache.org/repos/asf/usergrid/tree/cdf7c293
Diff: http://git-wip-us.apache.org/repos/asf/usergrid/diff/cdf7c293

Branch: refs/heads/usergrid-1007-shiro-cache
Commit: cdf7c293f5127d21b6726f8ba0b7c121722e1f36
Parents: c8b8430
Author: Dave Johnson <sn...@apache.org>
Authored: Tue Sep 8 13:26:29 2015 -0400
Committer: Dave Johnson <sn...@apache.org>
Committed: Tue Sep 8 13:26:29 2015 -0400

----------------------------------------------------------------------
 .../organizations/OrganizationResource.java     |  1 +
 .../organizations/OrganizationsResource.java    | 21 ++------------------
 2 files changed, 3 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/usergrid/blob/cdf7c293/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/OrganizationResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/OrganizationResource.java b/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/OrganizationResource.java
index 287b5a7..c43b463 100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/OrganizationResource.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/OrganizationResource.java
@@ -107,6 +107,7 @@ public class OrganizationResource extends AbstractContextResource {
 
     @GET
     @JSONP
+    @RequireOrganizationAccess
     @Produces({"application/json", "application/javascript"})
     public ApiResponse getOrganizationDetails( @Context UriInfo ui,
                                                    @QueryParam("callback") @DefaultValue("callback") String callback )

http://git-wip-us.apache.org/repos/asf/usergrid/blob/cdf7c293/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/OrganizationsResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/OrganizationsResource.java b/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/OrganizationsResource.java
index 26f6b5c..660e93d 100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/OrganizationsResource.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/OrganizationsResource.java
@@ -66,13 +66,6 @@ public class OrganizationsResource extends AbstractContextResource {
     public OrganizationsResource() {
     }
 
-    // TODO: better solution to this Jersey 2 introduced problem:
-    // Problem is that when Jersey scans the resources classes and methods to add our
-    // secured resource filter, it only recognizes methods with an HTTP method annotation
-    // but when I add the @GET annotation to the methods below, Jersey fails to resolve
-    // the resource methods when they are called.
-
-    //@GET
     @Path(RootResource.ORGANIZATION_ID_PATH)
     @RequireOrganizationAccess
     public OrganizationResource getOrganizationById( @Context UriInfo ui,
@@ -83,17 +76,11 @@ public class OrganizationsResource extends AbstractContextResource {
             throw new ManagementException( "Could not find organization for ID: " + organizationIdStr );
         }
 
-//        // TODO: get rid of this and make annotations work (see above)
-//        if ( !isPermittedAccessToOrganization( Identifier.from(organization) ) ) {
-//            logger.debug("No organization access authorized");
-//            throw mappableSecurityException( "unauthorized", "No organization access authorized" );
-//        }
+
 
         return getSubResource( OrganizationResource.class ).init( organization );
     }
 
-
-    //@GET
     @Path( "{organizationName}" )
     @RequireOrganizationAccess
     public OrganizationResource getOrganizationByName( @Context UriInfo ui,
@@ -104,11 +91,7 @@ public class OrganizationsResource extends AbstractContextResource {
             throw new ManagementException( "Could not find organization for name: " + organizationName );
         }
 
-//        // TODO: get rid of this and make annotations work (see above)
-//        if ( !isPermittedAccessToOrganization( Identifier.from(organization) ) ) {
-//            logger.debug("No organization access authorized");
-//            throw mappableSecurityException( "unauthorized", "No organization access authorized" );
-//        }
+
 
         return getSubResource( OrganizationResource.class ).init(organization);
     }


[11/54] usergrid git commit: Client side error handling fixes get two more tests passing.

Posted by sn...@apache.org.
Client side error handling fixes get two more tests passing.


Project: http://git-wip-us.apache.org/repos/asf/usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/usergrid/commit/e070ad55
Tree: http://git-wip-us.apache.org/repos/asf/usergrid/tree/e070ad55
Diff: http://git-wip-us.apache.org/repos/asf/usergrid/diff/e070ad55

Branch: refs/heads/usergrid-1007-shiro-cache
Commit: e070ad55fe2ca5e5fa9dca95029b501a4389c043
Parents: eb2aa6f
Author: Dave Johnson <sn...@apache.org>
Authored: Thu Sep 3 17:11:13 2015 -0400
Committer: Dave Johnson <sn...@apache.org>
Committed: Thu Sep 3 17:11:13 2015 -0400

----------------------------------------------------------------------
 .../rest/management/OrganizationsIT.java        | 28 +++++++++------
 .../resource/endpoints/mgmt/OrgResource.java    | 36 ++++++++------------
 2 files changed, 31 insertions(+), 33 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/usergrid/blob/e070ad55/stack/rest/src/test/java/org/apache/usergrid/rest/management/OrganizationsIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/management/OrganizationsIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/management/OrganizationsIT.java
index 64ad8b0..72a2f8c 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/management/OrganizationsIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/management/OrganizationsIT.java
@@ -21,6 +21,7 @@ import java.io.IOException;
 import java.util.HashMap;
 import java.util.Map;
 
+import org.apache.usergrid.java.client.exception.ClientException;
 import org.apache.usergrid.rest.test.resource.model.*;
 import org.junit.Ignore;
 import org.junit.Test;
@@ -100,25 +101,27 @@ public class OrganizationsIT extends AbstractRestIT {
     @Test
     public void testCreateDuplicateOrgName() throws Exception {
 
-        //Create organization
+        // Create organization
         Organization organization = createOrgPayload( "testCreateDuplicateOrgName", null );
-
         Organization orgCreatedResponse = clientSetup.getRestClient().management().orgs().post( organization );
         this.refreshIndex();
 
         assertNotNull( orgCreatedResponse );
 
-        //Ensure that the token from the newly created organization works.
+        // Ensure that the token from the newly created organization works.
         Token tokenPayload = new Token( "password", organization.getUsername(), organization.getPassword() );
-        Token tokenReturned = clientSetup.getRestClient().management().token().post(false,Token.class, tokenPayload,null );
+        Token tokenReturned = clientSetup.getRestClient().management().token()
+            .post( false, Token.class, tokenPayload, null );
         this.management().token().setToken(tokenReturned);
         assertNotNull( tokenReturned );
 
-        //Try to create a organization with the same name as an organization that already exists, ensure that it fails
-        Organization orgTestDuplicatePayload =
-                new Organization( organization.getOrganization(), organization.getUsername() + "test",
-                        organization.getEmail() + "test", organization.getName() + "test",
-                        organization.getPassword(), null );
+        // Try to create a organization with the same name as an organization that already exists, ensure that it fails
+        Organization orgTestDuplicatePayload = new Organization(
+            organization.getOrganization(),
+            organization.getUsername() + "test",
+            organization.getEmail() + "test",
+            organization.getName() + "test",
+            organization.getPassword(), null );
         try {
             clientSetup.getRestClient().management().orgs().post( orgTestDuplicatePayload );
             fail("Should not have been able to create duplicate organization");
@@ -164,7 +167,8 @@ public class OrganizationsIT extends AbstractRestIT {
 
         //get token from organization that was created to verify it exists.
         Token tokenPayload = new Token( "password", organization.getUsername(), organization.getPassword() );
-        Token tokenReturned = clientSetup.getRestClient().management().token().post(Token.class, tokenPayload );
+        Token tokenReturned = clientSetup.getRestClient().management().token()
+            .post( Token.class, tokenPayload );
 
         assertNotNull( tokenReturned );
 
@@ -184,7 +188,9 @@ public class OrganizationsIT extends AbstractRestIT {
         }
 
         //try to get the token from the organization that failed to be created to verify it was not made.
-        tokenPayload = new Token( "password", organization.getUsername()+"test", organization.getPassword()+"test" );
+        tokenPayload = new Token( "password",
+            organization.getUsername()+"test",
+            organization.getPassword()+"test" );
         Token tokenError = null;
         try {
             tokenError = clientSetup.getRestClient().management().token().post(false,Token.class, tokenPayload,null );

http://git-wip-us.apache.org/repos/asf/usergrid/blob/e070ad55/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/mgmt/OrgResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/mgmt/OrgResource.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/mgmt/OrgResource.java
index 0569ac2..4d7b2f9 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/mgmt/OrgResource.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/mgmt/OrgResource.java
@@ -18,6 +18,7 @@
 package org.apache.usergrid.rest.test.resource.endpoints.mgmt;
 
 import com.fasterxml.jackson.databind.ObjectMapper;
+import org.apache.usergrid.java.client.exception.ClientException;
 import org.apache.usergrid.rest.test.resource.endpoints.NamedResource;
 import org.apache.usergrid.rest.test.resource.endpoints.UrlResource;
 import org.apache.usergrid.rest.test.resource.model.ApiResponse;
@@ -35,6 +36,7 @@ import javax.ws.rs.ClientErrorException;
 import javax.ws.rs.client.WebTarget;
 import javax.ws.rs.core.Form;
 import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
 import java.io.IOException;
 import java.io.StringReader;
 
@@ -102,36 +104,26 @@ public class OrgResource  extends NamedResource {
 
     public Organization post(Organization organization){
 
-        // use string type so we can log actual response from server
-        String responseString = null;
-        try {
-            responseString = getTarget( false ).request()
-                .accept( MediaType.APPLICATION_JSON )
-                .post( Entity.json( organization ), String.class );
-        } catch ( ClientErrorException e ) {
-            logger.info("Response from post: " + e.getMessage() + ": " + e.getResponse().readEntity( String.class ));
-        }
+        ApiResponse apiResponse = getTarget( false ).request()
+            .accept( MediaType.APPLICATION_JSON )
+            .post( Entity.json( organization ), ApiResponse.class );
 
-        ObjectMapper mapper = new ObjectMapper();
-        ApiResponse response;
-        try {
-            response = mapper.readValue( new StringReader(responseString), ApiResponse.class);
-        } catch (IOException e) {
-            throw new RuntimeException("Error parsing response", e);
-        }
 
-        Organization org = new Organization(response);
-        org.setOwner( response );
+        Organization org = new Organization(apiResponse);
+        org.setOwner( apiResponse );
 
         return org;
     }
-    public Organization post(Organization organization, Token token){
-        ApiResponse response = getTarget( true, token ).request()
+
+    public Organization post(Organization organization, Token token) {
+
+        ApiResponse apiResponse = getTarget( true, token ).request()
             .accept( MediaType.APPLICATION_JSON )
             .post( Entity.json( organization ), ApiResponse.class );
 
-        Organization org = new Organization(response);
-        org.setOwner( response );
+
+        Organization org = new Organization(apiResponse);
+        org.setOwner( apiResponse );
 
         return org;
     }


[40/54] usergrid git commit: Example app for experimenting with Swagger annotations.

Posted by sn...@apache.org.
Example app for experimenting with Swagger annotations.


Project: http://git-wip-us.apache.org/repos/asf/usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/usergrid/commit/6ea66856
Tree: http://git-wip-us.apache.org/repos/asf/usergrid/tree/6ea66856
Diff: http://git-wip-us.apache.org/repos/asf/usergrid/diff/6ea66856

Branch: refs/heads/usergrid-1007-shiro-cache
Commit: 6ea668560f1bcbfb3ab55e4c2a3b61e6b67f5adb
Parents: 54f61dc
Author: Dave Johnson <sn...@apache.org>
Authored: Wed Sep 16 16:07:42 2015 -0400
Committer: Dave Johnson <sn...@apache.org>
Committed: Wed Sep 16 16:07:42 2015 -0400

----------------------------------------------------------------------
 docs/jersey2skeleton/README.md                  |   9 +
 docs/jersey2skeleton/pom.xml                    | 387 +++++++++++++++++++
 .../usergrid/testapp/AbstractResource.java      |  51 +++
 .../apache/usergrid/testapp/ApiResponse.java    |  52 +++
 .../org/apache/usergrid/testapp/Entity.java     |  55 +++
 .../usergrid/testapp/ManagementResource.java    |  56 +++
 .../usergrid/testapp/OrganizationResource.java  |  64 +++
 .../usergrid/testapp/OrganizationsResource.java |  76 ++++
 .../apache/usergrid/testapp/StatusResource.java |  34 ++
 .../java/org/apache/usergrid/testapp/User.java  |  28 ++
 .../src/main/resources/applicationContext.xml   |  28 ++
 .../main/resources/jersey2skeleton-context.xml  |  28 ++
 .../src/main/webapp/WEB-INF/web.xml             |  95 +++++
 .../usergrid/testapp/AvailablePortFinder.java   | 208 ++++++++++
 .../usergrid/testapp/OrganizationTest.java      | 127 ++++++
 .../org/apache/usergrid/testapp/TomcatMain.java |  57 +++
 .../apache/usergrid/testapp/TomcatRuntime.java  | 185 +++++++++
 .../src/test/resources/log4j.properties         |  31 ++
 .../src/test/resources/logging.properties       |  26 ++
 docs/jersey2skeleton/templates/markdown.hbs     | 108 ++++++
 docs/jersey2skeleton/templates/operation.hbs    |  73 ++++
 docs/jersey2skeleton/templates/security.hbs     |  88 +++++
 .../templates/strapdown.html.hbs                |  10 +
 23 files changed, 1876 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/usergrid/blob/6ea66856/docs/jersey2skeleton/README.md
----------------------------------------------------------------------
diff --git a/docs/jersey2skeleton/README.md b/docs/jersey2skeleton/README.md
new file mode 100644
index 0000000..f0115f1
--- /dev/null
+++ b/docs/jersey2skeleton/README.md
@@ -0,0 +1,9 @@
+# jersey2skeleton
+
+This is a minimal example project designed to mimic how Usergrid uses Jersey 2.
+
+Goal is to determine correct way to use Jersey and Swagger annotations to automatically
+generate Swagger from Usergrid's Java code.
+
+Current status: cannot determine correct combination of annotations to get the correct
+Swagger generated for the /management and /management/organizations end-points.

http://git-wip-us.apache.org/repos/asf/usergrid/blob/6ea66856/docs/jersey2skeleton/pom.xml
----------------------------------------------------------------------
diff --git a/docs/jersey2skeleton/pom.xml b/docs/jersey2skeleton/pom.xml
new file mode 100644
index 0000000..dfeede5
--- /dev/null
+++ b/docs/jersey2skeleton/pom.xml
@@ -0,0 +1,387 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+
+    <!-- based on Usergrid's REST POM -->
+
+    <!-- Jersey 2 project with Spring wiring and Jackson for JSON processing -->
+
+    <groupId>org.apache.usergrid</groupId>
+    <artifactId>jersey2skeleton</artifactId>
+    <version>1.0-SNAPSHOT</version>
+
+    <properties>
+        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+    </properties>
+
+    <build>
+        <finalName>ROOT</finalName>
+
+        <resources>
+            <resource>
+                <directory>src/main/resources</directory>
+                <filtering>true</filtering>
+                <includes>
+                    <include>**/*.xml</include>
+                    <include>**/*.json</include>
+                </includes>
+            </resource>
+        </resources>
+
+        <testResources>
+            <testResource>
+                <directory>src/test/resources</directory>
+                <filtering>true</filtering>
+                <includes>
+                    <include>**/*</include>
+                </includes>
+            </testResource>
+        </testResources>
+
+        <plugins>
+
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-compiler-plugin</artifactId>
+                <version>3.3</version>
+                <configuration>
+                    <source>1.7</source>
+                    <target>1.7</target>
+                    <optimize>true</optimize>
+                    <showDeprecation>true</showDeprecation>
+                    <debug>true</debug>
+                    <encoding>UTF-8</encoding>
+                    <showWarnings>true</showWarnings>
+                </configuration>
+            </plugin>
+
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-surefire-plugin</artifactId>
+                <version>2.18.1</version>
+                <configuration>
+                    <systemPropertyVariables>
+                        <storage-config>${basedir}/src/test/conf</storage-config>
+                        <target.directory>${project.build.directory}</target.directory>
+                    </systemPropertyVariables>
+                    <parallel>methods</parallel>
+                    <forkCount>1</forkCount>
+                    <threadCount>1</threadCount>
+                    <useSystemClassLoader>false</useSystemClassLoader>
+                    <reuseForks>true</reuseForks>
+                    <argLine>-Dwebapp.directory=${basedir}/src/main/webapp
+                        -Djava.util.logging.config.file=${basedir}/src/test/resources/logging.properties
+                    </argLine>
+                    <includes>
+                        <include>**/*Test.java</include>
+                    </includes>
+                </configuration>
+
+                <dependencies>
+                    <dependency>
+                        <groupId>org.apache.maven.surefire</groupId>
+                        <artifactId>surefire-junit4</artifactId>
+                        <version>2.18.1</version>
+                    </dependency>
+                </dependencies>
+            </plugin>
+
+
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-war-plugin</artifactId>
+                <version>2.6</version>
+            </plugin>
+
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-jar-plugin</artifactId>
+                <version>2.6</version>
+                <configuration>
+                    <finalName>${project.artifactId}-${project.version}</finalName>
+                </configuration>
+                <executions>
+                    <execution>
+                        <id>make-a-jar</id>
+                        <phase>package</phase>
+                        <goals>
+                            <goal>jar</goal>
+                        </goals>
+                        <configuration>
+                            <classifier>classes</classifier>
+                        </configuration>
+                    </execution>
+                    <execution>
+                        <id>jsp-jar-execution</id>
+                        <phase>package</phase>
+                        <goals>
+                            <goal>jar</goal>
+                        </goals>
+                        <configuration>
+                            <classifier>compiled-jsp</classifier>
+                            <classesDirectory>${project.build.directory}/jsp-source</classesDirectory>
+                        </configuration>
+                    </execution>
+                    <execution>
+                        <goals>
+                            <goal>test-jar</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+
+            <plugin>
+                <groupId>com.github.kongchen</groupId>
+                <artifactId>swagger-maven-plugin</artifactId>
+                <version>3.1.0</version>
+                <configuration>
+                    <apiSources>
+                        <apiSource>
+                            <springmvc>false</springmvc>
+                            <locations>org.apache.usergrid.testapp</locations>
+                            <info>
+                                <title>Test Docs</title>
+                                <version>v1</version>
+                                <description>Testing the Swagger Maven plugin</description>
+                                <license>
+                                    <url>http://www.apache.org/licenses/LICENSE-2.0.html</url>
+                                    <name>Apache 2.0</name>
+                                </license>
+                            </info>
+                            <templatePath>${basedir}/templates/strapdown.html.hbs</templatePath>
+                            <outputPath>${basedir}/target/swagger-docs/document.html</outputPath>
+                            <swaggerDirectory>${basedir}/target/swagger-docs</swaggerDirectory>
+                        </apiSource>
+                    </apiSources>
+                </configuration>
+                <executions>
+                    <execution>
+                        <phase>compile</phase>
+                        <goals>
+                            <goal>generate</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+            
+        </plugins>
+        
+    </build>
+
+    <dependencies>
+
+        <dependency>
+            <groupId>javax.servlet</groupId>
+            <artifactId>javax.servlet-api</artifactId>
+            <scope>provided</scope>
+            <version>3.1.0</version>
+        </dependency>
+
+        <dependency>
+            <groupId>javax.servlet</groupId>
+            <artifactId>jstl</artifactId>
+            <version>1.2</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.glassfish.jersey.containers</groupId>
+            <artifactId>jersey-container-servlet</artifactId>
+            <version>2.21</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.glassfish.jersey.core</groupId>
+            <artifactId>jersey-client</artifactId>
+            <version>2.21</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.glassfish.jersey.connectors</groupId>
+            <artifactId>jersey-apache-connector</artifactId>
+            <version>2.21</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.glassfish.jersey.ext</groupId>
+            <artifactId>jersey-mvc-jsp</artifactId>
+            <version>2.21</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.glassfish.jersey.media</groupId>
+            <artifactId>jersey-media-multipart</artifactId>
+            <version>2.21</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.glassfish.jersey.media</groupId>
+            <artifactId>jersey-media-json-jackson</artifactId>
+            <version>2.21</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.glassfish.jersey.ext</groupId>
+            <artifactId>jersey-spring3</artifactId>
+            <version>2.21</version>
+        </dependency>
+
+        <dependency>
+            <groupId>com.fasterxml.jackson.jaxrs</groupId>
+            <artifactId>jackson-jaxrs-json-provider</artifactId>
+            <version>2.4.4</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.springframework</groupId>
+            <artifactId>spring-webmvc</artifactId>
+            <version>3.2.3.RELEASE</version>
+        </dependency>
+
+        <dependency>
+            <groupId>io.swagger</groupId>
+            <artifactId>swagger-jersey2-jaxrs</artifactId>
+            <version>1.5.0</version>
+        </dependency>
+
+        <!-- need Spring 4 to take full advantage of Java 8 features, but Jersey 2 doesn't support it? 
+        <dependency>
+            <groupId>org.springframework</groupId>
+            <artifactId>spring-core</artifactId>
+            <version>4.2.0.RELEASE</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.springframework</groupId>
+            <artifactId>spring-web</artifactId>
+            <version>4.2.0.RELEASE</version>
+        </dependency>
+        -->
+
+        <dependency>
+            <groupId>com.fasterxml.jackson.core</groupId>
+            <artifactId>jackson-core</artifactId>
+            <version>2.5.3</version>
+        </dependency>
+
+        <dependency>
+            <groupId>com.fasterxml.jackson.core</groupId>
+            <artifactId>jackson-annotations</artifactId>
+            <version>2.5.0</version>
+        </dependency>
+
+        <dependency>
+            <groupId>com.fasterxml.jackson.core</groupId>
+            <artifactId>jackson-databind</artifactId>
+            <version>2.5.3</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-api</artifactId>
+            <version>1.7.12</version>
+        </dependency>
+        
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-log4j12</artifactId>
+            <version>1.7.12</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>jul-to-slf4j</artifactId>
+            <version>1.7.12</version>
+        </dependency>
+        
+        
+        <!-- scope: test -->
+
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <version>4.11</version>
+            <scope>test</scope>
+        </dependency>
+        
+        <dependency>
+            <groupId>org.glassfish.jersey.test-framework</groupId>
+            <artifactId>jersey-test-framework-core</artifactId>
+            <version>2.21</version>
+            <scope>test</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>org.glassfish.jersey.test-framework.providers</groupId>
+            <artifactId>jersey-test-framework-provider-external</artifactId>
+            <version>2.21</version>
+            <scope>test</scope>
+        </dependency>
+        
+        <dependency>
+            <groupId>commons-lang</groupId>
+            <artifactId>commons-lang</artifactId>
+            <version>2.6</version>
+            <scope>test</scope>
+        </dependency>
+        
+        <dependency>
+            <groupId>com.google.guava</groupId>
+            <artifactId>guava</artifactId>
+            <version>17.0</version>
+            <scope>test</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.tomcat.embed</groupId>
+            <artifactId>tomcat-embed-core</artifactId>
+            <scope>test</scope>
+            <version>7.0.64</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.tomcat.embed</groupId>
+            <artifactId>tomcat-embed-logging-juli</artifactId>
+            <scope>test</scope>
+            <version>7.0.64</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.tomcat.embed</groupId>
+            <artifactId>tomcat-embed-jasper</artifactId>
+            <scope>test</scope>
+            <version>7.0.64</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.tomcat</groupId>
+            <artifactId>tomcat-jasper</artifactId>
+            <scope>test</scope>
+            <version>7.0.64</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.tomcat</groupId>
+            <artifactId>tomcat-jasper-el</artifactId>
+            <scope>test</scope>
+            <version>7.0.64</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.tomcat</groupId>
+            <artifactId>tomcat-servlet-api</artifactId>
+            <scope>test</scope>
+            <version>7.0.64</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.tomcat</groupId>
+            <artifactId>tomcat-jsp-api</artifactId>
+            <scope>test</scope>
+            <version>7.0.64</version>
+        </dependency>
+
+    </dependencies>
+
+</project>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/usergrid/blob/6ea66856/docs/jersey2skeleton/src/main/java/org/apache/usergrid/testapp/AbstractResource.java
----------------------------------------------------------------------
diff --git a/docs/jersey2skeleton/src/main/java/org/apache/usergrid/testapp/AbstractResource.java b/docs/jersey2skeleton/src/main/java/org/apache/usergrid/testapp/AbstractResource.java
new file mode 100644
index 0000000..cca3629
--- /dev/null
+++ b/docs/jersey2skeleton/src/main/java/org/apache/usergrid/testapp/AbstractResource.java
@@ -0,0 +1,51 @@
+/*
+ * 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.usergrid.testapp;
+
+import javax.ws.rs.container.ResourceContext;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.UriInfo;
+import javax.xml.ws.spi.http.HttpContext;
+
+
+public class AbstractResource {
+
+    @Context
+    protected UriInfo uriInfo;
+
+    @Context
+    protected HttpContext hc;
+
+    @Context
+    protected ResourceContext resourceContext;
+    
+    private AbstractResource parent;
+
+    public <T extends AbstractResource> T getSubResource(Class<T> t) {
+        T subResource = resourceContext.getResource(t);
+        subResource.setParent(this);
+        return subResource;
+    }
+
+    public void setParent(AbstractResource parent) {
+        this.parent = parent;
+    }
+
+    public AbstractResource getParent() {
+        return parent;
+    }
+}

http://git-wip-us.apache.org/repos/asf/usergrid/blob/6ea66856/docs/jersey2skeleton/src/main/java/org/apache/usergrid/testapp/ApiResponse.java
----------------------------------------------------------------------
diff --git a/docs/jersey2skeleton/src/main/java/org/apache/usergrid/testapp/ApiResponse.java b/docs/jersey2skeleton/src/main/java/org/apache/usergrid/testapp/ApiResponse.java
new file mode 100644
index 0000000..042bd53
--- /dev/null
+++ b/docs/jersey2skeleton/src/main/java/org/apache/usergrid/testapp/ApiResponse.java
@@ -0,0 +1,52 @@
+/*
+ * 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.usergrid.testapp;
+
+import io.swagger.annotations.ApiModelProperty;
+
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+import java.util.List;
+
+
+@XmlRootElement(name = "ApiResponse")
+public class ApiResponse {
+    private String content;
+    private List<Entity> entities;
+    
+    public ApiResponse() {
+    }
+
+    @XmlElement(name = "content")
+    public String getContent() {
+        return content;
+    }
+
+    public void setContent(String content) {
+        this.content = content;
+    }
+
+    @XmlElement(name = "entities")
+    @ApiModelProperty(value = "Entities contained in response.")
+    public List<Entity> getEntities() {
+        return entities;
+    }
+
+    public void setEntities(List<Entity> entities) {
+        this.entities = entities;
+    }
+}

http://git-wip-us.apache.org/repos/asf/usergrid/blob/6ea66856/docs/jersey2skeleton/src/main/java/org/apache/usergrid/testapp/Entity.java
----------------------------------------------------------------------
diff --git a/docs/jersey2skeleton/src/main/java/org/apache/usergrid/testapp/Entity.java b/docs/jersey2skeleton/src/main/java/org/apache/usergrid/testapp/Entity.java
new file mode 100644
index 0000000..f765320
--- /dev/null
+++ b/docs/jersey2skeleton/src/main/java/org/apache/usergrid/testapp/Entity.java
@@ -0,0 +1,55 @@
+/*
+ * 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.usergrid.testapp;
+
+import javax.xml.bind.annotation.XmlElement;
+import java.util.UUID;
+
+
+//@XmlRootElement(name="Entity")
+public class Entity {
+    private UUID id;
+    private String type;
+    private String name;
+
+    //@XmlElement(name="id")
+    public UUID getId() {
+        return id;
+    }
+
+    public void setId(UUID id) {
+        this.id = id;
+    }
+
+    //@XmlElement(name="type")
+    public String getType() {
+        return type;
+    }
+
+    public void setType(String type) {
+        this.type = type;
+    }
+
+    //@XmlElement(name="name")
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+}

http://git-wip-us.apache.org/repos/asf/usergrid/blob/6ea66856/docs/jersey2skeleton/src/main/java/org/apache/usergrid/testapp/ManagementResource.java
----------------------------------------------------------------------
diff --git a/docs/jersey2skeleton/src/main/java/org/apache/usergrid/testapp/ManagementResource.java b/docs/jersey2skeleton/src/main/java/org/apache/usergrid/testapp/ManagementResource.java
new file mode 100644
index 0000000..b857d55
--- /dev/null
+++ b/docs/jersey2skeleton/src/main/java/org/apache/usergrid/testapp/ManagementResource.java
@@ -0,0 +1,56 @@
+/*
+ * 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.usergrid.testapp;
+
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Component;
+
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+
+
+@Api(value="/management", description = "Access to management information.")
+@Path("/management")
+@Component
+@Scope( "singleton" )
+@Produces({
+        MediaType.APPLICATION_JSON,
+        "application/javascript",
+        "application/x-javascript",
+        "text/ecmascript",
+        "application/ecmascript",
+        "text/jscript"
+})
+public class ManagementResource extends AbstractResource {
+
+    @GET
+    @Path("status")
+    @ApiOperation(value = "Status of management service")
+    public String getStatus() {
+        return "OK";     
+    }
+
+    @Path( "organizations" )
+    public OrganizationsResource getOrganizations() {
+        return getSubResource( OrganizationsResource.class );
+    }
+}

http://git-wip-us.apache.org/repos/asf/usergrid/blob/6ea66856/docs/jersey2skeleton/src/main/java/org/apache/usergrid/testapp/OrganizationResource.java
----------------------------------------------------------------------
diff --git a/docs/jersey2skeleton/src/main/java/org/apache/usergrid/testapp/OrganizationResource.java b/docs/jersey2skeleton/src/main/java/org/apache/usergrid/testapp/OrganizationResource.java
new file mode 100644
index 0000000..de58f2a
--- /dev/null
+++ b/docs/jersey2skeleton/src/main/java/org/apache/usergrid/testapp/OrganizationResource.java
@@ -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.usergrid.testapp;
+
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Component;
+
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+import java.util.Collections;
+import java.util.UUID;
+
+
+@Component
+@Scope( "singleton" )
+@Produces({
+    MediaType.APPLICATION_JSON, 
+    "application/javascript", 
+    "application/x-javascript", 
+    "text/ecmascript", 
+    "application/ecmascript", 
+    "text/jscript"
+})
+public class OrganizationResource extends AbstractResource {
+    private String id;
+
+    public OrganizationResource() {
+    }
+    
+    public void init( String id ) {
+        this.id = id;
+    }
+
+    @GET
+    public ApiResponse getOrganization() {
+        Entity org = new Entity();
+        org.setName( "org:" + id );
+        org.setId( UUID.randomUUID() );
+        org.setType( "organization" );
+        ApiResponse response = new ApiResponse();
+        response.setContent( "organization:" + id );
+        response.setEntities( Collections.singletonList( org ));
+        return response;
+    }
+}

http://git-wip-us.apache.org/repos/asf/usergrid/blob/6ea66856/docs/jersey2skeleton/src/main/java/org/apache/usergrid/testapp/OrganizationsResource.java
----------------------------------------------------------------------
diff --git a/docs/jersey2skeleton/src/main/java/org/apache/usergrid/testapp/OrganizationsResource.java b/docs/jersey2skeleton/src/main/java/org/apache/usergrid/testapp/OrganizationsResource.java
new file mode 100644
index 0000000..9c2d5bd
--- /dev/null
+++ b/docs/jersey2skeleton/src/main/java/org/apache/usergrid/testapp/OrganizationsResource.java
@@ -0,0 +1,76 @@
+/*
+ * 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.usergrid.testapp;
+
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import jersey.repackaged.com.google.common.collect.Lists;
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Component;
+
+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.MediaType;
+import java.util.UUID;
+
+
+@Api(value="/management/organizations", description = "Access to organizations.", tags="management")
+@Path("/management/organizations")
+@Component
+@Scope("singleton")
+@Produces({
+        MediaType.APPLICATION_JSON,
+        "application/javascript",
+        "application/x-javascript",
+        "text/ecmascript",
+        "application/ecmascript",
+        "text/jscript"
+})
+public class OrganizationsResource extends AbstractResource {
+
+    @Path("/{id}")
+    @ApiOperation(value = "Get organization by id.", response=ApiResponse.class)
+    public OrganizationResource getOrganizationById(@PathParam("id") String id) {
+        OrganizationResource or = getSubResource( OrganizationResource.class );
+        or.init(id);
+        return or;
+    }
+
+    @GET
+    @ApiOperation(value = "Get organizations.", response=ApiResponse.class)
+    public ApiResponse getOrganizations() {
+        
+        Entity org1 = new Entity();
+        org1.setId( UUID.randomUUID() );
+        org1.setName( "org1" );
+        org1.setType( "organization" );
+        
+        Entity org2 = new Entity();
+        org2.setId( UUID.randomUUID() );
+        org2.setName( "org2" );
+        org2.setType( "organization" );
+
+        ApiResponse response = new ApiResponse();
+        response.setContent( "All Organizations" );
+        response.setEntities( Lists.newArrayList( org1, org2 ) );
+        
+        return response;
+    } 
+}

http://git-wip-us.apache.org/repos/asf/usergrid/blob/6ea66856/docs/jersey2skeleton/src/main/java/org/apache/usergrid/testapp/StatusResource.java
----------------------------------------------------------------------
diff --git a/docs/jersey2skeleton/src/main/java/org/apache/usergrid/testapp/StatusResource.java b/docs/jersey2skeleton/src/main/java/org/apache/usergrid/testapp/StatusResource.java
new file mode 100644
index 0000000..f537a01
--- /dev/null
+++ b/docs/jersey2skeleton/src/main/java/org/apache/usergrid/testapp/StatusResource.java
@@ -0,0 +1,34 @@
+/*
+ * 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.usergrid.testapp;
+
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+
+@Api(value="/status", description = "Status end-point.")
+@Path("status")
+public class StatusResource {
+
+    @GET
+    @ApiOperation(value = "Status of webapp.")
+    public String getStatus() {
+        return "good";
+    }
+}

http://git-wip-us.apache.org/repos/asf/usergrid/blob/6ea66856/docs/jersey2skeleton/src/main/java/org/apache/usergrid/testapp/User.java
----------------------------------------------------------------------
diff --git a/docs/jersey2skeleton/src/main/java/org/apache/usergrid/testapp/User.java b/docs/jersey2skeleton/src/main/java/org/apache/usergrid/testapp/User.java
new file mode 100644
index 0000000..5e24f51
--- /dev/null
+++ b/docs/jersey2skeleton/src/main/java/org/apache/usergrid/testapp/User.java
@@ -0,0 +1,28 @@
+/*
+ * 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.usergrid.testapp;
+
+import javax.xml.bind.annotation.XmlRootElement;
+
+
+//@XmlRootElement(name="User")
+public class User extends Entity {
+    public User() {
+        super();
+        setType("user");
+    }
+}

http://git-wip-us.apache.org/repos/asf/usergrid/blob/6ea66856/docs/jersey2skeleton/src/main/resources/applicationContext.xml
----------------------------------------------------------------------
diff --git a/docs/jersey2skeleton/src/main/resources/applicationContext.xml b/docs/jersey2skeleton/src/main/resources/applicationContext.xml
new file mode 100644
index 0000000..2b877b1
--- /dev/null
+++ b/docs/jersey2skeleton/src/main/resources/applicationContext.xml
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    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.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:util="http://www.springframework.org/schema/util"
+       xmlns:context="http://www.springframework.org/schema/context" xmlns:p="http://www.springframework.org/schema/p"
+       xsi:schemaLocation="
+	http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
+	http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.1.xsd
+	http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd">
+
+    <context:component-scan base-package="org.apache.usergrid.testapp" />
+
+</beans>

http://git-wip-us.apache.org/repos/asf/usergrid/blob/6ea66856/docs/jersey2skeleton/src/main/resources/jersey2skeleton-context.xml
----------------------------------------------------------------------
diff --git a/docs/jersey2skeleton/src/main/resources/jersey2skeleton-context.xml b/docs/jersey2skeleton/src/main/resources/jersey2skeleton-context.xml
new file mode 100644
index 0000000..2b877b1
--- /dev/null
+++ b/docs/jersey2skeleton/src/main/resources/jersey2skeleton-context.xml
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    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.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:util="http://www.springframework.org/schema/util"
+       xmlns:context="http://www.springframework.org/schema/context" xmlns:p="http://www.springframework.org/schema/p"
+       xsi:schemaLocation="
+	http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
+	http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.1.xsd
+	http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd">
+
+    <context:component-scan base-package="org.apache.usergrid.testapp" />
+
+</beans>

http://git-wip-us.apache.org/repos/asf/usergrid/blob/6ea66856/docs/jersey2skeleton/src/main/webapp/WEB-INF/web.xml
----------------------------------------------------------------------
diff --git a/docs/jersey2skeleton/src/main/webapp/WEB-INF/web.xml b/docs/jersey2skeleton/src/main/webapp/WEB-INF/web.xml
new file mode 100644
index 0000000..d005b3a
--- /dev/null
+++ b/docs/jersey2skeleton/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,95 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    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.
+-->
+<web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" 
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
+         xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
+
+    <display-name>Jersey Skeleton app</display-name>
+
+    <context-param>
+        <param-name>contextConfigLocation</param-name>
+        <param-value>classpath:/jersey2skeleton-context.xml</param-value>
+    </context-param>
+
+    <listener>
+        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
+    </listener>
+
+    <listener>
+        <listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
+    </listener>
+
+    <filter>
+        <filter-name>jersey2skeleton</filter-name>
+        <filter-class>org.glassfish.jersey.servlet.ServletContainer</filter-class>
+
+        <init-param>
+            <param-name>jersey.config.servlet.filter.contextPath</param-name>
+            <param-value>/</param-value>
+        </init-param>
+
+        <init-param>
+            <param-name>jersey.config.server.provider.packages</param-name>
+            <param-value>org.apache.usergrid.testapp</param-value>
+        </init-param>
+
+        <init-param>
+            <param-name>jersey.config.server.provider.scanning.recursive</param-name>
+            <param-value>true</param-value>
+        </init-param>
+
+        <init-param>
+            <param-name>jersey.config.server.provider.classnames</param-name>
+            <param-value>
+                org.apache.usergrid.testapp.SecuredResourceFilterFactory,
+                org.glassfish.jersey.server.mvc.jsp.JspMvcFeature,
+                org.glassfish.jersey.media.multipart.MultiPartFeature
+
+                <!-- TODO: someday use @PermitAll, @DenyAll, @RolesAllowed -->
+                <!-- , org.glassfish.jersey.server.filter.RolesAllowedDynamicFeature -->
+            </param-value>
+        </init-param>
+
+        <init-param>
+            <param-name>jersey.config.server.mvc.templateBasePath.jsp</param-name>
+            <param-value>/WEB-INF/jsp</param-value>
+        </init-param>
+
+        <init-param>
+            <param-name>jersey.config.server.wadl.disableWadl</param-name>
+            <param-value>true</param-value>
+        </init-param>
+
+        <init-param>
+            <param-name>jersey.config.servlet.filter.staticContentRegex</param-name>
+            <param-value>/(((images|css|js|jsp|WEB-INF/jsp)/.*)|(favicon\.ico))</param-value>
+        </init-param>
+
+        <init-param>
+            <param-name>jersey.config.server.mediaTypeMappings</param-name>
+            <param-value>json:application/json,js:application/javascript</param-value>
+        </init-param>
+
+    </filter>
+
+    <filter-mapping>
+        <filter-name>jersey2skeleton</filter-name>
+        <url-pattern>/*</url-pattern>
+    </filter-mapping>
+
+</web-app>

http://git-wip-us.apache.org/repos/asf/usergrid/blob/6ea66856/docs/jersey2skeleton/src/test/java/org/apache/usergrid/testapp/AvailablePortFinder.java
----------------------------------------------------------------------
diff --git a/docs/jersey2skeleton/src/test/java/org/apache/usergrid/testapp/AvailablePortFinder.java b/docs/jersey2skeleton/src/test/java/org/apache/usergrid/testapp/AvailablePortFinder.java
new file mode 100644
index 0000000..0a33688
--- /dev/null
+++ b/docs/jersey2skeleton/src/test/java/org/apache/usergrid/testapp/AvailablePortFinder.java
@@ -0,0 +1,208 @@
+/*
+ * 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.usergrid.testapp;
+
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+import java.net.DatagramSocket;
+import java.net.InetAddress;
+import java.net.InetSocketAddress;
+import java.net.ServerSocket;
+import java.util.NoSuchElementException;
+import java.util.Set;
+import java.util.TreeSet;
+
+
+/**
+ * Finds currently available server ports.
+ *
+ * @author <a href="http://mina.apache.org">Apache MINA Project</a>
+ * @see <a href="http://www.iana.org/assignments/port-numbers">IANA.org</a>
+ */
+public class AvailablePortFinder {
+	
+	private static final Logger LOG = LoggerFactory.getLogger( AvailablePortFinder.class );
+    /** The minimum number of server port number. */
+    public static final int MIN_PORT_NUMBER = 1;
+
+    /** The maximum number of server port number. */
+    public static final int MAX_PORT_NUMBER = 49151;
+
+
+    /** Creates a new instance. */
+    private AvailablePortFinder() {
+        // Do nothing
+    }
+
+
+    /**
+     * Returns the {@link Set} of currently available port numbers ({@link Integer}).  This method is identical to
+     * <code>getAvailablePorts(MIN_PORT_NUMBER, MAX_PORT_NUMBER)</code>.
+     * <p/>
+     * WARNING: this can take a very long time.
+     */
+    public static Set<Integer> getAvailablePorts() {
+        return getAvailablePorts( MIN_PORT_NUMBER, MAX_PORT_NUMBER );
+    }
+
+
+    /**
+     * Gets an available port, selected by the system.
+     *
+     * @throws NoSuchElementException if there are no ports available
+     */
+    public static int getNextAvailable() {
+        ServerSocket serverSocket = null;
+
+        try {
+            // Here, we simply return an available port found by the system
+            serverSocket = new ServerSocket( 0 );
+            int port = serverSocket.getLocalPort();
+
+            // Don't forget to close the socket...
+            serverSocket.close();
+
+            return port;
+        }
+        catch ( IOException ioe ) {
+            throw new NoSuchElementException( ioe.getMessage() );
+        }
+    }
+
+
+    /**
+     * Gets the next available port starting at a port.
+     *
+     * @param fromPort the port to scan for availability
+     *
+     * @throws NoSuchElementException if there are no ports available
+     */
+    public static int getNextAvailable( int fromPort ) {
+        if ( fromPort < MIN_PORT_NUMBER || fromPort > MAX_PORT_NUMBER ) {
+            throw new IllegalArgumentException( "Invalid start port: " + fromPort );
+        }
+
+        for ( int i = fromPort; i <= MAX_PORT_NUMBER; i++ ) {
+            if ( available( i ) ) {
+                return i;
+            }
+        }
+
+        throw new NoSuchElementException( "Could not find an available port " + "above " + fromPort );
+    }
+
+
+    /**
+     * Checks to see if a specific port is available.
+     *
+     * @param port the port to check for availability
+     */
+    public static boolean available( int port ) {
+        if ( port < MIN_PORT_NUMBER || port > MAX_PORT_NUMBER ) {
+            throw new IllegalArgumentException( "Invalid start port: " + port );
+        }
+
+        ServerSocket ss = null;
+        DatagramSocket ds = null;
+
+        try {
+			// Jackson: It seems like the code below intends to
+			// setReuseAddress(true), but that needs to be set before the bind.
+			// The constructor for the ServerSocket(int) will bind, so not sure
+			// how it would have been working as intended previously. 
+        	
+			// Changing ServerSocket constructor to use default constructor,
+			// this would be unbound, then set the socket reuse, and
+			// call the bind separately
+        	
+            //ss = new ServerSocket( port );
+        	ss = new ServerSocket();
+            ss.setReuseAddress( true );
+            ss.bind(new InetSocketAddress((InetAddress) null, port), 0);
+            
+			// Unlike ServerSocket, the default constructor of DatagramSocket
+			// will bound. To create an unbound DatagramSocket, use null address 
+            //ds = new DatagramSocket( port );
+            ds = new DatagramSocket(null);
+            ds.setReuseAddress( true );
+            ds.bind(new InetSocketAddress((InetAddress) null, port));
+            LOG.info("port {} available", port);
+            return true;
+        }
+        catch ( IOException e ) {
+            // Do nothing
+        }
+        finally {
+            if ( ds != null ) {
+                ds.close();
+            }
+
+            if ( ss != null ) {
+                try {
+                    ss.close();
+                }
+                catch ( IOException e ) {
+                    /* should not be thrown */
+                }
+            }
+        }
+        LOG.info("port {} unavailable", port);
+        return false;
+    }
+
+
+    /**
+     * Returns the {@link Set} of currently avaliable port numbers ({@link Integer}) between the specified port range.
+     *
+     * @throws IllegalArgumentException if port range is not between {@link #MIN_PORT_NUMBER} and {@link
+     * #MAX_PORT_NUMBER} or <code>fromPort</code> if greater than <code>toPort</code>.
+     */
+    public static Set<Integer> getAvailablePorts( int fromPort, int toPort ) {
+        if ( fromPort < MIN_PORT_NUMBER || toPort > MAX_PORT_NUMBER || fromPort > toPort ) {
+            throw new IllegalArgumentException( "Invalid port range: " + fromPort + " ~ " + toPort );
+        }
+
+        Set<Integer> result = new TreeSet<Integer>();
+
+        for ( int i = fromPort; i <= toPort; i++ ) {
+            ServerSocket s = null;
+
+            try {
+                s = new ServerSocket( i );
+                result.add(i);
+            }
+            catch ( IOException e ) {
+                // Do nothing
+            }
+            finally {
+                if ( s != null ) {
+                    try {
+                        s.close();
+                    }
+                    catch ( IOException e ) {
+                        /* should not be thrown */
+                    }
+                }
+            }
+        }
+
+        return result;
+    }
+}

http://git-wip-us.apache.org/repos/asf/usergrid/blob/6ea66856/docs/jersey2skeleton/src/test/java/org/apache/usergrid/testapp/OrganizationTest.java
----------------------------------------------------------------------
diff --git a/docs/jersey2skeleton/src/test/java/org/apache/usergrid/testapp/OrganizationTest.java b/docs/jersey2skeleton/src/test/java/org/apache/usergrid/testapp/OrganizationTest.java
new file mode 100644
index 0000000..faaaf95
--- /dev/null
+++ b/docs/jersey2skeleton/src/test/java/org/apache/usergrid/testapp/OrganizationTest.java
@@ -0,0 +1,127 @@
+/*
+ * 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.usergrid.testapp;
+
+import org.glassfish.jersey.client.ClientConfig;
+import org.glassfish.jersey.jackson.JacksonFeature;
+import org.glassfish.jersey.test.DeploymentContext;
+import org.glassfish.jersey.test.JerseyTest;
+import org.glassfish.jersey.test.spi.TestContainer;
+import org.glassfish.jersey.test.spi.TestContainerFactory;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.ws.rs.core.Application;
+import java.net.URI;
+import java.net.URISyntaxException;
+
+import static junit.framework.Assert.assertEquals;
+
+
+public class OrganizationTest extends JerseyTest {
+    private static final Logger logger = LoggerFactory.getLogger( TomcatMain.class );
+    
+    // TomcatRuntime is copied from Usergrid
+    public static TomcatRuntime tomcatRuntime = TomcatRuntime.getInstance();
+
+    private static ClientConfig clientConfig = new ClientConfig();
+    static {
+        clientConfig.register( new JacksonFeature() );
+    }
+
+    @Override
+    protected Application configure() {
+        return new Application();
+    }
+
+    @Test
+    public void testGetManagementStatus() {
+        
+        String path = "/management/status";
+        logger.info( "***** Testing against URI: {}{}", getBaseUri(), path );
+        String responseString = getClient().target( getBaseUri() + path ).request().get( String.class );
+        
+        assertEquals( "OK", responseString );
+    }
+
+    @Test
+    public void testGetOrganizations() {
+        
+        String path = "/management/organizations";
+        logger.info( "***** Testing against URI: {}{}", getBaseUri(), path );
+        ApiResponse response = getClient().target( getBaseUri() + path ).request().get( ApiResponse.class );
+        
+        assertEquals( "All Organizations", response.getContent() );
+        assertEquals( 2, response.getEntities().size() );
+    }
+    
+    @Test
+    public void testGetOrganization() {
+        
+        String path = "/management/organizations/1";
+        logger.info( "***** Testing against URI: {}{}", getBaseUri(), path );
+        ApiResponse response = getClient().target( getBaseUri() + path ).request().get( ApiResponse.class );
+        
+        assertEquals( "organization:1", response.getContent() );
+        assertEquals( 1, response.getEntities().size() );
+    }
+    
+    // Returns a do-nothing test container, we're using TomcatRuntime instead.
+    @Override
+    protected TestContainerFactory getTestContainerFactory() {
+        final URI baseURI = getBaseUri();
+        
+        return new TestContainerFactory() {
+            @Override
+            public TestContainer create(URI uri, DeploymentContext deploymentContext) {
+                return new TestContainer() {
+
+                    @Override
+                    public ClientConfig getClientConfig() {
+                        return clientConfig;
+                    }
+
+                    @Override
+                    public URI getBaseUri() {
+                        return baseURI;
+                    }
+
+                    @Override
+                    public void start() {
+                        // noop
+                    }
+
+                    @Override
+                    public void stop() {
+                        // noop
+                    }
+                };
+            }
+        };
+
+    }
+
+    protected URI getBaseUri() {
+        try {
+            return new URI("http://localhost:" + tomcatRuntime.getPort());
+        } catch (URISyntaxException e) {
+            throw new RuntimeException("Error determining baseURI", e);
+        }
+    }
+    
+}

http://git-wip-us.apache.org/repos/asf/usergrid/blob/6ea66856/docs/jersey2skeleton/src/test/java/org/apache/usergrid/testapp/TomcatMain.java
----------------------------------------------------------------------
diff --git a/docs/jersey2skeleton/src/test/java/org/apache/usergrid/testapp/TomcatMain.java b/docs/jersey2skeleton/src/test/java/org/apache/usergrid/testapp/TomcatMain.java
new file mode 100644
index 0000000..c0e41ba
--- /dev/null
+++ b/docs/jersey2skeleton/src/test/java/org/apache/usergrid/testapp/TomcatMain.java
@@ -0,0 +1,57 @@
+/*
+ * Copyright 2014 The Apache Software Foundation.
+ *
+ * Licensed 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.usergrid.testapp;
+
+import com.google.common.io.Files;
+import org.apache.catalina.startup.Tomcat;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.File;
+
+
+/**
+ * Simple wrapper for starting "embedded" Tomcat as it's own process, for testing.
+ */
+public class TomcatMain {
+    
+    private static final Logger log = LoggerFactory.getLogger( TomcatMain.class );
+
+    public static void main(String[] args) throws Exception {
+
+        String webappsPath = args[0];
+        int port = Integer.parseInt( args[1] );
+
+        File dataDir = Files.createTempDir();
+        dataDir.deleteOnExit();
+
+        Tomcat tomcat = new Tomcat();
+        tomcat.setBaseDir(dataDir.getAbsolutePath());
+        tomcat.setPort(port);
+        tomcat.getConnector().setAttribute("maxThreads", "1000");
+        tomcat.addWebapp("/", new File(webappsPath).getAbsolutePath());
+
+        log.info("-----------------------------------------------------------------");
+        log.info("Starting Tomcat port {} dir {}", port, webappsPath);
+        log.info("-----------------------------------------------------------------");
+        tomcat.start();
+
+        while ( true ) {
+            Thread.sleep(1000);
+        }
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/usergrid/blob/6ea66856/docs/jersey2skeleton/src/test/java/org/apache/usergrid/testapp/TomcatRuntime.java
----------------------------------------------------------------------
diff --git a/docs/jersey2skeleton/src/test/java/org/apache/usergrid/testapp/TomcatRuntime.java b/docs/jersey2skeleton/src/test/java/org/apache/usergrid/testapp/TomcatRuntime.java
new file mode 100644
index 0000000..16bd77f
--- /dev/null
+++ b/docs/jersey2skeleton/src/test/java/org/apache/usergrid/testapp/TomcatRuntime.java
@@ -0,0 +1,185 @@
+/*
+ * 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.usergrid.testapp;
+
+
+import com.google.common.io.Files;
+import org.apache.catalina.LifecycleException;
+import org.apache.catalina.startup.Tomcat;
+import org.apache.commons.lang.math.RandomUtils;
+import org.junit.rules.ExternalResource;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.ws.rs.client.Client;
+import javax.ws.rs.client.ClientBuilder;
+import javax.ws.rs.client.WebTarget;
+import java.io.File;
+
+
+/**
+ * Start and stop embedded Tomcat.
+ */
+public class TomcatRuntime extends ExternalResource {
+    private static final Logger log = LoggerFactory.getLogger( TomcatRuntime.class );
+
+
+    private static final String WEBAPP_PATH = System.getProperty("webapp.directory");
+
+    private static TomcatRuntime instance;
+
+    public final TomcatInstance tomcat;
+
+
+    private TomcatRuntime() {
+
+        tomcat = new TomcatInstance( WEBAPP_PATH );
+        tomcat.startTomcat();
+
+        //stop on JVM shutdown
+        Runtime.getRuntime().addShutdownHook( new Thread() {
+            @Override
+            public void run() {
+                tomcat.stopTomcat();
+            }
+        } );
+    }
+
+
+    /**
+     * Get the instance of the tomcat runtime and starts the tomcat singleton.  Starts tomcat once per JVM
+     * @return
+     */
+    public static synchronized TomcatRuntime getInstance() {
+        if ( instance == null ) {
+
+
+            instance = new TomcatRuntime();
+        }
+
+        return instance;
+    }
+
+
+    /**
+     * Get the port tomcat is running on
+     */
+    public int getPort() {
+        return tomcat.getPort();
+    }
+
+
+    /**
+     * Inner class of tomcat runtime
+     */
+    private static class TomcatInstance {
+
+        public static final int THREADS_PERPROC = 25;
+
+        private final String webAppsPath;
+
+        private Tomcat tomcat = null;
+        private int port;
+
+        private boolean started = false;
+
+
+        private TomcatInstance( final String webAppsPath ) {this.webAppsPath = webAppsPath;}
+
+
+        /**
+         * Start the tomcat instance
+         */
+        public void startTomcat() {
+            try {
+
+                //we don't want to use all our threads, we'll kill the box
+                final int availableProcessors = Runtime.getRuntime().availableProcessors();
+                final int usedProcs = Math.min( 2, availableProcessors );
+                final int threads = usedProcs * THREADS_PERPROC;
+
+
+                File dataDir = Files.createTempDir();
+                dataDir.deleteOnExit();
+
+                port = AvailablePortFinder.getNextAvailable( 9998 + RandomUtils.nextInt( 10 ) );
+
+                tomcat = new Tomcat();
+                tomcat.setBaseDir( dataDir.getAbsolutePath() );
+                tomcat.setPort( port );
+
+
+                tomcat.getConnector().setAttribute( "maxThreads", "" + threads );
+
+                tomcat.addWebapp( "/", new File( webAppsPath ).getAbsolutePath() );
+
+
+                log.info( "-----------------------------------------------------------------" );
+                log.info( "Starting Tomcat embedded port {} dir {}", port, dataDir.getAbsolutePath() );
+                log.info( "-----------------------------------------------------------------" );
+                tomcat.start();
+
+                waitForTomcat();
+
+            }
+            catch ( Exception e ) {
+                throw new RuntimeException( "Couldn't start tomcat", e );
+            }
+        }
+
+
+        /**
+         * Stop the embedded tomcat process
+         */
+        public void stopTomcat() {
+            try {
+                tomcat.stop();
+            }
+            catch ( LifecycleException e ) {
+                throw new RuntimeException( "Unable to stop tomcat", e );
+            }
+        }
+
+
+        public int getPort() {
+            return port;
+        }
+
+
+        private void waitForTomcat() throws RuntimeException {
+            String url = "http://localhost:" + port + "/status";
+            int count = 0;
+            while ( count++ < 30 ) {
+                try {
+                    Thread.sleep( 1000 );
+                    Client c = ClientBuilder.newClient();
+                    WebTarget wr = c.target( url );
+                    wr.request().get( String.class );
+                    log.info( "Tomcat is started." );
+                    started = true;
+                    break;
+                }
+                catch ( Exception e ) {
+                    log.info( "Waiting for Tomcat on url {}", url );
+                }
+            }
+            if ( !started ) {
+                throw new RuntimeException( "Tomcat process never started." );
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/usergrid/blob/6ea66856/docs/jersey2skeleton/src/test/resources/log4j.properties
----------------------------------------------------------------------
diff --git a/docs/jersey2skeleton/src/test/resources/log4j.properties b/docs/jersey2skeleton/src/test/resources/log4j.properties
new file mode 100644
index 0000000..8241c0a
--- /dev/null
+++ b/docs/jersey2skeleton/src/test/resources/log4j.properties
@@ -0,0 +1,31 @@
+# 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.
+
+# for production, you should probably set the root to INFO
+# and the pattern to %c instead of %l.  (%l is slower.)
+
+# output messages into a rolling log file as well as stdout
+log4j.rootLogger=ERROR,stdout
+
+# stdout
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+#log4j.appender.stdout.layout=org.apache.log4j.SimpleLayout
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+log4j.appender.stdout.layout.ConversionPattern=%d %p (%t) %c{1} - %m%n
+
+log4j.logger.org.glassfish=DEBUG
+
+log4j.logger.org.apache.usergrid.testapp=DEBUG

http://git-wip-us.apache.org/repos/asf/usergrid/blob/6ea66856/docs/jersey2skeleton/src/test/resources/logging.properties
----------------------------------------------------------------------
diff --git a/docs/jersey2skeleton/src/test/resources/logging.properties b/docs/jersey2skeleton/src/test/resources/logging.properties
new file mode 100644
index 0000000..f0dcc65
--- /dev/null
+++ b/docs/jersey2skeleton/src/test/resources/logging.properties
@@ -0,0 +1,26 @@
+# 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.
+
+# Tweak this file to get more logging out Jersey and other depedencies that use
+# Java Logging instead of our preferred SLF4J via Log4j setup.
+
+handlers = org.slf4j.bridge.SLF4JBridgeHandler
+
+#All log level details
+.level=INFO
+org.glassfish.jersey.level=FINE
+org.glassfish.jersey.tracing.level=FINE
+

http://git-wip-us.apache.org/repos/asf/usergrid/blob/6ea66856/docs/jersey2skeleton/templates/markdown.hbs
----------------------------------------------------------------------
diff --git a/docs/jersey2skeleton/templates/markdown.hbs b/docs/jersey2skeleton/templates/markdown.hbs
new file mode 100644
index 0000000..546f673
--- /dev/null
+++ b/docs/jersey2skeleton/templates/markdown.hbs
@@ -0,0 +1,108 @@
+#{{#info}}{{title}}
+
+
+## {{join schemes " | "}}://{{host}}{{basePath}}
+
+
+{{description}}
+
+{{#contact}}
+[**Contact the developer**](mailto:{{email}})
+{{/contact}}
+
+**Version** {{version}}
+
+[**Terms of Service**]({{termsOfService}})
+
+{{#license}}[**{{name}}**]({{url}}){{/license}}
+
+{{/info}}
+
+{{#if consumes}}**Consumes:** {{join consumes ", "}}{{/if}}
+
+{{#if produces}}**Produces:** {{join produces ", "}}{{/if}}
+
+{{#if securityDefinitions}}
+# Security Definitions
+{{/if}}
+{{> security}}
+
+# APIs
+
+{{#each paths}}
+## {{@key}}
+{{#this}}
+{{#get}}
+### GET
+{{> operation}}
+{{/get}}
+
+{{#put}}
+### PUT
+{{> operation}}
+{{/put}}
+
+{{#post}}
+### POST
+
+{{> operation}}
+
+{{/post}}
+
+{{#delete}}
+### DELETE
+{{> operation}}
+{{/delete}}
+
+{{#option}}
+### OPTION
+{{> operation}}
+{{/option}}
+
+{{#patch}}
+### PATCH
+{{> operation}}
+{{/patch}}
+
+{{#head}}
+### HEAD
+{{> operation}}
+{{/head}}
+
+{{/this}}
+{{/each}}
+
+# Definitions
+{{#each definitions}}
+## <a name="/definitions/{{key}}">{{@key}}</a>
+
+<table border="1">
+    <tr>
+        <th>name</th>
+        <th>type</th>
+        <th>required</th>
+        <th>description</th>
+        <th>example</th>
+    </tr>
+    {{#each this.properties}}
+        <tr>
+            <td>{{@key}}</td>
+            <td>
+                {{#ifeq type "array"}}
+                {{#items.$ref}}
+                    {{type}}[<a href="{{items.$ref}}">{{basename items.$ref}}</a>]
+                {{/items.$ref}}
+                {{^items.$ref}}{{type}}[{{items.type}}]{{/items.$ref}}
+                {{else}}
+                    {{#$ref}}<a href="{{$ref}}">{{basename $ref}}</a>{{/$ref}}
+                    {{^$ref}}{{type}}{{#format}} ({{format}}){{/format}}{{/$ref}}
+                {{/ifeq}}
+            </td>
+            <td>{{#required}}required{{/required}}{{^required}}optional{{/required}}</td>
+            <td>{{#description}}{{{description}}}{{/description}}{{^description}}-{{/description}}</td>
+            <td>{{example}}</td>
+        </tr>
+    {{/each}}
+</table>
+{{/each}}
+

http://git-wip-us.apache.org/repos/asf/usergrid/blob/6ea66856/docs/jersey2skeleton/templates/operation.hbs
----------------------------------------------------------------------
diff --git a/docs/jersey2skeleton/templates/operation.hbs b/docs/jersey2skeleton/templates/operation.hbs
new file mode 100644
index 0000000..a581961
--- /dev/null
+++ b/docs/jersey2skeleton/templates/operation.hbs
@@ -0,0 +1,73 @@
+{{#deprecated}}-deprecated-{{/deprecated}}
+<a id="{{operationId}}">{{summary}}</a>
+
+{{description}}
+
+{{#if externalDocs.url}}{{externalDocs.description}}. [See external documents for more details]({{externalDocs.url}})
+{{/if}}
+
+{{#if security}}
+#### Security
+{{/if}}
+
+{{#security}}
+{{#each this}}
+* {{@key}}
+{{#this}}   * {{this}}
+{{/this}}
+{{/each}}
+{{/security}}
+
+#### Request
+
+{{#if consumes}}
+**Content-Type: ** {{join consumes ", "}}{{/if}}
+
+##### Parameters
+{{#if parameters}}
+<table border="1">
+    <tr>
+        <th>Name</th>
+        <th>Located in</th>
+        <th>Required</th>
+        <th>Description</th>
+        <th>Default</th>
+        <th>Schema</th>
+    </tr>
+{{/if}}
+
+{{#parameters}}
+<tr>
+    <th>{{name}}</th>
+    <td>{{in}}</td>
+    <td>{{#if required}}yes{{else}}no{{/if}}</td>
+    <td>{{description}}{{#if pattern}} (**Pattern**: `{{pattern}}`){{/if}}</td>
+    <td> - </td>
+{{#ifeq in "body"}}
+    <td>
+    {{#ifeq schema.type "array"}}Array[<a href="{{schema.items.$ref}}">{{basename schema.items.$ref}}</a>]{{/ifeq}}
+    {{#schema.$ref}}<a href="{{schema.$ref}}">{{basename schema.$ref}}</a> {{/schema.$ref}}
+    </td>
+{{else}}
+    {{#ifeq type "array"}}
+            <td>Array[{{items.type}}] ({{collectionFormat}})</td>
+    {{else}}
+            <td>{{type}} {{#format}}({{format}}){{/format}}</td>
+    {{/ifeq}}
+{{/ifeq}}
+</tr>
+{{/parameters}}
+{{#if parameters}}
+</table>
+{{/if}}
+
+
+#### Response
+
+{{#if produces}}**Content-Type: ** {{join produces ", "}}{{/if}}
+
+
+| Status Code | Reason      | Response Model |
+|-------------|-------------|----------------|
+{{#each responses}}| {{@key}}    | {{description}} | {{#schema.$ref}}<a href="{{schema.$ref}}">{{basename schema.$ref}}</a>{{/schema.$ref}}{{#ifeq schema.type "array"}}Array[<a href="{{schema.items.$ref}}">{{basename schema.items.$ref}}</a>]{{/ifeq}}{{^schema}} - {{/schema}}|
+{{/each}}

http://git-wip-us.apache.org/repos/asf/usergrid/blob/6ea66856/docs/jersey2skeleton/templates/security.hbs
----------------------------------------------------------------------
diff --git a/docs/jersey2skeleton/templates/security.hbs b/docs/jersey2skeleton/templates/security.hbs
new file mode 100644
index 0000000..04f86e8
--- /dev/null
+++ b/docs/jersey2skeleton/templates/security.hbs
@@ -0,0 +1,88 @@
+{{#each securityDefinitions}}
+### {{@key}}
+{{#this}}
+{{#ifeq type "oauth2"}}
+<table>
+    <tr>
+        <th>type</th>
+        <th colspan="2">{{type}}</th>
+    </tr>
+{{#if description}}
+        <tr>
+            <th>description</th>
+            <th colspan="2">{{description}}</th>
+        </tr>
+{{/if}}
+{{#if authorizationUrl}}
+        <tr>
+            <th>authorizationUrl</th>
+            <th colspan="2">{{authorizationUrl}}</th>
+        </tr>
+{{/if}}
+{{#if flow}}
+        <tr>
+            <th>flow</th>
+            <th colspan="2">{{flow}}</th>
+        </tr>
+{{/if}}
+{{#if tokenUrl}}
+        <tr>
+            <th>tokenUrl</th>
+            <th colspan="2">{{tokenUrl}}</th>
+        </tr>
+{{/if}}
+{{#if scopes}}
+    <tr>
+        <td rowspan="3">scopes</td>
+{{#each scopes}}
+            <td>{{@key}}</td>
+            <td>{{this}}</td>
+        </tr>
+        <tr>
+{{/each}}
+    </tr>
+{{/if}}
+</table>
+{{/ifeq}}
+{{#ifeq type "apiKey"}}
+<table>
+    <tr>
+        <th>type</th>
+        <th colspan="2">{{type}}</th>
+    </tr>
+{{#if description}}
+        <tr>
+            <th>description</th>
+            <th colspan="2">{{description}}</th>
+        </tr>
+{{/if}}
+{{#if name}}
+        <tr>
+            <th>name</th>
+            <th colspan="2">{{name}}</th>
+        </tr>
+{{/if}}
+{{#if in}}
+        <tr>
+            <th>in</th>
+            <th colspan="2">{{in}}</th>
+        </tr>
+{{/if}}
+</table>
+{{/ifeq}}
+{{#ifeq type "basic"}}
+<table>
+    <tr>
+        <th>type</th>
+        <th colspan="2">{{type}}</th>
+    </tr>
+{{#if description}}
+        <tr>
+            <th>description</th>
+            <th colspan="2">{{description}}</th>
+        </tr>
+{{/if}}
+</table>
+{{/ifeq}}
+{{/this}}
+{{/each}}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/usergrid/blob/6ea66856/docs/jersey2skeleton/templates/strapdown.html.hbs
----------------------------------------------------------------------
diff --git a/docs/jersey2skeleton/templates/strapdown.html.hbs b/docs/jersey2skeleton/templates/strapdown.html.hbs
new file mode 100644
index 0000000..ec02669
--- /dev/null
+++ b/docs/jersey2skeleton/templates/strapdown.html.hbs
@@ -0,0 +1,10 @@
+<!DOCTYPE html>
+<html>
+<title>API Document</title>
+
+<xmp theme="united" style="display:none;">
+{{>markdown}}
+</xmp>
+
+<script src="http://strapdownjs.com/v/0.2/strapdown.js"></script>
+</html>
\ No newline at end of file


[30/54] usergrid git commit: Added test to prove issue in graph. Need to fix version load.

Posted by sn...@apache.org.
Added test to prove issue in graph.  Need to fix version load.


Project: http://git-wip-us.apache.org/repos/asf/usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/usergrid/commit/13d25941
Tree: http://git-wip-us.apache.org/repos/asf/usergrid/tree/13d25941
Diff: http://git-wip-us.apache.org/repos/asf/usergrid/diff/13d25941

Branch: refs/heads/usergrid-1007-shiro-cache
Commit: 13d2594196bd6315af4305e95e8314cbb600ee3e
Parents: 85e1e7c
Author: Todd Nine <tn...@apigee.com>
Authored: Tue Sep 15 13:34:34 2015 -0600
Committer: Todd Nine <tn...@apigee.com>
Committed: Tue Sep 15 13:35:21 2015 -0600

----------------------------------------------------------------------
 .../service/ConnectionServiceImpl.java          | 26 ++++---
 .../service/ConnectionServiceImplTest.java      | 36 ++++++++--
 stack/core/src/test/resources/log4j.properties  |  3 +-
 .../migration/schema/MigrationManagerFig.java   |  1 +
 .../impl/stage/EdgeDeleteListenerImpl.java      |  4 +-
 .../graph/impl/stage/EdgeDeleteRepairImpl.java  | 61 +++++-----------
 .../persistence/graph/GraphManagerIT.java       | 73 +++++++++++++++++++-
 7 files changed, 136 insertions(+), 68 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/usergrid/blob/13d25941/stack/core/src/main/java/org/apache/usergrid/corepersistence/service/ConnectionServiceImpl.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/service/ConnectionServiceImpl.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/service/ConnectionServiceImpl.java
index 41e6f80..d60426c 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/service/ConnectionServiceImpl.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/service/ConnectionServiceImpl.java
@@ -147,18 +147,18 @@ public class ConnectionServiceImpl implements ConnectionService {
         final Observable<ApplicationScope> applicationScopeObservable ) {
 
 
-        final Observable<EntityIdScope> entityIds =allEntityIdsObservable.getEntities( applicationScopeObservable );
+        final Observable<EntityIdScope> entityIds = allEntityIdsObservable.getEntities( applicationScopeObservable );
         //now we have an observable of entityIds.  Walk each connection type
 
         //get all edge types for connections
-       return  entityIds.flatMap( entityIdScope -> {
+        return entityIds.flatMap( entityIdScope -> {
 
             final ApplicationScope applicationScope = entityIdScope.getApplicationScope();
             final Id entityId = entityIdScope.getId();
 
-            final GraphManager gm = graphManagerFactory.createEdgeManager(applicationScope );
+            final GraphManager gm = graphManagerFactory.createEdgeManager( applicationScope );
 
-           logger.debug( "Checking connections of id {} in application {}", entityId, applicationScope );
+            logger.debug( "Checking connections of id {} in application {}", entityId, applicationScope );
 
             return gm.getEdgeTypesFromSource(
                 new SimpleSearchEdgeType( entityId, CpNamingUtils.EDGE_CONN_PREFIX, Optional.absent() ) )
@@ -176,7 +176,7 @@ public class ConnectionServiceImpl implements ConnectionService {
                     return gm.loadEdgesFromSource( searchByEdge );
                 } )
 
-                //now that we have a stream of edges, stream all versions
+                    //now that we have a stream of edges, stream all versions
                 .flatMap( edge -> {
 
                     logger.debug( "Found edge {}, searching for multiple versions of edge", edge );
@@ -187,19 +187,17 @@ public class ConnectionServiceImpl implements ConnectionService {
                     return gm.loadEdgeVersions( searchByEdge );
                 } )
 
-            //skip the first version since it's the one we want to retain
-            // validate there is only 1 version of it, delete anything > than the min
-                .skip( 1 )
-                .flatMap( edgeToDelete -> {
+                    //skip the first version since it's the one we want to retain
+                    // validate there is only 1 version of it, delete anything > than the min
+                .skip( 1 ).flatMap( edgeToDelete -> {
 
                     logger.debug( "Deleting edge {}", edgeToDelete );
 
                     //mark the edge and ignore the cleanup result
                     return gm.markEdge( edgeToDelete )
-                             //delete the edge
-                             .flatMap( edge -> gm.deleteEdge( edgeToDelete ));
-                } )
-                .map( deletedEdge -> new ConnectionScope( applicationScope, deletedEdge ) ) ;
-        });
+                        //delete the edge
+                        .flatMap( edge -> gm.deleteEdge( edgeToDelete ) );
+                } ).map( deletedEdge -> new ConnectionScope( applicationScope, deletedEdge ) );
+        } );
     }
 }

http://git-wip-us.apache.org/repos/asf/usergrid/blob/13d25941/stack/core/src/test/java/org/apache/usergrid/corepersistence/service/ConnectionServiceImplTest.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/corepersistence/service/ConnectionServiceImplTest.java b/stack/core/src/test/java/org/apache/usergrid/corepersistence/service/ConnectionServiceImplTest.java
index e03a9b3..152721a 100644
--- a/stack/core/src/test/java/org/apache/usergrid/corepersistence/service/ConnectionServiceImplTest.java
+++ b/stack/core/src/test/java/org/apache/usergrid/corepersistence/service/ConnectionServiceImplTest.java
@@ -23,6 +23,8 @@ import java.util.List;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.runner.RunWith;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import org.apache.usergrid.corepersistence.TestCoreModule;
 import org.apache.usergrid.corepersistence.util.CpNamingUtils;
@@ -53,6 +55,9 @@ import static org.junit.Assert.assertNotNull;
 @UseModules( TestCoreModule.class )
 public class ConnectionServiceImplTest {
 
+
+    private static final Logger logger = LoggerFactory.getLogger(ConnectionServiceImplTest.class);
+
     @Inject
     private GraphManagerFactory graphManagerFactory;
 
@@ -158,19 +163,23 @@ public class ConnectionServiceImplTest {
 
         final Edge written1 = gm.writeEdge( connection1 ).toBlocking().last();
 
+        logger.info( "Wrote edge 1 with edge {}", written1 );
+
 
         //write the second
         final Edge connection2 = CpNamingUtils.createConnectionEdge( source, connectionType, target );
 
         final Edge written2 = gm.writeEdge( connection2 ).toBlocking().last();
 
+        logger.info( "Wrote edge 2 with edge {}", written2 );
+
 
         //write the 3rd
         final Edge connection3 = CpNamingUtils.createConnectionEdge( source, connectionType, target );
 
         final Edge written3 = gm.writeEdge( connection3 ).toBlocking().last();
 
-
+        logger.info( "Wrote edge 3 with edge {}", written3 );
 
 
         //now run the cleanup
@@ -178,13 +187,16 @@ public class ConnectionServiceImplTest {
         final List<ConnectionScope> deletedConnections =
             connectionService.deDupeConnections( Observable.just( applicationScope ) ).toList().toBlocking().last();
 
-        assertEquals( "2 edges deleted", 2, deletedConnections.size() );
+//        assertEquals( "2 edges deleted", 2, deletedConnections.size() );
 
         //check our oldest was deleted first
 
-        assertEquals(written2, deletedConnections.get( 0 ));
 
-        assertEquals(written3, deletedConnections.get( 1 ));
+        assertEdgeData( written2, deletedConnections.get( 0 ).getEdge() );
+
+        assertEdgeData( written3, deletedConnections.get( 1 ).getEdge() );
+
+        assertEquals( "2 edges deleted", 2, deletedConnections.size() );
 
 
 
@@ -201,4 +213,20 @@ public class ConnectionServiceImplTest {
 
         assertEquals( written1, edges.get( 0 ) );
     }
+
+
+    /**
+     * Compares edges based on their sourceId, type, targetId and timestamp. It ignores the deleted flag
+     * @param expected
+     * @param asserted
+     */
+    private void assertEdgeData(final Edge expected, final Edge asserted){
+        assertEquals("SourceId the same", expected.getSourceNode(), expected.getTargetNode());
+        assertEquals("TargetId the same", expected.getTargetNode(), expected.getTargetNode());
+
+        assertEquals("Type the same", expected.getType(), expected.getType());
+
+        assertEquals("Timestamp the same", expected.getTimestamp(), expected.getTimestamp());
+
+    }
 }

http://git-wip-us.apache.org/repos/asf/usergrid/blob/13d25941/stack/core/src/test/resources/log4j.properties
----------------------------------------------------------------------
diff --git a/stack/core/src/test/resources/log4j.properties b/stack/core/src/test/resources/log4j.properties
index dd29671..93951fe 100644
--- a/stack/core/src/test/resources/log4j.properties
+++ b/stack/core/src/test/resources/log4j.properties
@@ -47,7 +47,8 @@ log4j.logger.org.apache.usergrid.persistence.PerformanceEntityRebuildIndexTest=D
 log4j.logger.org.apache.usergrid.corepersistence.migration=WARN
 
 #Debug our queries
-log4j.logger.org.apache.usergrid.persistence.index.impl.EsApplicationEntityIndexImpl=DEBUG
+#log4j.logger.org.apache.usergrid.persistence.index.impl.EsApplicationEntityIndexImpl=DEBUG
+log4j.logger.org.apache.usergrid.corepersistence.service.ConnectionServiceImpl=DEBUG
 
 #log4j.logger.org.apache.usergrid.persistence.index.impl=DEBUG
 #log4j.logger.org.apache.usergrid.corepersistence.CpSetup=INFO

http://git-wip-us.apache.org/repos/asf/usergrid/blob/13d25941/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/schema/MigrationManagerFig.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/schema/MigrationManagerFig.java b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/schema/MigrationManagerFig.java
index b95338a..d8f3d1f 100644
--- a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/schema/MigrationManagerFig.java
+++ b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/schema/MigrationManagerFig.java
@@ -35,6 +35,7 @@ public interface MigrationManagerFig extends GuicyFig {
     String getStrategyClass();
 
     @Key( "collections.keyspace.strategy.options" )
+    @Default("replication_factor:1")
     String getStrategyOptions();
 
 }

http://git-wip-us.apache.org/repos/asf/usergrid/blob/13d25941/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/impl/stage/EdgeDeleteListenerImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/impl/stage/EdgeDeleteListenerImpl.java b/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/impl/stage/EdgeDeleteListenerImpl.java
index 22a5ad0..fa289bd 100644
--- a/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/impl/stage/EdgeDeleteListenerImpl.java
+++ b/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/impl/stage/EdgeDeleteListenerImpl.java
@@ -30,6 +30,7 @@ import com.google.inject.Singleton;
 import rx.Observable;
 import rx.functions.Func1;
 import rx.functions.Func2;
+import rx.observables.MathObservable;
 
 
 /**
@@ -69,8 +70,7 @@ public class EdgeDeleteListenerImpl implements EdgeDeleteListener {
                                    Observable<Integer> targetDelete = edgeMetaRepair
                                            .repairTargets( scope, edge.getTargetNode(), edge.getType(), maxTimestamp );
 
-                                   return Observable.zip( sourceDelete, targetDelete,
-                                       ( sourceCount, targetCount ) -> sourceCount + targetCount );
+                                   return MathObservable.sumInteger( Observable.merge( sourceDelete, targetDelete ) );
                                } );
     }
 }

http://git-wip-us.apache.org/repos/asf/usergrid/blob/13d25941/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/impl/stage/EdgeDeleteRepairImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/impl/stage/EdgeDeleteRepairImpl.java b/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/impl/stage/EdgeDeleteRepairImpl.java
index 9b84978..643dcc1 100644
--- a/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/impl/stage/EdgeDeleteRepairImpl.java
+++ b/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/impl/stage/EdgeDeleteRepairImpl.java
@@ -79,52 +79,25 @@ public class EdgeDeleteRepairImpl implements EdgeDeleteRepair {
 
 
         //merge source and target then deal with the distinct values
-        return Observable.just( edge ).flatMap( new Func1<MarkedEdge, Observable<? extends MarkedEdge>>() {
-            @Override
-            public Observable<? extends MarkedEdge> call( final MarkedEdge edge ) {
-
-                return getEdgeVersions( scope, edge, storageSerialization ).take( 1 )
-                        .doOnNext( new Action1<MarkedEdge>() {
-                            @Override
-                            public void call( final MarkedEdge markedEdge ) {
-                                //it's still in the same state as it was when we queued it. Remove it
-                                if ( edge.equals( markedEdge ) ) {
-                                    LOG.info( "Removing edge {} ", edge );
-
-                                    //remove from the commit log
-
-
-                                    //remove from storage
-                                    try {
-                                        storageSerialization.deleteEdge( scope, edge, timestamp ).execute();
-                                    }
-                                    catch ( ConnectionException e ) {
-                                        throw new RuntimeException( "Unable to connect to casandra", e );
-                                    }
-                                }
-                            }
-                        } );
-            }
-        } );
+        return Observable.just( edge )
+                .doOnNext( markedEdge -> {
+                    //it's still in the same state as it was when we queued it. Remove it
+                        LOG.info( "Removing edge {} ", markedEdge );
+
+                        //remove from the commit log
+
+
+                        //remove from storage
+                        try {
+                            storageSerialization.deleteEdge( scope, markedEdge, timestamp ).execute();
+                        }
+                        catch ( ConnectionException e ) {
+                            throw new RuntimeException( "Unable to connect to casandra", e );
+                        }
+                    }
+              );
     }
 
 
-    /**
-     * Get all edge versions <= the specified max from the source
-     */
-    private Observable<MarkedEdge> getEdgeVersions( final ApplicationScope scope, final Edge edge,
-                                                    final EdgeSerialization serialization ) {
 
-        return Observable.create( new ObservableIterator<MarkedEdge>( "edgeVersions" ) {
-            @Override
-            protected Iterator<MarkedEdge> getIterator() {
-
-                final SimpleSearchByEdge search =
-                        new SimpleSearchByEdge( edge.getSourceNode(), edge.getType(), edge.getTargetNode(),
-                                edge.getTimestamp(), SearchByEdgeType.Order.DESCENDING, Optional.<Edge>absent() );
-
-                return serialization.getEdgeVersions( scope, search );
-            }
-        } );
-    }
 }

http://git-wip-us.apache.org/repos/asf/usergrid/blob/13d25941/stack/corepersistence/graph/src/test/java/org/apache/usergrid/persistence/graph/GraphManagerIT.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/graph/src/test/java/org/apache/usergrid/persistence/graph/GraphManagerIT.java b/stack/corepersistence/graph/src/test/java/org/apache/usergrid/persistence/graph/GraphManagerIT.java
index d416b1d..4b2ffc8 100644
--- a/stack/corepersistence/graph/src/test/java/org/apache/usergrid/persistence/graph/GraphManagerIT.java
+++ b/stack/corepersistence/graph/src/test/java/org/apache/usergrid/persistence/graph/GraphManagerIT.java
@@ -20,9 +20,9 @@ package org.apache.usergrid.persistence.graph;
 
 
 import java.util.Iterator;
+import java.util.List;
 import java.util.concurrent.TimeoutException;
 
-import com.google.common.base.Optional;
 import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
@@ -35,11 +35,14 @@ import org.apache.usergrid.persistence.core.test.ITRunner;
 import org.apache.usergrid.persistence.core.test.UseModules;
 import org.apache.usergrid.persistence.core.util.IdGenerator;
 import org.apache.usergrid.persistence.graph.guice.TestGraphModule;
+import org.apache.usergrid.persistence.graph.impl.SimpleSearchByEdge;
+import org.apache.usergrid.persistence.graph.impl.SimpleSearchByEdgeType;
 import org.apache.usergrid.persistence.graph.impl.SimpleSearchEdgeType;
 import org.apache.usergrid.persistence.graph.impl.SimpleSearchIdType;
 import org.apache.usergrid.persistence.model.entity.Id;
 import org.apache.usergrid.persistence.model.entity.SimpleId;
 
+import com.google.common.base.Optional;
 import com.google.inject.Inject;
 
 import rx.Observable;
@@ -836,7 +839,7 @@ public class GraphManagerIT {
         //now load the next page
 
         //tests that even if a prefix is specified, the last takes precedence
-        edgeTypes = new SimpleSearchEdgeType( testTargetEdge.getSourceNode(), null, Optional.fromNullable("test") );
+        edgeTypes = new SimpleSearchEdgeType( testTargetEdge.getSourceNode(), null, Optional.fromNullable( "test" ) );
 
         edges = gm.getEdgeTypesFromSource( edgeTypes );
 
@@ -914,7 +917,7 @@ public class GraphManagerIT {
 
         //now load the next page
 
-        edgeTypes = new SimpleSearchEdgeType( testTargetEdge2.getTargetNode(), null,  Optional.fromNullable("test") );
+        edgeTypes = new SimpleSearchEdgeType( testTargetEdge2.getTargetNode(), null, Optional.fromNullable( "test" ) );
 
         edges = gm.getEdgeTypesToTarget( edgeTypes );
 
@@ -2321,6 +2324,70 @@ public class GraphManagerIT {
 
         em.markEdge( null );
     }
+
+
+    @Test
+    public void testReadMultipleVersionOrder() {
+
+        GraphManager gm = emf.createEdgeManager( scope );
+
+        final Id sourceId = createId( "source" );
+
+        final Id target = createId( "target" );
+
+
+        //write 3 edges with 3 different timestamp
+        final Edge edge1 = createEdge( sourceId, "test", target, 1, false );
+
+        gm.writeEdge( edge1 ).toBlocking().last();
+
+        final Edge edge2 = createEdge( sourceId, "test", target, 2, false );
+
+        gm.writeEdge( edge2 ).toBlocking().last();
+
+        final Edge edge3 = createEdge( sourceId, "test", target, 3, false );
+
+        gm.writeEdge( edge3 ).toBlocking().last();
+
+        //now test retrieving it
+
+
+        final SearchByEdge searchDescending =
+            new SimpleSearchByEdge( edge1.getSourceNode(), edge1.getType(), edge1.getTargetNode(),Long.MAX_VALUE,
+                SearchByEdgeType.Order.DESCENDING, Optional.<Edge>absent()   );
+
+        final Observable<Edge> edgesDescending = gm.loadEdgeVersions( searchDescending );
+
+        //search descending
+        final List<Edge> descending = edgesDescending.toList().toBlocking().single();
+
+        assertEquals( "Correct size returned", 3, descending.size() );
+
+        assertEquals( "Correct edges returned", edge3, descending.get( 0 ) );
+
+        assertEquals( "Correct edges returned", edge2, descending.get( 1 ) );
+
+        assertEquals( "Correct edges returned", edge1, descending.get( 2 ) );
+
+
+        //now search ascending
+
+        final SearchByEdge searchAscending =
+                    new SimpleSearchByEdge( edge1.getSourceNode(), edge1.getType(), edge1.getTargetNode(),Long.MAX_VALUE,
+                        SearchByEdgeType.Order.ASCENDING, Optional.<Edge>absent()   );
+
+        Observable<Edge> edgesAscending = gm.loadEdgeVersions( searchAscending );
+
+        List<Edge> ascending = edgesAscending.toList().toBlocking().single();
+
+        assertEquals( "Correct size returned", 3, ascending.size() );
+
+        assertEquals( "Correct edges returned", edge1, ascending.get( 0 ) );
+
+        assertEquals( "Correct edges returned", edge2, ascending.get( 1 ) );
+
+        assertEquals( "Correct edges returned", edge3, ascending.get( 2 ) );
+    }
 }
 
 


[10/54] usergrid git commit: Changes to configure our filters correctly, and numerous other test fixes. Only 7 REST tests are not passing.

Posted by sn...@apache.org.
Changes to configure our filters correctly, and numerous other test fixes. Only 7 REST tests are not passing.


Project: http://git-wip-us.apache.org/repos/asf/usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/usergrid/commit/eb2aa6ff
Tree: http://git-wip-us.apache.org/repos/asf/usergrid/tree/eb2aa6ff
Diff: http://git-wip-us.apache.org/repos/asf/usergrid/diff/eb2aa6ff

Branch: refs/heads/usergrid-1007-shiro-cache
Commit: eb2aa6ff9d45861c9a3e7d7cb0496423fc3c9a23
Parents: 0578d98
Author: Dave Johnson <sn...@apache.org>
Authored: Thu Sep 3 15:01:37 2015 -0400
Committer: Dave Johnson <sn...@apache.org>
Committed: Thu Sep 3 15:01:37 2015 -0400

----------------------------------------------------------------------
 stack/pom.xml                                   |   2 +-
 stack/rest/pom.xml                              | 120 +++++++------------
 .../rest/filters/ContentTypeFilter.java         |  34 +++---
 .../rest/filters/JSONPCallbackFilter.java       |   4 +
 .../usergrid/rest/filters/MeteringFilter.java   |   8 +-
 .../usergrid/rest/filters/TracingFilter.java    |   8 +-
 .../rest/management/ManagementResource.java     |  22 ++--
 .../organizations/OrganizationsResource.java    |  25 ++++
 .../rest/security/CrossOriginRequestFilter.java |   2 +
 .../security/SecuredResourceFilterFactory.java  |  73 ++++++++---
 .../shiro/filters/BasicAuthSecurityFilter.java  |  10 +-
 .../ClientCredentialsSecurityFilter.java        |   8 +-
 .../OAuth2AccessTokenSecurityFilter.java        |  29 +++--
 .../security/shiro/filters/SecurityFilter.java  |  26 ++--
 stack/rest/src/main/webapp/WEB-INF/web.xml      |  66 +++++++---
 .../java/org/apache/usergrid/rest/BasicIT.java  |   7 +-
 .../apache/usergrid/rest/IndexResourceIT.java   |  15 +--
 .../apache/usergrid/rest/PartialUpdateTest.java |   6 +-
 .../rest/applications/ApplicationDeleteIT.java  | 103 +++++++---------
 .../applications/ApplicationResourceIT.java     |  17 +--
 .../applications/assets/AssetResourceIT.java    |  12 +-
 .../applications/assets/AwsAssetResourceIT.java |   8 +-
 .../collection/CollectionsResourceIT.java       |  10 +-
 .../collection/DuplicateNameIT.java             |   4 +-
 .../activities/ActivityResourceIT.java          |   4 +-
 .../collection/devices/DevicesResourceIT.java   |   4 +-
 .../collection/groups/GroupResourceIT.java      |  12 +-
 .../users/ConnectionResourceTest.java           |   8 +-
 .../collection/users/OwnershipResourceIT.java   |  14 +--
 .../collection/users/PermissionsResourceIT.java |  22 ++--
 .../collection/users/UserResourceIT.java        |  22 ++--
 .../queries/BadGrammarQueryTest.java            |  14 +--
 .../applications/queries/BasicGeoTests.java     |  18 +--
 .../usergrid/rest/management/AccessTokenIT.java |  18 +--
 .../usergrid/rest/management/AdminUsersIT.java  |  33 ++---
 .../rest/management/ExportResourceIT.java       |  60 +++++-----
 .../rest/management/ImportResourceIT.java       |  16 +--
 .../rest/management/ManagementResourceIT.java   |  33 ++---
 .../rest/management/OrganizationsIT.java        |  14 +--
 .../rest/management/RegistrationIT.java         |   4 +-
 .../rest/test/resource/AbstractRestIT.java      |  68 +++++++----
 .../rest/test/resource/ClientSetup.java         |   3 +-
 .../usergrid/rest/test/resource/RestClient.java |  13 +-
 .../test/resource/endpoints/NamedResource.java  |  34 +++---
 .../test/resource/endpoints/SetupResource.java  |  10 +-
 .../resource/endpoints/mgmt/OrgResource.java    |  22 ++--
 stack/rest/src/test/resources/log4j.properties  |  36 +++---
 .../rest/src/test/resources/logging.properties  |  13 +-
 stack/services/pom.xml                          |   6 +
 .../security/providers/FoursquareProvider.java  |   6 +-
 .../usergrid/management/OrganizationIT.java     |  18 +--
 51 files changed, 628 insertions(+), 516 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/usergrid/blob/eb2aa6ff/stack/pom.xml
----------------------------------------------------------------------
diff --git a/stack/pom.xml b/stack/pom.xml
index dc42920..15cca38 100644
--- a/stack/pom.xml
+++ b/stack/pom.xml
@@ -114,7 +114,7 @@
       <shiro-version>1.2.4</shiro-version>
       <slf4j-version>1.6.1</slf4j-version>
       <snakeyaml-version>1.9</snakeyaml-version>
-      <tomcat-version>7.0.59</tomcat-version>
+      <tomcat-version>7.0.64</tomcat-version>
       <antlr.version>3.4</antlr.version>
       <tika.version>1.4</tika.version>
       <mockito.version>1.10.8</mockito.version>

http://git-wip-us.apache.org/repos/asf/usergrid/blob/eb2aa6ff/stack/rest/pom.xml
----------------------------------------------------------------------
diff --git a/stack/rest/pom.xml b/stack/rest/pom.xml
index e95e66f..bea05fe 100644
--- a/stack/rest/pom.xml
+++ b/stack/rest/pom.xml
@@ -39,26 +39,28 @@
     <!-- profile that arquillian uses when it builds/starts tomcat -->
     <profiles>
 
-        <!--<profile>-->
-            <!--<id>arquillian-tomcat</id>-->
-            <!--<activation>-->
-                <!--<activeByDefault>true</activeByDefault>-->
-            <!--</activation>-->
-            <!--<dependencies>-->
-                <!--<dependency>-->
-                    <!--<groupId>org.jboss.arquillian.container</groupId>-->
-                    <!--<artifactId>arquillian-tomcat-remote-7</artifactId>-->
-                    <!--<version>1.0.0.CR7</version>-->
-                    <!--<scope>test</scope>-->
-                <!--</dependency>-->
-                <!--<dependency>-->
-                    <!--<groupId>org.eu.ingwar.tools</groupId>-->
-                    <!--<artifactId>arquillian-suite-extension</artifactId>-->
-                    <!--<version>1.1.1</version>-->
-                    <!--<scope>test</scope>-->
-                <!--</dependency>-->
-            <!--</dependencies>-->
-        <!--</profile>-->
+        <!--
+        <profile>
+            <id>arquillian-tomcat</id>
+            <activation>
+                <activeByDefault>true</activeByDefault>
+            </activation>
+            <dependencies>
+                <dependency>
+                    <groupId>org.jboss.arquillian.container</groupId>
+                    <artifactId>arquillian-tomcat-remote-7</artifactId>
+                    <version>1.0.0.CR7</version>
+                    <scope>test</scope>
+                </dependency>
+                <dependency>
+                    <groupId>org.eu.ingwar.tools</groupId>
+                    <artifactId>arquillian-suite-extension</artifactId>
+                    <version>1.1.1</version>
+                    <scope>test</scope>
+                </dependency>
+            </dependencies>
+        </profile>
+        -->
 
     </profiles>
 
@@ -103,7 +105,7 @@
                     <threadCount>${usergrid.rest.threads}</threadCount>
                     <useSystemClassLoader>false</useSystemClassLoader>
                     <reuseForks>true</reuseForks>
-                    <argLine>-Dwebapp.directory=${basedir}/src/main/webapp -Dtest.barrier.timestamp=${maven.build.timestamp} -Dtest.clean.storage=true -Xmx${ug.heapmax} -Xms${ug.heapmin} -Dfile.encoding=UTF-8 -Dsun.jnu.encoding=UTF-8 -javaagent:${settings.localRepository}/com/github/stephenc/jamm/0.2.5/jamm-0.2.5.jar ${ug.argline}
+                    <argLine>-Dwebapp.directory=${basedir}/src/main/webapp -Dtest.barrier.timestamp=${maven.build.timestamp} -Dtest.clean.storage=true -Xmx${ug.heapmax} -Xms${ug.heapmin} -Dfile.encoding=UTF-8 -Dsun.jnu.encoding=UTF-8 -javaagent:${settings.localRepository}/com/github/stephenc/jamm/0.2.5/jamm-0.2.5.jar -Djava.util.logging.config.file=${basedir}/src/test/resources/logging.properties ${ug.argline}
                     </argLine>
                     <includes>
                         <include>**/*IT.java</include>
@@ -128,6 +130,7 @@
                 <version>2.6</version>
             </plugin>
 
+            <!-- TODO: do we need this?
             <plugin>
                 <groupId>org.jasig.mojo.jspc</groupId>
                 <artifactId>jspc-maven-plugin</artifactId>
@@ -144,14 +147,7 @@
                         </goals>
                     </execution>
                 </executions>
-                <dependencies>
-                    <dependency>
-                        <groupId>org.jasig.mojo.jspc</groupId>
-                        <artifactId>jspc-compiler-tomcat6</artifactId>
-                        <version>2.0.0</version>
-                    </dependency>
-                </dependencies>
-            </plugin>
+            </plugin> -->
 
             <plugin>
                 <groupId>org.apache.maven.plugins</groupId>
@@ -213,11 +209,11 @@
             </exclusions>
         </dependency>
 
-        <!--<dependency>-->
-            <!--<groupId>org.apache.usergrid</groupId>-->
-            <!--<artifactId>usergrid-mongo-emulator</artifactId>-->
-            <!--<version>${project.version}</version>-->
-        <!--</dependency>-->
+        <!-- <dependency>
+            <groupId>org.apache.usergrid</groupId>
+            <artifactId>usergrid-mongo-emulator</artifactId>
+            <version>${project.version}</version>
+        </dependency> -->
 
         <!-- Apache Dependencies -->
 
@@ -226,7 +222,7 @@
             <artifactId>commons-collections</artifactId>
         </dependency>
 
-        <!-- SUN, Javax Package, and Other Com Dependencies -->
+        <!-- Java EE and Jersey dependencies -->
 
         <dependency>
             <groupId>javax.servlet</groupId>
@@ -241,12 +237,10 @@
 
         <dependency>
             <groupId>org.glassfish.jersey.containers</groupId>
-            <!-- if your container implements Servlet API older than 3.0, use "jersey-container-servlet-core"  -->
             <artifactId>jersey-container-servlet</artifactId>
             <version>2.21</version>
         </dependency>
 
-        <!-- Required only when you are using JAX-RS Client -->
         <dependency>
             <groupId>org.glassfish.jersey.core</groupId>
             <artifactId>jersey-client</artifactId>
@@ -259,7 +253,6 @@
             <version>2.21</version>
         </dependency>
 
-        <!-- support for JSP and Viewable -->
         <dependency>
             <groupId>org.glassfish.jersey.ext</groupId>
             <artifactId>jersey-mvc-jsp</artifactId>
@@ -269,7 +262,7 @@
         <dependency>
             <groupId>org.glassfish.jersey.media</groupId>
             <artifactId>jersey-media-multipart</artifactId>
-            <version>2.7</version>
+            <version>2.21</version>
         </dependency>
 
         <dependency>
@@ -278,42 +271,24 @@
             <version>2.21</version>
         </dependency>
 
-        <!--<dependency>-->
-            <!--<groupId>com.sun.jersey.contribs</groupId>-->
-            <!--<artifactId>jersey-multipart</artifactId>-->
-        <!--</dependency>-->
+        <dependency>
+            <groupId>org.glassfish.jersey.ext</groupId>
+            <artifactId>jersey-spring3</artifactId>
+            <version>2.21</version>
+        </dependency>
 
-        <!--<dependency>-->
-            <!--<groupId>com.sun.jersey</groupId>-->
-            <!--<artifactId>jersey-json</artifactId>-->
-        <!--</dependency>-->
+        <!-- Jackson, Spring, and other dependencies -->
 
         <dependency>
             <groupId>com.fasterxml.jackson.jaxrs</groupId>
             <artifactId>jackson-jaxrs-json-provider</artifactId>
         </dependency>
 
-        <!--<dependency>-->
-            <!--<groupId>com.sun.jersey</groupId>-->
-            <!--<artifactId>jersey-client</artifactId>-->
-        <!--</dependency>-->
-
         <dependency>
             <groupId>com.google.code.maven-play-plugin.net.tanesha.recaptcha4j</groupId>
             <artifactId>recaptcha4j</artifactId>
         </dependency>
 
-        <!--<dependency>-->
-            <!--<groupId>com.sun.jersey</groupId>-->
-            <!--<artifactId>jersey-server</artifactId>-->
-        <!--</dependency>-->
-
-        <!--<dependency>-->
-            <!--<groupId>com.sun.jersey.contribs</groupId>-->
-            <!--<artifactId>jersey-spring</artifactId>-->
-        <!--</dependency>-->
-
-        <!-- Codehaus, Spring, and Other Org Dependencies -->
 
         <dependency>
             <groupId>org.springframework</groupId>
@@ -415,24 +390,17 @@
             <scope>test</scope>
         </dependency>
 
-        <!--  use the in-memory test setup.  Just depend on the maven jetty plugin to launch jetty -->
         <dependency>
             <groupId>org.glassfish.jersey.test-framework.providers</groupId>
-            <artifactId>jersey-test-framework-provider-inmemory</artifactId>
+            <artifactId>jersey-test-framework-provider-external</artifactId>
             <version>2.21</version>
         </dependency>
 
-        <!--<dependency>-->
-            <!--<groupId>com.sun.jersey.jersey-test-framework</groupId>-->
-            <!--<artifactId>jersey-test-framework-external</artifactId>-->
-            <!--<scope>test</scope>-->
-        <!--</dependency>-->
-
-        <!--<dependency>-->
-            <!--<groupId>com.sun.jersey.jersey-test-framework</groupId>-->
-            <!--<artifactId>jersey-test-framework-core</artifactId>-->
-            <!--<scope>test</scope>-->
-        <!--</dependency>-->
+        <dependency>
+            <groupId>org.glassfish.jersey.test-framework</groupId>
+            <artifactId>jersey-test-framework-core</artifactId>
+            <version>2.21</version>
+        </dependency>
 
         <dependency>
             <groupId>org.apache.usergrid</groupId>

http://git-wip-us.apache.org/repos/asf/usergrid/blob/eb2aa6ff/stack/rest/src/main/java/org/apache/usergrid/rest/filters/ContentTypeFilter.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/filters/ContentTypeFilter.java b/stack/rest/src/main/java/org/apache/usergrid/rest/filters/ContentTypeFilter.java
index 14f8fb2..93048db 100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/filters/ContentTypeFilter.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/filters/ContentTypeFilter.java
@@ -59,7 +59,7 @@ public class ContentTypeFilter implements Filter {
 
     /*
      * (non-Javadoc)
-     * 
+     *
      * @see javax.servlet.Filter#init(javax.servlet.FilterConfig)
      */
     @Override
@@ -70,7 +70,7 @@ public class ContentTypeFilter implements Filter {
 
     /*
      * (non-Javadoc)
-     * 
+     *
      * @see javax.servlet.Filter#doFilter(javax.servlet.ServletRequest,
      * javax.servlet.ServletResponse, javax.servlet.FilterChain)
      */
@@ -98,7 +98,7 @@ public class ContentTypeFilter implements Filter {
 
     /*
      * (non-Javadoc)
-     * 
+     *
      * @see javax.servlet.Filter#destroy()
      */
     @Override
@@ -153,12 +153,10 @@ public class ContentTypeFilter implements Filter {
             // nothing to read, check if it's a put or a post. If so set the
             // content type to json to create an empty json request
             if ( initial == -1 ) {
-                if ( ( HttpMethod.POST.equals( method ) || HttpMethod.PUT.equals( method ) ) && !MediaType
-                        .APPLICATION_FORM_URLENCODED.equals( getContentType() ) ) {
-
-                    logger.debug(
-                            "Setting content type to application/json for POST or PUT with no content at path '{}'",
-                            path );
+                if ( ( HttpMethod.POST.equals( method ) || HttpMethod.PUT.equals( method ) )
+                    && !MediaType.APPLICATION_FORM_URLENCODED.equals( getContentType() ) ) {
+                    logger.debug("Setting content type to application/json " +
+                            "for POST or PUT with no content at path '{}'", path );
 
                     setHeader( HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON );
                     setHeader( HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON );
@@ -170,9 +168,11 @@ public class ContentTypeFilter implements Filter {
             char firstChar = ( char ) initial;
 
             // its json, make it so
-            if ( firstChar == '{' || firstChar == '[' ) {
-                logger.debug( "Setting content type to application/json for POST or PUT with json content at path '{}'",
-                        path );
+            if ( firstChar == '{' || firstChar == '['
+                && !MediaType.APPLICATION_JSON.equals( getContentType() )) {
+
+                logger.debug( "Setting content type to application/json " +
+                        "for POST or PUT with json content at path '{}'", path );
 
                 setHeader( HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON );
                 setHeader( HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON );
@@ -193,7 +193,7 @@ public class ContentTypeFilter implements Filter {
 
         /*
          * (non-Javadoc)
-         * 
+         *
          * @see
          * javax.servlet.http.HttpServletRequestWrapper#getHeader(java.lang.
          * String)
@@ -212,7 +212,7 @@ public class ContentTypeFilter implements Filter {
 
         /*
          * (non-Javadoc)
-         * 
+         *
          * @see
          * javax.servlet.http.HttpServletRequestWrapper#getHeaders(java.lang
          * .String)
@@ -238,7 +238,7 @@ public class ContentTypeFilter implements Filter {
 
         /*
          * (non-Javadoc)
-         * 
+         *
          * @see javax.servlet.http.HttpServletRequestWrapper#getHeaderNames()
          */
         @Override
@@ -257,7 +257,7 @@ public class ContentTypeFilter implements Filter {
 
         /*
          * (non-Javadoc)
-         * 
+         *
          * @see javax.servlet.ServletRequestWrapper#getInputStream()
          */
         @Override
@@ -268,7 +268,7 @@ public class ContentTypeFilter implements Filter {
 
         /*
          * (non-Javadoc)
-         * 
+         *
          * @see javax.servlet.ServletRequestWrapper#getReader()
          */
         @Override

http://git-wip-us.apache.org/repos/asf/usergrid/blob/eb2aa6ff/stack/rest/src/main/java/org/apache/usergrid/rest/filters/JSONPCallbackFilter.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/filters/JSONPCallbackFilter.java b/stack/rest/src/main/java/org/apache/usergrid/rest/filters/JSONPCallbackFilter.java
index bc2bdc7d..23ccdf9 100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/filters/JSONPCallbackFilter.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/filters/JSONPCallbackFilter.java
@@ -21,15 +21,19 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.stereotype.Component;
 
+import javax.annotation.Resource;
 import javax.servlet.http.HttpServletRequest;
 import javax.ws.rs.container.ContainerRequestContext;
 import javax.ws.rs.container.ContainerRequestFilter;
+import javax.ws.rs.container.PreMatching;
 import javax.ws.rs.core.Context;
 import java.io.IOException;
 
 import static org.apache.commons.lang.StringUtils.isNotBlank;
 
 
+@Resource
+@PreMatching
 @Component
 public class JSONPCallbackFilter implements ContainerRequestFilter {
 

http://git-wip-us.apache.org/repos/asf/usergrid/blob/eb2aa6ff/stack/rest/src/main/java/org/apache/usergrid/rest/filters/MeteringFilter.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/filters/MeteringFilter.java b/stack/rest/src/main/java/org/apache/usergrid/rest/filters/MeteringFilter.java
index 24051ad..2735cdf 100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/filters/MeteringFilter.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/filters/MeteringFilter.java
@@ -32,11 +32,9 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Qualifier;
 import org.springframework.stereotype.Component;
 
+import javax.annotation.Resource;
 import javax.servlet.http.HttpServletRequest;
-import javax.ws.rs.container.ContainerRequestContext;
-import javax.ws.rs.container.ContainerRequestFilter;
-import javax.ws.rs.container.ContainerResponseContext;
-import javax.ws.rs.container.ContainerResponseFilter;
+import javax.ws.rs.container.*;
 import javax.ws.rs.core.Context;
 import java.io.FilterInputStream;
 import java.io.IOException;
@@ -49,6 +47,8 @@ import java.util.concurrent.TimeUnit;
 
 
 // TODO: Metering for Jersey 2
+@Resource
+@PreMatching
 @Component
 public class MeteringFilter implements ContainerRequestFilter, ContainerResponseFilter {
 

http://git-wip-us.apache.org/repos/asf/usergrid/blob/eb2aa6ff/stack/rest/src/main/java/org/apache/usergrid/rest/filters/TracingFilter.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/filters/TracingFilter.java b/stack/rest/src/main/java/org/apache/usergrid/rest/filters/TracingFilter.java
index fcff69d..64d0209 100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/filters/TracingFilter.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/filters/TracingFilter.java
@@ -26,11 +26,9 @@ import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
+import javax.annotation.Resource;
 import javax.servlet.http.HttpServletRequest;
-import javax.ws.rs.container.ContainerRequestContext;
-import javax.ws.rs.container.ContainerRequestFilter;
-import javax.ws.rs.container.ContainerResponseContext;
-import javax.ws.rs.container.ContainerResponseFilter;
+import javax.ws.rs.container.*;
 import javax.ws.rs.core.Context;
 
 
@@ -39,6 +37,8 @@ import javax.ws.rs.core.Context;
  *
  * @author zznate
  */
+@Resource
+@PreMatching
 @Component
 public class TracingFilter implements ContainerRequestFilter, ContainerResponseFilter {
 

http://git-wip-us.apache.org/repos/asf/usergrid/blob/eb2aa6ff/stack/rest/src/main/java/org/apache/usergrid/rest/management/ManagementResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/management/ManagementResource.java b/stack/rest/src/main/java/org/apache/usergrid/rest/management/ManagementResource.java
index e79e521..8fba027 100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/management/ManagementResource.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/management/ManagementResource.java
@@ -25,13 +25,8 @@ import org.apache.amber.oauth2.common.error.OAuthError;
 import org.apache.amber.oauth2.common.exception.OAuthProblemException;
 import org.apache.amber.oauth2.common.message.OAuthResponse;
 import org.apache.amber.oauth2.common.message.types.GrantType;
-import org.apache.commons.httpclient.HttpClient;
-import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager;
-import org.apache.commons.httpclient.params.HttpConnectionManagerParams;
 import org.apache.commons.lang.RandomStringUtils;
 import org.apache.commons.lang.StringUtils;
-import org.apache.http.HttpHost;
-import org.apache.http.conn.routing.HttpRoute;
 import org.apache.http.impl.conn.PoolingClientConnectionManager;
 import org.apache.shiro.codec.Base64;
 import org.apache.usergrid.exception.NotImplementedException;
@@ -54,8 +49,6 @@ import org.glassfish.jersey.apache.connector.ApacheClientProperties;
 import org.glassfish.jersey.apache.connector.ApacheConnectorProvider;
 import org.glassfish.jersey.client.ClientConfig;
 import org.glassfish.jersey.client.ClientProperties;
-import org.glassfish.jersey.client.spi.Connector;
-import org.glassfish.jersey.client.spi.ConnectorProvider;
 import org.glassfish.jersey.jackson.JacksonFeature;
 import org.glassfish.jersey.server.mvc.Viewable;
 import org.slf4j.Logger;
@@ -67,7 +60,10 @@ import org.springframework.stereotype.Component;
 import javax.ws.rs.*;
 import javax.ws.rs.client.Client;
 import javax.ws.rs.client.ClientBuilder;
-import javax.ws.rs.core.*;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.UriInfo;
 import java.net.URLEncoder;
 import java.util.Collections;
 import java.util.Iterator;
@@ -650,7 +646,8 @@ public class ManagementResource extends AbstractContextResource {
                     } else {
 
                         // already created user, so just create an org
-                        final OrganizationInfo organization = management.createOrganization( orgName, userInfo, true );
+                        final OrganizationInfo organization =
+                            management.createOrganization( orgName, userInfo, true );
 
                         applicationCreator.createSampleFor( organization );
 
@@ -674,7 +671,8 @@ public class ManagementResource extends AbstractContextResource {
             throw e;
         }
 
-        final Response response = Response.status( SC_OK ).type( jsonMediaType( callback ) ).entity( accessInfo ).build();
+        final Response response = Response.status( SC_OK )
+            .type( jsonMediaType( callback ) ).entity( accessInfo ).build();
 
         timerContext.stop();
 
@@ -695,7 +693,7 @@ public class ManagementResource extends AbstractContextResource {
         Counter tokensRejectedCounter = getMetricsFactory().getCounter(
             ManagementResource.class, SSO_TOKENS_REJECTED );
         Counter tokensValidatedCounter = getMetricsFactory().getCounter(
-                ManagementResource.class, SSO_TOKENS_VALIDATED );
+            ManagementResource.class, SSO_TOKENS_VALIDATED );
 
         // create URL of central Usergrid's /management/me endpoint
 
@@ -762,7 +760,7 @@ public class ManagementResource extends AbstractContextResource {
                 clientConfig.connectorProvider( new ApacheConnectorProvider() );
 
                 jerseyClient = ClientBuilder.newClient( clientConfig );
-                jerseyClient.property( ClientProperties.CONNECT_TIMEOUT, timeout);
+                jerseyClient.property( ClientProperties.CONNECT_TIMEOUT, timeout );
                 jerseyClient.property( ClientProperties.READ_TIMEOUT, readTimeout );
             }
         }

http://git-wip-us.apache.org/repos/asf/usergrid/blob/eb2aa6ff/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/OrganizationsResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/OrganizationsResource.java b/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/OrganizationsResource.java
index 9398f0e..26f6b5c 100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/OrganizationsResource.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/OrganizationsResource.java
@@ -24,6 +24,7 @@ import org.apache.usergrid.management.ApplicationCreator;
 import org.apache.usergrid.management.OrganizationInfo;
 import org.apache.usergrid.management.OrganizationOwnerInfo;
 import org.apache.usergrid.management.exceptions.ManagementException;
+import org.apache.usergrid.persistence.index.query.Identifier;
 import org.apache.usergrid.rest.AbstractContextResource;
 import org.apache.usergrid.rest.ApiResponse;
 import org.apache.usergrid.rest.RootResource;
@@ -42,6 +43,9 @@ import javax.ws.rs.core.UriInfo;
 import java.util.Map;
 import java.util.UUID;
 
+import static org.apache.usergrid.rest.exceptions.SecurityException.mappableSecurityException;
+import static org.apache.usergrid.security.shiro.utils.SubjectUtils.isPermittedAccessToOrganization;
+
 
 @Component( "org.apache.usergrid.rest.management.organizations.OrganizationsResource" )
 @Scope( "prototype" )
@@ -62,7 +66,13 @@ public class OrganizationsResource extends AbstractContextResource {
     public OrganizationsResource() {
     }
 
+    // TODO: better solution to this Jersey 2 introduced problem:
+    // Problem is that when Jersey scans the resources classes and methods to add our
+    // secured resource filter, it only recognizes methods with an HTTP method annotation
+    // but when I add the @GET annotation to the methods below, Jersey fails to resolve
+    // the resource methods when they are called.
 
+    //@GET
     @Path(RootResource.ORGANIZATION_ID_PATH)
     @RequireOrganizationAccess
     public OrganizationResource getOrganizationById( @Context UriInfo ui,
@@ -72,10 +82,18 @@ public class OrganizationsResource extends AbstractContextResource {
         if ( organization == null ) {
             throw new ManagementException( "Could not find organization for ID: " + organizationIdStr );
         }
+
+//        // TODO: get rid of this and make annotations work (see above)
+//        if ( !isPermittedAccessToOrganization( Identifier.from(organization) ) ) {
+//            logger.debug("No organization access authorized");
+//            throw mappableSecurityException( "unauthorized", "No organization access authorized" );
+//        }
+
         return getSubResource( OrganizationResource.class ).init( organization );
     }
 
 
+    //@GET
     @Path( "{organizationName}" )
     @RequireOrganizationAccess
     public OrganizationResource getOrganizationByName( @Context UriInfo ui,
@@ -85,6 +103,13 @@ public class OrganizationsResource extends AbstractContextResource {
         if ( organization == null ) {
             throw new ManagementException( "Could not find organization for name: " + organizationName );
         }
+
+//        // TODO: get rid of this and make annotations work (see above)
+//        if ( !isPermittedAccessToOrganization( Identifier.from(organization) ) ) {
+//            logger.debug("No organization access authorized");
+//            throw mappableSecurityException( "unauthorized", "No organization access authorized" );
+//        }
+
         return getSubResource( OrganizationResource.class ).init(organization);
     }
 

http://git-wip-us.apache.org/repos/asf/usergrid/blob/eb2aa6ff/stack/rest/src/main/java/org/apache/usergrid/rest/security/CrossOriginRequestFilter.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/security/CrossOriginRequestFilter.java b/stack/rest/src/main/java/org/apache/usergrid/rest/security/CrossOriginRequestFilter.java
index be6c3e9..00c12d7 100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/security/CrossOriginRequestFilter.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/security/CrossOriginRequestFilter.java
@@ -21,12 +21,14 @@ import org.apache.usergrid.rest.utils.CORSUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import javax.annotation.Resource;
 import javax.ws.rs.container.ContainerRequestContext;
 import javax.ws.rs.container.ContainerResponseContext;
 import javax.ws.rs.container.ContainerResponseFilter;
 import java.io.IOException;
 
 
+@Resource
 public class CrossOriginRequestFilter implements ContainerResponseFilter {
     public static final Logger logger = LoggerFactory.getLogger( CrossOriginRequestFilter.class );
 

http://git-wip-us.apache.org/repos/asf/usergrid/blob/eb2aa6ff/stack/rest/src/main/java/org/apache/usergrid/rest/security/SecuredResourceFilterFactory.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/security/SecuredResourceFilterFactory.java b/stack/rest/src/main/java/org/apache/usergrid/rest/security/SecuredResourceFilterFactory.java
index 6e4fc1e..f6edfcc 100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/security/SecuredResourceFilterFactory.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/security/SecuredResourceFilterFactory.java
@@ -34,8 +34,9 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Qualifier;
-import org.springframework.stereotype.Component;
 
+import javax.annotation.Resource;
+import javax.inject.Inject;
 import javax.ws.rs.container.ContainerRequestContext;
 import javax.ws.rs.container.ContainerRequestFilter;
 import javax.ws.rs.container.DynamicFeature;
@@ -54,14 +55,12 @@ import static org.apache.usergrid.rest.exceptions.SecurityException.mappableSecu
 import static org.apache.usergrid.security.shiro.utils.SubjectUtils.*;
 
 
-@Component
+@Resource
 public class SecuredResourceFilterFactory implements DynamicFeature {
 
     private static final Logger logger = LoggerFactory.getLogger( SecuredResourceFilterFactory.class );
 
-    private
-    @Context
-    UriInfo uriInfo;
+    private @Context UriInfo uriInfo;
 
     EntityManagerFactory emf;
     ServiceManagerFactory smf;
@@ -71,6 +70,7 @@ public class SecuredResourceFilterFactory implements DynamicFeature {
     ManagementService management;
 
 
+    @Inject
     public SecuredResourceFilterFactory() {
         logger.info( "SecuredResourceFilterFactory is installed" );
     }
@@ -115,6 +115,9 @@ public class SecuredResourceFilterFactory implements DynamicFeature {
     public void configure(ResourceInfo resourceInfo, FeatureContext featureContext) {
         Method am = resourceInfo.getResourceMethod();
 
+        logger.debug( "configure {} method {}",
+            resourceInfo.getResourceClass().getSimpleName(), resourceInfo.getResourceMethod().getName() );
+
         if ( am.isAnnotationPresent( RequireApplicationAccess.class ) ) {
             featureContext.register( ApplicationFilter.class );
         }
@@ -130,8 +133,12 @@ public class SecuredResourceFilterFactory implements DynamicFeature {
 
     }
 
-    public abstract class AbstractFilter implements ContainerRequestFilter {
-        public AbstractFilter() {
+    public static abstract class AbstractFilter implements ContainerRequestFilter {
+
+        private UriInfo uriInfo;
+
+        public AbstractFilter( UriInfo uriInfo ) {
+            this.uriInfo = uriInfo;
         }
 
         @Override
@@ -209,13 +216,14 @@ public class SecuredResourceFilterFactory implements DynamicFeature {
         }
     }
 
+    @Resource
+    public static class OrganizationFilter extends AbstractFilter {
 
-    private class OrganizationFilter extends AbstractFilter {
-
-        protected OrganizationFilter() {
+        @Inject
+        public OrganizationFilter( UriInfo uriInfo ) {
+            super(uriInfo);
         }
 
-
         @Override
         public void authorize( ContainerRequestContext request ) {
             logger.debug( "OrganizationFilter.authorize" );
@@ -230,12 +238,32 @@ public class SecuredResourceFilterFactory implements DynamicFeature {
     }
 
 
-    private class ApplicationFilter extends AbstractFilter {
+    @Resource
+    public static class ApplicationFilter extends AbstractFilter {
+
+        EntityManagerFactory emf;
+        ManagementService management;
 
-        protected ApplicationFilter() {
+        @Autowired
+        public void setEntityManagerFactory( EntityManagerFactory emf ) {
+            this.emf = emf;
         }
 
 
+        public EntityManagerFactory getEntityManagerFactory() {
+            return emf;
+        }
+
+        @Autowired
+        public void setManagementService( ManagementService management ) {
+            this.management = management;
+        }
+
+        @Inject
+        public ApplicationFilter( UriInfo uriInfo ) {
+            super(uriInfo);
+        }
+
         @Override
         public void authorize( ContainerRequestContext request ) {
             logger.debug( "ApplicationFilter.authorize" );
@@ -248,7 +276,7 @@ public class SecuredResourceFilterFactory implements DynamicFeature {
                 catch ( Exception e ) {
                     e.printStackTrace();
                 }
-                EntityManager em = emf.getEntityManager( application.getId() );
+                EntityManager em = getEntityManagerFactory().getEntityManager( application.getId() );
                 Map<String, String> roles = null;
                 try {
                     roles = em.getRoles();
@@ -271,8 +299,12 @@ public class SecuredResourceFilterFactory implements DynamicFeature {
     }
 
 
-    public class SystemFilter extends AbstractFilter {
-        public SystemFilter() {
+    @Resource
+    public static class SystemFilter extends AbstractFilter {
+
+        @Inject
+        public SystemFilter( UriInfo uriInfo ) {
+            super(uriInfo);
         }
 
 
@@ -298,10 +330,13 @@ public class SecuredResourceFilterFactory implements DynamicFeature {
     }
 
 
-    public class AdminUserFilter extends AbstractFilter {
-        public AdminUserFilter() {
-        }
+    @Resource
+    public static class AdminUserFilter extends AbstractFilter {
 
+        @Inject
+        public AdminUserFilter( UriInfo uriInfo ) {
+            super(uriInfo);
+        }
 
         @Override
         public void authorize( ContainerRequestContext request ) {

http://git-wip-us.apache.org/repos/asf/usergrid/blob/eb2aa6ff/stack/rest/src/main/java/org/apache/usergrid/rest/security/shiro/filters/BasicAuthSecurityFilter.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/security/shiro/filters/BasicAuthSecurityFilter.java b/stack/rest/src/main/java/org/apache/usergrid/rest/security/shiro/filters/BasicAuthSecurityFilter.java
index 6bf825f..cb0745a 100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/security/shiro/filters/BasicAuthSecurityFilter.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/security/shiro/filters/BasicAuthSecurityFilter.java
@@ -20,15 +20,17 @@ package org.apache.usergrid.rest.security.shiro.filters;
 import org.apache.shiro.codec.Base64;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import org.springframework.stereotype.Component;
 
 import javax.ws.rs.container.ContainerRequestContext;
+import javax.ws.rs.container.PreMatching;
 import javax.ws.rs.core.SecurityContext;
+import javax.ws.rs.ext.Provider;
 import java.security.Principal;
 import java.util.Map;
 
 
-@Component
+@Provider
+@PreMatching
 public class BasicAuthSecurityFilter extends SecurityFilter {
 
     private static final Logger logger = LoggerFactory.getLogger( BasicAuthSecurityFilter.class );
@@ -41,6 +43,8 @@ public class BasicAuthSecurityFilter extends SecurityFilter {
 
     @Override
     public void filter( ContainerRequestContext request ) {
+        logger.info("Filtering: " + request.getUriInfo().getBaseUri());
+
         Map<String, String> auth_types = getAuthTypes( request );
         if ( ( auth_types == null ) || !auth_types.containsKey( AUTH_BASIC_TYPE ) ) {
             return;
@@ -59,7 +63,7 @@ public class BasicAuthSecurityFilter extends SecurityFilter {
         if ( name.equals( sysadmin_login_name ) && password.equals( sysadmin_login_password )
                 && sysadmin_login_allowed ) {
             request.setSecurityContext( new SysAdminRoleAuthenticator() );
-            logger.info( "System administrator access allowed" );
+            logger.debug( "System administrator access allowed" );
         }
     }
 

http://git-wip-us.apache.org/repos/asf/usergrid/blob/eb2aa6ff/stack/rest/src/main/java/org/apache/usergrid/rest/security/shiro/filters/ClientCredentialsSecurityFilter.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/security/shiro/filters/ClientCredentialsSecurityFilter.java b/stack/rest/src/main/java/org/apache/usergrid/rest/security/shiro/filters/ClientCredentialsSecurityFilter.java
index c4ee3e7..eb982b8 100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/security/shiro/filters/ClientCredentialsSecurityFilter.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/security/shiro/filters/ClientCredentialsSecurityFilter.java
@@ -22,18 +22,20 @@ import org.apache.usergrid.security.shiro.PrincipalCredentialsToken;
 import org.apache.usergrid.security.shiro.utils.SubjectUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import org.springframework.stereotype.Component;
 
 import javax.servlet.http.HttpServletRequest;
 import javax.ws.rs.container.ContainerRequestContext;
+import javax.ws.rs.container.PreMatching;
 import javax.ws.rs.core.Context;
+import javax.ws.rs.ext.Provider;
 
 import static org.apache.commons.lang.StringUtils.isNotBlank;
 import static org.apache.usergrid.rest.exceptions.AuthErrorInfo.OAUTH2_INVALID_CLIENT;
 import static org.apache.usergrid.rest.exceptions.SecurityException.mappableSecurityException;
 
 
-@Component
+@Provider
+@PreMatching
 public class ClientCredentialsSecurityFilter extends SecurityFilter {
 
     private static final Logger logger = LoggerFactory.getLogger( ClientCredentialsSecurityFilter.class );
@@ -49,6 +51,8 @@ public class ClientCredentialsSecurityFilter extends SecurityFilter {
 
     @Override
     public void filter( ContainerRequestContext request ) {
+        logger.debug("Filtering: " + request.getUriInfo().getBaseUri());
+
         String clientId = httpServletRequest.getParameter( "client_id" );
         String clientSecret = httpServletRequest.getParameter( "client_secret" );
 

http://git-wip-us.apache.org/repos/asf/usergrid/blob/eb2aa6ff/stack/rest/src/main/java/org/apache/usergrid/rest/security/shiro/filters/OAuth2AccessTokenSecurityFilter.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/security/shiro/filters/OAuth2AccessTokenSecurityFilter.java b/stack/rest/src/main/java/org/apache/usergrid/rest/security/shiro/filters/OAuth2AccessTokenSecurityFilter.java
index 08de618..4bb0c83 100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/security/shiro/filters/OAuth2AccessTokenSecurityFilter.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/security/shiro/filters/OAuth2AccessTokenSecurityFilter.java
@@ -38,27 +38,29 @@ import org.apache.usergrid.security.tokens.exceptions.ExpiredTokenException;
 import org.apache.usergrid.security.tokens.exceptions.InvalidTokenException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import org.springframework.stereotype.Component;
 
 import javax.servlet.http.HttpServletRequest;
 import javax.ws.rs.container.ContainerRequestContext;
+import javax.ws.rs.container.ContainerRequestFilter;
+import javax.ws.rs.container.PreMatching;
 import javax.ws.rs.core.Context;
+import javax.ws.rs.ext.Provider;
 import java.io.IOException;
 
 import static org.apache.usergrid.rest.exceptions.AuthErrorInfo.*;
 import static org.apache.usergrid.rest.exceptions.SecurityException.mappableSecurityException;
 
-
-@Component
-public class OAuth2AccessTokenSecurityFilter extends SecurityFilter {
+@Provider
+@PreMatching
+public class OAuth2AccessTokenSecurityFilter extends SecurityFilter implements ContainerRequestFilter {
 
     public static final String REALM = "Usergrid Authentication";
 
-    private static final Logger LOG = LoggerFactory.getLogger( OAuth2AccessTokenSecurityFilter.class );
+    private static final Logger logger = LoggerFactory.getLogger( OAuth2AccessTokenSecurityFilter.class );
 
 
     public OAuth2AccessTokenSecurityFilter() {
-        LOG.info( "OAuth2AccessTokenSecurityFilter is installed" );
+        logger.info( "OAuth2AccessTokenSecurityFilter is installed" );
     }
 
 
@@ -68,6 +70,7 @@ public class OAuth2AccessTokenSecurityFilter extends SecurityFilter {
 
     @Override
     public void filter(ContainerRequestContext request) throws IOException {
+        logger.debug("Filtering: " + request.getUriInfo().getBaseUri());
 
         try {
             try {
@@ -102,10 +105,10 @@ public class OAuth2AccessTokenSecurityFilter extends SecurityFilter {
                     // token is just some rubbish string
                     throw mappableSecurityException( BAD_ACCESS_TOKEN_ERROR );
                 } catch (Exception e) {
-                    if (LOG.isDebugEnabled()) {
-                        LOG.debug( "Unable to verify OAuth token: " + accessToken, e );
+                    if (logger.isDebugEnabled()) {
+                        logger.debug( "Unable to verify OAuth token: " + accessToken, e );
                     } else {
-                        LOG.warn( "Unable to verify OAuth token" );
+                        logger.warn( "Unable to verify OAuth token" );
                     }
                     throw mappableSecurityException( UNVERIFIED_OAUTH_ERROR );
                 }
@@ -124,7 +127,7 @@ public class OAuth2AccessTokenSecurityFilter extends SecurityFilter {
                     } catch (ManagementException e) {
                         throw mappableSecurityException( e, BAD_ACCESS_TOKEN_ERROR );
                     } catch (Exception e) {
-                        LOG.error( "failed to get admin user info from access token", e );
+                        logger.error( "failed to get admin user info from access token", e );
                     }
                     if (user == null) {
                         throw mappableSecurityException( BAD_ACCESS_TOKEN_ERROR );
@@ -140,7 +143,7 @@ public class OAuth2AccessTokenSecurityFilter extends SecurityFilter {
                     } catch (ManagementException e) {
                         throw mappableSecurityException( e, BAD_ACCESS_TOKEN_ERROR );
                     } catch (Exception e) {
-                        LOG.error( "failed to get app user from access token", e );
+                        logger.error( "failed to get app user from access token", e );
                     }
                     if (user == null) {
                         throw mappableSecurityException( BAD_ACCESS_TOKEN_ERROR );
@@ -155,7 +158,7 @@ public class OAuth2AccessTokenSecurityFilter extends SecurityFilter {
                     } catch (ManagementException e) {
                         throw mappableSecurityException( e, BAD_ACCESS_TOKEN_ERROR );
                     } catch (Exception e) {
-                        LOG.error( "failed to get organization info from access token", e );
+                        logger.error( "failed to get organization info from access token", e );
                     }
                     if (organization == null) {
                         throw mappableSecurityException( BAD_ACCESS_TOKEN_ERROR );
@@ -171,7 +174,7 @@ public class OAuth2AccessTokenSecurityFilter extends SecurityFilter {
                     } catch (ManagementException e) {
                         throw mappableSecurityException( e, BAD_ACCESS_TOKEN_ERROR );
                     } catch (Exception e) {
-                        LOG.error( "failed to get application info from access token", e );
+                        logger.error( "failed to get application info from access token", e );
                     }
                     if (application == null) {
                         throw mappableSecurityException( BAD_ACCESS_TOKEN_ERROR );

http://git-wip-us.apache.org/repos/asf/usergrid/blob/eb2aa6ff/stack/rest/src/main/java/org/apache/usergrid/rest/security/shiro/filters/SecurityFilter.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/security/shiro/filters/SecurityFilter.java b/stack/rest/src/main/java/org/apache/usergrid/rest/security/shiro/filters/SecurityFilter.java
index 625d352..e0dadba 100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/security/shiro/filters/SecurityFilter.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/security/shiro/filters/SecurityFilter.java
@@ -17,9 +17,13 @@
 package org.apache.usergrid.rest.security.shiro.filters;
 
 
-import java.util.LinkedHashMap;
-import java.util.Map;
-import java.util.Properties;
+import org.apache.commons.lang.StringUtils;
+import org.apache.usergrid.management.ManagementService;
+import org.apache.usergrid.persistence.EntityManagerFactory;
+import org.apache.usergrid.security.tokens.TokenService;
+import org.apache.usergrid.services.ServiceManagerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
 
 import javax.ws.rs.container.ContainerRequestContext;
 import javax.ws.rs.container.ContainerRequestFilter;
@@ -27,23 +31,13 @@ import javax.ws.rs.core.Context;
 import javax.ws.rs.core.HttpHeaders;
 import javax.ws.rs.core.UriInfo;
 import javax.xml.ws.spi.http.HttpContext;
-
-import org.glassfish.jersey.server.ContainerRequest;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Qualifier;
-
-import org.apache.usergrid.management.ManagementService;
-import org.apache.usergrid.persistence.EntityManagerFactory;
-import org.apache.usergrid.security.tokens.TokenService;
-import org.apache.usergrid.services.ServiceManagerFactory;
-
-import org.apache.commons.lang.StringUtils;
-
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.Properties;
 
 import static org.apache.usergrid.utils.StringUtils.stringOrSubstringAfterFirst;
 import static org.apache.usergrid.utils.StringUtils.stringOrSubstringBeforeFirst;
 
-
 public abstract class SecurityFilter implements ContainerRequestFilter {
 
     public static final String AUTH_OAUTH_2_ACCESS_TOKEN_TYPE = "BEARER";

http://git-wip-us.apache.org/repos/asf/usergrid/blob/eb2aa6ff/stack/rest/src/main/webapp/WEB-INF/web.xml
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/webapp/WEB-INF/web.xml b/stack/rest/src/main/webapp/WEB-INF/web.xml
index 23c0751..0c46fe4 100644
--- a/stack/rest/src/main/webapp/WEB-INF/web.xml
+++ b/stack/rest/src/main/webapp/WEB-INF/web.xml
@@ -40,7 +40,6 @@
         <filter-name>swaggerFilter</filter-name>
         <filter-class>org.apache.usergrid.rest.SwaggerServlet</filter-class>
     </filter>
-
     <filter-mapping>
         <filter-name>swaggerFilter</filter-name>
         <url-pattern>/resources.json</url-pattern>
@@ -54,7 +53,7 @@
         <url-pattern>/management.json</url-pattern>
     </filter-mapping>
 
-    <!--  filter for setting default accept and Content-Type as application/json when undefined by client -->
+    <!--  filter for setting default accept and Content-Type as application/json when undefined by client
     <filter>
         <filter-name>contentTypeFilter</filter-name>
         <filter-class>org.apache.usergrid.rest.filters.ContentTypeFilter</filter-class>
@@ -63,6 +62,7 @@
         <filter-name>contentTypeFilter</filter-name>
         <url-pattern>/*</url-pattern>
     </filter-mapping>
+    -->
 
     <filter>
         <filter-name>shiroFilter</filter-name>
@@ -79,43 +79,71 @@
 
     <filter>
         <filter-name>Usergrid REST API Server</filter-name>
-        <filter-class>com.sun.jersey.spi.spring.container.servlet.SpringServlet</filter-class>
+        <filter-class>org.glassfish.jersey.servlet.ServletContainer</filter-class>
+
+        <init-param>
+            <param-name>jersey.config.servlet.filter.contextPath</param-name>
+            <param-value>/</param-value>
+        </init-param>
+
+        <!-- Look for resources, providers and other annotated JAX-RS things in rest package -->
         <init-param>
-            <param-name>com.sun.jersey.config.property.packages</param-name>
+            <param-name>jersey.config.server.provider.packages</param-name>
             <param-value>org.apache.usergrid.rest</param-value>
         </init-param>
+
+        <!-- Look recursively in all packages -->
         <init-param>
-            <param-name>com.sun.jersey.api.json.POJOMappingFeature</param-name>
+            <param-name>jersey.config.server.provider.scanning.recursive</param-name>
             <param-value>true</param-value>
         </init-param>
+
         <init-param>
-            <param-name>com.sun.jersey.spi.container.ContainerRequestFilters</param-name>
-            <param-value>org.apache.usergrid.rest.filters.TracingFilter,org.apache.usergrid.rest.filters.MeteringFilter,org.apache.usergrid.rest.filters.JSONPCallbackFilter,org.apache.usergrid.rest.security.shiro.filters.OAuth2AccessTokenSecurityFilter,org.apache.usergrid.rest.security.shiro.filters.BasicAuthSecurityFilter,org.apache.usergrid.rest.security.shiro.filters.ClientCredentialsSecurityFilter</param-value>
+            <param-name>jersey.config.server.provider.classnames</param-name>
+            <param-value>
+
+                org.apache.usergrid.rest.security.SecuredResourceFilterFactory,
+                org.glassfish.jersey.server.mvc.jsp.JspMvcFeature,
+                org.glassfish.jersey.media.multipart.MultiPartFeature
+
+                <!-- Currently, we do not use the JAX-RS annotations @PermitAll, @DenyAll, @RolesAllowed -->
+                <!-- , org.glassfish.jersey.server.filter.RolesAllowedDynamicFeature -->
+
+            </param-value>
         </init-param>
+
         <init-param>
-            <param-name>com.sun.jersey.spi.container.ContainerResponseFilters</param-name>
-            <param-value>org.apache.usergrid.rest.filters.TracingFilter,org.apache.usergrid.rest.security.CrossOriginRequestFilter,org.apache.usergrid.rest.filters.MeteringFilter</param-value>
+            <param-name>jersey.config.server.mvc.templateBasePath.jsp</param-name>
+            <param-value>/WEB-INF/jsp</param-value>
         </init-param>
+
         <init-param>
-            <param-name>com.sun.jersey.spi.container.ResourceFilters</param-name>
-            <param-value>org.apache.usergrid.rest.security.SecuredResourceFilterFactory,com.sun.jersey.api.container.filter.RolesAllowedResourceFilterFactory</param-value>
+            <param-name>jersey.config.server.wadl.disableWadl</param-name>
+            <param-value>true</param-value>
         </init-param>
+
         <init-param>
-            <param-name>com.sun.jersey.config.feature.DisableWADL</param-name>
-            <param-value>true</param-value>
+            <param-name>jersey.config.servlet.filter.staticContentRegex</param-name>
+            <param-value>/(((images|css|js|jsp|WEB-INF/jsp)/.*)|(favicon\.ico))</param-value>
         </init-param>
+
         <init-param>
-            <param-name>com.sun.jersey.config.property.JSPTemplatesBasePath</param-name>
-            <param-value>/WEB-INF/jsp</param-value>
+            <param-name>jersey.config.server.mediaTypeMappings</param-name>
+            <param-value>json:application/json,js:application/javascript</param-value>
         </init-param>
+
+        <!-- Have not had success with this yet:
         <init-param>
-            <param-name>com.sun.jersey.config.property.WebPageContentRegex</param-name>
-            <param-value>/(((images|css|js|jsp|WEB-INF/jsp)/.*)|(favicon\.ico))</param-value>
+            <param-name>jersey.config.server.tracing.threshold</param-name>
+            <param-value>TRACE</param-value>
         </init-param>
+
         <init-param>
-            <param-name>com.sun.jersey.config.property.MediaTypeMappings</param-name>
-            <param-value>json:application/json,js:application/javascript<!-- Temporarily removed until more testing can occur,csv:text/csv --></param-value>
+            <param-name>jersey.config.server.tracing.type</param-name>
+            <param-value>ALL</param-value>
         </init-param>
+        -->
+
     </filter>
 
     <filter-mapping>

http://git-wip-us.apache.org/repos/asf/usergrid/blob/eb2aa6ff/stack/rest/src/test/java/org/apache/usergrid/rest/BasicIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/BasicIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/BasicIT.java
index edda5e5..905c522 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/BasicIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/BasicIT.java
@@ -25,7 +25,8 @@ import org.junit.Test;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import javax.ws.rs.client.ResponseProcessingException;
+
+import javax.ws.rs.ClientErrorException;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
@@ -74,9 +75,9 @@ public class BasicIT extends AbstractRestIT {
             try {
                 clientSetup.getRestClient().pathResource( getOrgAppPath( "users/JOE" ) ).get( ApiResponse.class );
                 fail("A get on a nonexistant object should fail");
-            } catch ( ResponseProcessingException e ) {
+            } catch ( ClientErrorException e ) {
                 assertEquals( "Guests should not be able to get a 404", 404,
-                    e.getResponse().getStatusInfo().getStatusCode());
+                    e.getResponse().getStatusInfo().getStatusCode() );
             }
     }
 }

http://git-wip-us.apache.org/repos/asf/usergrid/blob/eb2aa6ff/stack/rest/src/test/java/org/apache/usergrid/rest/IndexResourceIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/IndexResourceIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/IndexResourceIT.java
index 065cd10..2bf9855 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/IndexResourceIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/IndexResourceIT.java
@@ -87,10 +87,10 @@ public class IndexResourceIT extends AbstractRestIT {
                 .get( "jobId" ).toString() )
             .getTarget();
 
-        result = res.request()
-            .property( HttpAuthenticationFeature.HTTP_AUTHENTICATION_BASIC_USERNAME, "superuser")
-            .property( HttpAuthenticationFeature.HTTP_AUTHENTICATION_BASIC_PASSWORD, "superpassword" )
-            .get(ApiResponse.class);
+        HttpAuthenticationFeature feature = HttpAuthenticationFeature.basicBuilder()
+            .credentials( "superuser", "superpassword" ).build();
+
+        result = res.register( feature ).request().get( ApiResponse.class );
 
         assertNotNull( result );
         assertEquals(status,result.getProperties().get("jobId").toString());
@@ -116,9 +116,10 @@ public class IndexResourceIT extends AbstractRestIT {
 
             WebTarget resource = this.clientSetup.getRestClient().pathResource("/system/index/" + appId).getTarget();
 
-            node = resource.request()
-                .property( HttpAuthenticationFeature.HTTP_AUTHENTICATION_BASIC_USERNAME, "superuser")
-                .property( HttpAuthenticationFeature.HTTP_AUTHENTICATION_BASIC_PASSWORD, "superpassword" )
+            HttpAuthenticationFeature feature = HttpAuthenticationFeature.basicBuilder()
+                .credentials( "superuser", "superpassword" ).build();
+
+            node = resource.register( feature ).request()
                 .accept( MediaType.APPLICATION_JSON )
                 .get( org.apache.usergrid.rest.test.resource.model.ApiResponse.class);
 

http://git-wip-us.apache.org/repos/asf/usergrid/blob/eb2aa6ff/stack/rest/src/test/java/org/apache/usergrid/rest/PartialUpdateTest.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/PartialUpdateTest.java b/stack/rest/src/test/java/org/apache/usergrid/rest/PartialUpdateTest.java
index 109c76d..bc66467 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/PartialUpdateTest.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/PartialUpdateTest.java
@@ -24,7 +24,7 @@ import org.junit.Test;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import javax.ws.rs.client.ResponseProcessingException;
+import javax.ws.rs.ClientErrorException;
 import java.io.IOException;
 import java.util.LinkedHashMap;
 import java.util.Map;
@@ -77,7 +77,7 @@ public class PartialUpdateTest extends AbstractRestIT {
             try {
                 // PUT the updates to the user and ensure they were saved
                 userNode = this.app().collection("users").entity(userNode).put(updateProps);
-            } catch (ResponseProcessingException uie) {
+            } catch (ClientErrorException uie) {
                 fail("Update failed due to: " + uie.getResponse().readEntity(String.class));
             }
 
@@ -118,7 +118,7 @@ public class PartialUpdateTest extends AbstractRestIT {
         try { //  PUT /users/fred   put /users/uuid
             userNode = this.app().collection("users").entity(props.get("username").toString()).put(updateProps);
 
-        } catch (ResponseProcessingException uie) {
+        } catch (ClientErrorException uie) {
             fail("Update failed due to: " + uie.getResponse().readEntity(String.class));
         }
         refreshIndex();

http://git-wip-us.apache.org/repos/asf/usergrid/blob/eb2aa6ff/stack/rest/src/test/java/org/apache/usergrid/rest/applications/ApplicationDeleteIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/ApplicationDeleteIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/ApplicationDeleteIT.java
index b863a8e..d215256 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/ApplicationDeleteIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/ApplicationDeleteIT.java
@@ -30,8 +30,9 @@ import org.junit.Test;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import javax.ws.rs.client.ResponseProcessingException;
+import javax.ws.rs.ClientErrorException;
 import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
@@ -72,20 +73,13 @@ public class ApplicationDeleteIT extends AbstractRestIT {
 
         // delete the app
 
-        try {
-            clientSetup.getRestClient() .management().orgs()
-                .org(orgName).apps().app(appToDeleteId.toString()).getTarget()
-                .queryParam("access_token", orgAdminToken.getAccessToken())
-                .request()
-                .delete();
-
-            fail("Delete must fail without app_delete_confirm parameter");
+        final Response response = clientSetup.getRestClient().management().orgs()
+            .org( orgName ).apps().app( appToDeleteId.toString() ).getTarget()
+            .queryParam( "access_token", orgAdminToken.getAccessToken() )
+            .request()
+            .delete();
 
-        } catch (  ResponseProcessingException expected  ) {
-            Assert.assertEquals("Error must be 400", 400, expected.getResponse().getStatus() );
-            JsonNode node = mapper.readTree( expected.getResponse().readEntity( String.class ));
-            Assert.assertEquals("Cannot delete application without app_delete_confirm parameter", node.get("error_description").textValue());
-        }
+        Assert.assertEquals("Error must be 400", 400, response.getStatus() );
 
         clientSetup.getRestClient().management().orgs()
             .org(orgName).apps().app(appToDeleteId.toString() ).getTarget()
@@ -105,7 +99,7 @@ public class ApplicationDeleteIT extends AbstractRestIT {
 
             fail("Must not be able to get deleted app");
 
-        } catch ( ResponseProcessingException expected ) {
+        } catch ( ClientErrorException expected ) {
             Assert.assertEquals("Error must be 404", 404, expected.getResponse().getStatus() );
             JsonNode node = mapper.readTree( expected.getResponse().readEntity( String.class ));
             Assert.assertEquals("entity_not_found", node.get("error").textValue());
@@ -119,7 +113,7 @@ public class ApplicationDeleteIT extends AbstractRestIT {
 
             fail( "Must not be able to get deleted app" );
         }
-        catch ( ResponseProcessingException expected ) {
+        catch ( ClientErrorException expected ) {
             Assert.assertEquals( "Error must be 404", 404, expected.getResponse().getStatus() );
             JsonNode node = mapper.readTree( expected.getResponse().readEntity( String.class ) );
             Assert.assertEquals( "organization_application_not_found", node.get( "error" ).textValue() );
@@ -137,7 +131,7 @@ public class ApplicationDeleteIT extends AbstractRestIT {
 
             fail("Must not be able to get deleted app's collection");
 
-        } catch ( ResponseProcessingException expected ) {
+        } catch ( ClientErrorException expected ) {
             Assert.assertEquals("Error must be 400", 404, expected.getResponse().getStatus() );
             JsonNode node = mapper.readTree( expected.getResponse().readEntity( String.class ));
             Assert.assertEquals("organization_application_not_found", node.get("error").textValue());
@@ -155,7 +149,7 @@ public class ApplicationDeleteIT extends AbstractRestIT {
 
             fail("Must not be able to get deleted app entity");
 
-        } catch ( ResponseProcessingException expected ) {
+        } catch ( ClientErrorException expected ) {
             // TODO: why not a 404?
             Assert.assertEquals("Error must be 400", 404, expected.getResponse().getStatus() );
             JsonNode node = mapper.readTree( expected.getResponse().readEntity( String.class ));
@@ -178,20 +172,13 @@ public class ApplicationDeleteIT extends AbstractRestIT {
 
         // test that we cannot delete the application a second time
 
-        try {
-            clientSetup.getRestClient().management().orgs().org( orgName ).apps().app( appToDeleteId.toString() )
-                .getTarget().queryParam( "access_token", orgAdminToken.getAccessToken() )
-                .queryParam( "app_delete_confirm", "confirm_delete_of_application_and_data" )
-                .request()
-                .delete();
-
-            fail("Can't delete a non existent app twice");
-        }
-        catch ( ResponseProcessingException expected ) {
-            Assert.assertEquals( "Error must be 404", 404, expected.getResponse().getStatus() );
-            JsonNode node = mapper.readTree( expected.getResponse().readEntity( String.class ) );
-            Assert.assertEquals( "entity_not_found", node.get( "error" ).textValue() );
-        }
+        final Response response1 = clientSetup.getRestClient().management()
+            .orgs().org( orgName ).apps().app( appToDeleteId.toString() )
+            .getTarget().queryParam( "access_token", orgAdminToken.getAccessToken() )
+            .queryParam( "app_delete_confirm", "confirm_delete_of_application_and_data" )
+            .request()
+            .delete();
+        Assert.assertEquals( "Error must be 404", 404, response1.getStatus() );
 
         // test that we can create a new application with the same name
 
@@ -203,7 +190,7 @@ public class ApplicationDeleteIT extends AbstractRestIT {
 
         Assert.assertEquals("Must be able to create app with same name as deleted app",
             (orgName + "/" + appToDeleteName).toLowerCase(),
-            appCreateAgainResponse.getEntities().get(0).get("name"));
+            appCreateAgainResponse.getEntities().get(0).get( "name" ));
     }
 
 
@@ -245,13 +232,13 @@ public class ApplicationDeleteIT extends AbstractRestIT {
 
         // restore the app
 
-        logger.debug("\n\nRestoring app\n");
+        logger.debug( "\n\nRestoring app\n" );
 
         clientSetup.getRestClient().management().orgs()
             .org( orgName ).apps().app( appToDeleteId.toString() ).getTarget()
             .queryParam( "access_token", orgAdminToken.getAccessToken() )
             .request()
-            .put( javax.ws.rs.client.Entity.json( null ));
+            .put( javax.ws.rs.client.Entity.entity( "", MediaType.APPLICATION_JSON )); // must send body
 
         refreshIndex();
 
@@ -274,9 +261,9 @@ public class ApplicationDeleteIT extends AbstractRestIT {
 
         // test that we can get an app entity
 
-        logger.debug("\n\nGetting entities from app\n");
+        logger.debug( "\n\nGetting entities from app\n" );
 
-        UUID entityId = entities.get(0).getUuid();
+        UUID entityId = entities.get( 0 ).getUuid();
         ApiResponse entityResponse = clientSetup.getRestClient()
             .org( orgName ).app( appToDeleteName ).collection( "things" ).entity( entityId ).getTarget()
             .queryParam( "access_token", orgAdminToken.getAccessToken() )
@@ -290,7 +277,7 @@ public class ApplicationDeleteIT extends AbstractRestIT {
             .org( orgName ).app( appToDeleteName ).collection( "things" ).getTarget()
             .queryParam( "access_token", orgAdminToken.getAccessToken() )
             .request()
-            .get(ApiResponse.class);
+            .get( ApiResponse.class );
         Assert.assertEquals( entities.size(), collectionReponse.getEntityCount() );
     }
 
@@ -326,19 +313,13 @@ public class ApplicationDeleteIT extends AbstractRestIT {
 
         // attempt to restore original app, should get 409
 
-        try {
-
-            clientSetup.getRestClient() .management().orgs()
-                .org(orgName).apps().app(appToDeleteId.toString()).getTarget()
-                .queryParam("access_token", orgAdminToken.getAccessToken())
-                .request()
-                .put( javax.ws.rs.client.Entity.json(null) );
-
-            fail("Must fail to restore app with same name as existing app");
+        final Response response = clientSetup.getRestClient().management().orgs()
+            .org( orgName ).apps().app( appToDeleteId.toString() ).getTarget()
+            .queryParam( "access_token", orgAdminToken.getAccessToken() )
+            .request()
+            .put( javax.ws.rs.client.Entity.entity( "", MediaType.TEXT_PLAIN ) );// must send body with put
 
-        } catch ( ResponseProcessingException e ) {
-            Assert.assertEquals(409, e.getResponse().getStatus());
-        }
+        Assert.assertEquals( 409, response.getStatus() );
     }
 
 
@@ -361,7 +342,8 @@ public class ApplicationDeleteIT extends AbstractRestIT {
 
         // delete the app
 
-        clientSetup.getRestClient().management().orgs().org( orgName ).apps().app( appToDeleteId.toString() ).getTarget()
+        clientSetup.getRestClient().management()
+            .orgs().org( orgName ).apps().app( appToDeleteId.toString() ).getTarget()
             .queryParam( "access_token", orgAdminToken.getAccessToken() )
             .queryParam( "app_delete_confirm", "confirm_delete_of_application_and_data" )
             .request()
@@ -373,19 +355,14 @@ public class ApplicationDeleteIT extends AbstractRestIT {
 
         // attempt to delete new app, it should fail
 
-        try {
-
-            clientSetup.getRestClient().management().orgs().org( orgName ).apps().app( newAppId.toString() ).getTarget()
-                .queryParam( "access_token", orgAdminToken.getAccessToken() )
-                .queryParam("app_delete_confirm", "confirm_delete_of_application_and_data")
-                .request()
-                .delete();
-
-            fail("Must fail to delete app with same name as deleted app");
+        final Response response = clientSetup.getRestClient().management()
+            .orgs().org( orgName ).apps().app( newAppId.toString() ).getTarget()
+            .queryParam( "access_token", orgAdminToken.getAccessToken() )
+            .queryParam( "app_delete_confirm", "confirm_delete_of_application_and_data" )
+            .request()
+            .delete();
 
-        } catch ( ResponseProcessingException e ) {
-            Assert.assertEquals( 409, e.getResponse().getStatus() );
-        }
+        Assert.assertEquals( 409, response.getStatus() );
     }
 
 

http://git-wip-us.apache.org/repos/asf/usergrid/blob/eb2aa6ff/stack/rest/src/test/java/org/apache/usergrid/rest/applications/ApplicationResourceIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/ApplicationResourceIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/ApplicationResourceIT.java
index f071b5e..bc24f5b 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/ApplicationResourceIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/ApplicationResourceIT.java
@@ -32,8 +32,9 @@ import org.junit.Test;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import javax.ws.rs.InternalServerErrorException;
 import javax.ws.rs.client.Invocation;
-import javax.ws.rs.client.ResponseProcessingException;
+import javax.ws.rs.ClientErrorException;
 import javax.ws.rs.core.Form;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.Response;
@@ -228,6 +229,7 @@ public class ApplicationResourceIT extends AbstractRestIT {
      * (for backwards compatibility)
      */
     @Test
+    @Ignore("this form of backwards compatibility no longer needed")
     public void jsonForAcceptsTextHtml() throws Exception {
 
         //Create the organization resource
@@ -414,7 +416,7 @@ public class ApplicationResourceIT extends AbstractRestIT {
                 .accept(MediaType.APPLICATION_JSON)
                 .post( javax.ws.rs.client.Entity.entity(entity, MediaType.APPLICATION_JSON_TYPE ), ApiResponse.class);
             fail("This should cause an exception");
-        } catch (ResponseProcessingException uie) {
+        } catch (ClientErrorException uie) {
             assertEquals(
                 String.valueOf( Response.Status.BAD_REQUEST.getStatusCode()),
                 String.valueOf(uie.getResponse().getStatus()));
@@ -480,7 +482,7 @@ public class ApplicationResourceIT extends AbstractRestIT {
             this.app().collection("users").entity(entity).get(
                 new QueryParameters().addParam("access_token", token), false);
             fail("The expired token should cause an exception");
-        } catch (ResponseProcessingException uie) {
+        } catch (ClientErrorException uie) {
             assertEquals( Response.Status.UNAUTHORIZED.getStatusCode(), uie.getResponse().getStatus());
         }
 
@@ -519,8 +521,8 @@ public class ApplicationResourceIT extends AbstractRestIT {
                 .get( ApiResponse.class );
             fail("The invalid TTL should cause an exception");
 
-        } catch (ResponseProcessingException uie) {
-            //TODO should this be handled and returned as a Status.BAD_REQUEST?
+        } catch (InternalServerErrorException uie) {
+            // TODO should this be handled and returned as a Status.BAD_REQUEST?
             //Status.INTERNAL_SERVER_ERROR is thrown because Jersey throws a NumberFormatException
             assertEquals( Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), uie.getResponse().getStatus());
         }
@@ -655,7 +657,7 @@ public class ApplicationResourceIT extends AbstractRestIT {
                 .request()
                 .accept( MediaType.TEXT_HTML )
                 .post( javax.ws.rs.client.Entity.form( payload ), String.class );
-        } catch (ResponseProcessingException uie) {
+        } catch (ClientErrorException uie) {
             assertEquals(String.valueOf( Response.Status.TEMPORARY_REDIRECT.getStatusCode()), uie.getResponse().getStatus());
         }
 
@@ -780,6 +782,7 @@ public class ApplicationResourceIT extends AbstractRestIT {
      * Ensure that the Apigee Mobile Analytics config returns valid JSON
      */
     @Test
+    @Ignore
     public void validateApigeeApmConfigAPP() throws IOException {
         String orgName = clientSetup.getOrganizationName().toLowerCase();
         String appName = clientSetup.getAppName().toLowerCase();
@@ -795,7 +798,7 @@ public class ApplicationResourceIT extends AbstractRestIT {
 
             //if things are kosher then JSON should have value for instaOpsApplicationId
             assertTrue("it's valid json for APM", node.has("instaOpsApplicationId"));
-        } catch (ResponseProcessingException uie) {
+        } catch (ClientErrorException uie) {
             //Validate that APM config exists
             assertNotEquals("APM Config API exists", Response.Status.NOT_FOUND,
                 uie.getResponse().getStatus()); //i.e It should not be "Not Found"

http://git-wip-us.apache.org/repos/asf/usergrid/blob/eb2aa6ff/stack/rest/src/test/java/org/apache/usergrid/rest/applications/assets/AssetResourceIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/assets/AssetResourceIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/assets/AssetResourceIT.java
index 92705b2..0342883 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/assets/AssetResourceIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/assets/AssetResourceIT.java
@@ -24,6 +24,10 @@ import org.apache.usergrid.rest.test.resource.model.ApiResponse;
 import org.apache.usergrid.rest.test.resource.model.Entity;
 import org.apache.usergrid.services.assets.data.AssetUtils;
 import org.glassfish.jersey.media.multipart.FormDataMultiPart;
+import org.glassfish.jersey.media.multipart.MultiPart;
+import org.glassfish.jersey.media.multipart.MultiPartFeature;
+import org.glassfish.jersey.media.multipart.file.FileDataBodyPart;
+import org.glassfish.jersey.media.multipart.file.StreamDataBodyPart;
 import org.junit.After;
 import org.junit.Assert;
 import org.junit.Before;
@@ -240,9 +244,11 @@ public class AssetResourceIT extends AbstractRestIT {
 
             // upload a file larger than 6mb
 
-            byte[] data = IOUtils.toByteArray( this.getClass().getResourceAsStream( "/ship-larger-than-6mb.gif" ) );
-            FormDataMultiPart form = new FormDataMultiPart().field( "file", data, MediaType.MULTIPART_FORM_DATA_TYPE );
-            ApiResponse postResponse = pathResource( getOrgAppPath( "bars" ) ).post( form );
+            final StreamDataBodyPart part = new StreamDataBodyPart(
+                "file", getClass().getResourceAsStream( "/ship-larger-than-6mb.gif" ), "ship");
+            final MultiPart multipart = new FormDataMultiPart().bodyPart( part );
+
+            ApiResponse postResponse = pathResource( getOrgAppPath( "bars" ) ).post( multipart );
             UUID assetId = postResponse.getEntities().get(0).getUuid();
 
             String errorMessage = null;

http://git-wip-us.apache.org/repos/asf/usergrid/blob/eb2aa6ff/stack/rest/src/test/java/org/apache/usergrid/rest/applications/assets/AwsAssetResourceIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/assets/AwsAssetResourceIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/assets/AwsAssetResourceIT.java
index 72d45de..af41b69 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/assets/AwsAssetResourceIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/assets/AwsAssetResourceIT.java
@@ -31,7 +31,7 @@ import org.junit.*;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import javax.ws.rs.client.ResponseProcessingException;
+import javax.ws.rs.ClientErrorException;
 import javax.ws.rs.core.MediaType;
 import java.io.IOException;
 import java.io.InputStream;
@@ -95,7 +95,7 @@ public class AwsAssetResourceIT extends AbstractRestIT {
         }catch ( AwsPropertiesNotFoundException e ){
             fail("Shouldn't interrupt runtime if access key isnt found.");
         }
-        catch( ResponseProcessingException uie){
+        catch( ClientErrorException uie){
             assertEquals(500,uie.getResponse().getStatus());
         }
         finally{
@@ -129,7 +129,7 @@ public class AwsAssetResourceIT extends AbstractRestIT {
         }catch ( AwsPropertiesNotFoundException e ){
             fail("Shouldn't interrupt runtime if access key isnt found.");
         }
-        catch( ResponseProcessingException uie){
+        catch( ClientErrorException uie){
             assertEquals( 500, uie.getResponse().getStatus() );
         }
         finally{
@@ -171,7 +171,7 @@ public class AwsAssetResourceIT extends AbstractRestIT {
         }catch ( AwsPropertiesNotFoundException e ){
             fail("Shouldn't interrupt runtime if access key isnt found.");
         }
-        catch( ResponseProcessingException uie){
+        catch( ClientErrorException uie){
             assertEquals( 500, uie.getResponse().getStatus() );
         }
         finally{

http://git-wip-us.apache.org/repos/asf/usergrid/blob/eb2aa6ff/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/CollectionsResourceIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/CollectionsResourceIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/CollectionsResourceIT.java
index b2bab35..92eac90 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/CollectionsResourceIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/CollectionsResourceIT.java
@@ -28,7 +28,7 @@ import org.junit.Test;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import javax.ws.rs.client.ResponseProcessingException;
+import javax.ws.rs.ClientErrorException;
 import java.io.IOException;
 
 import static org.junit.Assert.*;
@@ -62,7 +62,7 @@ public class CollectionsResourceIT extends AbstractRestIT {
         try {
             this.clientSetup.getRestClient().org(org).app(app).collection("cities").get();
             fail("Call to bad path exists, but it should not");
-        } catch (ResponseProcessingException e) {
+        } catch (ClientErrorException e) {
             //verify the correct error was returned
             JsonNode node = mapper.readTree( e.getResponse().readEntity( String.class ));
             assertEquals( "organization_application_not_found", node.get( "error" ).textValue() );
@@ -75,7 +75,7 @@ public class CollectionsResourceIT extends AbstractRestIT {
         try {
             this.clientSetup.getRestClient().org(org).app(app).collection("cities").post(payload);
             fail("Call to bad path exists, but it should not");
-        } catch (ResponseProcessingException e) {
+        } catch (ClientErrorException e) {
             //verify the correct error was returned
             JsonNode node = mapper.readTree( e.getResponse().readEntity( String.class ));
             assertEquals( "organization_application_not_found", node.get( "error" ).textValue() );
@@ -85,7 +85,7 @@ public class CollectionsResourceIT extends AbstractRestIT {
         try {
             this.clientSetup.getRestClient().org(org).app(app).collection("cities").entity(entity).put(payload);
             fail("Call to bad path exists, but it should not");
-        } catch (ResponseProcessingException e) {
+        } catch (ClientErrorException e) {
             //verify the correct error was returned
             JsonNode node = mapper.readTree( e.getResponse().readEntity( String.class ));
             assertEquals( "organization_application_not_found", node.get( "error" ).textValue() );
@@ -95,7 +95,7 @@ public class CollectionsResourceIT extends AbstractRestIT {
         try {
             this.clientSetup.getRestClient().org(org).app(app).collection("cities").entity(entity).delete();
             fail("Call to bad path exists, but it should not");
-        } catch (ResponseProcessingException e) {
+        } catch (ClientErrorException e) {
             //verify the correct error was returned
             JsonNode node = mapper.readTree( e.getResponse().readEntity( String.class ));
             assertEquals( "organization_application_not_found", node.get( "error" ).textValue() );

http://git-wip-us.apache.org/repos/asf/usergrid/blob/eb2aa6ff/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/DuplicateNameIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/DuplicateNameIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/DuplicateNameIT.java
index 4e21ca7..0776705 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/DuplicateNameIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/DuplicateNameIT.java
@@ -20,7 +20,7 @@ import org.apache.usergrid.rest.test.resource.AbstractRestIT;
 import org.apache.usergrid.rest.test.resource.model.Entity;
 import org.junit.Test;
 
-import javax.ws.rs.client.ResponseProcessingException;
+import javax.ws.rs.ClientErrorException;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.fail;
@@ -47,7 +47,7 @@ public class DuplicateNameIT extends AbstractRestIT {
             this.app().collection(collectionName).post(entity);
             // fail if the POST did not return an exception
             fail("Should not have created duplicate entity");
-        } catch (ResponseProcessingException uie) {
+        } catch (ClientErrorException uie) {
             //Check for an exception
             assertEquals(400, uie.getResponse().getStatus());
         }

http://git-wip-us.apache.org/repos/asf/usergrid/blob/eb2aa6ff/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/activities/ActivityResourceIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/activities/ActivityResourceIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/activities/ActivityResourceIT.java
index 239bb13..e71f4a8 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/activities/ActivityResourceIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/activities/ActivityResourceIT.java
@@ -28,7 +28,7 @@ import org.slf4j.LoggerFactory;
 
 import org.apache.usergrid.utils.UUIDUtils;
 
-import javax.ws.rs.client.ResponseProcessingException;
+import javax.ws.rs.ClientErrorException;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
@@ -88,7 +88,7 @@ public class ActivityResourceIT extends AbstractRestIT {
         // don't populate the user, it will use the currently authenticated user.
         try {
             groupActivityResource.post(activity);
-        }catch (ResponseProcessingException e)
+        }catch (ClientErrorException e)
         {
             throw e;
         }

http://git-wip-us.apache.org/repos/asf/usergrid/blob/eb2aa6ff/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/devices/DevicesResourceIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/devices/DevicesResourceIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/devices/DevicesResourceIT.java
index 6e44e39..02716a7 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/devices/DevicesResourceIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/devices/DevicesResourceIT.java
@@ -36,7 +36,7 @@ import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.fail;
 import org.junit.Ignore;
 
-import javax.ws.rs.client.ResponseProcessingException;
+import javax.ws.rs.ClientErrorException;
 
 
 public class DevicesResourceIT extends AbstractRestIT {
@@ -68,7 +68,7 @@ public class DevicesResourceIT extends AbstractRestIT {
             entity = devicesResource.entity(uuid).get();
             fail( "should get 404 error" );
         }
-        catch ( ResponseProcessingException e ) {
+        catch ( ClientErrorException e ) {
             assertEquals( 404, e.getResponse().getStatus() );
         }
         refreshIndex();


[12/54] usergrid git commit: Jersey 2 fix for IndexResourceIT

Posted by sn...@apache.org.
Jersey 2 fix for IndexResourceIT


Project: http://git-wip-us.apache.org/repos/asf/usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/usergrid/commit/dfa65d61
Tree: http://git-wip-us.apache.org/repos/asf/usergrid/tree/dfa65d61
Diff: http://git-wip-us.apache.org/repos/asf/usergrid/diff/dfa65d61

Branch: refs/heads/usergrid-1007-shiro-cache
Commit: dfa65d61000ad1443c7e6125706dc0642e5b7463
Parents: e070ad5
Author: Dave Johnson <sn...@apache.org>
Authored: Fri Sep 4 09:24:09 2015 -0400
Committer: Dave Johnson <sn...@apache.org>
Committed: Fri Sep 4 09:24:09 2015 -0400

----------------------------------------------------------------------
 .../apache/usergrid/rest/IndexResourceIT.java   |  5 ++--
 .../resource/endpoints/CollectionEndpoint.java  | 29 ++++++++++++--------
 .../test/resource/endpoints/NamedResource.java  | 21 +++++++-------
 3 files changed, 32 insertions(+), 23 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/usergrid/blob/dfa65d61/stack/rest/src/test/java/org/apache/usergrid/rest/IndexResourceIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/IndexResourceIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/IndexResourceIT.java
index 2bf9855..af91ad7 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/IndexResourceIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/IndexResourceIT.java
@@ -62,12 +62,13 @@ public class IndexResourceIT extends AbstractRestIT {
         assertNotNull( collectionResponse );
 
         //try reindex endpoint with ALl mixed case characters
-        Token superUserToken = clientSetup.getRestClient().management().token().get(clientSetup.getSuperuserName(),clientSetup.getSuperuserPassword());
+        Token superUserToken = clientSetup.getRestClient().management().token()
+            .get(clientSetup.getSuperuserName(),clientSetup.getSuperuserPassword());
 
         QueryParameters queryParameters = new QueryParameters();
         queryParameters.addParam( "access_token",superUserToken.getAccessToken());
         ApiResponse result = clientSetup.getRestClient()
-            .pathResource( "system/index/rebuild/"+clientSetup.getAppUuid()+"/StOrElaTloNs" )
+            .pathResource( "system/index/rebuild/" + clientSetup.getAppUuid() + "/StOrElaTloNs" )
             .post( false, ApiResponse.class, null, queryParameters, true );
 
         assertNotNull(result);

http://git-wip-us.apache.org/repos/asf/usergrid/blob/dfa65d61/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/CollectionEndpoint.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/CollectionEndpoint.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/CollectionEndpoint.java
index 6873955..958079c 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/CollectionEndpoint.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/CollectionEndpoint.java
@@ -203,11 +203,13 @@ public class CollectionEndpoint extends NamedResource {
      * DELETE /users
      * </pre>
      */
-    public org.apache.usergrid.rest.test.resource.model.ApiResponse delete( final org.apache.usergrid.rest.test.resource.model.QueryParameters parameters ){
+    public org.apache.usergrid.rest.test.resource.model.ApiResponse delete(
+        final org.apache.usergrid.rest.test.resource.model.QueryParameters parameters ){
         return delete(parameters, true);
     }
 
-    public org.apache.usergrid.rest.test.resource.model.ApiResponse delete(final org.apache.usergrid.rest.test.resource.model.QueryParameters parameters, final boolean useToken) {
+    public org.apache.usergrid.rest.test.resource.model.ApiResponse delete(
+        final org.apache.usergrid.rest.test.resource.model.QueryParameters parameters, final boolean useToken) {
 
         String acceptHeader = MediaType.APPLICATION_JSON;
 
@@ -230,7 +232,8 @@ public class CollectionEndpoint extends NamedResource {
      * POST /users {"color","red"}
      * </pre>
      */
-    public org.apache.usergrid.rest.test.resource.model.Entity post(org.apache.usergrid.rest.test.resource.model.Entity payload){
+    public org.apache.usergrid.rest.test.resource.model.Entity post(
+        org.apache.usergrid.rest.test.resource.model.Entity payload){
 
         String acceptHeader = MediaType.APPLICATION_JSON;
         if (this.acceptHeaders.size() > 0) {
@@ -248,7 +251,8 @@ public class CollectionEndpoint extends NamedResource {
         ObjectMapper mapper = new ObjectMapper();
         org.apache.usergrid.rest.test.resource.model.ApiResponse response;
         try {
-            response = mapper.readValue( new StringReader(responseString), org.apache.usergrid.rest.test.resource.model.ApiResponse.class);
+            response = mapper.readValue( new StringReader(responseString),
+                org.apache.usergrid.rest.test.resource.model.ApiResponse.class);
         } catch (IOException e) {
             throw new RuntimeException("Error parsing response", e);
         }
@@ -275,7 +279,8 @@ public class CollectionEndpoint extends NamedResource {
         ObjectMapper mapper = new ObjectMapper();
         org.apache.usergrid.rest.test.resource.model.ApiResponse response;
         try {
-            response = mapper.readValue( new StringReader(responseString), org.apache.usergrid.rest.test.resource.model.ApiResponse.class);
+            response = mapper.readValue( new StringReader(responseString),
+                org.apache.usergrid.rest.test.resource.model.ApiResponse.class);
         } catch (IOException e) {
             throw new RuntimeException("Error parsing response", e);
         }
@@ -283,7 +288,8 @@ public class CollectionEndpoint extends NamedResource {
         return new org.apache.usergrid.rest.test.resource.model.Entity(response);
     }
 
-    public org.apache.usergrid.rest.test.resource.model.ApiResponse post(List<org.apache.usergrid.rest.test.resource.model.Entity> entityList) {
+    public org.apache.usergrid.rest.test.resource.model.ApiResponse post(
+        List<org.apache.usergrid.rest.test.resource.model.Entity> entityList) {
 
         String acceptHeader = MediaType.APPLICATION_JSON;
 
@@ -302,8 +308,8 @@ public class CollectionEndpoint extends NamedResource {
         ObjectMapper mapper = new ObjectMapper();
         org.apache.usergrid.rest.test.resource.model.ApiResponse response;
         try {
-            response = mapper.readValue(
-                new StringReader(responseString), org.apache.usergrid.rest.test.resource.model.ApiResponse.class);
+            response = mapper.readValue( new StringReader(responseString),
+                org.apache.usergrid.rest.test.resource.model.ApiResponse.class);
         } catch (IOException e) {
             throw new RuntimeException("Error parsing response", e);
         }
@@ -351,8 +357,8 @@ public class CollectionEndpoint extends NamedResource {
         ObjectMapper mapper = new ObjectMapper();
         org.apache.usergrid.rest.test.resource.model.ApiResponse response;
         try {
-            response = mapper.readValue(
-                new StringReader(responseString), org.apache.usergrid.rest.test.resource.model.ApiResponse.class);
+            response = mapper.readValue( new StringReader(responseString),
+                org.apache.usergrid.rest.test.resource.model.ApiResponse.class);
         } catch (IOException e) {
             throw new RuntimeException("Error parsing response", e);
         }
@@ -360,7 +366,8 @@ public class CollectionEndpoint extends NamedResource {
         return response;
     }
 
-    public CollectionEndpoint matrix(org.apache.usergrid.rest.test.resource.model.QueryParameters parameters) {
+    public CollectionEndpoint matrix(
+        org.apache.usergrid.rest.test.resource.model.QueryParameters parameters) {
         this.matrix = getMatrixValue(parameters);
         return this;
     }

http://git-wip-us.apache.org/repos/asf/usergrid/blob/dfa65d61/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/NamedResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/NamedResource.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/NamedResource.java
index 34e3a84..dc6de4b 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/NamedResource.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/NamedResource.java
@@ -24,6 +24,8 @@ import org.apache.usergrid.rest.test.resource.model.Token;
 import org.apache.usergrid.rest.test.resource.state.ClientContext;
 import static org.glassfish.jersey.client.authentication.HttpAuthenticationFeature.HTTP_AUTHENTICATION_BASIC_USERNAME;
 import static org.glassfish.jersey.client.authentication.HttpAuthenticationFeature.HTTP_AUTHENTICATION_BASIC_PASSWORD;
+
+import org.glassfish.jersey.client.authentication.HttpAuthenticationFeature;
 import org.glassfish.jersey.media.multipart.FormDataMultiPart;
 import org.glassfish.jersey.media.multipart.MultiPart;
 
@@ -243,21 +245,20 @@ public class NamedResource implements UrlResource {
 
         WebTarget resource = getTarget( useToken );
         resource = addParametersToResource(resource, queryParameters);
-        Invocation.Builder builder = resource.request()
-            .accept( MediaType.APPLICATION_JSON );
 
+        GenericType<T> gt = new GenericType<>((Class) type);
 
         if ( useBasicAuthentication ) {
-            String uname = (String)entity.get("username");
-            String pword = (String)entity.get("password");
-            builder = builder.property( HTTP_AUTHENTICATION_BASIC_USERNAME, uname )
-                             .property( HTTP_AUTHENTICATION_BASIC_PASSWORD, pword );
+            HttpAuthenticationFeature feature = HttpAuthenticationFeature.basicBuilder()
+                .credentials( "superuser", "superpassword" ).build();
+            return resource.register( feature ).request()
+                .accept( MediaType.APPLICATION_JSON )
+                .post( javax.ws.rs.client.Entity.json( entity ), gt );
         }
 
-        // it's OK for the entity to be null
-        GenericType<T> gt = new GenericType<>((Class) type);
-        return builder.post( javax.ws.rs.client.Entity.json( entity ), gt );
-
+        return resource.request()
+            .accept( MediaType.APPLICATION_JSON )
+            .post( javax.ws.rs.client.Entity.json( entity ), gt );
     }
 
     //For edge cases like Organizations and Tokens without any payload


[46/54] usergrid git commit: Fix merge errors. Doh!

Posted by sn...@apache.org.
Fix merge errors. Doh!


Project: http://git-wip-us.apache.org/repos/asf/usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/usergrid/commit/5acb42ba
Tree: http://git-wip-us.apache.org/repos/asf/usergrid/tree/5acb42ba
Diff: http://git-wip-us.apache.org/repos/asf/usergrid/diff/5acb42ba

Branch: refs/heads/usergrid-1007-shiro-cache
Commit: 5acb42ba61246ba6b251c074b9a993dd7a5c2051
Parents: 65d2608
Author: Dave Johnson <sn...@apache.org>
Authored: Thu Sep 17 17:47:45 2015 -0400
Committer: Dave Johnson <sn...@apache.org>
Committed: Thu Sep 17 17:47:45 2015 -0400

----------------------------------------------------------------------
 .../org/apache/usergrid/tools/ExportAdmins.java    | 17 ++---------------
 1 file changed, 2 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/usergrid/blob/5acb42ba/stack/tools/src/main/java/org/apache/usergrid/tools/ExportAdmins.java
----------------------------------------------------------------------
diff --git a/stack/tools/src/main/java/org/apache/usergrid/tools/ExportAdmins.java b/stack/tools/src/main/java/org/apache/usergrid/tools/ExportAdmins.java
index 0bb74ab..b018cd5 100644
--- a/stack/tools/src/main/java/org/apache/usergrid/tools/ExportAdmins.java
+++ b/stack/tools/src/main/java/org/apache/usergrid/tools/ExportAdmins.java
@@ -23,9 +23,11 @@ import org.apache.commons.cli.Option;
 import org.apache.commons.cli.OptionBuilder;
 import org.apache.commons.cli.Options;
 import org.apache.usergrid.corepersistence.util.CpNamingUtils;
+import org.apache.usergrid.management.UserInfo;
 import org.apache.usergrid.persistence.Entity;
 import org.apache.usergrid.persistence.EntityManager;
 import org.apache.usergrid.persistence.Results;
+import org.apache.usergrid.persistence.index.query.Query;
 import org.apache.usergrid.utils.StringUtils;
 import org.codehaus.jackson.JsonGenerator;
 import org.slf4j.Logger;
@@ -385,13 +387,8 @@ public class ExportAdmins extends ExportingToolBase {
 
             task.orgNamesByUuid = managementService.getOrganizationsForAdminUser( task.adminUser.getUuid() );
 
-<<<<<<< HEAD
-            List<Org> orgs = orgMap.get( task.adminUser.getProperty( "username" ).toString().toLowerCase() );
-
-=======
             List<Org> orgs = userToOrgsMap.get( task.adminUser.getProperty( "username" ).toString().toLowerCase() );
 
->>>>>>> master
             if ( orgs != null && task.orgNamesByUuid.size() < orgs.size() ) {
 
                 // list of orgs from getOrganizationsForAdminUser() is less than expected, use userToOrgsMap
@@ -401,16 +398,6 @@ public class ExportAdmins extends ExportingToolBase {
                 }
                 task.orgNamesByUuid = bimap;
             }
-<<<<<<< HEAD
-
-            if ( task.orgNamesByUuid.isEmpty() ) {
-                logger.error("{}:{}:{} has no orgs", new Object[] {
-                        task.adminUser.getProperty("username"),
-                        task.adminUser.getProperty("email"),
-                        task.adminUser.getUuid() } );
-            }
-=======
->>>>>>> master
         }
     }
 


[26/54] usergrid git commit: Merge branch 'two-dot-o-dev' into usergrid-103-upgrade-jersey

Posted by sn...@apache.org.
Merge branch 'two-dot-o-dev' into usergrid-103-upgrade-jersey

Conflicts:
	stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/OrganizationResource.java
	stack/rest/src/main/java/org/apache/usergrid/rest/security/SecuredResourceFilterFactory.java
	stack/rest/src/main/java/org/apache/usergrid/rest/security/shiro/filters/BasicAuthSecurityFilter.java
	stack/rest/src/test/java/org/apache/usergrid/rest/applications/ApplicationResourceIT.java


Project: http://git-wip-us.apache.org/repos/asf/usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/usergrid/commit/d4e8be8b
Tree: http://git-wip-us.apache.org/repos/asf/usergrid/tree/d4e8be8b
Diff: http://git-wip-us.apache.org/repos/asf/usergrid/diff/d4e8be8b

Branch: refs/heads/usergrid-1007-shiro-cache
Commit: d4e8be8b09f914842407a35428617cd2f06db092
Parents: 2888a7c 2faa805
Author: Dave Johnson <sn...@apache.org>
Authored: Mon Sep 14 13:54:18 2015 -0400
Committer: Dave Johnson <sn...@apache.org>
Committed: Mon Sep 14 13:54:18 2015 -0400

----------------------------------------------------------------------
 .../creating-and-managing-notifications.md      |  2 +
 portal/bower.json                               |  2 +-
 portal/js/libs/usergrid.sdk.js                  |  8 ++-
 portal/package.json                             |  2 +-
 .../asyncevents/AmazonAsyncEventService.java    |  6 +-
 .../persistence/entities/Notification.java      | 13 ++--
 .../corepersistence/CpEntityMapUtilsTest.java   | 52 +++++++++++++--
 stack/corepersistence/model/pom.xml             |  6 +-
 .../model/entity/MapToEntityConverter.java      | 68 ++++++++++++--------
 .../queue/impl/QueueManagerFactoryImpl.java     | 16 ++++-
 .../rest/applications/ApplicationResource.java  | 11 +++-
 .../exceptions/AbstractExceptionMapper.java     | 13 ++--
 .../organizations/OrganizationResource.java     |  8 ++-
 .../security/SecuredResourceFilterFactory.java  | 46 ++++++-------
 .../shiro/filters/BasicAuthSecurityFilter.java  |  6 +-
 .../applications/ApplicationResourceIT.java     | 14 +++-
 stack/scripts/migrate_entity_data.py            | 17 +++++
 .../apache/usergrid/security/shiro/Realm.java   | 24 +++++++
 .../notifications/apns/APNsNotification.java    |  8 +--
 .../services/notifications/gcm/GCMAdapter.java  |  9 +--
 .../services/notifications/wns/WNSAdapter.java  | 13 +++-
 .../apns/NotificationsServiceIT.java            |  1 +
 .../gcm/NotificationsServiceIT.java             |  1 +
 23 files changed, 254 insertions(+), 92 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/usergrid/blob/d4e8be8b/stack/corepersistence/model/pom.xml
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/usergrid/blob/d4e8be8b/stack/rest/src/main/java/org/apache/usergrid/rest/applications/ApplicationResource.java
----------------------------------------------------------------------
diff --cc stack/rest/src/main/java/org/apache/usergrid/rest/applications/ApplicationResource.java
index afcbbaf,c521d4f..e830876
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/applications/ApplicationResource.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/applications/ApplicationResource.java
@@@ -34,9 -35,9 +34,10 @@@ import org.apache.usergrid.persistence.
  import org.apache.usergrid.persistence.SimpleEntityRef;
  import org.apache.usergrid.persistence.entities.Application;
  import org.apache.usergrid.persistence.entities.User;
+ import org.apache.usergrid.persistence.exceptions.EntityNotFoundException;
  import org.apache.usergrid.persistence.index.query.Identifier;
  import org.apache.usergrid.rest.AbstractContextResource;
 +import org.apache.usergrid.rest.ApiResponse;
  import org.apache.usergrid.rest.applications.assets.AssetsResource;
  import org.apache.usergrid.rest.applications.events.EventsResource;
  import org.apache.usergrid.rest.applications.queues.QueueResource;
@@@ -591,9 -591,14 +593,14 @@@ public class ApplicationResource extend
                  APIGEE_MOBILE_APM_CONFIG_JSON_KEY );
          //If there is no apm configuration then try to create apm config on the fly
          if ( value == null ) {
-             value = management.registerAppWithAPM( management.getOrganizationForApplication( applicationId ),
-                     management.getApplicationInfo( applicationId ) );
+             value = management.registerAppWithAPM(
+                 management.getOrganizationForApplication( applicationId ),
+                 management.getApplicationInfo( applicationId )
+             );
+         }
+         if(value==null){
+             throw new EntityNotFoundException("apigeeMobileConfig not found, it is possibly not enabled for your config.");
          }
 -        return new JSONWithPadding( value, callback );
 +        return value;
      }
  }

http://git-wip-us.apache.org/repos/asf/usergrid/blob/d4e8be8b/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/OrganizationResource.java
----------------------------------------------------------------------
diff --cc stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/OrganizationResource.java
index 8055849,5a55c9e..e1fde46
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/OrganizationResource.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/OrganizationResource.java
@@@ -362,11 -363,10 +363,11 @@@ public class OrganizationResource exten
      }
  
  
-     @RequireOrganizationAccess
 +    @JSONP
+     @RequireSystemAccess
      @GET
      @Path("config")
 -    public JSONWithPadding getConfig( @Context UriInfo ui,
 +    public ApiResponse getConfig( @Context UriInfo ui,
                                        @QueryParam("callback") @DefaultValue("callback") String callback )
              throws Exception {
  
@@@ -389,12 -389,11 +390,12 @@@
      }
  
  
-     @RequireOrganizationAccess
+     @RequireSystemAccess
      @Consumes(MediaType.APPLICATION_JSON)
 +    @JSONP
      @PUT
      @Path("config")
 -    public JSONWithPadding putConfig( @Context UriInfo ui, Map<String, Object> json,
 +    public ApiResponse putConfig( @Context UriInfo ui, Map<String, Object> json,
                                         @QueryParam("callback") @DefaultValue("callback") String callback )
              throws Exception {
  
@@@ -411,9 -410,12 +412,12 @@@
                  management.getOrganizationConfigByUuid( organization.getUuid() );
          orgConfig.addProperties(json);
          management.updateOrganizationConfig(orgConfig);
+ 
+         // refresh orgConfig -- to pick up removed entries and defaults
+         orgConfig = management.getOrganizationConfigByUuid( organization.getUuid() );
          response.setProperty( "configuration", management.getOrganizationConfigData( orgConfig ) );
  
 -        return new JSONWithPadding( response, callback );
 +        return response;
      }
  
  }

http://git-wip-us.apache.org/repos/asf/usergrid/blob/d4e8be8b/stack/rest/src/main/java/org/apache/usergrid/rest/security/SecuredResourceFilterFactory.java
----------------------------------------------------------------------
diff --cc stack/rest/src/main/java/org/apache/usergrid/rest/security/SecuredResourceFilterFactory.java
index f6edfcc,6f7d698..3a290d9
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/security/SecuredResourceFilterFactory.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/security/SecuredResourceFilterFactory.java
@@@ -52,11 -54,15 +52,12 @@@ import java.util.Properties
  
  import static org.apache.commons.lang.StringUtils.isNotEmpty;
  import static org.apache.usergrid.rest.exceptions.SecurityException.mappableSecurityException;
 -import static org.apache.usergrid.security.shiro.utils.SubjectUtils.isPermittedAccessToApplication;
 -import static org.apache.usergrid.security.shiro.utils.SubjectUtils.isPermittedAccessToOrganization;
 -import static org.apache.usergrid.security.shiro.utils.SubjectUtils.isUser;
 -import static org.apache.usergrid.security.shiro.utils.SubjectUtils.loginApplicationGuest;
+ import static org.apache.usergrid.security.shiro.Realm.ROLE_SERVICE_ADMIN;
 +import static org.apache.usergrid.security.shiro.utils.SubjectUtils.*;
  
  
 -@Component
 -public class SecuredResourceFilterFactory implements ResourceFilterFactory {
 +@Resource
 +public class SecuredResourceFilterFactory implements DynamicFeature {
  
      private static final Logger logger = LoggerFactory.getLogger( SecuredResourceFilterFactory.class );
  
@@@ -112,39 -119,43 +113,39 @@@
  
  
      @Override
 -    public List<ResourceFilter> create( AbstractMethod am ) {
 +    public void configure(ResourceInfo resourceInfo, FeatureContext featureContext) {
 +        Method am = resourceInfo.getResourceMethod();
 +
 +        logger.debug( "configure {} method {}",
 +            resourceInfo.getResourceClass().getSimpleName(), resourceInfo.getResourceMethod().getName() );
 +
          if ( am.isAnnotationPresent( RequireApplicationAccess.class ) ) {
 -            return Collections.<ResourceFilter>singletonList( new ApplicationFilter() );
 +            featureContext.register( ApplicationFilter.class );
          }
          else if ( am.isAnnotationPresent( RequireOrganizationAccess.class ) ) {
 -            return Collections.<ResourceFilter>singletonList( new OrganizationFilter() );
 +            featureContext.register( OrganizationFilter.class );
          }
          else if ( am.isAnnotationPresent( RequireSystemAccess.class ) ) {
 -            return Collections.<ResourceFilter>singletonList( new SystemFilter() );
 +            featureContext.register( SystemFilter.class );
          }
          else if ( am.isAnnotationPresent( RequireAdminUserAccess.class ) ) {
-             featureContext.register( AdminUserFilter.class );
 -            return Collections.<ResourceFilter>singletonList( new AdminUserFilter() );
++            featureContext.register( SystemFilter.AdminUserFilter.class );
          }
 -        return null;
 -    }
  
 +    }
  
 -    public abstract class AbstractFilter implements ResourceFilter, ContainerRequestFilter {
 -        public AbstractFilter() {
 -        }
 +    public static abstract class AbstractFilter implements ContainerRequestFilter {
  
 +        private UriInfo uriInfo;
  
 -        @Override
 -        public ContainerRequestFilter getRequestFilter() {
 -            return this;
 +        public AbstractFilter( UriInfo uriInfo ) {
 +            this.uriInfo = uriInfo;
          }
  
 -
          @Override
 -        public ContainerResponseFilter getResponseFilter() {
 -            return null;
 -        }
 -
 +        public void filter(ContainerRequestContext request) throws IOException {
  
 -        @Override
 -        public ContainerRequest filter( ContainerRequest request ) {
 -            logger.debug( "Filtering {}", request.getRequestUri().toString() );
 +            logger.debug( "Filtering {}", request.getUriInfo().getRequestUri().toString() );
  
              if ( request.getMethod().equalsIgnoreCase( "OPTIONS" ) ) {
                  logger.debug( "Skipping option request" );
@@@ -299,51 -291,44 +300,50 @@@
      }
  
  
 -    public class SystemFilter extends AbstractFilter {
 -        public SystemFilter() {
 +    @Resource
 +    public static class SystemFilter extends AbstractFilter {
 +
 +        @Inject
-         public SystemFilter( UriInfo uriInfo ) {
-             super(uriInfo);
++        public SystemFilter(UriInfo uriInfo) {
++            super( uriInfo );
          }
  
  
          @Override
-         public void authorize( ContainerRequestContext request ) {
 -        public void authorize( ContainerRequest request ) {
++        public void authorize(ContainerRequestContext request) {
              logger.debug( "SystemFilter.authorize" );
              try {
-                 if ( !request.getSecurityContext().isUserInRole( "sysadmin" ) ) {
 -                if ( !request.isUserInRole( ROLE_SERVICE_ADMIN ) ) {
++                if (!request.getSecurityContext().isUserInRole( ROLE_SERVICE_ADMIN )) {
                      logger.debug( "You are not the system admin." );
                      throw mappableSecurityException( "unauthorized", "No system access authorized",
 -                            SecurityException.REALM );
 +                        SecurityException.REALM );
                  }
--            }
--            catch ( IllegalStateException e ) {
--                logger.debug( "This is an invalid state",e );
-                 if ( ( request.getSecurityContext().getUserPrincipal() == null ) || !"sysadmin"
-                     .equals( request.getSecurityContext().getUserPrincipal().getName() ) ) {
 -                if ( ( request.getUserPrincipal() == null ) ||
 -                        !ROLE_SERVICE_ADMIN.equals( request.getUserPrincipal().getName() ) ) {
++            } catch (IllegalStateException e) {
++                logger.debug( "This is an invalid state", e );
++                if ((request.getSecurityContext().getUserPrincipal() == null) ||
++                    !ROLE_SERVICE_ADMIN.equals( request.getSecurityContext().getUserPrincipal().getName() )) {
                      throw mappableSecurityException( "unauthorized", "No system access authorized",
 -                            SecurityException.REALM );
 +                        SecurityException.REALM );
                  }
              }
          }
--    }
  
++        @Resource
++        public static class AdminUserFilter extends AbstractFilter {
  
-     @Resource
-     public static class AdminUserFilter extends AbstractFilter {
- 
-         @Inject
-         public AdminUserFilter( UriInfo uriInfo ) {
-             super(uriInfo);
 -    public class AdminUserFilter extends AbstractFilter {
 -        public AdminUserFilter() {
--        }
 -
++            @Inject
++            public AdminUserFilter(UriInfo uriInfo) {
++                super( uriInfo );
++            }
  
--        @Override
-         public void authorize( ContainerRequestContext request ) {
 -        public void authorize( ContainerRequest request ) {
--            logger.debug( "AdminUserFilter.authorize" );
--            if ( !isUser( getUserIdentifier() ) ) {
--                throw mappableSecurityException( "unauthorized", "No admin user access authorized" );
++            @Override
++            public void authorize(ContainerRequestContext request) {
++                logger.debug( "AdminUserFilter.authorize" );
++                if (!isUser( getUserIdentifier() )) {
++                    throw mappableSecurityException( "unauthorized", "No admin user access authorized" );
++                }
              }
          }
++
      }
  }

http://git-wip-us.apache.org/repos/asf/usergrid/blob/d4e8be8b/stack/rest/src/main/java/org/apache/usergrid/rest/security/shiro/filters/BasicAuthSecurityFilter.java
----------------------------------------------------------------------
diff --cc stack/rest/src/main/java/org/apache/usergrid/rest/security/shiro/filters/BasicAuthSecurityFilter.java
index cb0745a,d0fb3bf..1643501
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/security/shiro/filters/BasicAuthSecurityFilter.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/security/shiro/filters/BasicAuthSecurityFilter.java
@@@ -17,20 -17,22 +17,22 @@@
  package org.apache.usergrid.rest.security.shiro.filters;
  
  
 -import java.security.Principal;
 -import java.util.Map;
 -
 -import javax.ws.rs.core.SecurityContext;
 -
 +import org.apache.shiro.codec.Base64;
  import org.slf4j.Logger;
  import org.slf4j.LoggerFactory;
 -import org.springframework.stereotype.Component;
  
 -import org.apache.shiro.codec.Base64;
 -import static org.apache.usergrid.security.shiro.Realm.ROLE_SERVICE_ADMIN;
 +import javax.ws.rs.container.ContainerRequestContext;
 +import javax.ws.rs.container.PreMatching;
 +import javax.ws.rs.core.SecurityContext;
 +import javax.ws.rs.ext.Provider;
 +import java.security.Principal;
 +import java.util.Map;
  
 -import com.sun.jersey.spi.container.ContainerRequest;
++import static org.apache.usergrid.security.shiro.Realm.ROLE_SERVICE_ADMIN;
+ 
  
 -@Component
 +@Provider
 +@PreMatching
  public class BasicAuthSecurityFilter extends SecurityFilter {
  
      private static final Logger logger = LoggerFactory.getLogger( BasicAuthSecurityFilter.class );

http://git-wip-us.apache.org/repos/asf/usergrid/blob/d4e8be8b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/ApplicationResourceIT.java
----------------------------------------------------------------------
diff --cc stack/rest/src/test/java/org/apache/usergrid/rest/applications/ApplicationResourceIT.java
index bc24f5b,f7e8dc3..8a94760
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/ApplicationResourceIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/ApplicationResourceIT.java
@@@ -17,6 -17,11 +17,8 @@@
  package org.apache.usergrid.rest.applications;
  
  import com.fasterxml.jackson.databind.JsonNode;
 -import com.sun.jersey.api.client.ClientResponse.Status;
+ import com.sun.jersey.api.client.UniformInterfaceException;
 -import com.sun.jersey.api.client.WebResource;
 -import com.sun.jersey.api.representation.Form;
+ import junit.framework.Assert;
  import org.apache.commons.lang.RandomStringUtils;
  import org.apache.shiro.codec.Base64;
  import org.apache.usergrid.cassandra.SpringResource;
@@@ -32,12 -37,7 +34,12 @@@ import org.junit.Test
  import org.slf4j.Logger;
  import org.slf4j.LoggerFactory;
  
++import javax.ws.rs.ClientErrorException;
 +import javax.ws.rs.InternalServerErrorException;
 +import javax.ws.rs.client.Invocation;
- import javax.ws.rs.ClientErrorException;
 +import javax.ws.rs.core.Form;
  import javax.ws.rs.core.MediaType;
 +import javax.ws.rs.core.Response;
  import java.io.IOException;
  import java.util.HashMap;
  import java.util.Map;


[49/54] usergrid git commit: Fixes incorrect name issue

Posted by sn...@apache.org.
Fixes incorrect name issue


Project: http://git-wip-us.apache.org/repos/asf/usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/usergrid/commit/901d7c6f
Tree: http://git-wip-us.apache.org/repos/asf/usergrid/tree/901d7c6f
Diff: http://git-wip-us.apache.org/repos/asf/usergrid/diff/901d7c6f

Branch: refs/heads/usergrid-1007-shiro-cache
Commit: 901d7c6f76fa8143c3d19d5810ca925c0cf1d5b7
Parents: 2689a01
Author: Todd Nine <tn...@apigee.com>
Authored: Thu Sep 17 16:41:08 2015 -0600
Committer: Todd Nine <tn...@apigee.com>
Committed: Thu Sep 17 16:41:08 2015 -0600

----------------------------------------------------------------------
 .../usergrid/corepersistence/migration/CoreMigrationPlugin.java    | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/usergrid/blob/901d7c6f/stack/core/src/main/java/org/apache/usergrid/corepersistence/migration/CoreMigrationPlugin.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/migration/CoreMigrationPlugin.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/migration/CoreMigrationPlugin.java
index b69451a..b7529f8 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/migration/CoreMigrationPlugin.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/migration/CoreMigrationPlugin.java
@@ -36,7 +36,7 @@ import com.google.inject.Singleton;
 @Singleton
 public class CoreMigrationPlugin extends AbstractMigrationPlugin {
 
-    public static final String PLUGIN_NAME = "collections-entity-data";
+    public static final String PLUGIN_NAME = "core-data";
 
 
 


[21/54] usergrid git commit: Merge branch 'two-dot-o-dev' into usergrid-103-upgrade-jersey

Posted by sn...@apache.org.
Merge branch 'two-dot-o-dev' into usergrid-103-upgrade-jersey


Project: http://git-wip-us.apache.org/repos/asf/usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/usergrid/commit/4918a5a2
Tree: http://git-wip-us.apache.org/repos/asf/usergrid/tree/4918a5a2
Diff: http://git-wip-us.apache.org/repos/asf/usergrid/diff/4918a5a2

Branch: refs/heads/usergrid-1007-shiro-cache
Commit: 4918a5a2a0f2f5372a78da5cb119d7b24b6f6e82
Parents: 0db8622 2dd90b1
Author: Dave Johnson <sn...@apache.org>
Authored: Wed Sep 9 15:15:39 2015 -0400
Committer: Dave Johnson <sn...@apache.org>
Committed: Wed Sep 9 15:15:39 2015 -0400

----------------------------------------------------------------------
 .../service/StatusServiceImpl.java              | 22 ++++--
 .../usergrid/persistence/StatusServiceIT.java   | 75 ++++++++++++++++++++
 .../usergrid/rest/ApplicationsResource.java     |  3 +-
 3 files changed, 93 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/usergrid/blob/4918a5a2/stack/rest/src/main/java/org/apache/usergrid/rest/ApplicationsResource.java
----------------------------------------------------------------------


[36/54] usergrid git commit: clean up uuid to string code for index

Posted by sn...@apache.org.
clean up uuid to string code for index


Project: http://git-wip-us.apache.org/repos/asf/usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/usergrid/commit/a5620799
Tree: http://git-wip-us.apache.org/repos/asf/usergrid/tree/a5620799
Diff: http://git-wip-us.apache.org/repos/asf/usergrid/diff/a5620799

Branch: refs/heads/usergrid-1007-shiro-cache
Commit: a562079989cfe2d9ae46e0f8eb9ac07ded794023
Parents: 968496d
Author: Shawn Feldman <sf...@apache.org>
Authored: Wed Sep 16 07:40:07 2015 -0600
Committer: Shawn Feldman <sf...@apache.org>
Committed: Wed Sep 16 07:40:07 2015 -0600

----------------------------------------------------------------------
 .../usergrid/persistence/index/impl/EsQueryVistor.java  | 12 ++++--------
 .../persistence/index/impl/EntityIndexTest.java         |  1 +
 2 files changed, 5 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/usergrid/blob/a5620799/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsQueryVistor.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsQueryVistor.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsQueryVistor.java
index af60ed6..414f716 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsQueryVistor.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsQueryVistor.java
@@ -361,9 +361,9 @@ public class EsQueryVistor implements QueryVisitor {
         final String name = op.getProperty().getValue().toLowerCase();
         final Object value = op.getLiteral().getValue();
 
-        //special case so we support our '*' char with wildcard
+        //special case so we support our '*' char with wildcard, also should work for uuids
         if ( value instanceof String || value instanceof UUID ) {
-            final String stringValue = (value.toString()).toLowerCase().trim();
+            final String stringValue = ((value instanceof String) ? (String)value : value.toString()).toLowerCase().trim();
 
             // or field is just a string that does need a prefix us a query
             if ( stringValue.contains( "*" ) ) {
@@ -503,11 +503,7 @@ public class EsQueryVistor implements QueryVisitor {
      * Get the field name for the primitive type
      */
     private String getFieldNameForType( final Object object ) {
-        if ( object instanceof String) {
-            return IndexingUtils.FIELD_STRING_NESTED;
-        }
-
-        if(object instanceof UUID){
+        if ( object instanceof String || object instanceof UUID) {
             return IndexingUtils.FIELD_STRING_NESTED;
         }
 
@@ -540,7 +536,7 @@ public class EsQueryVistor implements QueryVisitor {
         }
 
         if ( input instanceof UUID ) {
-            return  input.toString() ;
+            return input.toString().toLowerCase() ;
         }
 
         return input;

http://git-wip-us.apache.org/repos/asf/usergrid/blob/a5620799/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EntityIndexTest.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EntityIndexTest.java b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EntityIndexTest.java
index 7aa97b1..6348a44 100644
--- a/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EntityIndexTest.java
+++ b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EntityIndexTest.java
@@ -179,6 +179,7 @@ public class EntityIndexTest extends BaseIT {
         assertEquals( entity2.getId(), candidate2.getId() );
         assertEquals( entity2.getVersion(), candidate2.getVersion() );
 
+        //make sure we can query uuids out as strings and not wrapped
         candidateResults =
             entityIndex.search( indexEdge, searchTypes, "select * where testuuid = '"+uuid+"'", 100, 0 );
         assertEquals(entity1.getId(),candidateResults.get(0).getId());


[16/54] usergrid git commit: use string constants wherever possible in @Produces annotations.

Posted by sn...@apache.org.
use string constants wherever possible in @Produces annotations.


Project: http://git-wip-us.apache.org/repos/asf/usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/usergrid/commit/3749e741
Tree: http://git-wip-us.apache.org/repos/asf/usergrid/tree/3749e741
Diff: http://git-wip-us.apache.org/repos/asf/usergrid/diff/3749e741

Branch: refs/heads/usergrid-1007-shiro-cache
Commit: 3749e7415197863b8fd0f8af3bbcdec59ba137fc
Parents: ed3ba7c
Author: Dave Johnson <sn...@apache.org>
Authored: Tue Sep 8 16:38:43 2015 -0400
Committer: Dave Johnson <sn...@apache.org>
Committed: Tue Sep 8 16:38:43 2015 -0400

----------------------------------------------------------------------
 .../org/apache/usergrid/rest/IndexResource.java | 18 ++++++-------
 .../apache/usergrid/rest/MigrateResource.java   | 10 +++----
 .../org/apache/usergrid/rest/RootResource.java  |  8 +++---
 .../apache/usergrid/rest/SwaggerServlet.java    |  5 ++--
 .../apache/usergrid/rest/SystemResource.java    |  4 +--
 .../usergrid/rest/TextToJsonSwapWriter.java     |  2 +-
 .../rest/applications/ApplicationResource.java  |  6 ++---
 .../rest/applications/ServiceResource.java      | 12 ++++-----
 .../applications/assets/AssetsResource.java     |  4 +--
 .../applications/events/EventsResource.java     |  2 +-
 .../notifiers/NotifierResource.java             |  2 +-
 .../notifiers/NotifiersResource.java            |  2 +-
 .../rest/applications/queues/QueueResource.java | 12 ++++-----
 .../queues/QueueSubscriberResource.java         |  8 +++---
 .../queues/QueueSubscriptionResource.java       |  8 +++---
 .../queues/QueueTransactionsResource.java       |  4 +--
 .../rest/applications/users/UserResource.java   | 28 ++++++++++----------
 .../rest/applications/users/UsersResource.java  |  4 +--
 .../exceptions/SecurityExceptionMapper.java     |  3 ++-
 .../organizations/OrganizationResource.java     | 12 ++++-----
 .../organizations/OrganizationsResource.java    |  6 ++---
 .../applications/ApplicationResource.java       | 12 ++++-----
 .../applications/ApplicationsResource.java      |  6 ++---
 .../imports/FileErrorsResource.java             |  4 +--
 .../imports/FileIncludesResource.java           |  4 +--
 .../applications/imports/ImportsResource.java   |  6 ++---
 .../organizations/users/UsersResource.java      | 16 +++++------
 .../rest/management/users/UserResource.java     | 20 +++++++-------
 .../organizations/OrganizationsResource.java    | 14 +++++-----
 .../ShiroAuthenticationExceptionMapper.java     |  3 ++-
 30 files changed, 124 insertions(+), 121 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/usergrid/blob/3749e741/stack/rest/src/main/java/org/apache/usergrid/rest/IndexResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/IndexResource.java b/stack/rest/src/main/java/org/apache/usergrid/rest/IndexResource.java
index a785c0b..adeb06b 100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/IndexResource.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/IndexResource.java
@@ -83,7 +83,7 @@ public class IndexResource extends AbstractContextResource {
     @GET
     @Path( "rebuild/{jobId}" )
     @JSONP
-    @Produces({"application/json", "application/javascript"})
+    @Produces({ MediaType.APPLICATION_JSON, "application/javascript" })
     public ApiResponse rebuildIndexesGet(
         @PathParam( "jobId" ) String jobId,
         @QueryParam( "callback" ) @DefaultValue( "callback" ) String callback )
@@ -114,7 +114,7 @@ public class IndexResource extends AbstractContextResource {
     @PUT
     @Path( "rebuild" )
     @JSONP
-    @Produces({"application/json", "application/javascript"})
+    @Produces({MediaType.APPLICATION_JSON, "application/javascript"})
     public ApiResponse rebuildIndexesPut( final Map<String, Object> payload,
                                               @QueryParam( "callback" ) @DefaultValue( "callback" ) String callback )
         throws Exception {
@@ -131,7 +131,7 @@ public class IndexResource extends AbstractContextResource {
     @POST
     @Path( "rebuild/" + RootResource.APPLICATION_ID_PATH )
     @JSONP
-    @Produces({"application/json", "application/javascript"})
+    @Produces({MediaType.APPLICATION_JSON, "application/javascript"})
     public ApiResponse rebuildIndexesPut( @PathParam( "applicationId" ) String applicationIdStr,
                                               @QueryParam( "callback" ) @DefaultValue( "callback" ) String callback,
                                               @QueryParam( "delay" ) @DefaultValue( "10" ) final long delay )
@@ -154,7 +154,7 @@ public class IndexResource extends AbstractContextResource {
     @PUT
     @Path( "rebuild/" + RootResource.APPLICATION_ID_PATH )
     @JSONP
-    @Produces({"application/json", "application/javascript"})
+    @Produces({MediaType.APPLICATION_JSON, "application/javascript"})
     public ApiResponse rebuildIndexesPut( final Map<String, Object> payload,
                                               @PathParam( "applicationId" ) String applicationIdStr,
                                               @QueryParam( "callback" ) @DefaultValue( "callback" ) String callback,
@@ -176,7 +176,7 @@ public class IndexResource extends AbstractContextResource {
     @POST
     @Path( "rebuild/" + RootResource.APPLICATION_ID_PATH + "/{collectionName}" )
     @JSONP
-    @Produces({"application/json", "application/javascript"})
+    @Produces({MediaType.APPLICATION_JSON, "application/javascript"})
     public ApiResponse rebuildIndexesPost( @PathParam( "applicationId" ) final String applicationIdStr,
                                                @PathParam( "collectionName" ) final String collectionName,
                                                @QueryParam( "reverse" ) @DefaultValue( "false" ) final Boolean reverse,
@@ -199,7 +199,7 @@ public class IndexResource extends AbstractContextResource {
     @PUT
     @Path( "rebuild/" + RootResource.APPLICATION_ID_PATH + "/{collectionName}" )
     @JSONP
-    @Produces({"application/json", "application/javascript"})
+    @Produces({MediaType.APPLICATION_JSON, "application/javascript"})
     public ApiResponse rebuildIndexesPut( final Map<String, Object> payload,
                                               @PathParam( "applicationId" ) final String applicationIdStr,
                                               @PathParam( "collectionName" ) final String collectionName,
@@ -222,7 +222,7 @@ public class IndexResource extends AbstractContextResource {
     @POST
     @Path( "rebuild/management" )
     @JSONP
-    @Produces({"application/json", "application/javascript"})
+    @Produces({MediaType.APPLICATION_JSON, "application/javascript"})
     public ApiResponse rebuildInternalIndexesPost(
         @QueryParam( "callback" ) @DefaultValue( "callback" ) String callback ) throws Exception {
 
@@ -240,7 +240,7 @@ public class IndexResource extends AbstractContextResource {
     @PUT
     @Path( "rebuild/management" )
     @JSONP
-    @Produces({"application/json", "application/javascript"})
+    @Produces({MediaType.APPLICATION_JSON, "application/javascript"})
     public ApiResponse rebuildInternalIndexesPut( final Map<String, Object> payload,
                                                       @QueryParam( "callback" ) @DefaultValue( "callback" )
                                                       String callback ) throws Exception {
@@ -259,7 +259,7 @@ public class IndexResource extends AbstractContextResource {
     @POST
     @Path(RootResource.APPLICATION_ID_PATH)
     @JSONP
-    @Produces({"application/json", "application/javascript"})
+    @Produces({MediaType.APPLICATION_JSON, "application/javascript"})
     public ApiResponse addIndex( @Context UriInfo ui,
                                      @PathParam( "applicationId" ) final String applicationIdStr,
                                      Map<String, Object> config,

http://git-wip-us.apache.org/repos/asf/usergrid/blob/3749e741/stack/rest/src/main/java/org/apache/usergrid/rest/MigrateResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/MigrateResource.java b/stack/rest/src/main/java/org/apache/usergrid/rest/MigrateResource.java
index 168a3b7..800ded8 100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/MigrateResource.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/MigrateResource.java
@@ -66,7 +66,7 @@ public class MigrateResource extends AbstractContextResource {
     @PUT
     @Path( "run" )
     @JSONP
-    @Produces({"application/json", "application/javascript"})
+    @Produces({MediaType.APPLICATION_JSON, "application/javascript"})
     public ApiResponse migrateData( @Context UriInfo ui,
                                         @QueryParam( "callback" ) @DefaultValue( "callback" ) String callback )
         throws Exception {
@@ -114,7 +114,7 @@ public class MigrateResource extends AbstractContextResource {
     @PUT
     @Path( "run/{pluginName}" )
     @JSONP
-    @Produces({"application/json", "application/javascript"})
+    @Produces({MediaType.APPLICATION_JSON, "application/javascript"})
     public ApiResponse migrateData(@PathParam("pluginName") String pluginName ,  @Context UriInfo ui,
                                         @QueryParam( "callback" ) @DefaultValue( "callback" ) String callback )
         throws Exception {
@@ -159,7 +159,7 @@ public class MigrateResource extends AbstractContextResource {
     @PUT
     @Path( "set" )
     @JSONP
-    @Produces({"application/json", "application/javascript"})
+    @Produces({MediaType.APPLICATION_JSON, "application/javascript"})
     public ApiResponse setMigrationVersion(
         @Context UriInfo ui, Map<String, Object> json,
         @QueryParam( "callback" ) @DefaultValue( "" ) String callback )
@@ -208,7 +208,7 @@ public class MigrateResource extends AbstractContextResource {
     @GET
     @Path( "status" )
     @JSONP
-    @Produces({"application/json", "application/javascript"})
+    @Produces({MediaType.APPLICATION_JSON, "application/javascript"})
     public ApiResponse migrateStatus(
         @Context UriInfo ui,
         @QueryParam( "callback" ) @DefaultValue( "callback" ) String callback )
@@ -241,7 +241,7 @@ public class MigrateResource extends AbstractContextResource {
     @GET
     @Path( "count" )
     @JSONP
-    @Produces({"application/json", "application/javascript"})
+    @Produces({MediaType.APPLICATION_JSON, "application/javascript"})
     public ApiResponse migrateCount(
         @Context UriInfo ui,
         @QueryParam( "callback" ) @DefaultValue( "callback" ) String callback )

http://git-wip-us.apache.org/repos/asf/usergrid/blob/3749e741/stack/rest/src/main/java/org/apache/usergrid/rest/RootResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/RootResource.java b/stack/rest/src/main/java/org/apache/usergrid/rest/RootResource.java
index 8875295..4afccf9 100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/RootResource.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/RootResource.java
@@ -96,7 +96,7 @@ public class RootResource extends AbstractContextResource implements MetricProce
     @GET
     @Path("applications")
     @JSONP
-    @Produces({"application/json", "application/javascript"})
+    @Produces({MediaType.APPLICATION_JSON, "application/javascript"})
     public ApiResponse getAllApplications(
         @Context UriInfo ui,
         @QueryParam("deleted") @DefaultValue("false") Boolean deleted,
@@ -130,7 +130,7 @@ public class RootResource extends AbstractContextResource implements MetricProce
     @GET
     @Path("apps")
     @JSONP
-    @Produces({"application/json", "application/javascript"})
+    @Produces({MediaType.APPLICATION_JSON, "application/javascript"})
     public ApiResponse getAllApplications2( @Context UriInfo ui,
                                                 @QueryParam("callback") @DefaultValue("callback") String callback )
             throws URISyntaxException {
@@ -165,7 +165,7 @@ public class RootResource extends AbstractContextResource implements MetricProce
     @GET
     @Path("status")
     @JSONP
-    @Produces({"application/json", "application/javascript"})
+    @Produces({MediaType.APPLICATION_JSON, "application/javascript"})
     public ApiResponse getStatus(
             @QueryParam("ignore_error") @DefaultValue("true") Boolean ignoreError,
             @QueryParam("callback") @DefaultValue("callback") String callback ) {
@@ -212,7 +212,7 @@ public class RootResource extends AbstractContextResource implements MetricProce
     @GET
     @Path("lb-status")
     @JSONP
-    @Produces({"application/json", "application/javascript"})
+    @Produces({MediaType.APPLICATION_JSON, "application/javascript"})
     public Response getLbStatus() {
         ResponseBuilder response;
         if ( usergridSystemMonitor.getIsCassandraAlive() ) {

http://git-wip-us.apache.org/repos/asf/usergrid/blob/3749e741/stack/rest/src/main/java/org/apache/usergrid/rest/SwaggerServlet.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/SwaggerServlet.java b/stack/rest/src/main/java/org/apache/usergrid/rest/SwaggerServlet.java
index 9db6ff4..e3a655b 100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/SwaggerServlet.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/SwaggerServlet.java
@@ -33,6 +33,7 @@ import javax.servlet.ServletResponse;
 import javax.servlet.http.HttpServlet;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
+import javax.ws.rs.core.MediaType;
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -85,7 +86,7 @@ public class SwaggerServlet extends HttpServlet implements Filter {
         if ( sc == null ) {
             return null;
         }
-        ApplicationContext appContext = 
+        ApplicationContext appContext =
                 WebApplicationContextUtils.getRequiredWebApplicationContext( sc );
         return appContext.getBean( beanName );
     }
@@ -162,7 +163,7 @@ public class SwaggerServlet extends HttpServlet implements Filter {
             if ( json != null ) {
                 allowAllOrigins( request, response );
                 if ( "get".equalsIgnoreCase( request.getMethod() ) ) {
-                    response.setContentType( "application/json" );
+                    response.setContentType( MediaType.APPLICATION_JSON );
                     response.getWriter().print( json );
                     return true;
                 }

http://git-wip-us.apache.org/repos/asf/usergrid/blob/3749e741/stack/rest/src/main/java/org/apache/usergrid/rest/SystemResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/SystemResource.java b/stack/rest/src/main/java/org/apache/usergrid/rest/SystemResource.java
index 0a09eba..bf2882c 100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/SystemResource.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/SystemResource.java
@@ -51,7 +51,7 @@ public class SystemResource extends AbstractContextResource {
     @GET
     @Path( "database/setup" )
     @JSONP
-    @Produces({"application/json", "application/javascript"})
+    @Produces({MediaType.APPLICATION_JSON, "application/javascript"})
     public ApiResponse getSetup( @Context UriInfo ui,
                                      @QueryParam( "callback" ) @DefaultValue( "callback" ) String callback )
             throws Exception {
@@ -77,7 +77,7 @@ public class SystemResource extends AbstractContextResource {
     @GET
     @Path( "superuser/setup" )
     @JSONP
-    @Produces({"application/json", "application/javascript"})
+    @Produces({MediaType.APPLICATION_JSON, "application/javascript"})
     public ApiResponse getSetupSuperuser( @Context UriInfo ui,
                                               @QueryParam( "callback" ) @DefaultValue( "callback" ) String callback )
             throws Exception {

http://git-wip-us.apache.org/repos/asf/usergrid/blob/3749e741/stack/rest/src/main/java/org/apache/usergrid/rest/TextToJsonSwapWriter.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/TextToJsonSwapWriter.java b/stack/rest/src/main/java/org/apache/usergrid/rest/TextToJsonSwapWriter.java
index f4067df..7a9b2d5 100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/TextToJsonSwapWriter.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/TextToJsonSwapWriter.java
@@ -40,7 +40,7 @@ import org.glassfish.jersey.server.mvc.Viewable;
 // TODO: text to JSON swapping for Jersey 2
 
 /**
- * A writer that will redirect requests for "text/html" to "application/json" if the value
+ * A writer that will redirect requests for "text/html" to MediaType.APPLICATION_JSON if the value
  * returned by the resource is an instance of JSONWithPadding
  *
  * @author tnine

http://git-wip-us.apache.org/repos/asf/usergrid/blob/3749e741/stack/rest/src/main/java/org/apache/usergrid/rest/applications/ApplicationResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/applications/ApplicationResource.java b/stack/rest/src/main/java/org/apache/usergrid/rest/applications/ApplicationResource.java
index f2bd8fc..7dc6717 100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/applications/ApplicationResource.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/applications/ApplicationResource.java
@@ -355,7 +355,7 @@ public class ApplicationResource extends ServiceResource {
     @Path("credentials")
     @RequireApplicationAccess
     @JSONP
-    @Produces({"application/json", "application/javascript"})
+    @Produces({MediaType.APPLICATION_JSON, "application/javascript"})
     public ApiResponse getKeys( @Context UriInfo ui,
                                     @QueryParam("callback") @DefaultValue("callback") String callback )
             throws Exception {
@@ -378,7 +378,7 @@ public class ApplicationResource extends ServiceResource {
     @Path("credentials")
     @RequireApplicationAccess
     @JSONP
-    @Produces({"application/json", "application/javascript"})
+    @Produces({MediaType.APPLICATION_JSON, "application/javascript"})
     public ApiResponse generateKeys( @Context UriInfo ui,
         @QueryParam("callback") @DefaultValue("callback") String callback ) throws Exception {
 
@@ -599,7 +599,7 @@ public class ApplicationResource extends ServiceResource {
     @GET
     @Path("apm/apigeeMobileConfig")
     @JSONP
-    @Produces({"application/json", "application/javascript"})
+    @Produces({MediaType.APPLICATION_JSON, "application/javascript"})
     public Object getAPMConfig( @Context UriInfo ui,
                                          @QueryParam("callback") @DefaultValue("callback") String callback )
             throws Exception {

http://git-wip-us.apache.org/repos/asf/usergrid/blob/3749e741/stack/rest/src/main/java/org/apache/usergrid/rest/applications/ServiceResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/applications/ServiceResource.java b/stack/rest/src/main/java/org/apache/usergrid/rest/applications/ServiceResource.java
index 6e10a9f..b0f1d51 100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/applications/ServiceResource.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/applications/ServiceResource.java
@@ -375,7 +375,7 @@ public class ServiceResource extends AbstractContextResource {
     @RequireApplicationAccess
     @Consumes(MediaType.APPLICATION_JSON)
     @JSONP
-    @Produces({"application/json", "application/javascript"})
+    @Produces({MediaType.APPLICATION_JSON, "application/javascript"})
     public ApiResponse executePost( @Context UriInfo ui, String body,
             @QueryParam("callback") @DefaultValue("callback") String callback ) throws Exception {
 
@@ -408,7 +408,7 @@ public class ServiceResource extends AbstractContextResource {
     @RequireApplicationAccess
     @Consumes(MediaType.APPLICATION_JSON)
     @JSONP
-    @Produces({"application/json", "application/javascript"})
+    @Produces({MediaType.APPLICATION_JSON, "application/javascript"})
     public ApiResponse executePut( @Context UriInfo ui, String body,
                                        @QueryParam("callback") @DefaultValue("callback") String callback )
             throws Exception {
@@ -425,7 +425,7 @@ public class ServiceResource extends AbstractContextResource {
     @DELETE
     @RequireApplicationAccess
     @JSONP
-    @Produces({"application/json", "application/javascript"})
+    @Produces({MediaType.APPLICATION_JSON, "application/javascript"})
     public ApiResponse executeDelete(
         @Context UriInfo ui,
         @QueryParam("callback") @DefaultValue("callback") String callback,
@@ -544,7 +544,7 @@ public class ServiceResource extends AbstractContextResource {
     @RequireApplicationAccess
     @Consumes(MediaType.MULTIPART_FORM_DATA)
     @JSONP
-    @Produces({"application/json", "application/javascript"})
+    @Produces({MediaType.APPLICATION_JSON, "application/javascript"})
     public ApiResponse executeMultiPartPost( @Context UriInfo ui,
                                                  @QueryParam("callback") @DefaultValue("callback") String callback,
                                                  FormDataMultiPart multiPart ) throws Exception {
@@ -558,7 +558,7 @@ public class ServiceResource extends AbstractContextResource {
     @RequireApplicationAccess
     @Consumes(MediaType.MULTIPART_FORM_DATA)
     @JSONP
-    @Produces({"application/json", "application/javascript"})
+    @Produces({MediaType.APPLICATION_JSON, "application/javascript"})
     public ApiResponse executeMultiPartPut( @Context UriInfo ui,
                                                 @QueryParam("callback") @DefaultValue("callback") String callback,
                                                 FormDataMultiPart multiPart ) throws Exception {
@@ -569,7 +569,7 @@ public class ServiceResource extends AbstractContextResource {
 
 
     @JSONP
-    @Produces({"application/json", "application/javascript"})
+    @Produces({MediaType.APPLICATION_JSON, "application/javascript"})
     private ApiResponse executeMultiPart( UriInfo ui, String callback, FormDataMultiPart multiPart,
                                               ServiceAction serviceAction ) throws Exception {
 

http://git-wip-us.apache.org/repos/asf/usergrid/blob/3749e741/stack/rest/src/main/java/org/apache/usergrid/rest/applications/assets/AssetsResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/applications/assets/AssetsResource.java b/stack/rest/src/main/java/org/apache/usergrid/rest/applications/assets/AssetsResource.java
index 4e2e6bb..a8a106e 100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/applications/assets/AssetsResource.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/applications/assets/AssetsResource.java
@@ -82,7 +82,7 @@ public class AssetsResource extends ServiceResource {
     @RequireApplicationAccess
     @GET
     @JSONP
-    @Produces({"application/json", "application/javascript"})
+    @Produces({MediaType.APPLICATION_JSON, "application/javascript"})
     public ApiResponse executeGet( @Context UriInfo ui,
                                        @QueryParam("callback") @DefaultValue("callback") String callback )
             throws Exception {
@@ -96,7 +96,7 @@ public class AssetsResource extends ServiceResource {
     @RequireApplicationAccess
     @Consumes(MediaType.APPLICATION_JSON)
     @JSONP
-    @Produces({"application/json", "application/javascript"})
+    @Produces({MediaType.APPLICATION_JSON, "application/javascript"})
     public ApiResponse executePut( @Context UriInfo ui, String body,
                                        @QueryParam("callback") @DefaultValue("callback") String callback )
             throws Exception {

http://git-wip-us.apache.org/repos/asf/usergrid/blob/3749e741/stack/rest/src/main/java/org/apache/usergrid/rest/applications/events/EventsResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/applications/events/EventsResource.java b/stack/rest/src/main/java/org/apache/usergrid/rest/applications/events/EventsResource.java
index 5c528bd..d5709d7 100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/applications/events/EventsResource.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/applications/events/EventsResource.java
@@ -55,7 +55,7 @@ public class EventsResource extends ServiceResource {
 
     @GET
     @JSONP
-    @Produces({"application/json", "application/javascript"})
+    @Produces({MediaType.APPLICATION_JSON, "application/javascript"})
     public QueueResults executeQueueGet(
         @Context UriInfo ui, @QueryParam("callback") @DefaultValue("callback") String callback ) throws Exception {
 

http://git-wip-us.apache.org/repos/asf/usergrid/blob/3749e741/stack/rest/src/main/java/org/apache/usergrid/rest/applications/notifiers/NotifierResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/applications/notifiers/NotifierResource.java b/stack/rest/src/main/java/org/apache/usergrid/rest/applications/notifiers/NotifierResource.java
index 1997601..c01f6a9 100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/applications/notifiers/NotifierResource.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/applications/notifiers/NotifierResource.java
@@ -57,7 +57,7 @@ public class NotifierResource extends ServiceResource {
     @RequireApplicationAccess
     @Consumes(MediaType.MULTIPART_FORM_DATA)
     @JSONP
-    @Produces({"application/json", "application/javascript"})
+    @Produces({MediaType.APPLICATION_JSON, "application/javascript"})
     @Override
     public ApiResponse executeMultiPartPut(@Context UriInfo ui,
         @QueryParam("callback") @DefaultValue("callback") String callback,

http://git-wip-us.apache.org/repos/asf/usergrid/blob/3749e741/stack/rest/src/main/java/org/apache/usergrid/rest/applications/notifiers/NotifiersResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/applications/notifiers/NotifiersResource.java b/stack/rest/src/main/java/org/apache/usergrid/rest/applications/notifiers/NotifiersResource.java
index b72a857..48493ce 100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/applications/notifiers/NotifiersResource.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/applications/notifiers/NotifiersResource.java
@@ -104,7 +104,7 @@ public class NotifiersResource extends ServiceResource {
     @Consumes(MediaType.MULTIPART_FORM_DATA)
     @Override
     @JSONP
-    @Produces({"application/json", "application/javascript"})
+    @Produces({MediaType.APPLICATION_JSON, "application/javascript"})
     public ApiResponse executeMultiPartPost(
             @Context UriInfo ui,
             @QueryParam("callback") @DefaultValue("callback") String callback,

http://git-wip-us.apache.org/repos/asf/usergrid/blob/3749e741/stack/rest/src/main/java/org/apache/usergrid/rest/applications/queues/QueueResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/applications/queues/QueueResource.java b/stack/rest/src/main/java/org/apache/usergrid/rest/applications/queues/QueueResource.java
index 9b9207b..98edf1c 100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/applications/queues/QueueResource.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/applications/queues/QueueResource.java
@@ -91,7 +91,7 @@ public class QueueResource extends AbstractContextResource {
     @Path("properties")
     @GET
     @JSONP
-    @Produces({"application/json", "application/javascript"})
+    @Produces({MediaType.APPLICATION_JSON, "application/javascript"})
     public Queue getProperties( @Context UriInfo ui,
                                           @QueryParam("callback") @DefaultValue("callback") String callback )
             throws Exception {
@@ -106,7 +106,7 @@ public class QueueResource extends AbstractContextResource {
     @PUT
     @Consumes(MediaType.APPLICATION_JSON)
     @JSONP
-    @Produces({"application/json", "application/javascript"})
+    @Produces({MediaType.APPLICATION_JSON, "application/javascript"})
     public Queue putProperties( @Context UriInfo ui, Map<String, Object> json,
                                           @QueryParam("callback") @DefaultValue("callback") String callback )
             throws Exception {
@@ -119,7 +119,7 @@ public class QueueResource extends AbstractContextResource {
 
     @GET
     @JSONP
-    @Produces({"application/json", "application/javascript"})
+    @Produces({MediaType.APPLICATION_JSON, "application/javascript"})
     public Object executeGet( @Context UriInfo ui, @QueryParam("start") String firstQueuePath,
                                        @QueryParam("limit") @DefaultValue("10") int limit,
                                        @QueryParam("callback") @DefaultValue("callback") String callback )
@@ -143,7 +143,7 @@ public class QueueResource extends AbstractContextResource {
     @POST
     @Consumes(MediaType.APPLICATION_JSON)
     @JSONP
-    @Produces({"application/json", "application/javascript"})
+    @Produces({MediaType.APPLICATION_JSON, "application/javascript"})
     public QueueResults executePost( @Context UriInfo ui, Object body,
                                         @QueryParam("callback") @DefaultValue("callback") String callback )
             throws Exception {
@@ -165,7 +165,7 @@ public class QueueResource extends AbstractContextResource {
     @PUT
     @Consumes(MediaType.APPLICATION_JSON)
     @JSONP
-    @Produces({"application/json", "application/javascript"})
+    @Produces({MediaType.APPLICATION_JSON, "application/javascript"})
     public Map<String, Object> executePut( @Context UriInfo ui, Map<String, Object> json,
                                        @QueryParam("callback") @DefaultValue("callback") String callback )
             throws Exception {
@@ -180,7 +180,7 @@ public class QueueResource extends AbstractContextResource {
 
     @DELETE
     @JSONP
-    @Produces({"application/json", "application/javascript"})
+    @Produces({MediaType.APPLICATION_JSON, "application/javascript"})
     public Queue executeDelete(
             @Context UriInfo ui, @QueryParam("callback") @DefaultValue("callback") String callback ) throws Exception {
         throw new NotImplementedException( "Queue delete is not implemented yet" );

http://git-wip-us.apache.org/repos/asf/usergrid/blob/3749e741/stack/rest/src/main/java/org/apache/usergrid/rest/applications/queues/QueueSubscriberResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/applications/queues/QueueSubscriberResource.java b/stack/rest/src/main/java/org/apache/usergrid/rest/applications/queues/QueueSubscriberResource.java
index 5e6b57d..baa9535 100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/applications/queues/QueueSubscriberResource.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/applications/queues/QueueSubscriberResource.java
@@ -81,7 +81,7 @@ public class QueueSubscriberResource extends AbstractContextResource {
 
     @GET
     @JSONP
-    @Produces({"application/json", "application/javascript"})
+    @Produces({MediaType.APPLICATION_JSON, "application/javascript"})
     public QueueSet executeGet( @Context UriInfo ui, @QueryParam("start") String firstSubscriberQueuePath,
                                        @QueryParam("limit") @DefaultValue("10") int limit,
                                        @QueryParam("callback") @DefaultValue("callback") String callback )
@@ -98,7 +98,7 @@ public class QueueSubscriberResource extends AbstractContextResource {
     @POST
     @Consumes(MediaType.APPLICATION_JSON)
     @JSONP
-    @Produces({"application/json", "application/javascript"})
+    @Produces({MediaType.APPLICATION_JSON, "application/javascript"})
     public QueueSet executePost( @Context UriInfo ui, Map<String, Object> body,
                                         @QueryParam("callback") @DefaultValue("callback") String callback )
             throws Exception {
@@ -112,7 +112,7 @@ public class QueueSubscriberResource extends AbstractContextResource {
     @PUT
     @Consumes(MediaType.APPLICATION_JSON)
     @JSONP
-    @Produces({"application/json", "application/javascript"})
+    @Produces({MediaType.APPLICATION_JSON, "application/javascript"})
     public QueueSet executePut( @Context UriInfo ui, Map<String, Object> body,
                                        @QueryParam("callback") @DefaultValue("callback") String callback )
             throws Exception {
@@ -138,7 +138,7 @@ public class QueueSubscriberResource extends AbstractContextResource {
 
     @DELETE
     @JSONP
-    @Produces({"application/json", "application/javascript"})
+    @Produces({MediaType.APPLICATION_JSON, "application/javascript"})
     public QueueSet executeDelete( @Context UriInfo ui,
                                           @QueryParam("callback") @DefaultValue("callback") String callback )
             throws Exception {

http://git-wip-us.apache.org/repos/asf/usergrid/blob/3749e741/stack/rest/src/main/java/org/apache/usergrid/rest/applications/queues/QueueSubscriptionResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/applications/queues/QueueSubscriptionResource.java b/stack/rest/src/main/java/org/apache/usergrid/rest/applications/queues/QueueSubscriptionResource.java
index b99ecad..a21cd66 100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/applications/queues/QueueSubscriptionResource.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/applications/queues/QueueSubscriptionResource.java
@@ -83,7 +83,7 @@ public class QueueSubscriptionResource extends AbstractContextResource {
 
     @GET
     @JSONP
-    @Produces({"application/json", "application/javascript"})
+    @Produces({MediaType.APPLICATION_JSON, "application/javascript"})
     public QueueSet executeGet( @Context UriInfo ui, @QueryParam("start") String firstSubscriptionQueuePath,
                                        @QueryParam("limit") @DefaultValue("10") int limit,
                                        @QueryParam("callback") @DefaultValue("callback") String callback )
@@ -100,7 +100,7 @@ public class QueueSubscriptionResource extends AbstractContextResource {
     @POST
     @Consumes(MediaType.APPLICATION_JSON)
     @JSONP
-    @Produces({"application/json", "application/javascript"})
+    @Produces({MediaType.APPLICATION_JSON, "application/javascript"})
     public QueueSet executePost( @Context UriInfo ui, Map<String, Object> body,
                                         @QueryParam("callback") @DefaultValue("callback") String callback )
             throws Exception {
@@ -114,7 +114,7 @@ public class QueueSubscriptionResource extends AbstractContextResource {
     @PUT
     @Consumes(MediaType.APPLICATION_JSON)
     @JSONP
-    @Produces({"application/json", "application/javascript"})
+    @Produces({MediaType.APPLICATION_JSON, "application/javascript"})
     public QueueSet executePut( @Context UriInfo ui, Map<String, Object> body,
                                        @QueryParam("callback") @DefaultValue("callback") String callback )
             throws Exception {
@@ -140,7 +140,7 @@ public class QueueSubscriptionResource extends AbstractContextResource {
 
     @DELETE
     @JSONP
-    @Produces({"application/json", "application/javascript"})
+    @Produces({MediaType.APPLICATION_JSON, "application/javascript"})
     public QueueSet executeDelete( @Context UriInfo ui,
                                           @QueryParam("callback") @DefaultValue("callback") String callback )
             throws Exception {

http://git-wip-us.apache.org/repos/asf/usergrid/blob/3749e741/stack/rest/src/main/java/org/apache/usergrid/rest/applications/queues/QueueTransactionsResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/applications/queues/QueueTransactionsResource.java b/stack/rest/src/main/java/org/apache/usergrid/rest/applications/queues/QueueTransactionsResource.java
index 1e7e304..199e7f8 100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/applications/queues/QueueTransactionsResource.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/applications/queues/QueueTransactionsResource.java
@@ -65,7 +65,7 @@ public class QueueTransactionsResource extends AbstractContextResource {
     @Path("{id}")
     @PUT
     @JSONP
-    @Produces({"application/json", "application/javascript"})
+    @Produces({MediaType.APPLICATION_JSON, "application/javascript"})
     public Results updateTransaction( @Context UriInfo ui, @PathParam("id") UUID transactionId,
                                               @QueryParam("callback") @DefaultValue("callback") String callback )
             throws Exception {
@@ -81,7 +81,7 @@ public class QueueTransactionsResource extends AbstractContextResource {
     @Path("{id}")
     @DELETE
     @JSONP
-    @Produces({"application/json", "application/javascript"})
+    @Produces({MediaType.APPLICATION_JSON, "application/javascript"})
     public Results removeTransaction( @Context UriInfo ui, @PathParam("id") UUID transactionId,
                                               @QueryParam("callback") @DefaultValue("callback") String callback )
             throws Exception {

http://git-wip-us.apache.org/repos/asf/usergrid/blob/3749e741/stack/rest/src/main/java/org/apache/usergrid/rest/applications/users/UserResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/applications/users/UserResource.java b/stack/rest/src/main/java/org/apache/usergrid/rest/applications/users/UserResource.java
index 95adfc4..b84fc08 100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/applications/users/UserResource.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/applications/users/UserResource.java
@@ -84,7 +84,7 @@ public class UserResource extends ServiceResource {
     @RequireApplicationAccess
     @Consumes(MediaType.APPLICATION_JSON)
     @JSONP
-    @Produces({"application/json", "application/javascript"})
+    @Produces({MediaType.APPLICATION_JSON, "application/javascript"})
     public ApiResponse executePut( @Context UriInfo ui, String body,
                                        @QueryParam("callback") @DefaultValue("callback") String callback )
             throws Exception {
@@ -104,7 +104,7 @@ public class UserResource extends ServiceResource {
     @PUT
     @Path("password")
     @JSONP
-    @Produces({"application/json", "application/javascript"})
+    @Produces({MediaType.APPLICATION_JSON, "application/javascript"})
     public ApiResponse setUserPasswordPut( @Context UriInfo ui, Map<String, Object> json,
                                                @QueryParam("callback") @DefaultValue("callback") String callback )
             throws Exception {
@@ -150,7 +150,7 @@ public class UserResource extends ServiceResource {
     @POST
     @Path("password")
     @JSONP
-    @Produces({"application/json", "application/javascript"})
+    @Produces({MediaType.APPLICATION_JSON, "application/javascript"})
     public ApiResponse setUserPasswordPost( @Context UriInfo ui, Map<String, Object> json,
                                                 @QueryParam("callback") @DefaultValue("callback") String callback )
             throws Exception {
@@ -161,7 +161,7 @@ public class UserResource extends ServiceResource {
     @POST
     @Path("deactivate")
     @JSONP
-    @Produces({"application/json", "application/javascript"})
+    @Produces({MediaType.APPLICATION_JSON, "application/javascript"})
     public ApiResponse deactivate( @Context UriInfo ui, Map<String, Object> json,
                                        @QueryParam("callback") @DefaultValue("") String callback ) throws Exception {
 
@@ -179,7 +179,7 @@ public class UserResource extends ServiceResource {
     @GET
     @Path("sendpin")
     @JSONP
-    @Produces({"application/json", "application/javascript"})
+    @Produces({MediaType.APPLICATION_JSON, "application/javascript"})
     public ApiResponse sendPin( @Context UriInfo ui,
                                     @QueryParam("callback") @DefaultValue("callback") String callback )
             throws Exception {
@@ -203,7 +203,7 @@ public class UserResource extends ServiceResource {
     @POST
     @Path("sendpin")
     @JSONP
-    @Produces({"application/json", "application/javascript"})
+    @Produces({MediaType.APPLICATION_JSON, "application/javascript"})
     public ApiResponse postSendPin( @Context UriInfo ui,
                                         @QueryParam("callback") @DefaultValue("callback") String callback )
             throws Exception {
@@ -215,7 +215,7 @@ public class UserResource extends ServiceResource {
     @Path("setpin")
     @RequireApplicationAccess
     @JSONP
-    @Produces({"application/json", "application/javascript"})
+    @Produces({MediaType.APPLICATION_JSON, "application/javascript"})
     public ApiResponse setPin( @Context UriInfo ui, @QueryParam("pin") String pin,
                                    @QueryParam("callback") @DefaultValue("callback") String callback )
             throws Exception {
@@ -241,7 +241,7 @@ public class UserResource extends ServiceResource {
     @Consumes("application/x-www-form-urlencoded")
     @RequireApplicationAccess
     @JSONP
-    @Produces({"application/json", "application/javascript"})
+    @Produces({MediaType.APPLICATION_JSON, "application/javascript"})
     public ApiResponse postPin( @Context UriInfo ui, @FormParam("pin") String pin,
                                     @QueryParam("callback") @DefaultValue("callback") String callback )
             throws Exception {
@@ -267,7 +267,7 @@ public class UserResource extends ServiceResource {
     @Consumes(MediaType.APPLICATION_JSON)
     @RequireApplicationAccess
     @JSONP
-    @Produces({"application/json", "application/javascript"})
+    @Produces({MediaType.APPLICATION_JSON, "application/javascript"})
     public ApiResponse jsonPin( @Context UriInfo ui, JsonNode json,
                                     @QueryParam("callback") @DefaultValue("callback") String callback )
             throws Exception {
@@ -457,7 +457,7 @@ public class UserResource extends ServiceResource {
     @GET
     @Path("reactivate")
     @JSONP
-    @Produces({"application/json", "application/javascript"})
+    @Produces({MediaType.APPLICATION_JSON, "application/javascript"})
     public ApiResponse reactivate( @Context UriInfo ui,
                                        @QueryParam("callback") @DefaultValue("callback") String callback )
             throws Exception {
@@ -476,7 +476,7 @@ public class UserResource extends ServiceResource {
     @POST
     @Path("revoketokens")
     @JSONP
-    @Produces({"application/json", "application/javascript"})
+    @Produces({MediaType.APPLICATION_JSON, "application/javascript"})
     public ApiResponse revokeTokensPost( @Context UriInfo ui,
                                              @QueryParam("callback") @DefaultValue("callback") String callback )
             throws Exception {
@@ -495,7 +495,7 @@ public class UserResource extends ServiceResource {
     @PUT
     @Path("revoketokens")
     @JSONP
-    @Produces({"application/json", "application/javascript"})
+    @Produces({MediaType.APPLICATION_JSON, "application/javascript"})
     public ApiResponse revokeTokensPut( @Context UriInfo ui,
                                             @QueryParam("callback") @DefaultValue("callback") String callback )
             throws Exception {
@@ -506,7 +506,7 @@ public class UserResource extends ServiceResource {
     @POST
     @Path("revoketoken")
     @JSONP
-    @Produces({"application/json", "application/javascript"})
+    @Produces({MediaType.APPLICATION_JSON, "application/javascript"})
     public ApiResponse revokeTokenPost( @Context UriInfo ui,
                                             @QueryParam("callback") @DefaultValue("callback") String callback,
                                             @QueryParam("token") String token ) throws Exception {
@@ -525,7 +525,7 @@ public class UserResource extends ServiceResource {
     @PUT
     @Path("revoketoken")
     @JSONP
-    @Produces({"application/json", "application/javascript"})
+    @Produces({MediaType.APPLICATION_JSON, "application/javascript"})
     public ApiResponse revokeTokenPut( @Context UriInfo ui,
                                            @QueryParam("callback") @DefaultValue("callback") String callback,
                                            @QueryParam("token") String token ) throws Exception {

http://git-wip-us.apache.org/repos/asf/usergrid/blob/3749e741/stack/rest/src/main/java/org/apache/usergrid/rest/applications/users/UsersResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/applications/users/UsersResource.java b/stack/rest/src/main/java/org/apache/usergrid/rest/applications/users/UsersResource.java
index e39a311..3769449 100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/applications/users/UsersResource.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/applications/users/UsersResource.java
@@ -180,7 +180,7 @@ public class UsersResource extends ServiceResource {
     @Override
     @RequireApplicationAccess
     @JSONP
-    @Produces({"application/json", "application/javascript"})
+    @Produces({MediaType.APPLICATION_JSON, "application/javascript"})
     public ApiResponse executePut( @Context UriInfo ui, String body,
                                        @QueryParam("callback") @DefaultValue("callback") String callback )
             throws Exception {
@@ -204,7 +204,7 @@ public class UsersResource extends ServiceResource {
     @Override
     @RequireApplicationAccess
     @JSONP
-    @Produces({"application/json", "application/javascript"})
+    @Produces({MediaType.APPLICATION_JSON, "application/javascript"})
     public ApiResponse executePost( @Context UriInfo ui, String body,
                                         @QueryParam("callback") @DefaultValue("callback") String callback )
             throws Exception {

http://git-wip-us.apache.org/repos/asf/usergrid/blob/3749e741/stack/rest/src/main/java/org/apache/usergrid/rest/exceptions/SecurityExceptionMapper.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/exceptions/SecurityExceptionMapper.java b/stack/rest/src/main/java/org/apache/usergrid/rest/exceptions/SecurityExceptionMapper.java
index dc069e7..dcd59ce 100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/exceptions/SecurityExceptionMapper.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/exceptions/SecurityExceptionMapper.java
@@ -17,6 +17,7 @@
 package org.apache.usergrid.rest.exceptions;
 
 
+import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.Response;
 import javax.ws.rs.core.Response.Status;
 import javax.ws.rs.ext.Provider;
@@ -37,7 +38,7 @@ public class SecurityExceptionMapper extends AbstractExceptionMapper<SecurityExc
         if ( e.getRealm() != null ) {
             return Response.status( Status.UNAUTHORIZED )
                            .header( "WWW-Authenticate", "Basic realm=\"" + e.getRealm() + "\"" )
-                           .type( "application/json" ).entity( e.getJsonResponse() ).build();
+                           .type( MediaType.APPLICATION_JSON ).entity( e.getJsonResponse() ).build();
         }
         else {
             return toResponse( UNAUTHORIZED, e.getJsonResponse() );

http://git-wip-us.apache.org/repos/asf/usergrid/blob/3749e741/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/OrganizationResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/OrganizationResource.java b/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/OrganizationResource.java
index c43b463..2e17cfb 100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/OrganizationResource.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/OrganizationResource.java
@@ -108,7 +108,7 @@ public class OrganizationResource extends AbstractContextResource {
     @GET
     @JSONP
     @RequireOrganizationAccess
-    @Produces({"application/json", "application/javascript"})
+    @Produces({MediaType.APPLICATION_JSON, "application/javascript"})
     public ApiResponse getOrganizationDetails( @Context UriInfo ui,
                                                    @QueryParam("callback") @DefaultValue("callback") String callback )
             throws Exception {
@@ -170,7 +170,7 @@ public class OrganizationResource extends AbstractContextResource {
     @GET
     @Path("reactivate")
     @JSONP
-    @Produces({"application/json", "application/javascript"})
+    @Produces({MediaType.APPLICATION_JSON, "application/javascript"})
     public ApiResponse reactivate( @Context UriInfo ui,
                                        @QueryParam("callback") @DefaultValue("callback") String callback )
             throws Exception {
@@ -190,7 +190,7 @@ public class OrganizationResource extends AbstractContextResource {
     @GET
     @Path("feed")
     @JSONP
-    @Produces({"application/json", "application/javascript"})
+    @Produces({MediaType.APPLICATION_JSON, "application/javascript"})
     public ApiResponse getFeed( @Context UriInfo ui,
                                     @QueryParam("callback") @DefaultValue("callback") String callback )
             throws Exception {
@@ -210,7 +210,7 @@ public class OrganizationResource extends AbstractContextResource {
     @GET
     @Path("credentials")
     @JSONP
-    @Produces({"application/json", "application/javascript"})
+    @Produces({MediaType.APPLICATION_JSON, "application/javascript"})
     public ApiResponse getCredentials( @Context UriInfo ui,
                                            @QueryParam("callback") @DefaultValue("callback") String callback )
             throws Exception {
@@ -231,7 +231,7 @@ public class OrganizationResource extends AbstractContextResource {
     @POST
     @Path("credentials")
     @JSONP
-    @Produces({"application/json", "application/javascript"})
+    @Produces({MediaType.APPLICATION_JSON, "application/javascript"})
     public ApiResponse generateCredentials( @Context UriInfo ui,
                                                 @QueryParam("callback") @DefaultValue("callback") String callback )
             throws Exception {
@@ -257,7 +257,7 @@ public class OrganizationResource extends AbstractContextResource {
     @Consumes(MediaType.APPLICATION_JSON)
     @PUT
     @JSONP
-    @Produces({"application/json", "application/javascript"})
+    @Produces({MediaType.APPLICATION_JSON, "application/javascript"})
     public ApiResponse executePut( @Context UriInfo ui, Map<String, Object> json,
                                        @QueryParam("callback") @DefaultValue("callback") String callback )
             throws Exception {

http://git-wip-us.apache.org/repos/asf/usergrid/blob/3749e741/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/OrganizationsResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/OrganizationsResource.java b/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/OrganizationsResource.java
index 660e93d..daa7264 100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/OrganizationsResource.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/OrganizationsResource.java
@@ -100,7 +100,7 @@ public class OrganizationsResource extends AbstractContextResource {
     @POST
     @Consumes( MediaType.APPLICATION_JSON )
     @JSONP
-    @Produces({"application/json", "application/javascript"})
+    @Produces({MediaType.APPLICATION_JSON, "application/javascript"})
     public ApiResponse newOrganization( @Context UriInfo ui, Map<String, Object> json,
                                             @QueryParam( "callback" ) @DefaultValue( "" ) String callback )
             throws Exception {
@@ -127,7 +127,7 @@ public class OrganizationsResource extends AbstractContextResource {
     @POST
     @Consumes( MediaType.APPLICATION_FORM_URLENCODED )
     @JSONP
-    @Produces({"application/json", "application/javascript"})
+    @Produces({MediaType.APPLICATION_JSON, "application/javascript"})
     public ApiResponse newOrganizationFromForm( @Context UriInfo ui,
                                                     @FormParam( "organization" ) String organizationNameForm,
                                                     @QueryParam( "organization" ) String organizationNameQuery,
@@ -156,7 +156,7 @@ public class OrganizationsResource extends AbstractContextResource {
 
     /** Create a new organization */
     @JSONP
-    @Produces({"application/json", "application/javascript"})
+    @Produces({MediaType.APPLICATION_JSON, "application/javascript"})
     private ApiResponse newOrganization( @Context UriInfo ui, String organizationName, String username, String name,
                                              String email, String password, Map<String, Object> userProperties,
                                              Map<String, Object> orgProperties, String callback ) throws Exception {

http://git-wip-us.apache.org/repos/asf/usergrid/blob/3749e741/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/applications/ApplicationResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/applications/ApplicationResource.java b/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/applications/ApplicationResource.java
index ae60123..5c83bbc 100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/applications/ApplicationResource.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/applications/ApplicationResource.java
@@ -107,7 +107,7 @@ public class ApplicationResource extends AbstractContextResource {
     @RequireOrganizationAccess
     @GET
     @JSONP
-    @Produces({"application/json", "application/javascript"})
+    @Produces({MediaType.APPLICATION_JSON, "application/javascript"})
     public ApiResponse getApplication(
             @Context UriInfo ui, @QueryParam("callback") @DefaultValue("callback") String callback )
         throws Exception {
@@ -126,7 +126,7 @@ public class ApplicationResource extends AbstractContextResource {
     @GET
     @Path("credentials")
     @JSONP
-    @Produces({"application/json", "application/javascript"})
+    @Produces({MediaType.APPLICATION_JSON, "application/javascript"})
     public ApiResponse getCredentials(
             @Context UriInfo ui, @QueryParam("callback") @DefaultValue("callback") String callback )
         throws Exception {
@@ -147,7 +147,7 @@ public class ApplicationResource extends AbstractContextResource {
     @POST
     @Path("credentials")
     @JSONP
-    @Produces({"application/json", "application/javascript"})
+    @Produces({MediaType.APPLICATION_JSON, "application/javascript"})
     public ApiResponse generateCredentials( @Context UriInfo ui,
             @QueryParam("callback") @DefaultValue("callback") String callback )
         throws Exception {
@@ -169,7 +169,7 @@ public class ApplicationResource extends AbstractContextResource {
     @Consumes(APPLICATION_JSON)
     @RequireOrganizationAccess
     @JSONP
-    @Produces({"application/json", "application/javascript"})
+    @Produces({MediaType.APPLICATION_JSON, "application/javascript"})
     public ApiResponse configureProvider(
             @Context UriInfo ui,
             @QueryParam("provider_key") String siaProvider,
@@ -396,7 +396,7 @@ public class ApplicationResource extends AbstractContextResource {
     @PUT
     @RequireOrganizationAccess
     @JSONP
-    @Produces({"application/json", "application/javascript"})
+    @Produces({MediaType.APPLICATION_JSON, "application/javascript"})
     public ApiResponse executePut(  @Context UriInfo ui, String body,
         @QueryParam("callback") @DefaultValue("callback") String callback ) throws Exception {
 
@@ -418,7 +418,7 @@ public class ApplicationResource extends AbstractContextResource {
     @DELETE
     @RequireOrganizationAccess
     @JSONP
-    @Produces({"application/json", "application/javascript"})
+    @Produces({MediaType.APPLICATION_JSON, "application/javascript"})
     public ApiResponse executeDelete(  @Context UriInfo ui,
         @QueryParam("callback") @DefaultValue("callback") String callback,
         @QueryParam("app_delete_confirm") String confirmDelete) throws Exception {

http://git-wip-us.apache.org/repos/asf/usergrid/blob/3749e741/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/applications/ApplicationsResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/applications/ApplicationsResource.java b/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/applications/ApplicationsResource.java
index ef9a5f4..3b609b8 100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/applications/ApplicationsResource.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/applications/ApplicationsResource.java
@@ -69,7 +69,7 @@ public class ApplicationsResource extends AbstractContextResource {
     @RequireOrganizationAccess
     @GET
     @JSONP
-    @Produces({"application/json", "application/javascript"})
+    @Produces({MediaType.APPLICATION_JSON, "application/javascript"})
     public ApiResponse getOrganizationApplications(
         @Context UriInfo ui,
         @QueryParam( "deleted" ) @DefaultValue( "false" ) Boolean deleted, // only return deleted apps if true
@@ -89,7 +89,7 @@ public class ApplicationsResource extends AbstractContextResource {
     @POST
     @Consumes( MediaType.APPLICATION_JSON )
     @JSONP
-    @Produces({"application/json", "application/javascript"})
+    @Produces({MediaType.APPLICATION_JSON, "application/javascript"})
     public ApiResponse newApplicationForOrganization( @Context UriInfo ui, Map<String, Object> json,
                                                           @QueryParam( "callback" ) @DefaultValue( "callback" )
                                                           String callback ) throws Exception {
@@ -102,7 +102,7 @@ public class ApplicationsResource extends AbstractContextResource {
     @POST
     @Consumes( MediaType.APPLICATION_FORM_URLENCODED )
     @JSONP
-    @Produces({"application/json", "application/javascript"})
+    @Produces({MediaType.APPLICATION_JSON, "application/javascript"})
     public ApiResponse newApplicationForOrganizationFromForm( @Context UriInfo ui, Map<String, Object> json,
                                                                   @QueryParam( "callback" ) @DefaultValue( "callback" )
                                                                   String callback,

http://git-wip-us.apache.org/repos/asf/usergrid/blob/3749e741/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/applications/imports/FileErrorsResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/applications/imports/FileErrorsResource.java b/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/applications/imports/FileErrorsResource.java
index d9fc009..d9bc81b 100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/applications/imports/FileErrorsResource.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/applications/imports/FileErrorsResource.java
@@ -76,7 +76,7 @@ public class FileErrorsResource extends AbstractContextResource {
 
     @GET
     @JSONP
-    @Produces({"application/json", "application/javascript"})
+    @Produces({MediaType.APPLICATION_JSON, "application/javascript"})
     public ApiResponse getFileIncludes( @Context UriInfo ui, @QueryParam( "ql" ) String query, @QueryParam( "cursor" ) String cursor )
           throws Exception {
 
@@ -105,7 +105,7 @@ public class FileErrorsResource extends AbstractContextResource {
     @GET
     @Path( RootResource.ENTITY_ID_PATH )
     @JSONP
-    @Produces({"application/json", "application/javascript"})
+    @Produces({MediaType.APPLICATION_JSON, "application/javascript"})
     public ApiResponse getFileIncludeById( @Context UriInfo ui, @PathParam( "entityId" ) PathSegment entityId )
         throws Exception {
 

http://git-wip-us.apache.org/repos/asf/usergrid/blob/3749e741/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/applications/imports/FileIncludesResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/applications/imports/FileIncludesResource.java b/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/applications/imports/FileIncludesResource.java
index 708aa80..41ae84c 100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/applications/imports/FileIncludesResource.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/applications/imports/FileIncludesResource.java
@@ -80,7 +80,7 @@ public class FileIncludesResource extends AbstractContextResource {
 
     @GET
     @JSONP
-    @Produces({"application/json", "application/javascript"})
+    @Produces({MediaType.APPLICATION_JSON, "application/javascript"})
     public ApiResponse getFileIncludes( @Context UriInfo ui, @QueryParam( "ql" ) String query, @QueryParam( "cursor" ) String cursor )
           throws Exception {
 
@@ -108,7 +108,7 @@ public class FileIncludesResource extends AbstractContextResource {
     @GET
     @Path( RootResource.ENTITY_ID_PATH )
     @JSONP
-    @Produces({"application/json", "application/javascript"})
+    @Produces({MediaType.APPLICATION_JSON, "application/javascript"})
     public ApiResponse getFileIncludeById( @Context UriInfo ui, @PathParam( "entityId" ) PathSegment entityId )
         throws Exception {
 

http://git-wip-us.apache.org/repos/asf/usergrid/blob/3749e741/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/applications/imports/ImportsResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/applications/imports/ImportsResource.java b/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/applications/imports/ImportsResource.java
index d829f80..6f89f9e 100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/applications/imports/ImportsResource.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/applications/imports/ImportsResource.java
@@ -83,7 +83,7 @@ public class ImportsResource extends AbstractContextResource {
     @RequireOrganizationAccess
     @Consumes( MediaType.APPLICATION_JSON )
     @JSONP
-    @Produces({"application/json", "application/javascript"})
+    @Produces({MediaType.APPLICATION_JSON, "application/javascript"})
     public ApiResponse executePost( @Context UriInfo ui, String body,
                                         @QueryParam( "callback" ) @DefaultValue( "callback" ) String callback )
         throws Exception {
@@ -139,7 +139,7 @@ public class ImportsResource extends AbstractContextResource {
 
     @GET
     @JSONP
-    @Produces({"application/json", "application/javascript"})
+    @Produces({MediaType.APPLICATION_JSON, "application/javascript"})
     public ApiResponse getImports( @Context UriInfo ui, @QueryParam( "ql" ) String query,  @QueryParam( "cursor" ) String cursor ) throws Exception {
 
         final Results importResults = importService.getImports( application.getId(), query, cursor );
@@ -161,7 +161,7 @@ public class ImportsResource extends AbstractContextResource {
     @GET
     @Path( RootResource.ENTITY_ID_PATH )
     @JSONP
-    @Produces({"application/json", "application/javascript"})
+    @Produces({MediaType.APPLICATION_JSON, "application/javascript"})
     public ApiResponse getImportById( @Context UriInfo ui, @PathParam( "entityId" ) PathSegment entityId )
         throws Exception {
 

http://git-wip-us.apache.org/repos/asf/usergrid/blob/3749e741/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/users/UsersResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/users/UsersResource.java b/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/users/UsersResource.java
index a4e3f40..d0dfbdb 100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/users/UsersResource.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/users/UsersResource.java
@@ -72,7 +72,7 @@ public class UsersResource extends AbstractContextResource {
     @RequireOrganizationAccess
     @GET
     @JSONP
-    @Produces({"application/json", "application/javascript"})
+    @Produces({MediaType.APPLICATION_JSON, "application/javascript"})
     public ApiResponse getOrganizationUsers( @Context UriInfo ui,
                                                  @QueryParam("callback") @DefaultValue("callback") String callback )
             throws Exception {
@@ -90,7 +90,7 @@ public class UsersResource extends AbstractContextResource {
     @POST
     @Consumes(MediaType.APPLICATION_JSON)
     @JSONP
-    @Produces({"application/json", "application/javascript"})
+    @Produces({MediaType.APPLICATION_JSON, "application/javascript"})
     public ApiResponse newUserForOrganization( @Context UriInfo ui, Map<String, Object> json,
                                                    @QueryParam("callback") @DefaultValue("callback") String callback )
             throws Exception {
@@ -109,7 +109,7 @@ public class UsersResource extends AbstractContextResource {
     @POST
     @Consumes(MediaType.APPLICATION_FORM_URLENCODED)
     @JSONP
-    @Produces({"application/json", "application/javascript"})
+    @Produces({MediaType.APPLICATION_JSON, "application/javascript"})
     public ApiResponse newUserForOrganizationFromForm( @Context UriInfo ui, @FormParam("username") String username,
                                                            @FormParam("name") String name,
                                                            @FormParam("email") String email,
@@ -176,7 +176,7 @@ public class UsersResource extends AbstractContextResource {
     @PUT
     @Path(RootResource.USER_ID_PATH)
     @JSONP
-    @Produces({"application/json", "application/javascript"})
+    @Produces({MediaType.APPLICATION_JSON, "application/javascript"})
     public ApiResponse addUserToOrganization( @Context UriInfo ui, @PathParam("userId") String userIdStr,
                                                   @QueryParam("callback") @DefaultValue("callback") String callback )
             throws Exception {
@@ -203,7 +203,7 @@ public class UsersResource extends AbstractContextResource {
     @PUT
     @Path(RootResource.EMAIL_PATH)
     @JSONP
-    @Produces({"application/json", "application/javascript"})
+    @Produces({MediaType.APPLICATION_JSON, "application/javascript"})
     public ApiResponse addUserToOrganizationByEmail( @Context UriInfo ui, @PathParam("email") String email,
                                                          @QueryParam("callback") @DefaultValue("callback")
                                                          String callback ) throws Exception {
@@ -230,7 +230,7 @@ public class UsersResource extends AbstractContextResource {
     @PUT
     @Path("{username}")
     @JSONP
-    @Produces({"application/json", "application/javascript"})
+    @Produces({MediaType.APPLICATION_JSON, "application/javascript"})
     public ApiResponse addUserToOrganizationByUsername( @Context UriInfo ui, @PathParam("username") String username,
                                                             @QueryParam("callback") @DefaultValue("callback")
                                                             String callback ) throws Exception {
@@ -291,7 +291,7 @@ public class UsersResource extends AbstractContextResource {
     @DELETE
     @Path("{username}")
     @JSONP
-    @Produces({"application/json", "application/javascript"})
+    @Produces({MediaType.APPLICATION_JSON, "application/javascript"})
     public ApiResponse removeUserFromOrganizationByUsername( @Context UriInfo ui,
                                                                  @PathParam("username") String username,
                                                                  @QueryParam("callback") @DefaultValue("callback")
@@ -327,7 +327,7 @@ public class UsersResource extends AbstractContextResource {
     @DELETE
     @Path(RootResource.EMAIL_PATH)
     @JSONP
-    @Produces({"application/json", "application/javascript"})
+    @Produces({MediaType.APPLICATION_JSON, "application/javascript"})
     public ApiResponse removeUserFromOrganizationByEmail( @Context UriInfo ui, @PathParam("email") String email,
                                                               @QueryParam("callback") @DefaultValue("callback")
                                                               String callback ) throws Exception {

http://git-wip-us.apache.org/repos/asf/usergrid/blob/3749e741/stack/rest/src/main/java/org/apache/usergrid/rest/management/users/UserResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/management/users/UserResource.java b/stack/rest/src/main/java/org/apache/usergrid/rest/management/users/UserResource.java
index 1741db6..037121b 100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/management/users/UserResource.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/management/users/UserResource.java
@@ -92,7 +92,7 @@ public class UserResource extends AbstractContextResource {
 
     @PUT
     @JSONP
-    @Produces({"application/json", "application/javascript"})
+    @Produces({MediaType.APPLICATION_JSON, "application/javascript"})
     public ApiResponse setUserInfo( @Context UriInfo ui, Map<String, Object> json,
                                         @QueryParam( "callback" ) @DefaultValue( "callback" ) String callback )
             throws Exception {
@@ -122,7 +122,7 @@ public class UserResource extends AbstractContextResource {
     @PUT
     @Path( "password" )
     @JSONP
-    @Produces({"application/json", "application/javascript"})
+    @Produces({MediaType.APPLICATION_JSON, "application/javascript"})
     public ApiResponse setUserPasswordPut( @Context UriInfo ui, Map<String, Object> json,
                                                @QueryParam( "callback" ) @DefaultValue( "callback" ) String callback )
             throws Exception {
@@ -151,7 +151,7 @@ public class UserResource extends AbstractContextResource {
     @POST
     @Path( "password" )
     @JSONP
-    @Produces({"application/json", "application/javascript"})
+    @Produces({MediaType.APPLICATION_JSON, "application/javascript"})
     public ApiResponse setUserPasswordPost( @Context UriInfo ui, Map<String, Object> json,
                                                 @QueryParam( "callback" ) @DefaultValue( "callback" ) String callback )
             throws Exception {
@@ -163,7 +163,7 @@ public class UserResource extends AbstractContextResource {
     @GET
     @Path( "feed" )
     @JSONP
-    @Produces({"application/json", "application/javascript"})
+    @Produces({MediaType.APPLICATION_JSON, "application/javascript"})
     public ApiResponse getFeed( @Context UriInfo ui,
                                     @QueryParam( "callback" ) @DefaultValue( "callback" ) String callback )
             throws Exception {
@@ -182,7 +182,7 @@ public class UserResource extends AbstractContextResource {
     @RequireAdminUserAccess
     @GET
     @JSONP
-    @Produces({"application/json", "application/javascript"})
+    @Produces({MediaType.APPLICATION_JSON, "application/javascript"})
     public ApiResponse getUserData( @Context UriInfo ui, @QueryParam( "ttl" ) long ttl,
                                         @QueryParam( "shallow" ) boolean shallow,
                                         @QueryParam( "callback" ) @DefaultValue( "callback" ) String callback )
@@ -387,7 +387,7 @@ public class UserResource extends AbstractContextResource {
     @GET
     @Path( "reactivate" )
     @JSONP
-    @Produces({"application/json", "application/javascript"})
+    @Produces({MediaType.APPLICATION_JSON, "application/javascript"})
     public ApiResponse reactivate( @Context UriInfo ui,
                                        @QueryParam( "callback" ) @DefaultValue( "callback" ) String callback )
             throws Exception {
@@ -414,7 +414,7 @@ public class UserResource extends AbstractContextResource {
     @POST
     @Path( "revoketokens" )
     @JSONP
-    @Produces({"application/json", "application/javascript"})
+    @Produces({MediaType.APPLICATION_JSON, "application/javascript"})
     public ApiResponse revokeTokensPost( @Context UriInfo ui,
                                              @QueryParam( "callback" ) @DefaultValue( "callback" ) String callback )
             throws Exception {
@@ -435,7 +435,7 @@ public class UserResource extends AbstractContextResource {
     @PUT
     @Path( "revoketokens" )
     @JSONP
-    @Produces({"application/json", "application/javascript"})
+    @Produces({MediaType.APPLICATION_JSON, "application/javascript"})
     public ApiResponse revokeTokensPut( @Context UriInfo ui,
                                             @QueryParam( "callback" ) @DefaultValue( "callback" ) String callback )
             throws Exception {
@@ -446,7 +446,7 @@ public class UserResource extends AbstractContextResource {
     @POST
     @Path( "revoketoken" )
     @JSONP
-    @Produces({"application/json", "application/javascript"})
+    @Produces({MediaType.APPLICATION_JSON, "application/javascript"})
     public ApiResponse revokeTokenPost( @Context UriInfo ui,
                                             @QueryParam( "callback" ) @DefaultValue( "callback" ) String callback,
                                             @QueryParam( "token" ) String token ) throws Exception {
@@ -468,7 +468,7 @@ public class UserResource extends AbstractContextResource {
     @PUT
     @Path( "revoketoken" )
     @JSONP
-    @Produces({"application/json", "application/javascript"})
+    @Produces({MediaType.APPLICATION_JSON, "application/javascript"})
     public ApiResponse revokeTokenPut( @Context UriInfo ui,
                                            @QueryParam( "callback" ) @DefaultValue( "callback" ) String callback,
                                            @QueryParam( "token" ) String token ) throws Exception {

http://git-wip-us.apache.org/repos/asf/usergrid/blob/3749e741/stack/rest/src/main/java/org/apache/usergrid/rest/management/users/organizations/OrganizationsResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/management/users/organizations/OrganizationsResource.java b/stack/rest/src/main/java/org/apache/usergrid/rest/management/users/organizations/OrganizationsResource.java
index 186ccd3..e55969c 100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/management/users/organizations/OrganizationsResource.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/management/users/organizations/OrganizationsResource.java
@@ -63,7 +63,7 @@ public class OrganizationsResource extends AbstractContextResource {
     @RequireAdminUserAccess
     @GET
     @JSONP
-    @Produces({"application/json", "application/javascript"})
+    @Produces({MediaType.APPLICATION_JSON, "application/javascript"})
     public ApiResponse getUserOrganizations( @Context UriInfo ui,
                                                  @QueryParam( "callback" ) @DefaultValue( "callback" ) String callback )
             throws Exception {
@@ -81,7 +81,7 @@ public class OrganizationsResource extends AbstractContextResource {
     @RequireAdminUserAccess
     @POST
     @JSONP
-    @Produces({"application/json", "application/javascript"})
+    @Produces({MediaType.APPLICATION_JSON, "application/javascript"})
     public ApiResponse newOrganizationForUser( @Context UriInfo ui, Map<String, Object> json,
                                                    @QueryParam( "callback" ) @DefaultValue( "callback" )
                                                    String callback ) throws Exception {
@@ -103,7 +103,7 @@ public class OrganizationsResource extends AbstractContextResource {
     @POST
     @Consumes( MediaType.APPLICATION_FORM_URLENCODED )
     @JSONP
-    @Produces({"application/json", "application/javascript"})
+    @Produces({MediaType.APPLICATION_JSON, "application/javascript"})
     public ApiResponse newOrganizationForUserFromForm( @Context UriInfo ui, Map<String, Object> json,
                                                            @QueryParam( "callback" ) @DefaultValue( "callback" )
                                                            String callback,
@@ -130,7 +130,7 @@ public class OrganizationsResource extends AbstractContextResource {
     @PUT
     @Path( "{organizationName}" )
     @JSONP
-    @Produces({"application/json", "application/javascript"})
+    @Produces({MediaType.APPLICATION_JSON, "application/javascript"})
     public ApiResponse addUserToOrganizationByOrganizationName( @Context UriInfo ui,
                                                                     @PathParam( "organizationName" )
                                                                     String organizationName, @QueryParam( "callback" )
@@ -151,7 +151,7 @@ public class OrganizationsResource extends AbstractContextResource {
     @PUT
     @Path(RootResource.ORGANIZATION_ID_PATH)
     @JSONP
-    @Produces({"application/json", "application/javascript"})
+    @Produces({MediaType.APPLICATION_JSON, "application/javascript"})
     public ApiResponse addUserToOrganizationByOrganizationId( @Context UriInfo ui, @PathParam( "organizationId" )
     String organizationIdStr, @QueryParam( "callback" ) @DefaultValue( "callback" ) String callback ) throws Exception {
 
@@ -169,7 +169,7 @@ public class OrganizationsResource extends AbstractContextResource {
     @DELETE
     @Path( RootResource.ORGANIZATION_ID_PATH )
     @JSONP
-    @Produces({"application/json", "application/javascript"})
+    @Produces({MediaType.APPLICATION_JSON, "application/javascript"})
     public ApiResponse removeUserFromOrganizationByOrganizationId( @Context UriInfo ui,
                                                                        @PathParam( "organizationId" )
                                                                        String organizationIdStr,
@@ -191,7 +191,7 @@ public class OrganizationsResource extends AbstractContextResource {
     @DELETE
     @Path( "{organizationName}" )
     @JSONP
-    @Produces({"application/json", "application/javascript"})
+    @Produces({MediaType.APPLICATION_JSON, "application/javascript"})
     public ApiResponse removeUserFromOrganizationByOrganizationName( @Context UriInfo ui,
                                                                          @PathParam( "organizationName" )
                                                                          String organizationName,

http://git-wip-us.apache.org/repos/asf/usergrid/blob/3749e741/stack/rest/src/main/java/org/apache/usergrid/rest/security/shiro/ShiroAuthenticationExceptionMapper.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/security/shiro/ShiroAuthenticationExceptionMapper.java b/stack/rest/src/main/java/org/apache/usergrid/rest/security/shiro/ShiroAuthenticationExceptionMapper.java
index 4b11fd9..9135ff2 100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/security/shiro/ShiroAuthenticationExceptionMapper.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/security/shiro/ShiroAuthenticationExceptionMapper.java
@@ -17,6 +17,7 @@
 package org.apache.usergrid.rest.security.shiro;
 
 
+import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.Response;
 import javax.ws.rs.core.Response.Status;
 import javax.ws.rs.ext.ExceptionMapper;
@@ -55,6 +56,6 @@ public class ShiroAuthenticationExceptionMapper implements ExceptionMapper<Authe
             type = BAD_ACCESS_TOKEN_ERROR.getType();
         }
         response.withError( type, message, e );
-        return Response.status( Status.UNAUTHORIZED ).type( "application/json" ).entity( response ).build();
+        return Response.status( Status.UNAUTHORIZED ).type( MediaType.APPLICATION_JSON ).entity( response ).build();
     }
 }


[33/54] usergrid git commit: Merge branch 'two-dot-o-dev' of https://git-wip-us.apache.org/repos/asf/usergrid into USERGRID-1018

Posted by sn...@apache.org.
Merge branch 'two-dot-o-dev' of https://git-wip-us.apache.org/repos/asf/usergrid into USERGRID-1018


Project: http://git-wip-us.apache.org/repos/asf/usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/usergrid/commit/fb1cf2e9
Tree: http://git-wip-us.apache.org/repos/asf/usergrid/tree/fb1cf2e9
Diff: http://git-wip-us.apache.org/repos/asf/usergrid/diff/fb1cf2e9

Branch: refs/heads/usergrid-1007-shiro-cache
Commit: fb1cf2e939fc123b9468df372c80664459ef0b96
Parents: b7a22c2 723ee3a
Author: Todd Nine <tn...@apigee.com>
Authored: Tue Sep 15 17:27:20 2015 -0600
Committer: Todd Nine <tn...@apigee.com>
Committed: Tue Sep 15 17:27:20 2015 -0600

----------------------------------------------------------------------
 .../rx/impl/AllApplicationsObservableImpl.java  | 36 +++-----
 .../corepersistence/CpEntityMapUtilsTest.java   |  4 +-
 .../org/apache/usergrid/persistence/GeoIT.java  | 52 ++++++++++-
 .../migration/MvccEntityDataMigrationImpl.java  | 94 +++++++++++---------
 .../model/entity/MapToEntityConverter.java      |  8 +-
 5 files changed, 119 insertions(+), 75 deletions(-)
----------------------------------------------------------------------



[37/54] usergrid git commit: Fixing weird formatting in license headers, no code changes. This closes #385.

Posted by sn...@apache.org.
http://git-wip-us.apache.org/repos/asf/usergrid/blob/65d2608e/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EsIndexMappingMigrationPluginTest.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EsIndexMappingMigrationPluginTest.java b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EsIndexMappingMigrationPluginTest.java
index d4ce9e6..90d030b 100644
--- a/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EsIndexMappingMigrationPluginTest.java
+++ b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EsIndexMappingMigrationPluginTest.java
@@ -1,20 +1,20 @@
 /*
  *
- *  * Licensed to the Apache Software Foundation (ASF) under one or more
- *  *  contributor license agreements.  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.  For additional information regarding
- *  * copyright in this work, please see the NOTICE file in the top level
- *  * directory of this distribution.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  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.  For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
  *
  */
 package org.apache.usergrid.persistence.index.impl;

http://git-wip-us.apache.org/repos/asf/usergrid/blob/65d2608e/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EsRunner.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EsRunner.java b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EsRunner.java
index c972851..2bfa8f6 100644
--- a/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EsRunner.java
+++ b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EsRunner.java
@@ -1,21 +1,21 @@
 /*
  *
- *  * 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.
  *
  */
 

http://git-wip-us.apache.org/repos/asf/usergrid/blob/65d2608e/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/GeoPagingTest.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/GeoPagingTest.java b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/GeoPagingTest.java
index fbe2bf5..dce69f9 100644
--- a/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/GeoPagingTest.java
+++ b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/GeoPagingTest.java
@@ -1,23 +1,23 @@
 /*
  *
- *  *
- *  * 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.
+ *
  *
  */
 package org.apache.usergrid.persistence.index.impl;

http://git-wip-us.apache.org/repos/asf/usergrid/blob/65d2608e/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/TestIndexIdentifier.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/TestIndexIdentifier.java b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/TestIndexIdentifier.java
index 29f9bad..2cc7e62 100644
--- a/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/TestIndexIdentifier.java
+++ b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/TestIndexIdentifier.java
@@ -1,20 +1,20 @@
 /*
  *
- *  * Licensed to the Apache Software Foundation (ASF) under one or more
- *  *  contributor license agreements.  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.  For additional information regarding
- *  * copyright in this work, please see the NOTICE file in the top level
- *  * directory of this distribution.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  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.  For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
  *
  */
 package org.apache.usergrid.persistence.index.impl;


[09/54] usergrid git commit: Changes to configure our filters correctly, and numerous other test fixes. Only 7 REST tests are not passing.

Posted by sn...@apache.org.
http://git-wip-us.apache.org/repos/asf/usergrid/blob/eb2aa6ff/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/groups/GroupResourceIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/groups/GroupResourceIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/groups/GroupResourceIT.java
index 787306c..0db7601 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/groups/GroupResourceIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/groups/GroupResourceIT.java
@@ -24,7 +24,7 @@ import org.apache.usergrid.rest.test.resource.model.Entity;
 import org.junit.Ignore;
 import org.junit.Test;
 
-import javax.ws.rs.client.ResponseProcessingException;
+import javax.ws.rs.ClientErrorException;
 import java.io.IOException;
 
 import static org.junit.Assert.*;
@@ -149,7 +149,7 @@ public class GroupResourceIT extends AbstractRestIT {
         try {
             this.createGroup(groupName, groupSpacePath);
             fail("Should not be able to create a group with a space in the path");
-        } catch (ResponseProcessingException e) {
+        } catch (ClientErrorException e) {
             //verify the correct error was returned
             JsonNode node = mapper.readTree( e.getResponse().readEntity( String.class ));
             assertEquals( "illegal_argument", node.get( "error" ).textValue() );
@@ -192,7 +192,7 @@ public class GroupResourceIT extends AbstractRestIT {
         try {
             this.app().collection("groups").uniqueID(groupName).get();
             fail("Entity still exists");
-        } catch (ResponseProcessingException e) {
+        } catch (ClientErrorException e) {
             //verify the correct error was returned
             JsonNode node = mapper.readTree( e.getResponse().readEntity( String.class ));
             assertEquals( "entity_not_found", node.get( "error" ).textValue() );
@@ -298,7 +298,7 @@ public class GroupResourceIT extends AbstractRestIT {
         try {
             this.app().collection("role").entity(role).get();
             fail("Entity still exists");
-        } catch (ResponseProcessingException e) {
+        } catch (ClientErrorException e) {
             //verify the correct error was returned
             JsonNode node = mapper.readTree( e.getResponse().readEntity( String.class ));
             assertEquals( "entity_not_found", node.get( "error" ).textValue() );
@@ -367,7 +367,7 @@ public class GroupResourceIT extends AbstractRestIT {
         try {
             this.app().collection("cats").uniqueID(catName).put(fluffy);
             fail("permissions should not allow this");
-        } catch (ResponseProcessingException e) {
+        } catch (ClientErrorException e) {
             //verify the correct error was returned
             JsonNode node = mapper.readTree( e.getResponse().readEntity( String.class ) );
             assertEquals( "unauthorized", node.get( "error" ).textValue() );
@@ -377,7 +377,7 @@ public class GroupResourceIT extends AbstractRestIT {
         try {
             this.app().collection("cats").uniqueID(catName).delete();
             fail("permissions should not allow this");
-        } catch (ResponseProcessingException e) {
+        } catch (ClientErrorException e) {
             //verify the correct error was returned
             JsonNode node = mapper.readTree( e.getResponse().readEntity( String.class ));
             assertEquals( "unauthorized", node.get( "error" ).textValue() );

http://git-wip-us.apache.org/repos/asf/usergrid/blob/eb2aa6ff/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/users/ConnectionResourceTest.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/users/ConnectionResourceTest.java b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/users/ConnectionResourceTest.java
index af3ce9b..3655300 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/users/ConnectionResourceTest.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/users/ConnectionResourceTest.java
@@ -25,7 +25,7 @@ import org.junit.Test;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import javax.ws.rs.client.ResponseProcessingException;
+import javax.ws.rs.ClientErrorException;
 import java.io.IOException;
 import java.util.Map;
 
@@ -71,7 +71,7 @@ public class ConnectionResourceTest extends AbstractRestIT {
 
             this.app().collection("users").entity(scott).collection("likes").collection("peeps").entity(peep).get();
             fail("This should throw an exception");
-        } catch (ResponseProcessingException uie) {
+        } catch (ClientErrorException uie) {
             // Should return a 404 Not Found
             assertEquals(404, uie.getResponse().getStatus());
         }
@@ -162,7 +162,7 @@ public class ConnectionResourceTest extends AbstractRestIT {
             //attempt to retrieve thing1
             thing2 = this.app().collection("things").entity(thing2).get();
             fail("This should throw an exception");
-        } catch (ResponseProcessingException uie) {
+        } catch (ClientErrorException uie) {
             // Should return a 404 Not Found
             assertEquals(404, uie.getResponse().getStatus());
         }
@@ -198,7 +198,7 @@ public class ConnectionResourceTest extends AbstractRestIT {
             //attempt to retrieve thing1
             thing1 = this.app().collection("things").entity(thing1).get();
             fail("This should throw an exception");
-        } catch (ResponseProcessingException uie) {
+        } catch (ClientErrorException uie) {
             // Should return a 404 Not Found
             assertEquals(404, uie.getResponse().getStatus());
         }

http://git-wip-us.apache.org/repos/asf/usergrid/blob/eb2aa6ff/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/users/OwnershipResourceIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/users/OwnershipResourceIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/users/OwnershipResourceIT.java
index f90b6ae..cfd08e5 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/users/OwnershipResourceIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/users/OwnershipResourceIT.java
@@ -30,7 +30,7 @@ import org.junit.Test;
 
 import org.apache.usergrid.utils.MapUtils;
 
-import javax.ws.rs.client.ResponseProcessingException;
+import javax.ws.rs.ClientErrorException;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
@@ -152,7 +152,7 @@ public class OwnershipResourceIT extends AbstractRestIT {
         int status = 0;
         try {
             data = devices.entity("device2").get();
-        }catch (ResponseProcessingException e){
+        }catch (ClientErrorException e){
             status = e.getResponse().getStatus();
         }
         assertEquals( status,404 );
@@ -176,7 +176,7 @@ public class OwnershipResourceIT extends AbstractRestIT {
         status = 0;
         try{
         data = devices.entity("device1").get();
-        }catch (ResponseProcessingException e){
+        }catch (ClientErrorException e){
             status = e.getResponse().getStatus();
         }
         assertEquals( status,404 );
@@ -283,7 +283,7 @@ public class OwnershipResourceIT extends AbstractRestIT {
         int status = 200;
         try {
             likeRestaurants.entity("arrogantbutcher").get();
-        }catch (ResponseProcessingException e){
+        }catch (ClientErrorException e){
             status = e.getResponse().getStatus();
         }
         assertEquals(status, 404);
@@ -291,7 +291,7 @@ public class OwnershipResourceIT extends AbstractRestIT {
         status = 200;
         try {
             likeRestaurants.entity( arrogantButcherId ).get();
-        }catch (ResponseProcessingException e){
+        }catch (ClientErrorException e){
             status = e.getResponse().getStatus();
         }
         assertEquals(status, 404);
@@ -320,7 +320,7 @@ public class OwnershipResourceIT extends AbstractRestIT {
          status = 200;
         try {
             data = likeRestaurants.entity( "4peaks" ).get();
-        }catch (ResponseProcessingException e){
+        }catch (ClientErrorException e){
             status = e.getResponse().getStatus();
         }
         assertEquals( status,404 );
@@ -331,7 +331,7 @@ public class OwnershipResourceIT extends AbstractRestIT {
         try {
             likeRestaurants.entity( peaksId ).get();
 
-        }catch (ResponseProcessingException e){
+        }catch (ClientErrorException e){
             status = e.getResponse().getStatus();
         }
         assertEquals( status,404 );

http://git-wip-us.apache.org/repos/asf/usergrid/blob/eb2aa6ff/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/users/PermissionsResourceIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/users/PermissionsResourceIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/users/PermissionsResourceIT.java
index f9f1743..49d7c00 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/users/PermissionsResourceIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/users/PermissionsResourceIT.java
@@ -28,7 +28,7 @@ import org.apache.usergrid.utils.UUIDUtils;
 import org.junit.Before;
 import org.junit.Test;
 
-import javax.ws.rs.client.ResponseProcessingException;
+import javax.ws.rs.ClientErrorException;
 import javax.ws.rs.core.Response;
 import java.io.IOException;
 
@@ -106,7 +106,7 @@ public class PermissionsResourceIT extends AbstractRestIT {
         int status = 0;
         try {
             node = this.app().collection("users").entity(USER).collection("roles").entity(ROLE).get();
-        }catch (ResponseProcessingException e){
+        }catch (ClientErrorException e){
             status = e.getResponse().getStatus();
         }
 
@@ -158,7 +158,7 @@ public class PermissionsResourceIT extends AbstractRestIT {
         try {
             this.app().collection("users").entity(user).collection("groups").entity( groupPath ).collection( "users" ).entity( user ).get();
             fail("Should not have been able to retrieve the user as it was deleted");
-        }catch (ResponseProcessingException e){
+        }catch (ClientErrorException e){
             status=e.getResponse().getStatus();
             assertEquals( 404,status );
         }
@@ -198,7 +198,7 @@ public class PermissionsResourceIT extends AbstractRestIT {
         //Call a get on a existing entity with no access token and check if we get a 401
         try {
             this.app().collection( "roles" ).entity( "guest" ).get( false );
-        }catch(ResponseProcessingException uie){
+        }catch(ClientErrorException uie){
             assertEquals( 401,uie.getResponse().getStatus() );
         }
 
@@ -209,13 +209,13 @@ public class PermissionsResourceIT extends AbstractRestIT {
         //Call a get on a non existing entity that doesn't need permissions and check it we get a 404.
         try {
             this.app().collection( "roles" ).entity( "banana" ).get( false );
-        }catch(ResponseProcessingException uie){
+        }catch(ClientErrorException uie){
             assertEquals( 404,uie.getResponse().getStatus() );
         }
 
         try {
             this.app().collection( "roles" ).entity( UUIDUtils.newTimeUUID() ).get( false );
-        }catch(ResponseProcessingException uie){
+        }catch(ClientErrorException uie){
             assertEquals( 404,uie.getResponse().getStatus() );
         }
     }
@@ -302,7 +302,7 @@ public class PermissionsResourceIT extends AbstractRestIT {
             this.app().collection("reviews").entity("noca").delete();
             fail( "this should have failed due to having insufficient permissions" );
         }
-        catch ( ResponseProcessingException uie ) {
+        catch ( ClientErrorException uie ) {
             status = uie.getResponse().getStatus();
         }
 
@@ -315,7 +315,7 @@ public class PermissionsResourceIT extends AbstractRestIT {
             this.app().collection("reviews").entity("4peaks").delete();
             fail( "this should have failed due to having insufficient permissions" );
         }
-        catch ( ResponseProcessingException uie ) {
+        catch ( ClientErrorException uie ) {
             status = uie.getResponse().getStatus();
         }
 
@@ -355,7 +355,7 @@ public class PermissionsResourceIT extends AbstractRestIT {
             this.app().collection("reviews").entity("cowboyciao").delete();
             fail( "this should have failed due to having insufficient permissions" );
         }
-        catch ( ResponseProcessingException uie ) {
+        catch ( ClientErrorException uie ) {
             status = uie.getResponse().getStatus();
         }
 
@@ -369,7 +369,7 @@ public class PermissionsResourceIT extends AbstractRestIT {
             this.app().collection("reviews").entity("currycorner").delete();
             fail( "this should have failed due to having insufficient permissions" );
         }
-        catch ( ResponseProcessingException uie ) {
+        catch ( ClientErrorException uie ) {
             status = uie.getResponse().getStatus();
         }
 
@@ -472,7 +472,7 @@ public class PermissionsResourceIT extends AbstractRestIT {
             this.app().collection("books").post(book);
 
         }
-        catch ( ResponseProcessingException uie ) {
+        catch ( ClientErrorException uie ) {
             status = uie.getResponse().getStatus();
         }
         assertEquals( Response.Status.UNAUTHORIZED.getStatusCode(), status );

http://git-wip-us.apache.org/repos/asf/usergrid/blob/eb2aa6ff/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/users/UserResourceIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/users/UserResourceIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/users/UserResourceIT.java
index 71a8447..dc8daf9 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/users/UserResourceIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/users/UserResourceIT.java
@@ -36,7 +36,7 @@ import org.slf4j.LoggerFactory;
 import org.apache.usergrid.rest.applications.utils.UserRepo;
 import org.apache.usergrid.utils.UUIDUtils;
 
-import javax.ws.rs.client.ResponseProcessingException;
+import javax.ws.rs.ClientErrorException;
 import javax.ws.rs.core.Response;
 import java.io.IOException;
 
@@ -588,7 +588,7 @@ public class UserResourceIT extends AbstractRestIT {
             userRoles = this.app().collection("roles").entity(roleId1).connection("users")
                 .get(new QueryParameters().setQuery("select%20*%20where%20username%20=%20'" + email + "'"));
             assertNull(userRoles);
-        } catch (ResponseProcessingException e) {
+        } catch (ClientErrorException e) {
             assertEquals( Response.Status.NOT_FOUND.getStatusCode(), e.getResponse().getStatus());
         }
 
@@ -817,7 +817,7 @@ public class UserResourceIT extends AbstractRestIT {
         int responseStatus = 0;
         try {
             usersResource.entity("edanuff").connection("password").post(data);
-        } catch (ResponseProcessingException uie) {
+        } catch (ClientErrorException uie) {
             responseStatus = uie.getResponse().getStatus();
         }
 
@@ -869,7 +869,7 @@ public class UserResourceIT extends AbstractRestIT {
             role = usersResource.entity(createdId).collection("roles").entity(roleName).get();
 
             assertNull(role);
-        } catch (ResponseProcessingException e) {
+        } catch (ClientErrorException e) {
             assertEquals(e.getResponse().getStatus(), Response.Status.NOT_FOUND.getStatusCode());
         }
     }
@@ -907,7 +907,7 @@ public class UserResourceIT extends AbstractRestIT {
 
             usersResource.entity("edanuff").get();
             assertFalse(true);
-        } catch (ResponseProcessingException uie) {
+        } catch (ClientErrorException uie) {
             status = uie.getResponse().getStatus();
         }
 
@@ -919,7 +919,7 @@ public class UserResourceIT extends AbstractRestIT {
             this.app().token().setToken(token2);
 
             usersResource.entity("edanuff").get();
-        } catch (ResponseProcessingException uie) {
+        } catch (ClientErrorException uie) {
             status = uie.getResponse().getStatus();
         }
 
@@ -955,7 +955,7 @@ public class UserResourceIT extends AbstractRestIT {
             this.app().token().setToken(token3);
             usersResource.entity("edanuff").get();
 
-        } catch (ResponseProcessingException uie) {
+        } catch (ClientErrorException uie) {
             status = uie.getResponse().getStatus();
         }
 
@@ -969,7 +969,7 @@ public class UserResourceIT extends AbstractRestIT {
 
 
             status = Response.Status.OK.getStatusCode();
-        } catch (ResponseProcessingException uie) {
+        } catch (ClientErrorException uie) {
             status = uie.getResponse().getStatus();
         }
 
@@ -1002,7 +1002,7 @@ public class UserResourceIT extends AbstractRestIT {
             userResource.entity("test_1").connection("token").get(
                 new QueryParameters().addParam("access_token", "blah"), false);
             assertTrue(false);
-        } catch (ResponseProcessingException uie) {
+        } catch (ClientErrorException uie) {
             status = uie.getResponse().getStatus();
             log.info("Error Response Body: " + uie.getResponse().readEntity(String.class));
         }
@@ -1013,7 +1013,7 @@ public class UserResourceIT extends AbstractRestIT {
             userResource.entity("test_2").connection("token").get(
                 new QueryParameters().addParam("access_token", token.getAccessToken()), false);
             assertTrue(false);
-        } catch (ResponseProcessingException uie) {
+        } catch (ClientErrorException uie) {
             status = uie.getResponse().getStatus();
             log.info("Error Response Body: " + uie.getResponse().readEntity(String.class));
         }
@@ -1041,7 +1041,7 @@ public class UserResourceIT extends AbstractRestIT {
         try {
             this.app().token().post(new Token("test_1", "test123"));
             fail("request for deactivated user should fail");
-        } catch (ResponseProcessingException uie) {
+        } catch (ClientErrorException uie) {
             status = uie.getResponse().getStatus();
             JsonNode body = mapper.readTree(uie.getResponse().readEntity(String.class));
             assertEquals("user not activated", body.findPath("error_description").textValue());

http://git-wip-us.apache.org/repos/asf/usergrid/blob/eb2aa6ff/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/BadGrammarQueryTest.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/BadGrammarQueryTest.java b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/BadGrammarQueryTest.java
index c4b24b4..0692667 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/BadGrammarQueryTest.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/BadGrammarQueryTest.java
@@ -21,7 +21,7 @@ import org.apache.usergrid.rest.test.resource.model.Collection;
 import org.apache.usergrid.rest.test.resource.model.QueryParameters;
 import org.junit.Test;
 
-import javax.ws.rs.client.ResponseProcessingException;
+import javax.ws.rs.ClientErrorException;
 import java.io.IOException;
 
 import static org.junit.Assert.assertEquals;
@@ -54,7 +54,7 @@ public class BadGrammarQueryTest extends QueryTestBase {
             QueryParameters params = new QueryParameters().setQuery(query);
             this.app().collection(collectionName).get(params);
             fail("This should throw an exception");
-        } catch (ResponseProcessingException uie) {
+        } catch (ClientErrorException uie) {
             //Check for an exception
             assertEquals(400, uie.getResponse().getStatus());
         }
@@ -80,7 +80,7 @@ public class BadGrammarQueryTest extends QueryTestBase {
             QueryParameters params = new QueryParameters().setQuery(query);
             this.app().collection(collectionName).get(params);
             fail("This should throw an exception");
-        } catch (ResponseProcessingException uie) {
+        } catch (ClientErrorException uie) {
             //Check for an exception
             assertEquals(400, uie.getResponse().getStatus());
         }
@@ -106,7 +106,7 @@ public class BadGrammarQueryTest extends QueryTestBase {
             QueryParameters params = new QueryParameters().setQuery(query);
             this.app().collection(collectionName).get(params);
             fail("This should throw an exception");
-        } catch (ResponseProcessingException uie) {
+        } catch (ClientErrorException uie) {
             //Check for an exception
             assertEquals(400, uie.getResponse().getStatus());
         }
@@ -132,7 +132,7 @@ public class BadGrammarQueryTest extends QueryTestBase {
             QueryParameters params = new QueryParameters().setQuery(query);
             this.app().collection(collectionName).get(params);
             fail("This should throw an exception");
-        } catch (ResponseProcessingException uie) {
+        } catch (ClientErrorException uie) {
             //Check for an exception
             assertEquals(400, uie.getResponse().getStatus());
         }
@@ -158,7 +158,7 @@ public class BadGrammarQueryTest extends QueryTestBase {
             QueryParameters params = new QueryParameters().setQuery(query);
             this.app().collection(collectionName).get(params);
             fail("This should throw an exception");
-        } catch (ResponseProcessingException uie) {
+        } catch (ClientErrorException uie) {
             //Check for an exception
             assertEquals(400, uie.getResponse().getStatus());
         }
@@ -184,7 +184,7 @@ public class BadGrammarQueryTest extends QueryTestBase {
             QueryParameters params = new QueryParameters().setQuery(query);
             this.app().collection(collectionName).get(params);
             fail("This should throw an exception");
-        } catch (ResponseProcessingException uie) {
+        } catch (ClientErrorException uie) {
             //Check for an exception
             assertEquals(400, uie.getResponse().getStatus());
         }

http://git-wip-us.apache.org/repos/asf/usergrid/blob/eb2aa6ff/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/BasicGeoTests.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/BasicGeoTests.java b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/BasicGeoTests.java
index fba7c66..f47fba0 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/BasicGeoTests.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/BasicGeoTests.java
@@ -22,7 +22,7 @@ import org.apache.usergrid.rest.test.resource.AbstractRestIT;
 import org.apache.usergrid.rest.test.resource.model.Entity;
 import org.junit.Test;
 
-import javax.ws.rs.client.ResponseProcessingException;
+import javax.ws.rs.ClientErrorException;
 import java.io.IOException;
 import java.util.HashMap;
 import java.util.Map;
@@ -62,7 +62,7 @@ public class BasicGeoTests extends AbstractRestIT {
         try {
             node = this.app().collection( collectionType ).post( entityData ).getEntity();
         }
-        catch ( ResponseProcessingException e ) {
+        catch ( ClientErrorException e ) {
             JsonNode nodeError = mapper.readTree( e.getResponse().readEntity( String.class ) );
             fail( nodeError.get( "error" ).textValue() );
         }
@@ -100,7 +100,7 @@ public class BasicGeoTests extends AbstractRestIT {
         try {
             entity = this.app().collection( collectionType ).post( entityData ).getEntities().get(0);
         }
-        catch ( ResponseProcessingException e ) {
+        catch ( ClientErrorException e ) {
             JsonNode nodeError = mapper.readTree( e.getResponse().readEntity( String.class ) );
             fail( nodeError.get( "error" ).textValue() );
         }
@@ -116,7 +116,7 @@ public class BasicGeoTests extends AbstractRestIT {
         try {
             node = context.collection( collectionType ).get(entityName);
         }
-        catch ( ResponseProcessingException e ) {
+        catch ( ClientErrorException e ) {
             JsonNode nodeError = mapper.readTree( e.getResponse().getEntity( String.class ) );
             fail( nodeError.get( "error" ).textValue() );
         }
@@ -134,7 +134,7 @@ public class BasicGeoTests extends AbstractRestIT {
             //entity.put(entityData);
 
         }
-        catch ( ResponseProcessingException e ) {
+        catch ( ClientErrorException e ) {
             JsonNode nodeError = mapper.readTree( e.getResponse().getEntity( String.class ) );
             fail( nodeError.get( "error" ).textValue() );
         }
@@ -177,7 +177,7 @@ public class BasicGeoTests extends AbstractRestIT {
             node = this.app().collection( collectionType ).post( misspelledLatitudeEntityData ).getEntity();
             fail("System allowed misspelled location property - latitudee, which it should not");
         }
-        catch ( ResponseProcessingException e ) {
+        catch ( ClientErrorException e ) {
             //verify the correct error was returned
             JsonNode nodeError = mapper.readTree( e.getResponse().readEntity( String.class ) );
             assertEquals( "illegal_argument", nodeError.get( "error" ).textValue() );
@@ -193,7 +193,7 @@ public class BasicGeoTests extends AbstractRestIT {
             node = this.app().collection( collectionType ).post( misspelledLongitudeEntityData ).getEntity();
             fail("System allowed misspelled location property - longitudee, which it should not");
         }
-        catch ( ResponseProcessingException e ) {
+        catch ( ClientErrorException e ) {
             //verify the correct error was returned
             JsonNode nodeError = mapper.readTree( e.getResponse().readEntity( String.class ));
             assertEquals( "illegal_argument", nodeError.get( "error" ).textValue() );
@@ -224,7 +224,7 @@ public class BasicGeoTests extends AbstractRestIT {
             node = this.app().collection( collectionType ).post( latitudeOnlyEntityData ).getEntity();
             fail("System allowed location with only one point, latitude, which it should not");
         }
-        catch ( ResponseProcessingException e ) {
+        catch ( ClientErrorException e ) {
             //verify the correct error was returned
             JsonNode nodeError = mapper.readTree( e.getResponse().readEntity( String.class ));
             assertEquals( "illegal_argument", nodeError.get( "error" ).textValue() );
@@ -240,7 +240,7 @@ public class BasicGeoTests extends AbstractRestIT {
             node = this.app().collection( collectionType ).post( notDoubleLatLonEntityData ).getEntity();
             fail("System allowed misspelled location values that are not doubles for latitude and longitude, which it should not");
         }
-        catch ( ResponseProcessingException e ) {
+        catch ( ClientErrorException e ) {
             //verify the correct error was returned
             JsonNode nodeError = mapper.readTree( e.getResponse().readEntity( String.class ));
             assertEquals( "illegal_argument", nodeError.get( "error" ).textValue() );

http://git-wip-us.apache.org/repos/asf/usergrid/blob/eb2aa6ff/stack/rest/src/test/java/org/apache/usergrid/rest/management/AccessTokenIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/management/AccessTokenIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/management/AccessTokenIT.java
index 7edc2a7..431d224 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/management/AccessTokenIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/management/AccessTokenIT.java
@@ -27,7 +27,7 @@ import org.apache.usergrid.rest.test.resource.model.Entity;
 import org.apache.usergrid.rest.test.resource.model.QueryParameters;
 import org.apache.usergrid.rest.test.resource.model.Token;
 
-import javax.ws.rs.client.ResponseProcessingException;
+import javax.ws.rs.ClientErrorException;
 import javax.ws.rs.core.Form;
 import javax.ws.rs.core.Response;
 
@@ -65,7 +65,7 @@ public class AccessTokenIT extends AbstractRestIT {
         Response.Status responseStatus = null;
         try {
             management().users().user( clientSetup.getUsername() ).get( ApiResponse.class);
-        } catch (ResponseProcessingException uie) {
+        } catch (ClientErrorException uie) {
             responseStatus = Response.Status.fromStatusCode( uie.getResponse().getStatus() );
         }
 
@@ -198,8 +198,8 @@ public class AccessTokenIT extends AbstractRestIT {
 
         try {
             management().token().post( Token.class,payload );
-        } catch (ResponseProcessingException uie) {
-            assertEquals(Response.Status.BAD_REQUEST, uie.getResponse().getStatus());
+        } catch (ClientErrorException uie) {
+            assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), uie.getResponse().getStatus());
         }
 
     }
@@ -218,7 +218,7 @@ public class AccessTokenIT extends AbstractRestIT {
 
         try {
             management().token().post( Token.class, payload );
-        } catch (ResponseProcessingException uie) {
+        } catch (ClientErrorException uie) {
             assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), uie.getResponse().getStatus());
         }
 
@@ -246,7 +246,7 @@ public class AccessTokenIT extends AbstractRestIT {
             management().users().user( clientSetup.getUsername() ).get();
             fail( "Token1 should have been revoked" );
         }
-        catch ( ResponseProcessingException uie ) {
+        catch ( ClientErrorException uie ) {
             assertEquals(Response.Status.UNAUTHORIZED.getStatusCode(), uie.getResponse().getStatus());
         }
 
@@ -257,7 +257,7 @@ public class AccessTokenIT extends AbstractRestIT {
             management().users().user( clientSetup.getUsername() ).get();
             fail( "Token2 should have been revoked" );
         }
-        catch ( ResponseProcessingException uie ) {
+        catch ( ClientErrorException uie ) {
             assertEquals( Response.Status.UNAUTHORIZED.getStatusCode(), uie.getResponse().getStatus());
         }
     }
@@ -287,7 +287,7 @@ public class AccessTokenIT extends AbstractRestIT {
             management().users().user( clientSetup.getUsername() ).get();
             fail( "Token1 should have been revoked" );
         }
-        catch ( ResponseProcessingException uie ) {
+        catch ( ClientErrorException uie ) {
             assertEquals( Response.Status.UNAUTHORIZED.getStatusCode(), uie.getResponse().getStatus());
         }
 
@@ -297,7 +297,7 @@ public class AccessTokenIT extends AbstractRestIT {
             management().token().setToken( token2 );
             management().users().user( clientSetup.getUsername() ).get();
         }
-        catch ( ResponseProcessingException uie ) {
+        catch ( ClientErrorException uie ) {
             fail( "Token2 shouldn't have been revoked" );
 
         }

http://git-wip-us.apache.org/repos/asf/usergrid/blob/eb2aa6ff/stack/rest/src/test/java/org/apache/usergrid/rest/management/AdminUsersIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/management/AdminUsersIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/management/AdminUsersIT.java
index 09c49e1..9864e65 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/management/AdminUsersIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/management/AdminUsersIT.java
@@ -31,7 +31,8 @@ import org.jvnet.mock_javamail.Mailbox;
 import javax.mail.Message;
 import javax.mail.MessagingException;
 import javax.mail.internet.MimeMultipart;
-import javax.ws.rs.client.ResponseProcessingException;
+import javax.ws.rs.ClientErrorException;
+import javax.ws.rs.InternalServerErrorException;
 import javax.ws.rs.core.Form;
 import javax.ws.rs.core.Response;
 import java.io.IOException;
@@ -83,7 +84,7 @@ public class AdminUsersIT extends AbstractRestIT {
         try {
             management.token().post(false, Token.class, new Token( username, password ),null);
             fail( "We shouldn't be able to get a token using the old password" );
-        }catch(ResponseProcessingException uie) {
+        }catch(ClientErrorException uie) {
             errorParse( 400,"invalid_grant",uie );
         }
     }
@@ -120,7 +121,7 @@ public class AdminUsersIT extends AbstractRestIT {
             management.users().user( username ).password().post( Entity.class ,passwordPayload );
             fail("We shouldn't be able to change the password with the same payload");
         }
-        catch ( ResponseProcessingException uie ) {
+        catch ( ClientErrorException uie ) {
             errorParse( Response.Status.BAD_REQUEST.getStatusCode(),"auth_invalid_username_or_password",uie );
         }
 
@@ -146,14 +147,14 @@ public class AdminUsersIT extends AbstractRestIT {
 
         this.refreshIndex();
 
-        assertNotNull(management.token().post( false,Token.class, new Token( username, "testPassword" ) ,null ));
+        assertNotNull( management.token().post( false, Token.class, new Token(username, "testPassword"), null ));
 
 
-        //Check that we cannot get the token using the old password
+        // Check that we cannot get the token using the old password
         try {
             management.token().post( false,Token.class, new Token( username, password) ,null);
             fail( "We shouldn't be able to get a token using the old password" );
-        }catch(ResponseProcessingException uie) {
+        } catch(ClientErrorException uie) {
             errorParse( 400,"invalid_grant",uie );
         }
     }
@@ -236,7 +237,7 @@ public class AdminUsersIT extends AbstractRestIT {
                 management().token().get( queryParameters );
                 fail( "Admin user should not be able to log in." );
             }
-            catch ( ResponseProcessingException uie ) {
+            catch ( ClientErrorException uie ) {
                 assertEquals( "Admin user should have failed with 403", 403, uie.getResponse().getStatus() );
             }
 
@@ -494,7 +495,7 @@ public class AdminUsersIT extends AbstractRestIT {
 
             fail( "should fail with conflict" );
         }
-        catch ( ResponseProcessingException e ) {
+        catch ( ClientErrorException e ) {
             assertEquals( 409, e.getResponse().getStatus() );
         }
 
@@ -513,7 +514,7 @@ public class AdminUsersIT extends AbstractRestIT {
 
             fail( "should fail with conflict" );
         }
-        catch ( ResponseProcessingException e ) {
+        catch ( ClientErrorException e ) {
             assertEquals( 409, e.getResponse().getStatus() );
         }
     }
@@ -617,20 +618,24 @@ public class AdminUsersIT extends AbstractRestIT {
      * Makes sure you can't create a already existing organization from a user connection.
      * @throws Exception
      */
-    //TODO: figure out what is the expected behavior from this test. While it fails it is not sure what it should return
+    // TODO: figure out what is the expected behavior from this test.
+    // While it fails it is not sure what it should return
     @Test
     public void createOrgFromUserConnectionFail() throws Exception {
 
-        Token token = management().token().post(Token.class ,new Token( clientSetup.getUsername(),clientSetup.getPassword() ) );
+        Token token = management().token()
+            .post( Token.class, new Token( clientSetup.getUsername(), clientSetup.getPassword() ) );
         management().token().setToken( token );
+
         // try to create the same org again off the connection
         try {
-            management().users().user( clientSetup.getUsername() ).organizations().post( clientSetup.getOrganization(),token );
+            management().users().user( clientSetup.getUsername() ).organizations()
+                .post( clientSetup.getOrganization(), token );
 
             fail( "Should have thrown unique exception on org name" );
         }
-        catch ( ResponseProcessingException uie ) {
-            assertEquals(500,uie.getResponse().getStatus());
+        catch ( InternalServerErrorException ise ) {
+            assertEquals(500, ise.getResponse().getStatus());
         }
     }
 

http://git-wip-us.apache.org/repos/asf/usergrid/blob/eb2aa6ff/stack/rest/src/test/java/org/apache/usergrid/rest/management/ExportResourceIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/management/ExportResourceIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/management/ExportResourceIT.java
index a4f5f2d..939363f 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/management/ExportResourceIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/management/ExportResourceIT.java
@@ -23,7 +23,7 @@ import org.apache.usergrid.rest.test.resource.model.ApiResponse;
 import org.junit.Ignore;
 import org.junit.Test;
 
-import javax.ws.rs.client.ResponseProcessingException;
+import javax.ws.rs.ClientErrorException;
 import javax.ws.rs.core.Response;
 import java.util.HashMap;
 import java.util.Map;
@@ -48,7 +48,7 @@ public class ExportResourceIT extends AbstractRestIT {
             management().orgs().org( clientSetup.getOrganizationName() )
                         .app().addToPath( clientSetup.getAppUuid() ).addToPath( "export" );
         }
-        catch ( ResponseProcessingException uie ) {
+        catch ( ClientErrorException uie ) {
             fail("We got back " + uie.getResponse().getStatus() + " instead of having a successful call" );
         }
 
@@ -68,7 +68,7 @@ public class ExportResourceIT extends AbstractRestIT {
                         .app().addToPath( clientSetup.getAppUuid()).addToPath( "collection" )
                         .addToPath( "users" ).addToPath( "export" ).post(ApiResponse.class,payloadBuilder() );
         }
-        catch ( ResponseProcessingException uie ) {
+        catch ( ClientErrorException uie ) {
             fail( "We got back "+uie.getResponse().getStatus()+" instead of having a successful call" );
         }
 
@@ -92,7 +92,7 @@ public class ExportResourceIT extends AbstractRestIT {
             exportEntity = management().orgs().org( clientSetup.getOrganizationName() )
                                        .addToPath( "export" ).post( ApiResponse.class, payloadBuilder() );
         }
-        catch ( ResponseProcessingException uie ) {
+        catch ( ClientErrorException uie ) {
             fail( "We got back "+uie.getResponse().getStatus()+" instead of having a successful call" );
         }
 
@@ -106,7 +106,7 @@ public class ExportResourceIT extends AbstractRestIT {
             exportEntity = management().orgs().org( clientSetup.getOrganizationName() )
                                        .addToPath( "export" ).addToPath( uuid ).get( ApiResponse.class );
         }
-        catch ( ResponseProcessingException uie ) {
+        catch ( ClientErrorException uie ) {
             fail( "We got back "+uie.getResponse().getStatus()+" instead of having a successful call" );
         }
 
@@ -135,7 +135,7 @@ public class ExportResourceIT extends AbstractRestIT {
                                        .app().addToPath( clientSetup.getAppUuid() )
                                        .addToPath( "export" ).post( ApiResponse.class, payloadBuilder() );
         }
-        catch ( ResponseProcessingException uie ) {
+        catch ( ClientErrorException uie ) {
             fail( "We got back "+uie.getResponse().getStatus()+" instead of having a successful call" );
         }
 
@@ -150,7 +150,7 @@ public class ExportResourceIT extends AbstractRestIT {
             exportEntity = management().orgs().org( clientSetup.getOrganizationName() )
                                        .addToPath( "export" ).addToPath( uuid ).get( ApiResponse.class );
         }
-        catch ( ResponseProcessingException uie ) {
+        catch ( ClientErrorException uie ) {
             fail( "We got back "+uie.getResponse().getStatus()+" instead of having a successful call" );
         }
 
@@ -180,7 +180,7 @@ public class ExportResourceIT extends AbstractRestIT {
             exportEntity = management().orgs().org( clientSetup.getOrganizationName() )
                                        .addToPath( "export" ).addToPath( uuid ).get( ApiResponse.class );
         }
-        catch ( ResponseProcessingException uie ) {
+        catch ( ClientErrorException uie ) {
             fail( "We got back "+uie.getResponse().getStatus()+" instead of having a successful call" );
         }
 
@@ -201,7 +201,7 @@ public class ExportResourceIT extends AbstractRestIT {
                                        .addToPath( "export" ).addToPath( fake.toString() ).get( ApiResponse.class );
             fail( "Should not have been able to get fake uuid" );
         }
-        catch ( ResponseProcessingException uie ) {
+        catch ( ClientErrorException uie ) {
             assertEquals( Response.Status.BAD_REQUEST.getStatusCode(), uie.getResponse().getStatus() );
 
         }
@@ -219,7 +219,7 @@ public class ExportResourceIT extends AbstractRestIT {
                 new HashMap<String, Object>() );
             fail( "Should not have passed, The payload is empty." );
         }
-        catch ( ResponseProcessingException uie ) {
+        catch ( ClientErrorException uie ) {
             assertEquals( Response.Status.BAD_REQUEST.getStatusCode(), uie.getResponse().getStatus() );
         }
     }
@@ -233,7 +233,7 @@ public class ExportResourceIT extends AbstractRestIT {
                         .addToPath( "export" ).post( ApiResponse.class, new HashMap<String, Object>()  );
             fail( "Should not have passed, The payload is empty." );
         }
-        catch ( ResponseProcessingException uie ) {
+        catch ( ClientErrorException uie ) {
             assertEquals( Response.Status.BAD_REQUEST.getStatusCode(), uie.getResponse().getStatus() );
         }
     }
@@ -250,7 +250,7 @@ public class ExportResourceIT extends AbstractRestIT {
 
             fail( "Should not have passed, The payload is empty." );
         }
-        catch ( ResponseProcessingException uie ) {
+        catch ( ClientErrorException uie ) {
             assertEquals( Response.Status.BAD_REQUEST.getStatusCode(), uie.getResponse().getStatus() );
         }
     }
@@ -267,7 +267,7 @@ public class ExportResourceIT extends AbstractRestIT {
                         .addToPath( "export" ).addToPath( fake.toString() ).get(ApiResponse.class ,false);
             fail( "Should not have passed as we didn't have an access token." );
         }
-        catch ( ResponseProcessingException uie ) {
+        catch ( ClientErrorException uie ) {
             assertEquals( Response.Status.UNAUTHORIZED.getStatusCode(), uie.getResponse().getStatus() );
         }
     }
@@ -283,7 +283,7 @@ public class ExportResourceIT extends AbstractRestIT {
                         .addToPath( "export" ).addToPath( fake.toString() ).get(ApiResponse.class ,false);
             fail( "Should not have passed as we didn't have an access token." );
         }
-        catch ( ResponseProcessingException uie ) {
+        catch ( ClientErrorException uie ) {
             assertEquals( Response.Status.UNAUTHORIZED.getStatusCode(), uie.getResponse().getStatus() );
         }
     }
@@ -298,7 +298,7 @@ public class ExportResourceIT extends AbstractRestIT {
                         .addToPath( "export" ).addToPath( fake.toString() ).get(ApiResponse.class ,false);
             fail( "Should not have passed as we didn't have an access token." );
         }
-        catch ( ResponseProcessingException uie ) {
+        catch ( ClientErrorException uie ) {
             assertEquals( Response.Status.UNAUTHORIZED.getStatusCode(), uie.getResponse().getStatus() );
         }
     }
@@ -317,7 +317,7 @@ public class ExportResourceIT extends AbstractRestIT {
             fail( "Should not have passed as we were missing an important part of the payload" );
 
         }
-        catch ( ResponseProcessingException uie ) {
+        catch ( ClientErrorException uie ) {
             assertEquals( Response.Status.BAD_REQUEST.getStatusCode(), uie.getResponse().getStatus() );
         }
     }
@@ -339,7 +339,7 @@ public class ExportResourceIT extends AbstractRestIT {
             fail( "Should not have passed as we were missing an important part of the payload" );
 
         }
-        catch ( ResponseProcessingException uie ) {
+        catch ( ClientErrorException uie ) {
             assertEquals( Response.Status.BAD_REQUEST.getStatusCode(), uie.getResponse().getStatus() );
         }
     }
@@ -361,7 +361,7 @@ public class ExportResourceIT extends AbstractRestIT {
             fail( "Should not have passed as we were missing an important part of the payload" );
 
         }
-        catch ( ResponseProcessingException uie ) {
+        catch ( ClientErrorException uie ) {
             assertEquals( Response.Status.BAD_REQUEST.getStatusCode(), uie.getResponse().getStatus() );
         }
     }
@@ -380,7 +380,7 @@ public class ExportResourceIT extends AbstractRestIT {
             fail( "Should not have passed as we were missing an important part of the payload" );
 
         }
-        catch ( ResponseProcessingException uie ) {
+        catch ( ClientErrorException uie ) {
             assertEquals( Response.Status.BAD_REQUEST.getStatusCode(), uie.getResponse().getStatus() );
         }
     }
@@ -402,7 +402,7 @@ public class ExportResourceIT extends AbstractRestIT {
             fail( "Should not have passed as we were missing an important part of the payload" );
 
         }
-        catch ( ResponseProcessingException uie ) {
+        catch ( ClientErrorException uie ) {
             assertEquals( Response.Status.BAD_REQUEST.getStatusCode(), uie.getResponse().getStatus() );
         }
     }
@@ -424,7 +424,7 @@ public class ExportResourceIT extends AbstractRestIT {
             fail( "Should not have passed as we were missing an important part of the payload" );
 
         }
-        catch ( ResponseProcessingException uie ) {
+        catch ( ClientErrorException uie ) {
             assertEquals( Response.Status.BAD_REQUEST.getStatusCode(), uie.getResponse().getStatus() );
         }
     }
@@ -445,7 +445,7 @@ public class ExportResourceIT extends AbstractRestIT {
             fail( "Should not have passed as we were missing an important part of the payload" );
 
         }
-        catch ( ResponseProcessingException uie ) {
+        catch ( ClientErrorException uie ) {
             assertEquals( Response.Status.BAD_REQUEST.getStatusCode(), uie.getResponse().getStatus() );
         }
 
@@ -461,7 +461,7 @@ public class ExportResourceIT extends AbstractRestIT {
             fail( "Should not have passed as we were missing an important part of the payload" );
 
         }
-        catch ( ResponseProcessingException uie ) {
+        catch ( ClientErrorException uie ) {
             assertEquals( Response.Status.BAD_REQUEST.getStatusCode(), uie.getResponse().getStatus() );
         }
 
@@ -477,7 +477,7 @@ public class ExportResourceIT extends AbstractRestIT {
             fail( "Should not have passed as we were missing an important part of the payload" );
 
         }
-        catch ( ResponseProcessingException uie ) {
+        catch ( ClientErrorException uie ) {
             assertEquals( Response.Status.BAD_REQUEST.getStatusCode(), uie.getResponse().getStatus() );
         }
     }
@@ -498,7 +498,7 @@ public class ExportResourceIT extends AbstractRestIT {
             fail( "Should not have passed as we were missing an important part of the payload" );
 
         }
-        catch ( ResponseProcessingException uie ) {
+        catch ( ClientErrorException uie ) {
             assertEquals( Response.Status.BAD_REQUEST.getStatusCode(), uie.getResponse().getStatus() );
         }
 
@@ -515,7 +515,7 @@ public class ExportResourceIT extends AbstractRestIT {
             fail( "Should not have passed as we were missing an important part of the payload" );
 
         }
-        catch ( ResponseProcessingException uie ) {
+        catch ( ClientErrorException uie ) {
             assertEquals( Response.Status.BAD_REQUEST.getStatusCode(), uie.getResponse().getStatus() );
         }
 
@@ -532,7 +532,7 @@ public class ExportResourceIT extends AbstractRestIT {
             fail( "Should not have passed as we were missing an important part of the payload" );
 
         }
-        catch ( ResponseProcessingException uie ) {
+        catch ( ClientErrorException uie ) {
             assertEquals( Response.Status.BAD_REQUEST.getStatusCode(), uie.getResponse().getStatus() );
         }
     }
@@ -554,7 +554,7 @@ public class ExportResourceIT extends AbstractRestIT {
             fail( "Should not have passed as we were missing an important part of the payload" );
 
         }
-        catch ( ResponseProcessingException uie ) {
+        catch ( ClientErrorException uie ) {
             assertEquals( Response.Status.BAD_REQUEST.getStatusCode(), uie.getResponse().getStatus() );
         }
 
@@ -572,7 +572,7 @@ public class ExportResourceIT extends AbstractRestIT {
             fail( "Should not have passed as we were missing an important part of the payload" );
 
         }
-        catch ( ResponseProcessingException uie ) {
+        catch ( ClientErrorException uie ) {
             assertEquals( Response.Status.BAD_REQUEST.getStatusCode(), uie.getResponse().getStatus() );
         }
 
@@ -590,7 +590,7 @@ public class ExportResourceIT extends AbstractRestIT {
             fail( "Should not have passed as we were missing an important part of the payload" );
 
         }
-        catch ( ResponseProcessingException uie ) {
+        catch ( ClientErrorException uie ) {
             assertEquals( Response.Status.BAD_REQUEST.getStatusCode(), uie.getResponse().getStatus() );
         }
     }

http://git-wip-us.apache.org/repos/asf/usergrid/blob/eb2aa6ff/stack/rest/src/test/java/org/apache/usergrid/rest/management/ImportResourceIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/management/ImportResourceIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/management/ImportResourceIT.java
index c55f953..784ff67 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/management/ImportResourceIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/management/ImportResourceIT.java
@@ -49,7 +49,7 @@ import org.junit.*;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import javax.ws.rs.client.ResponseProcessingException;
+import javax.ws.rs.ClientErrorException;
 import javax.ws.rs.core.Response;
 import java.io.File;
 import java.util.ArrayList;
@@ -211,7 +211,7 @@ public class ImportResourceIT extends AbstractRestIT {
             this.management().orgs().org( org ).app().addToPath(app)
                 .addToPath("imports").addToPath(entity.getUuid().toString()).get();
             fail("Should not be able to read import job with unauthorized token");
-        } catch (ResponseProcessingException ex) {
+        } catch (ClientErrorException ex) {
             errorParse(401, "unauthorized", ex);
         }
 
@@ -229,7 +229,7 @@ public class ImportResourceIT extends AbstractRestIT {
 
         try {
             this.management().orgs().org( org ).app().addToPath(app).addToPath("imports").post(Entity.class,payload);
-        } catch (ResponseProcessingException uie) {
+        } catch (ClientErrorException uie) {
             responseStatus = Response.Status.fromStatusCode( uie.getResponse().getStatus() );
         }
         assertEquals(Response.Status.BAD_REQUEST, responseStatus);
@@ -249,7 +249,7 @@ public class ImportResourceIT extends AbstractRestIT {
 
         try {
             this.management().orgs().org( org ).app().addToPath(app).addToPath("imports").post(Entity.class,payload);
-        } catch (ResponseProcessingException uie) {
+        } catch (ClientErrorException uie) {
             responseStatus = Response.Status.fromStatusCode( uie.getResponse().getStatus() );
         }
         assertEquals(Response.Status.BAD_REQUEST, responseStatus);
@@ -271,7 +271,7 @@ public class ImportResourceIT extends AbstractRestIT {
 
         try {
             this.management().orgs().org( org ).app().addToPath(app).addToPath("imports").post(Entity.class,payload);
-        } catch (ResponseProcessingException uie) {
+        } catch (ClientErrorException uie) {
             responseStatus = Response.Status.fromStatusCode( uie.getResponse().getStatus() );
         }
         assertEquals(Response.Status.BAD_REQUEST, responseStatus);
@@ -294,7 +294,7 @@ public class ImportResourceIT extends AbstractRestIT {
 
         try {
             this.management().orgs().org( org ).app().addToPath(app).addToPath("imports").post(Entity.class,payload);
-        } catch (ResponseProcessingException uie) {
+        } catch (ClientErrorException uie) {
             responseStatus = Response.Status.fromStatusCode( uie.getResponse().getStatus() );
         }
         assertEquals(Response.Status.BAD_REQUEST, responseStatus);
@@ -307,7 +307,7 @@ public class ImportResourceIT extends AbstractRestIT {
 
         try {
             this.management().orgs().org( org ).app().addToPath(app).addToPath("imports").post(Entity.class,payload);
-        } catch (ResponseProcessingException uie) {
+        } catch (ClientErrorException uie) {
             responseStatus = Response.Status.fromStatusCode( uie.getResponse().getStatus() );
         }
         assertEquals(Response.Status.BAD_REQUEST, responseStatus);
@@ -320,7 +320,7 @@ public class ImportResourceIT extends AbstractRestIT {
 
         try {
             this.management().orgs().org( org ).app().addToPath(app).addToPath("imports").post(Entity.class,payload);
-        } catch (ResponseProcessingException uie) {
+        } catch (ClientErrorException uie) {
             responseStatus = Response.Status.fromStatusCode( uie.getResponse().getStatus() );
         }
         assertEquals(Response.Status.BAD_REQUEST, responseStatus);

http://git-wip-us.apache.org/repos/asf/usergrid/blob/eb2aa6ff/stack/rest/src/test/java/org/apache/usergrid/rest/management/ManagementResourceIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/management/ManagementResourceIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/management/ManagementResourceIT.java
index 386f3b9..a26c8c7 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/management/ManagementResourceIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/management/ManagementResourceIT.java
@@ -30,7 +30,7 @@ import org.junit.Test;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import javax.ws.rs.client.ResponseProcessingException;
+import javax.ws.rs.ClientErrorException;
 import javax.ws.rs.core.Form;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.Response;
@@ -99,11 +99,12 @@ public class ManagementResourceIT extends AbstractRestIT {
     @Test
     public void crossOrgsNotViewable() throws Exception {
 
-        String username = "test" + UUIDUtils.newTimeUUID();
-        String name = "someguy2";
-        String email = "someguy" + "@usergrid.com";
+        String differentiator = UUIDUtils.newTimeUUID().toString();
+        String username = "test" + differentiator;
+        String name = "someguy2" + differentiator;
+        String email = "someguy" + differentiator + "@usergrid.com";
         String password = "password";
-        String orgName = "someneworg" + UUIDUtils.newTimeUUID();
+        String orgName = "someneworg" + differentiator;
 
         Entity payload =
                 new Entity().chainPut("company", "Apigee" );
@@ -121,7 +122,7 @@ public class ManagementResourceIT extends AbstractRestIT {
         try {
             returnVal = this.management().orgs().org( orgName ).get(String.class);
         }
-        catch ( ResponseProcessingException uie ) {
+        catch ( ClientErrorException uie ) {
             status = Response.Status.fromStatusCode( uie.getResponse().getStatus() );
         }
 
@@ -133,7 +134,7 @@ public class ManagementResourceIT extends AbstractRestIT {
         try {
             this.management().orgs().org( this.clientSetup.getOrganizationName() ).get( String.class );
         }
-        catch ( ResponseProcessingException uie ) {
+        catch ( ClientErrorException uie ) {
             status = Response.Status.fromStatusCode( uie.getResponse().getStatus() );
         }
 
@@ -145,7 +146,7 @@ public class ManagementResourceIT extends AbstractRestIT {
         try {
             this.management().orgs().org( this.clientSetup.getOrganizationName() ).get( String.class );
         }
-        catch ( ResponseProcessingException uie ) {
+        catch ( ClientErrorException uie ) {
             status = Response.Status.fromStatusCode( uie.getResponse().getStatus() );
         }
 
@@ -336,7 +337,7 @@ public class ManagementResourceIT extends AbstractRestIT {
         try {
             userdata = management.users().user(clientSetup.getEmail()).get();
         }
-        catch ( ResponseProcessingException uie ) {
+        catch ( ClientErrorException uie ) {
             responseStatus = Response.Status.fromStatusCode( uie.getResponse().getStatus() );
         }
 
@@ -455,7 +456,7 @@ public class ManagementResourceIT extends AbstractRestIT {
         try {
            management.token().post( JsonNode.class, payload );
         }
-        catch ( ResponseProcessingException uie ) {
+        catch ( ClientErrorException uie ) {
             responseStatus = Response.Status.fromStatusCode( uie.getResponse().getStatus());
         }
 
@@ -476,7 +477,7 @@ public class ManagementResourceIT extends AbstractRestIT {
         try {
             management.token().post( JsonNode.class, payload );
         }
-        catch ( ResponseProcessingException uie ) {
+        catch ( ClientErrorException uie ) {
             responseStatus = Response.Status.fromStatusCode( uie.getResponse().getStatus() );
         }
 
@@ -507,7 +508,7 @@ public class ManagementResourceIT extends AbstractRestIT {
         try {
             response = management.users().user(clientSetup.getUsername()).get();
         }
-        catch ( ResponseProcessingException uie ) {
+        catch ( ClientErrorException uie ) {
             status = Response.Status.fromStatusCode( uie.getResponse().getStatus() );
         }
 
@@ -530,7 +531,7 @@ public class ManagementResourceIT extends AbstractRestIT {
         try {
             management.users().user(clientSetup.getUsername()).get();
         }
-        catch ( ResponseProcessingException uie ) {
+        catch ( ClientErrorException uie ) {
             status = Response.Status.fromStatusCode( uie.getResponse().getStatus() );
         }
 
@@ -589,7 +590,7 @@ public class ManagementResourceIT extends AbstractRestIT {
 
                 fail( "Validation should have failed" );
 
-            } catch (ResponseProcessingException actual) {
+            } catch (ClientErrorException actual) {
                 assertEquals( 404, actual.getResponse().getStatus() );
                 String errorMsg = actual.getResponse().readEntity( JsonNode.class )
                     .get( "error_description" ).toString();
@@ -640,7 +641,7 @@ public class ManagementResourceIT extends AbstractRestIT {
                 ApiResponse postResponse = pathResource( "management/token" ).post( false, ApiResponse.class, loginInfo );
                 fail( "Login as Admin User must fail when validate external tokens is enabled" );
 
-            } catch (ResponseProcessingException actual) {
+            } catch (ClientErrorException actual) {
                 assertEquals( 400, actual.getResponse().getStatus() );
                 String errorMsg = actual.getResponse().readEntity( JsonNode.class )
                     .get( "error_description" ).toString();
@@ -648,7 +649,7 @@ public class ManagementResourceIT extends AbstractRestIT {
                 assertTrue( errorMsg.contains( "Admin Users must login via" ) );
 
             } catch (Exception e) {
-                fail( "We expected a ResponseProcessingException" );
+                fail( "We expected a ClientErrorException" );
             }
 
             // login as superuser must succeed

http://git-wip-us.apache.org/repos/asf/usergrid/blob/eb2aa6ff/stack/rest/src/test/java/org/apache/usergrid/rest/management/OrganizationsIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/management/OrganizationsIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/management/OrganizationsIT.java
index a0ebf6e..64ad8b0 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/management/OrganizationsIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/management/OrganizationsIT.java
@@ -29,7 +29,7 @@ import org.apache.usergrid.persistence.index.utils.UUIDUtils;
 import org.apache.usergrid.rest.test.resource.AbstractRestIT;
 import org.apache.usergrid.rest.test.resource.RestClient;
 
-import javax.ws.rs.client.ResponseProcessingException;
+import javax.ws.rs.ClientErrorException;
 import javax.ws.rs.core.Form;
 import javax.ws.rs.core.Response;
 
@@ -123,7 +123,7 @@ public class OrganizationsIT extends AbstractRestIT {
             clientSetup.getRestClient().management().orgs().post( orgTestDuplicatePayload );
             fail("Should not have been able to create duplicate organization");
         }
-        catch ( ResponseProcessingException ex ) {
+        catch ( ClientErrorException ex ) {
             errorParse( 400,duplicateUniquePropertyExistsErrorMessage, ex );
         }
 
@@ -135,7 +135,7 @@ public class OrganizationsIT extends AbstractRestIT {
             tokenError = clientSetup.getRestClient().management().token().post(false,Token.class, tokenPayload,null );
             fail( "Should not have created user" );
         }
-        catch ( ResponseProcessingException ex ) {
+        catch ( ClientErrorException ex ) {
             errorParse( 400,invalidGrantErrorMessage, ex );
 
         }
@@ -179,7 +179,7 @@ public class OrganizationsIT extends AbstractRestIT {
             clientSetup.getRestClient().management().orgs().post( orgDuplicatePayload );
             fail( "Should not have created organization" );
         }
-        catch ( ResponseProcessingException ex ) {
+        catch ( ClientErrorException ex ) {
             errorParse( 400,duplicateUniquePropertyExistsErrorMessage,ex);
         }
 
@@ -190,7 +190,7 @@ public class OrganizationsIT extends AbstractRestIT {
             tokenError = clientSetup.getRestClient().management().token().post(false,Token.class, tokenPayload,null );
             fail( "Should not have created organization" );
         }
-        catch ( ResponseProcessingException ex ) {
+        catch ( ClientErrorException ex ) {
             errorParse( 400,invalidGrantErrorMessage,ex );
         }
 
@@ -222,7 +222,7 @@ public class OrganizationsIT extends AbstractRestIT {
         try{
             Organization organizationReturned = clientSetup.getRestClient().management().orgs().post(queryParameters);
             fail();
-        }catch (ResponseProcessingException e){
+        }catch (ClientErrorException e){
             assertEquals("ensure bad request",e.getResponse().getStatus(), 400);
         }
 
@@ -295,7 +295,7 @@ public class OrganizationsIT extends AbstractRestIT {
             //Delete default organization
             clientSetup.getRestClient().management().orgs().org( clientSetup.getOrganizationName() ).delete();
             fail( "Delete is not implemented yet" );
-        }catch(ResponseProcessingException uie){
+        }catch(ClientErrorException uie){
             assertEquals( Response.Status.NOT_IMPLEMENTED ,uie.getResponse().getStatus());
         }
     }

http://git-wip-us.apache.org/repos/asf/usergrid/blob/eb2aa6ff/stack/rest/src/test/java/org/apache/usergrid/rest/management/RegistrationIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/management/RegistrationIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/management/RegistrationIT.java
index fc18292..efa1536 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/management/RegistrationIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/management/RegistrationIT.java
@@ -30,7 +30,7 @@ import org.slf4j.LoggerFactory;
 
 import javax.mail.*;
 import javax.mail.internet.MimeMultipart;
-import javax.ws.rs.client.ResponseProcessingException;
+import javax.ws.rs.ClientErrorException;
 import javax.ws.rs.core.Form;
 import javax.ws.rs.core.MediaType;
 import java.io.IOException;
@@ -109,7 +109,7 @@ public class RegistrationIT extends AbstractRestIT {
                     .request()
                     .accept(MediaType.APPLICATION_JSON)
                     .put( javax.ws.rs.client.Entity.form(form) );
-            } catch (ResponseProcessingException e) {
+            } catch (ClientErrorException e) {
                 assertEquals("Should receive a 404 Not Found", 404, e.getResponse().getStatus());
             }
         } finally {

http://git-wip-us.apache.org/repos/asf/usergrid/blob/eb2aa6ff/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/AbstractRestIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/AbstractRestIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/AbstractRestIT.java
index cc5807e..4282853 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/AbstractRestIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/AbstractRestIT.java
@@ -29,10 +29,16 @@ import org.apache.usergrid.rest.test.resource.model.Token;
 import org.apache.usergrid.rest.test.resource.state.ClientContext;
 import org.glassfish.jersey.client.ClientConfig;
 import org.glassfish.jersey.jackson.JacksonFeature;
+import org.glassfish.jersey.test.DeploymentContext;
 import org.glassfish.jersey.test.JerseyTest;
+import org.glassfish.jersey.test.external.ExternalTestContainerFactory;
+import org.glassfish.jersey.test.spi.TestContainer;
+import org.glassfish.jersey.test.spi.TestContainerFactory;
 import org.junit.Rule;
 
-import javax.ws.rs.client.ResponseProcessingException;
+import javax.ws.rs.ClientErrorException;
+import javax.ws.rs.client.WebTarget;
+import javax.ws.rs.core.Application;
 import java.net.URI;
 import java.net.URISyntaxException;
 import java.net.URLClassLoader;
@@ -56,13 +62,14 @@ public class AbstractRestIT extends JerseyTest {
     @Rule
     public ClientSetup clientSetup = new ClientSetup( this.getBaseURI().toString() );
 
-//    protected static final Application descriptor;
-//
-//    public AbstractRestIT() {
-//        super( descriptor );
-//    }
+    protected static final Application descriptor = new Application();
 
 
+    @Override
+    protected Application configure() {
+        return descriptor;
+    }
+
     protected ObjectMapper mapper = new ObjectMapper();
 
     static {
@@ -109,10 +116,31 @@ public class AbstractRestIT extends JerseyTest {
         }
     }
 
-//    @Override
-//    protected TestContainerFactory getTestContainerFactory() {
-//        return new ExternalTestContainerFactory();
-//    }
+    @Override
+    protected TestContainerFactory getTestContainerFactory() {
+        final URI baseURI = getBaseURI();
+        return (uri, deploymentContext) -> new TestContainer() {
+            @Override
+            public ClientConfig getClientConfig() {
+                return clientConfig;
+            }
+
+            @Override
+            public URI getBaseUri() {
+                return baseURI;
+            }
+
+            @Override
+            public void start() {
+                // noop
+            }
+
+            @Override
+            public void stop() {
+                // noop
+            }
+        };
+    }
 
     ///myorg/
     protected OrganizationResource org(){
@@ -151,13 +179,13 @@ public class AbstractRestIT extends JerseyTest {
 
 
     /**
-     * Takes in the expectedStatus message and the expectedErrorMessage then compares it to the ResponseProcessingException
+     * Takes in the expectedStatus message and the expectedErrorMessage then compares it to the ClientErrorException
      * to make sure that we got what we expected.
      * @param expectedStatus
      * @param expectedErrorMessage
      * @param uie
      */
-    public void errorParse(int expectedStatus, String expectedErrorMessage, ResponseProcessingException uie){
+    public void errorParse(int expectedStatus, String expectedErrorMessage, ClientErrorException uie){
         assertEquals(expectedStatus,uie.getResponse().getStatus());
         JsonNode errorJson = uie.getResponse().readEntity( JsonNode.class );
         assertEquals( expectedErrorMessage, errorJson.get( "error" ).asText() );
@@ -165,16 +193,16 @@ public class AbstractRestIT extends JerseyTest {
     }
 
 
-    protected Token getAdminToken(String username, String password){
-        return this.clientSetup.getRestClient().management().token().post(false,Token.class,
-                new Token(username, password),null,false
-        );
+    protected Token getAdminToken(String username, String password) {
+        Token token = new Token(username, password);
+        return this.clientSetup.getRestClient().management().token()
+            .post( false, Token.class, token, null, false );
     }
 
-    protected Token getAdminToken(){
-        return this.clientSetup.getRestClient().management().token().post(false,Token.class,
-                new Token(this.clientSetup.getUsername(),this.clientSetup.getUsername()),null,false
-        );
+    protected Token getAdminToken() {
+        Token token = new Token(this.clientSetup.getUsername(), this.clientSetup.getPassword());
+        return this.clientSetup.getRestClient().management().token()
+            .post( false, Token.class, token, null, false);
     }
     public Map<String, Object> getRemoteTestProperties() {
         return clientSetup.getRestClient().testPropertiesResource().get().getProperties();

http://git-wip-us.apache.org/repos/asf/usergrid/blob/eb2aa6ff/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/ClientSetup.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/ClientSetup.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/ClientSetup.java
index 3254173..f13e215 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/ClientSetup.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/ClientSetup.java
@@ -30,6 +30,7 @@ import org.junit.runners.model.Statement;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import javax.ws.rs.BadRequestException;
 import java.io.IOException;
 
 
@@ -95,7 +96,7 @@ public class ClientSetup implements TestRule {
         try {
             restClient.superuserSetup();
             superuserToken = restClient.management().token().get(superuserName, superuserPassword);
-        } catch ( Exception e ) {
+        } catch ( BadRequestException e ) {
             if ( logger.isDebugEnabled() ) {
                 logger.debug( "Error creating superuser, may already exist", e );
             } else {

http://git-wip-us.apache.org/repos/asf/usergrid/blob/eb2aa6ff/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/RestClient.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/RestClient.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/RestClient.java
index 23fa6c3..827f874 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/RestClient.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/RestClient.java
@@ -22,6 +22,7 @@ import org.apache.usergrid.rest.test.resource.endpoints.mgmt.ManagementResource;
 import org.apache.usergrid.rest.test.resource.state.ClientContext;
 import org.glassfish.jersey.client.ClientConfig;
 import org.glassfish.jersey.client.authentication.HttpAuthenticationFeature;
+import org.glassfish.jersey.media.multipart.MultiPartFeature;
 
 import javax.ws.rs.client.Client;
 import javax.ws.rs.client.ClientBuilder;
@@ -40,7 +41,9 @@ public class RestClient implements UrlResource {
 
     public WebTarget resource;
     ClientConfig config = new ClientConfig();
-    Client client = ClientBuilder.newClient( config );
+
+    Client client = ClientBuilder.newClient( config )
+        .register(MultiPartFeature.class);
 
     /**
      *
@@ -111,9 +114,11 @@ public class RestClient implements UrlResource {
     }
 
     public void superuserSetup() {
-        this.getTarget().path( "system/superuser/setup" ).request()
-            .property( HttpAuthenticationFeature.HTTP_AUTHENTICATION_BASIC_USERNAME, "superuser")
-            .property( HttpAuthenticationFeature.HTTP_AUTHENTICATION_BASIC_PASSWORD, "superpassword" )
+
+        HttpAuthenticationFeature feature = HttpAuthenticationFeature.basicBuilder()
+            .credentials( "superuser", "superpassword" ).build();
+
+        getTarget().path( "system/superuser/setup" ).register( feature ).request()
             .accept( MediaType.APPLICATION_JSON )
             .get( JsonNode.class );
     }

http://git-wip-us.apache.org/repos/asf/usergrid/blob/eb2aa6ff/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/NamedResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/NamedResource.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/NamedResource.java
index 336d709..34e3a84 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/NamedResource.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/NamedResource.java
@@ -22,8 +22,10 @@ import org.apache.usergrid.rest.test.resource.model.Entity;
 import org.apache.usergrid.rest.test.resource.model.QueryParameters;
 import org.apache.usergrid.rest.test.resource.model.Token;
 import org.apache.usergrid.rest.test.resource.state.ClientContext;
-import org.glassfish.jersey.client.authentication.HttpAuthenticationFeature;
+import static org.glassfish.jersey.client.authentication.HttpAuthenticationFeature.HTTP_AUTHENTICATION_BASIC_USERNAME;
+import static org.glassfish.jersey.client.authentication.HttpAuthenticationFeature.HTTP_AUTHENTICATION_BASIC_PASSWORD;
 import org.glassfish.jersey.media.multipart.FormDataMultiPart;
+import org.glassfish.jersey.media.multipart.MultiPart;
 
 import javax.ws.rs.client.Invocation;
 import javax.ws.rs.client.WebTarget;
@@ -46,11 +48,10 @@ public class NamedResource implements UrlResource {
 
     protected final String name;
     protected final ClientContext context;
-    /* Stores the path of the parent that called it.
-    i.e If we had a ApplicationResource ( an instance of a namedResource ) this would contain the OrganizationResource.
-     */
-    protected final UrlResource parent;
 
+    /** Stores the path of the parent that called it. i.e If we had a ApplicationResource
+       (an instance of a namedResource) this would contain the OrganizationResource. */
+    protected final UrlResource parent;
 
     public NamedResource( final String name, final ClientContext context, final UrlResource parent ) {
         this.name = name;
@@ -58,7 +59,6 @@ public class NamedResource implements UrlResource {
         this.parent = parent;
     }
 
-
     @Override
     public String getPath() {
         return name + getMatrix();
@@ -68,17 +68,19 @@ public class NamedResource implements UrlResource {
     public WebTarget getTarget() {
         return getTarget( false );
     }
+
     public WebTarget getTarget(boolean useToken) {
         return getTarget( useToken, null );
     }
-    public WebTarget getTarget(boolean useToken,Token token) {
+
+    public WebTarget getTarget(boolean useToken, Token token) {
         WebTarget resource = parent.getTarget().path( getPath() );
         token = token !=null ? token : this.context.getToken();
         //error checking
         if (token == null) {
             return resource;
         }
-        return  useToken    ? resource.queryParam("access_token",token.getAccessToken()) :  resource;
+        return useToken ? resource.queryParam("access_token", token.getAccessToken()) :  resource;
     }
 
     protected WebTarget addParametersToResource(WebTarget resource, final QueryParameters parameters){
@@ -246,8 +248,10 @@ public class NamedResource implements UrlResource {
 
 
         if ( useBasicAuthentication ) {
-            builder = builder.property( HttpAuthenticationFeature.HTTP_AUTHENTICATION_BASIC_USERNAME, "superuser")
-                             .property( HttpAuthenticationFeature.HTTP_AUTHENTICATION_BASIC_PASSWORD, "superpassword");
+            String uname = (String)entity.get("username");
+            String pword = (String)entity.get("password");
+            builder = builder.property( HTTP_AUTHENTICATION_BASIC_USERNAME, uname )
+                             .property( HTTP_AUTHENTICATION_BASIC_PASSWORD, pword );
         }
 
         // it's OK for the entity to be null
@@ -258,7 +262,7 @@ public class NamedResource implements UrlResource {
 
     //For edge cases like Organizations and Tokens without any payload
     public <T> T get(Class<T> type) {
-        return get(type,null,true);
+        return get(type, null, true);
 
     }
 
@@ -273,9 +277,9 @@ public class NamedResource implements UrlResource {
         return get( type, queryParameters, true );
     }
 
-    public <T> T get(Class<T> type,QueryParameters queryParameters, boolean useToken) {
+    public <T> T get(Class<T> type, QueryParameters queryParameters, boolean useToken) {
         WebTarget resource = getTarget( useToken );
-        if(queryParameters!=null) {
+        if (queryParameters != null) {
             resource = addParametersToResource(resource, queryParameters);
         }
         GenericType<T> gt = new GenericType<>((Class) type);
@@ -289,13 +293,13 @@ public class NamedResource implements UrlResource {
         return "";
     }
 
-    public ApiResponse post( boolean useToken, FormDataMultiPart multiPartForm ) {
+    public ApiResponse post( boolean useToken, MultiPart multiPartForm ) {
         WebTarget resource = getTarget( useToken );
         return resource.request().post(
             javax.ws.rs.client.Entity.entity( multiPartForm, multiPartForm.getMediaType() ), ApiResponse.class );
     }
 
-    public ApiResponse post( FormDataMultiPart multiPartForm ) {
+    public ApiResponse post( MultiPart multiPartForm ) {
         return post( true, multiPartForm );
     }
 

http://git-wip-us.apache.org/repos/asf/usergrid/blob/eb2aa6ff/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/SetupResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/SetupResource.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/SetupResource.java
index 75f1b6b..f11b062 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/SetupResource.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/SetupResource.java
@@ -39,10 +39,10 @@ public class SetupResource extends NamedResource {
         WebTarget resource = getTarget();
         resource = addParametersToResource( resource, queryParameters );
 
-        return resource.request()
-            .property( HttpAuthenticationFeature.HTTP_AUTHENTICATION_BASIC_USERNAME, "superuser")
-            .property( HttpAuthenticationFeature.HTTP_AUTHENTICATION_BASIC_PASSWORD, "superpassword" )
-            .accept( MediaType.APPLICATION_JSON )
-            .get( Entity.class );
+        HttpAuthenticationFeature feature = HttpAuthenticationFeature.basicBuilder()
+            .credentials( "superuser", "superpassword" ).build();
+
+        return resource.register( feature ).request()
+            .accept( MediaType.APPLICATION_JSON ).get( Entity.class );
     }
 }

http://git-wip-us.apache.org/repos/asf/usergrid/blob/eb2aa6ff/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/mgmt/OrgResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/mgmt/OrgResource.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/mgmt/OrgResource.java
index 096422c..0569ac2 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/mgmt/OrgResource.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/mgmt/OrgResource.java
@@ -28,7 +28,10 @@ import org.apache.usergrid.rest.test.resource.state.ClientContext;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import javax.ws.rs.BadRequestException;
+import javax.ws.rs.ClientErrorException;
 import javax.ws.rs.client.Entity;
+import javax.ws.rs.ClientErrorException;
 import javax.ws.rs.client.WebTarget;
 import javax.ws.rs.core.Form;
 import javax.ws.rs.core.MediaType;
@@ -100,11 +103,14 @@ public class OrgResource  extends NamedResource {
     public Organization post(Organization organization){
 
         // use string type so we can log actual response from server
-        String responseString = getTarget(false).request()
-            .accept( MediaType.APPLICATION_JSON )
-            .post( Entity.json(organization), String.class );
-
-        logger.debug("Response from post: " + responseString);
+        String responseString = null;
+        try {
+            responseString = getTarget( false ).request()
+                .accept( MediaType.APPLICATION_JSON )
+                .post( Entity.json( organization ), String.class );
+        } catch ( ClientErrorException e ) {
+            logger.info("Response from post: " + e.getMessage() + ": " + e.getResponse().readEntity( String.class ));
+        }
 
         ObjectMapper mapper = new ObjectMapper();
         ApiResponse response;
@@ -120,9 +126,9 @@ public class OrgResource  extends NamedResource {
         return org;
     }
     public Organization post(Organization organization, Token token){
-        ApiResponse response = getTarget(true,token).request()
+        ApiResponse response = getTarget( true, token ).request()
             .accept( MediaType.APPLICATION_JSON )
-            .post( Entity.json(organization), ApiResponse.class );
+            .post( Entity.json( organization ), ApiResponse.class );
 
         Organization org = new Organization(response);
         org.setOwner( response );
@@ -134,7 +140,7 @@ public class OrgResource  extends NamedResource {
 
         // use string type so we can log actual response from server
         String responseString = getTarget().request()
-            .accept(MediaType.APPLICATION_JSON)
+            .accept( MediaType.APPLICATION_JSON )
             .post( Entity.json( organization ), String.class );
 
         logger.debug("Response from put: " + responseString);

http://git-wip-us.apache.org/repos/asf/usergrid/blob/eb2aa6ff/stack/rest/src/test/resources/log4j.properties
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/resources/log4j.properties b/stack/rest/src/test/resources/log4j.properties
index 71dd540..201550b 100644
--- a/stack/rest/src/test/resources/log4j.properties
+++ b/stack/rest/src/test/resources/log4j.properties
@@ -18,7 +18,7 @@
 # and the pattern to %c instead of %l.  (%l is slower.)
 
 # output messages into a rolling log file as well as stdout
-log4j.rootLogger=WARN,stdout
+log4j.rootLogger=ERROR,stdout
 
 # stdout
 log4j.appender.stdout=org.apache.log4j.ConsoleAppender
@@ -26,12 +26,12 @@ log4j.appender.stdout=org.apache.log4j.ConsoleAppender
 log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
 log4j.appender.stdout.layout.ConversionPattern=%d %p (%t) %c{1} - %m%n
 
+log4j.logger.org.glassfish=DEBUG
+log4j.logger.org.apache.shiro=DEBUG
 log4j.logger.org.apache.usergrid=INFO
+
 #log4j.logger.org.apache.usergrid.cassandra=DEBUG
 #log4j.logger.org.apache.usergrid.persistence.cassandra=DEBUG
-log4j.category.org.apache=ERROR
-log4j.category.org.apache.usergrid=WARN
-log4j.category.org.apache.usergrid.rest=INFO
 
 log4j.logger.org.apache.usergrid.persistence.cassandra.CounterUtils=ERROR
 log4j.logger.org.apache.usergrid.persistence.cassandra.DB=WARN
@@ -46,6 +46,20 @@ log4j.logger.me.prettyprint.hector.api.beans.AbstractComposite=ERROR
 log4j.logger.org.apache.usergrid.locking.singlenode.SingleNodeLockManagerImpl=DEBUG
 log4j.logger.org.apache.usergrid.rest.filters.MeteringFilter=ERROR
 
+log4j.logger.org.apache.usergrid.rest=DEBUG
+log4j.logger.org.apache.usergrid.rest.exceptions=DEBUG
+
+#log4j.logger.org.apache.usergrid.rest.NotificationsIT=DEBUG
+#log4j.logger.org.apache.usergrid.cassandra.CassandraResource=DEBUG
+#log4j.logger.org.apache.usergrid.rest.TomcatResource=INFO
+#log4j.logger.org.apache.usergrid.rest.management=DEBUG
+#log4j.logger.org.apache.usergrid.rest.management.users=DEBUG
+#log4j.logger.org.apache.usergrid.rest.organizations.users=DEBUG
+#log4j.logger.org.apache.usergrid.rest.applications.users.UsersResource=DEBUG
+#log4j.logger.org.apache.usergrid.rest.applications.ServiceResource=DEBUG
+#log4j.logger.org.apache.usergrid.rest.security=DEBUG
+#log4j.logger.org.apache.usergrid.security=DEBUG
+
 #log4j.logger.org.apache.usergrid.corepersistence=DEBUG
 #log4j.logger.org.apache.usergrid.corepersistence.CpRelationManager=DEBUG
 #log4j.logger.org.apache.usergrid.corepersistence.CpEntityManager=DEBUG
@@ -69,19 +83,7 @@ log4j.logger.org.apache.usergrid.rest.filters.MeteringFilter=ERROR
 #log4j.logger.org.apache.usergrid.services.notifiers=DEBUG
 #log4j.logger.org.apache.usergrid.services.groups.users.devices=DEBUG
 
-log4j.logger.org.apache.usergrid.rest=DEBUG
-log4j.logger.org.apache.usergrid.rest.exceptions=DEBUG
-#log4j.logger.org.apache.usergrid.rest.NotificationsIT=DEBUG
-#log4j.logger.org.apache.usergrid.cassandra.CassandraResource=DEBUG
-#log4j.logger.org.apache.usergrid.rest.TomcatResource=INFO
-#log4j.logger.org.apache.usergrid.rest.management=DEBUG
-#log4j.logger.org.apache.usergrid.rest.management.users=DEBUG
-#log4j.logger.org.apache.usergrid.rest.organizations.users=DEBUG
-#log4j.logger.org.apache.usergrid.rest.applications.users.UsersResource=DEBUG
-#log4j.logger.org.apache.usergrid.rest.applications.ServiceResource=DEBUG
-#log4j.logger.org.apache.usergrid.rest.security=DEBUG
-#log4j.logger.org.apache.usergrid.security=DEBUG
-
 #log4j.logger.org.elasticsearch=DEBUG
 #log4j.logger.com.netflix.hystrix=DEBUG
 #log4j.logger.org.antlr=DEBUG
+


[23/54] usergrid git commit: Remove @RequireFooAccess annotations from all resource methods that lack HTTP annotations (i.e. @GET, @PUT, etc.) and add test logic to ensure that cross-org access is restricted to org users and apps.

Posted by sn...@apache.org.
Remove @RequireFooAccess annotations from all resource methods that lack HTTP annotations (i.e. @GET, @PUT, etc.) and add test logic to ensure that cross-org access is restricted to org users and apps.


Project: http://git-wip-us.apache.org/repos/asf/usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/usergrid/commit/1bfa32a9
Tree: http://git-wip-us.apache.org/repos/asf/usergrid/tree/1bfa32a9
Diff: http://git-wip-us.apache.org/repos/asf/usergrid/diff/1bfa32a9

Branch: refs/heads/usergrid-1007-shiro-cache
Commit: 1bfa32a9eabd1a2bcc7c945d34423423167e6489
Parents: 8081401
Author: Dave Johnson <sn...@apache.org>
Authored: Thu Sep 10 15:18:50 2015 -0400
Committer: Dave Johnson <sn...@apache.org>
Committed: Thu Sep 10 15:18:50 2015 -0400

----------------------------------------------------------------------
 .../organizations/OrganizationResource.java     |  3 --
 .../organizations/OrganizationsResource.java    |  2 -
 .../applications/ApplicationResource.java       |  1 -
 .../applications/ApplicationsResource.java      |  2 -
 .../rest/management/ManagementResourceIT.java   | 50 ++++++++++++++++++--
 .../endpoints/mgmt/OrganizationResource.java    |  4 ++
 6 files changed, 51 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/usergrid/blob/1bfa32a9/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/OrganizationResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/OrganizationResource.java b/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/OrganizationResource.java
index 8c5328e..8055849 100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/OrganizationResource.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/OrganizationResource.java
@@ -85,21 +85,18 @@ public class OrganizationResource extends AbstractContextResource {
     }
 
 
-    @RequireOrganizationAccess
     @Path("users")
     public UsersResource getOrganizationUsers( @Context UriInfo ui ) throws Exception {
         return getSubResource( UsersResource.class ).init( organization );
     }
 
 
-    @RequireOrganizationAccess
     @Path("applications")
     public ApplicationsResource getOrganizationApplications( @Context UriInfo ui ) throws Exception {
         return getSubResource( ApplicationsResource.class ).init( organization );
     }
 
 
-    @RequireOrganizationAccess
     @Path("apps")
     public ApplicationsResource getOrganizationApplications2( @Context UriInfo ui ) throws Exception {
         return getSubResource( ApplicationsResource.class ).init( organization );

http://git-wip-us.apache.org/repos/asf/usergrid/blob/1bfa32a9/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/OrganizationsResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/OrganizationsResource.java b/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/OrganizationsResource.java
index 27d8d6a..28d8c87 100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/OrganizationsResource.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/OrganizationsResource.java
@@ -68,7 +68,6 @@ public class OrganizationsResource extends AbstractContextResource {
     }
 
     @Path(RootResource.ORGANIZATION_ID_PATH)
-    @RequireOrganizationAccess
     public OrganizationResource getOrganizationById( @Context UriInfo ui,
                                                      @PathParam( "organizationId" ) String organizationIdStr )
             throws Exception {
@@ -83,7 +82,6 @@ public class OrganizationsResource extends AbstractContextResource {
     }
 
     @Path( "{organizationName}" )
-    @RequireOrganizationAccess
     public OrganizationResource getOrganizationByName( @Context UriInfo ui,
                                                        @PathParam( "organizationName" ) String organizationName )
             throws Exception {

http://git-wip-us.apache.org/repos/asf/usergrid/blob/1bfa32a9/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/applications/ApplicationResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/applications/ApplicationResource.java b/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/applications/ApplicationResource.java
index 8ac44de..cf575a5 100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/applications/ApplicationResource.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/applications/ApplicationResource.java
@@ -414,7 +414,6 @@ public class ApplicationResource extends AbstractContextResource {
 
 
     @Path( "imports" )
-    @RequireOrganizationAccess
     public ImportsResource importGetJson( @Context UriInfo ui,
                                           @QueryParam( "callback" ) @DefaultValue( "" ) String callback )
         throws Exception {

http://git-wip-us.apache.org/repos/asf/usergrid/blob/1bfa32a9/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/applications/ApplicationsResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/applications/ApplicationsResource.java b/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/applications/ApplicationsResource.java
index 3b609b8..86584c3 100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/applications/ApplicationsResource.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/applications/ApplicationsResource.java
@@ -128,7 +128,6 @@ public class ApplicationsResource extends AbstractContextResource {
     }
 
 
-    @RequireOrganizationAccess
     @Path(RootResource.APPLICATION_ID_PATH)
     public ApplicationResource applicationFromOrganizationByApplicationId(
         @Context UriInfo ui, @PathParam( "applicationId" ) String applicationIdStr ) throws Exception {
@@ -138,7 +137,6 @@ public class ApplicationsResource extends AbstractContextResource {
     }
 
 
-    @RequireOrganizationAccess
     @Path( "{applicationName}" )
     public ApplicationResource applicationFromOrganizationByApplicationName(
         @Context UriInfo ui, @PathParam( "applicationName" ) String applicationName ) throws Exception {

http://git-wip-us.apache.org/repos/asf/usergrid/blob/1bfa32a9/stack/rest/src/test/java/org/apache/usergrid/rest/management/ManagementResourceIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/management/ManagementResourceIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/management/ManagementResourceIT.java
index 68fc172..c54fa0c 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/management/ManagementResourceIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/management/ManagementResourceIT.java
@@ -116,19 +116,42 @@ public class ManagementResourceIT extends AbstractRestIT {
 
         // check that the test admin cannot access the new org info
 
+        //  management/organizations/{orgName}
         Response.Status status = null;
-        String returnVal = "";
+        try {
+            this.management().orgs().org( orgName ).get(String.class);
+        }
+        catch ( ClientErrorException uie ) {
+            status = Response.Status.fromStatusCode( uie.getResponse().getStatus() );
+        }
+        assertNotNull( status );
+        assertEquals( Response.Status.UNAUTHORIZED, status );
 
+
+        //  management/organizations/{orgName}/users
+        status = null;
         try {
-            returnVal = this.management().orgs().org( orgName ).get(String.class);
+            this.management().orgs().org( orgName ).users().get( String.class );
         }
         catch ( ClientErrorException uie ) {
             status = Response.Status.fromStatusCode( uie.getResponse().getStatus() );
         }
+        assertNotNull( status );
+        assertEquals( Response.Status.UNAUTHORIZED, status );
+
 
+        //  management/organizations/{orgName}/applications
+        status = null;
+        try {
+            this.management().orgs().org( orgName ).applications().get( String.class );
+        }
+        catch ( ClientErrorException uie ) {
+            status = Response.Status.fromStatusCode( uie.getResponse().getStatus() );
+        }
         assertNotNull( status );
         assertEquals( Response.Status.UNAUTHORIZED, status );
 
+
         // this admin should have access to test org
         status = null;
         try {
@@ -137,11 +160,32 @@ public class ManagementResourceIT extends AbstractRestIT {
         catch ( ClientErrorException uie ) {
             status = Response.Status.fromStatusCode( uie.getResponse().getStatus() );
         }
+        assertNull( status );
+
 
+        // this admin should have access to test org - users
+        status = null;
+        try {
+            this.management().orgs().org( this.clientSetup.getOrganizationName() ).users().get( String.class );
+        }
+        catch ( ClientErrorException uie ) {
+            status = Response.Status.fromStatusCode( uie.getResponse().getStatus() );
+        }
+        assertNull(status);
+
+
+        // this admin should have access to test org - apps
+        status = null;
+        try {
+            this.management().orgs().org( this.clientSetup.getOrganizationName() ).applications().get( String.class );
+        }
+        catch ( ClientErrorException uie ) {
+            status = Response.Status.fromStatusCode( uie.getResponse().getStatus() );
+        }
         assertNull(status);
 
-        //test getting the organization by org
 
+        // test getting the organization by org
         status = null;
         try {
             this.management().orgs().org( this.clientSetup.getOrganizationName() ).get( String.class );

http://git-wip-us.apache.org/repos/asf/usergrid/blob/1bfa32a9/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/mgmt/OrganizationResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/mgmt/OrganizationResource.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/mgmt/OrganizationResource.java
index b9bd35e..20ea98f 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/mgmt/OrganizationResource.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/mgmt/OrganizationResource.java
@@ -42,6 +42,10 @@ public class OrganizationResource extends NamedResource {
         return new UsersResource(context, this);
     }
 
+    public ApplicationsResource applications() {
+        return new ApplicationsResource(context, this);
+    }
+
     public Organization get() {
         ApiResponse rep = getTarget( true ).request()
             .accept(MediaType.APPLICATION_JSON)


[15/54] usergrid git commit: Don't hard-code the Jersey version number, use a property instead.

Posted by sn...@apache.org.
Don't hard-code the Jersey version number, use a property instead.


Project: http://git-wip-us.apache.org/repos/asf/usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/usergrid/commit/ed3ba7c3
Tree: http://git-wip-us.apache.org/repos/asf/usergrid/tree/ed3ba7c3
Diff: http://git-wip-us.apache.org/repos/asf/usergrid/diff/ed3ba7c3

Branch: refs/heads/usergrid-1007-shiro-cache
Commit: ed3ba7c3991793bebed6fea4b25b7543a21e530e
Parents: cdf7c29
Author: Dave Johnson <sn...@apache.org>
Authored: Tue Sep 8 16:38:12 2015 -0400
Committer: Dave Johnson <sn...@apache.org>
Committed: Tue Sep 8 16:38:12 2015 -0400

----------------------------------------------------------------------
 stack/pom.xml      |  2 +-
 stack/rest/pom.xml | 34 +++++++++++++++++-----------------
 2 files changed, 18 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/usergrid/blob/ed3ba7c3/stack/pom.xml
----------------------------------------------------------------------
diff --git a/stack/pom.xml b/stack/pom.xml
index 15cca38..47a08d7 100644
--- a/stack/pom.xml
+++ b/stack/pom.xml
@@ -107,7 +107,7 @@
       <jackson-version>1.9.9</jackson-version>
       <jackson-2-version>2.3.3</jackson-2-version>
       <jclouds.version>1.9.0</jclouds.version>
-      <!--<jersey-version>1.19</jersey-version>-->
+      <jersey-version>2.21</jersey-version>
       <junit-version>4.12</junit-version>
       <log4j-version>1.2.16</log4j-version>
       <org.springframework.version>3.2.13.RELEASE</org.springframework.version>

http://git-wip-us.apache.org/repos/asf/usergrid/blob/ed3ba7c3/stack/rest/pom.xml
----------------------------------------------------------------------
diff --git a/stack/rest/pom.xml b/stack/rest/pom.xml
index bea05fe..ebbc375 100644
--- a/stack/rest/pom.xml
+++ b/stack/rest/pom.xml
@@ -238,43 +238,43 @@
         <dependency>
             <groupId>org.glassfish.jersey.containers</groupId>
             <artifactId>jersey-container-servlet</artifactId>
-            <version>2.21</version>
+            <version>${jersey-version}</version>
         </dependency>
 
         <dependency>
             <groupId>org.glassfish.jersey.core</groupId>
             <artifactId>jersey-client</artifactId>
-            <version>2.21</version>
+            <version>${jersey-version}</version>
         </dependency>
 
         <dependency>
             <groupId>org.glassfish.jersey.connectors</groupId>
             <artifactId>jersey-apache-connector</artifactId>
-            <version>2.21</version>
+            <version>${jersey-version}</version>
         </dependency>
 
         <dependency>
             <groupId>org.glassfish.jersey.ext</groupId>
             <artifactId>jersey-mvc-jsp</artifactId>
-            <version>2.21</version>
+            <version>${jersey-version}</version>
         </dependency>
 
         <dependency>
             <groupId>org.glassfish.jersey.media</groupId>
             <artifactId>jersey-media-multipart</artifactId>
-            <version>2.21</version>
+            <version>${jersey-version}</version>
         </dependency>
 
         <dependency>
             <groupId>org.glassfish.jersey.media</groupId>
             <artifactId>jersey-media-json-jackson</artifactId>
-            <version>2.21</version>
+            <version>${jersey-version}</version>
         </dependency>
 
         <dependency>
             <groupId>org.glassfish.jersey.ext</groupId>
             <artifactId>jersey-spring3</artifactId>
-            <version>2.21</version>
+            <version>${jersey-version}</version>
         </dependency>
 
         <!-- Jackson, Spring, and other dependencies -->
@@ -361,6 +361,14 @@
         </dependency>
 
         <dependency>
+            <groupId>org.apache.usergrid</groupId>
+            <artifactId>usergrid-services</artifactId>
+            <version>${project.version}</version>
+            <scope>test</scope>
+            <classifier>tests</classifier>
+        </dependency>
+
+        <dependency>
             <groupId>org.springframework</groupId>
             <artifactId>spring-test</artifactId>
             <scope>test</scope>
@@ -393,13 +401,13 @@
         <dependency>
             <groupId>org.glassfish.jersey.test-framework.providers</groupId>
             <artifactId>jersey-test-framework-provider-external</artifactId>
-            <version>2.21</version>
+            <version>${jersey-version}</version>
         </dependency>
 
         <dependency>
             <groupId>org.glassfish.jersey.test-framework</groupId>
             <artifactId>jersey-test-framework-core</artifactId>
-            <version>2.21</version>
+            <version>${jersey-version}</version>
         </dependency>
 
         <dependency>
@@ -408,14 +416,6 @@
             <scope>test</scope>
         </dependency>
 
-        <dependency>
-            <groupId>org.apache.usergrid</groupId>
-            <artifactId>usergrid-services</artifactId>
-            <version>2.1.0-SNAPSHOT</version>
-            <scope>test</scope>
-            <classifier>tests</classifier>
-        </dependency>
-
     </dependencies>
 
 </project>


[22/54] usergrid git commit: Merge branch 'two-dot-o-dev' into usergrid-103-upgrade-jersey

Posted by sn...@apache.org.
Merge branch 'two-dot-o-dev' into usergrid-103-upgrade-jersey

Conflicts:
	stack/rest/src/main/java/org/apache/usergrid/rest/applications/ServiceResource.java


Project: http://git-wip-us.apache.org/repos/asf/usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/usergrid/commit/8081401d
Tree: http://git-wip-us.apache.org/repos/asf/usergrid/tree/8081401d
Diff: http://git-wip-us.apache.org/repos/asf/usergrid/diff/8081401d

Branch: refs/heads/usergrid-1007-shiro-cache
Commit: 8081401dc19443a0e968be5110b6ad7de22b8b12
Parents: 4918a5a b67f0b1
Author: Dave Johnson <sn...@apache.org>
Authored: Wed Sep 9 18:32:12 2015 -0400
Committer: Dave Johnson <sn...@apache.org>
Committed: Wed Sep 9 18:32:12 2015 -0400

----------------------------------------------------------------------
 .../corepersistence/util/CpNamingUtils.java     |   3 +
 .../org/apache/usergrid/rest/ApiResponse.java   |  14 ++
 .../rest/applications/ServiceResource.java      |  24 ++-
 .../organizations/OrganizationResource.java     |  55 ++++++
 .../organizations/OrganizationsResource.java    |   3 +-
 .../usergrid/management/ManagementService.java  |  10 ++
 .../usergrid/management/OrganizationConfig.java | 170 +++++++++++++++++++
 .../cassandra/ManagementServiceImpl.java        |  84 +++++++++
 8 files changed, 357 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/usergrid/blob/8081401d/stack/rest/src/main/java/org/apache/usergrid/rest/applications/ServiceResource.java
----------------------------------------------------------------------
diff --cc stack/rest/src/main/java/org/apache/usergrid/rest/applications/ServiceResource.java
index eba9e27,866a74d..e98f366
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/applications/ServiceResource.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/applications/ServiceResource.java
@@@ -17,9 -17,41 +17,10 @@@
  package org.apache.usergrid.rest.applications;
  
  
 -import java.io.InputStream;
 -import java.util.ArrayList;
 -import java.util.Date;
 -import java.util.HashMap;
 -import java.util.List;
 -import java.util.Map;
 -import java.util.UUID;
 -
 -import javax.ws.rs.Consumes;
 -import javax.ws.rs.DELETE;
 -import javax.ws.rs.DefaultValue;
 -import javax.ws.rs.GET;
 -import javax.ws.rs.HeaderParam;
 -import javax.ws.rs.POST;
 -import javax.ws.rs.PUT;
 -import javax.ws.rs.Path;
 -import javax.ws.rs.PathParam;
 -import javax.ws.rs.Produces;
 -import javax.ws.rs.QueryParam;
 -import javax.ws.rs.core.Context;
 -import javax.ws.rs.core.MediaType;
 -import javax.ws.rs.core.MultivaluedMap;
 -import javax.ws.rs.core.PathSegment;
 -import javax.ws.rs.core.Response;
 -import javax.ws.rs.core.UriInfo;
 -
 -import org.apache.usergrid.management.OrganizationConfig;
 -import org.slf4j.Logger;
 -import org.slf4j.LoggerFactory;
 -import org.springframework.beans.factory.annotation.Autowired;
 -import org.springframework.context.annotation.Scope;
 -import org.springframework.stereotype.Component;
 -
 +import com.fasterxml.jackson.databind.ObjectMapper;
 +import com.fasterxml.jackson.jaxrs.json.annotation.JSONP;
  import org.apache.commons.lang.StringUtils;
 -
++import org.apache.usergrid.management.OrganizationConfig;
  import org.apache.usergrid.persistence.Entity;
  import org.apache.usergrid.persistence.EntityManager;
  import org.apache.usergrid.persistence.Query;

http://git-wip-us.apache.org/repos/asf/usergrid/blob/8081401d/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/OrganizationResource.java
----------------------------------------------------------------------
diff --cc stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/OrganizationResource.java
index 2e17cfb,f45e1b2..8c5328e
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/OrganizationResource.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/OrganizationResource.java
@@@ -17,13 -17,21 +17,14 @@@
  package org.apache.usergrid.rest.management.organizations;
  
  
 -import com.sun.jersey.api.json.JSONWithPadding;
 -import com.sun.jersey.api.view.Viewable;
 +import com.fasterxml.jackson.jaxrs.json.annotation.JSONP;
  import org.apache.amber.oauth2.common.exception.OAuthSystemException;
  import org.apache.commons.lang.NullArgumentException;
 -
 -import org.apache.usergrid.corepersistence.util.CpNamingUtils;
  import org.apache.usergrid.management.ActivationState;
+ import org.apache.usergrid.management.OrganizationConfig;
  import org.apache.usergrid.management.OrganizationInfo;
  import org.apache.usergrid.management.export.ExportService;
 -import org.apache.usergrid.management.importer.ImportService;
 -import org.apache.usergrid.persistence.EntityRef;
 -import org.apache.usergrid.persistence.SimpleEntityRef;
  import org.apache.usergrid.persistence.entities.Export;
 -import org.apache.usergrid.persistence.entities.Import;
  import org.apache.usergrid.persistence.queue.impl.UsergridAwsCredentials;
  import org.apache.usergrid.rest.AbstractContextResource;
  import org.apache.usergrid.rest.ApiResponse;
@@@ -364,4 -363,56 +365,58 @@@ public class OrganizationResource exten
      }
  
  
+     @RequireOrganizationAccess
++    @JSONP
+     @GET
+     @Path("config")
 -    public JSONWithPadding getConfig( @Context UriInfo ui,
++    public ApiResponse getConfig( @Context UriInfo ui,
+                                       @QueryParam("callback") @DefaultValue("callback") String callback )
+             throws Exception {
+ 
+         logger.info( "Get configuration for organization: " + organization.getUuid() );
+ 
+         // TODO: check for super user, @RequireSystemAccess didn't work
+ 
+         ApiResponse response = createApiResponse();
+         response.setAction( "get organization configuration" );
+ 
+         // TODO: check for super user
+ 
+         OrganizationConfig orgConfig =
+                 management.getOrganizationConfigByUuid( organization.getUuid() );
+ 
+         response.setProperty( "configuration", management.getOrganizationConfigData( orgConfig ) );
+         // response.setOrganizationConfig( orgConfig );
+ 
 -        return new JSONWithPadding( response, callback );
++        return response;
+     }
+ 
+ 
+     @RequireOrganizationAccess
+     @Consumes(MediaType.APPLICATION_JSON)
++    @JSONP
+     @PUT
+     @Path("config")
 -    public JSONWithPadding putConfig( @Context UriInfo ui, Map<String, Object> json,
++    public ApiResponse putConfig( @Context UriInfo ui, Map<String, Object> json,
+                                        @QueryParam("callback") @DefaultValue("callback") String callback )
+             throws Exception {
+ 
+         logger.debug("Put configuration for organization: " + organization.getUuid());
+ 
+         ApiResponse response = createApiResponse();
+         response.setAction("put organization configuration");
+ 
+         // TODO: check for super user
+ 
+         // response.setParams(ui.getQueryParameters());
+ 
+         OrganizationConfig orgConfig =
+                 management.getOrganizationConfigByUuid( organization.getUuid() );
+         orgConfig.addProperties(json);
+         management.updateOrganizationConfig(orgConfig);
+         response.setProperty( "configuration", management.getOrganizationConfigData( orgConfig ) );
+ 
 -        return new JSONWithPadding( response, callback );
++        return response;
+     }
+ 
  }

http://git-wip-us.apache.org/repos/asf/usergrid/blob/8081401d/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/OrganizationsResource.java
----------------------------------------------------------------------
diff --cc stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/OrganizationsResource.java
index daa7264,4eac80d..27d8d6a
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/OrganizationsResource.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/OrganizationsResource.java
@@@ -90,9 -96,6 +91,7 @@@ public class OrganizationsResource exte
          if ( organization == null ) {
              throw new ManagementException( "Could not find organization for name: " + organizationName );
          }
 +
- 
- 
          return getSubResource( OrganizationResource.class ).init(organization);
      }
  


[48/54] usergrid git commit: Removes obsolete plugins.

Posted by sn...@apache.org.
Removes obsolete plugins.

Adds tests and implements entity-data plugin.


Project: http://git-wip-us.apache.org/repos/asf/usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/usergrid/commit/2689a015
Tree: http://git-wip-us.apache.org/repos/asf/usergrid/tree/2689a015
Diff: http://git-wip-us.apache.org/repos/asf/usergrid/diff/2689a015

Branch: refs/heads/usergrid-1007-shiro-cache
Commit: 2689a015938e6b05ceb6f6cc2c228f61cb5e3b17
Parents: acbf3a1
Author: Todd Nine <tn...@apigee.com>
Authored: Thu Sep 17 16:17:43 2015 -0600
Committer: Todd Nine <tn...@apigee.com>
Committed: Thu Sep 17 16:17:43 2015 -0600

----------------------------------------------------------------------
 .../usergrid/corepersistence/CoreModule.java    |  53 +++++--
 .../migration/CoreMigration.java                |  45 ++----
 .../migration/CoreMigrationPlugin.java          |  31 ++--
 .../migration/DeDupConnectionDataMigration.java |  93 ++++++++++++
 .../migration/EntityTypeMappingMigration.java   | 104 --------------
 .../corepersistence/migration/Versions.java     |  31 ----
 .../DeDupConnectionDataMigrationTest.java       | 144 +++++++++++++++++++
 .../migration/EntityTypeMappingMigrationIT.java | 125 ----------------
 .../migration/data/TestProgressObserver.java    |  10 +-
 9 files changed, 314 insertions(+), 322 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/usergrid/blob/2689a015/stack/core/src/main/java/org/apache/usergrid/corepersistence/CoreModule.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CoreModule.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CoreModule.java
index 7ed95e2..11707be 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CoreModule.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CoreModule.java
@@ -16,22 +16,43 @@
 package org.apache.usergrid.corepersistence;
 
 
-import com.google.inject.AbstractModule;
-import com.google.inject.TypeLiteral;
-import com.google.inject.assistedinject.FactoryModuleBuilder;
-import com.google.inject.multibindings.Multibinder;
+import org.safehaus.guicyfig.GuicyFigModule;
+
 import org.apache.usergrid.corepersistence.asyncevents.AsyncEventService;
 import org.apache.usergrid.corepersistence.asyncevents.AsyncIndexProvider;
 import org.apache.usergrid.corepersistence.asyncevents.EventBuilder;
 import org.apache.usergrid.corepersistence.asyncevents.EventBuilderImpl;
-import org.apache.usergrid.corepersistence.index.*;
+import org.apache.usergrid.corepersistence.index.ApplicationIndexBucketLocator;
+import org.apache.usergrid.corepersistence.index.CoreIndexFig;
+import org.apache.usergrid.corepersistence.index.IndexLocationStrategyFactory;
+import org.apache.usergrid.corepersistence.index.IndexLocationStrategyFactoryImpl;
+import org.apache.usergrid.corepersistence.index.IndexProcessorFig;
+import org.apache.usergrid.corepersistence.index.IndexService;
+import org.apache.usergrid.corepersistence.index.IndexServiceImpl;
+import org.apache.usergrid.corepersistence.index.ReIndexService;
+import org.apache.usergrid.corepersistence.index.ReIndexServiceImpl;
 import org.apache.usergrid.corepersistence.migration.CoreMigration;
 import org.apache.usergrid.corepersistence.migration.CoreMigrationPlugin;
-import org.apache.usergrid.corepersistence.migration.EntityTypeMappingMigration;
+import org.apache.usergrid.corepersistence.migration.DeDupConnectionDataMigration;
 import org.apache.usergrid.corepersistence.migration.MigrationModuleVersionPlugin;
 import org.apache.usergrid.corepersistence.pipeline.PipelineModule;
-import org.apache.usergrid.corepersistence.rx.impl.*;
-import org.apache.usergrid.corepersistence.service.*;
+import org.apache.usergrid.corepersistence.rx.impl.AllApplicationsObservable;
+import org.apache.usergrid.corepersistence.rx.impl.AllApplicationsObservableImpl;
+import org.apache.usergrid.corepersistence.rx.impl.AllEntitiesInSystemImpl;
+import org.apache.usergrid.corepersistence.rx.impl.AllEntityIdsObservable;
+import org.apache.usergrid.corepersistence.rx.impl.AllEntityIdsObservableImpl;
+import org.apache.usergrid.corepersistence.rx.impl.AllNodesInGraphImpl;
+import org.apache.usergrid.corepersistence.service.AggregationService;
+import org.apache.usergrid.corepersistence.service.AggregationServiceFactory;
+import org.apache.usergrid.corepersistence.service.AggregationServiceImpl;
+import org.apache.usergrid.corepersistence.service.ApplicationService;
+import org.apache.usergrid.corepersistence.service.ApplicationServiceImpl;
+import org.apache.usergrid.corepersistence.service.CollectionService;
+import org.apache.usergrid.corepersistence.service.CollectionServiceImpl;
+import org.apache.usergrid.corepersistence.service.ConnectionService;
+import org.apache.usergrid.corepersistence.service.ConnectionServiceImpl;
+import org.apache.usergrid.corepersistence.service.StatusService;
+import org.apache.usergrid.corepersistence.service.StatusServiceImpl;
 import org.apache.usergrid.persistence.collection.guice.CollectionModule;
 import org.apache.usergrid.persistence.collection.serialization.impl.migration.EntityIdScope;
 import org.apache.usergrid.persistence.core.guice.CommonModule;
@@ -42,7 +63,11 @@ import org.apache.usergrid.persistence.core.scope.ApplicationScope;
 import org.apache.usergrid.persistence.graph.guice.GraphModule;
 import org.apache.usergrid.persistence.graph.serialization.impl.migration.GraphNode;
 import org.apache.usergrid.persistence.index.guice.IndexModule;
-import org.safehaus.guicyfig.GuicyFigModule;
+
+import com.google.inject.AbstractModule;
+import com.google.inject.TypeLiteral;
+import com.google.inject.assistedinject.FactoryModuleBuilder;
+import com.google.inject.multibindings.Multibinder;
 
 
 /**
@@ -105,7 +130,7 @@ public class CoreModule  extends AbstractModule {
                         new TypeLiteral<DataMigration>() {}, CoreMigration.class );
 
 
-        dataMigrationMultibinder.addBinding().to( EntityTypeMappingMigration.class );
+        dataMigrationMultibinder.addBinding().to( DeDupConnectionDataMigration.class );
 
 
         //wire up the collection migration plugin
@@ -164,6 +189,14 @@ public class CoreModule  extends AbstractModule {
         bind( ApplicationService.class ).to( ApplicationServiceImpl.class );
 
         bind( StatusService.class ).to( StatusServiceImpl.class );
+
+        /**
+         * Install migration services
+         */
+
+          //migrations
+        //we want to make sure our generics are retained, so we use a typeliteral
+
     }
 
 }

http://git-wip-us.apache.org/repos/asf/usergrid/blob/2689a015/stack/core/src/main/java/org/apache/usergrid/corepersistence/migration/CoreMigration.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/migration/CoreMigration.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/migration/CoreMigration.java
index 4df32da..b491e1f 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/migration/CoreMigration.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/migration/CoreMigration.java
@@ -1,40 +1,21 @@
 /*
- * 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
+ * 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
+ *      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.
+ * 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.usergrid.corepersistence.migration;/*
- * 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.usergrid.corepersistence.migration;
 
 
 import java.lang.annotation.Retention;

http://git-wip-us.apache.org/repos/asf/usergrid/blob/2689a015/stack/core/src/main/java/org/apache/usergrid/corepersistence/migration/CoreMigrationPlugin.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/migration/CoreMigrationPlugin.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/migration/CoreMigrationPlugin.java
index 810f9fb..b69451a 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/migration/CoreMigrationPlugin.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/migration/CoreMigrationPlugin.java
@@ -1,20 +1,18 @@
 /*
- * 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
+ * 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
+ *      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.
+ * 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.usergrid.corepersistence.migration;
@@ -22,9 +20,10 @@ package org.apache.usergrid.corepersistence.migration;
 
 import java.util.Set;
 
-import org.apache.usergrid.persistence.core.migration.data.MigrationInfoSerialization;
+import org.apache.usergrid.persistence.collection.serialization.impl.migration.CollectionMigration;
 import org.apache.usergrid.persistence.core.migration.data.AbstractMigrationPlugin;
 import org.apache.usergrid.persistence.core.migration.data.DataMigration;
+import org.apache.usergrid.persistence.core.migration.data.MigrationInfoSerialization;
 import org.apache.usergrid.persistence.core.migration.data.PluginPhase;
 
 import com.google.inject.Inject;
@@ -37,7 +36,7 @@ import com.google.inject.Singleton;
 @Singleton
 public class CoreMigrationPlugin extends AbstractMigrationPlugin {
 
-    public static final String PLUGIN_NAME = "core-data";
+    public static final String PLUGIN_NAME = "collections-entity-data";
 
 
 

http://git-wip-us.apache.org/repos/asf/usergrid/blob/2689a015/stack/core/src/main/java/org/apache/usergrid/corepersistence/migration/DeDupConnectionDataMigration.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/migration/DeDupConnectionDataMigration.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/migration/DeDupConnectionDataMigration.java
new file mode 100644
index 0000000..f65864a
--- /dev/null
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/migration/DeDupConnectionDataMigration.java
@@ -0,0 +1,93 @@
+/*
+ * 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.usergrid.corepersistence.migration;
+
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.usergrid.corepersistence.rx.impl.AllApplicationsObservable;
+import org.apache.usergrid.corepersistence.service.ConnectionService;
+import org.apache.usergrid.persistence.core.migration.data.DataMigration;
+import org.apache.usergrid.persistence.core.migration.data.ProgressObserver;
+
+import com.google.inject.Inject;
+import com.google.inject.Singleton;
+
+
+@Singleton
+public class DeDupConnectionDataMigration implements DataMigration {
+
+    private static final Logger logger = LoggerFactory.getLogger(DeDupConnectionDataMigration.class);
+
+    private static final long UPDATE_COUNT = 1000;
+
+    private final ConnectionService connectionService;
+    private final AllApplicationsObservable allApplicationsObservable;
+
+
+    @Inject
+    public DeDupConnectionDataMigration( final ConnectionService connectionService,
+                                         final AllApplicationsObservable allApplicationsObservable ) {
+        this.connectionService = connectionService;
+        this.allApplicationsObservable = allApplicationsObservable;
+    }
+
+
+    @Override
+    public int migrate( final int currentVersion, final ProgressObserver observer ) {
+
+        final int migrationVersion = getMaxVersion();
+
+        observer.start();
+
+        connectionService.deDupeConnections( allApplicationsObservable.getData() ).reduce( 0l, (count, deDuped) ->{
+
+            final long newCount = count+1;
+
+            /**
+             * Update our progress observer
+             */
+            if(newCount % UPDATE_COUNT == 0){
+                logger.info( "De duped {} edges", newCount );
+                observer.update( migrationVersion, String.format("De duped %d edges", newCount) );
+            }
+
+            return newCount;
+
+        }).doOnNext( total -> {
+            logger.info("Completed de-duping {} edges", total );
+            observer.complete();;
+        }).subscribe();
+
+        return migrationVersion;
+
+    }
+
+
+    @Override
+    public boolean supports( final int currentVersion ) {
+        return currentVersion == getMaxVersion() - 1;
+    }
+
+
+    @Override
+    public int getMaxVersion() {
+        return 1;
+    }
+}

http://git-wip-us.apache.org/repos/asf/usergrid/blob/2689a015/stack/core/src/main/java/org/apache/usergrid/corepersistence/migration/EntityTypeMappingMigration.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/migration/EntityTypeMappingMigration.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/migration/EntityTypeMappingMigration.java
deleted file mode 100644
index ef65ff2..0000000
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/migration/EntityTypeMappingMigration.java
+++ /dev/null
@@ -1,104 +0,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.
- */
-
-package org.apache.usergrid.corepersistence.migration;
-
-
-import java.util.UUID;
-import java.util.concurrent.atomic.AtomicLong;
-
-import org.apache.usergrid.corepersistence.ManagerCache;
-import org.apache.usergrid.corepersistence.util.CpNamingUtils;
-import org.apache.usergrid.persistence.collection.serialization.impl.migration.EntityIdScope;
-import org.apache.usergrid.persistence.core.migration.data.DataMigration;
-import org.apache.usergrid.persistence.core.migration.data.MigrationDataProvider;
-import org.apache.usergrid.persistence.core.migration.data.ProgressObserver;
-import org.apache.usergrid.persistence.map.MapManager;
-import org.apache.usergrid.persistence.map.MapScope;
-
-import com.google.inject.Inject;
-
-import rx.Observable;
-import rx.schedulers.Schedulers;
-
-
-/**
- * Migration to ensure that our entity id is written into our map data
- */
-public class EntityTypeMappingMigration implements DataMigration {
-
-    private final ManagerCache managerCache;
-    private final MigrationDataProvider<EntityIdScope> allEntitiesInSystemObservable;
-
-
-    @Inject
-    public EntityTypeMappingMigration( final ManagerCache managerCache,
-                                       final MigrationDataProvider<EntityIdScope> allEntitiesInSystemObservable ) {
-        this.managerCache = managerCache;
-        this.allEntitiesInSystemObservable = allEntitiesInSystemObservable;
-    }
-
-
-    @Override
-    public int migrate( final int currentVersion,
-                        final ProgressObserver observer ) {
-
-        final AtomicLong atomicLong = new AtomicLong();
-
-
-        //migrate up to 100 types simultaneously
-        allEntitiesInSystemObservable.getData().flatMap( entityIdScope -> {
-            return Observable.just( entityIdScope ).doOnNext( entityIdScopeObservable -> {
-                final MapScope ms = CpNamingUtils
-                                                 .getEntityTypeMapScope( entityIdScope.getApplicationScope().getApplication() );
-
-                                             final MapManager mapManager = managerCache.getMapManager( ms );
-
-                                             final UUID entityUuid = entityIdScope.getId().getUuid();
-                                             final String entityType = entityIdScope.getId().getType();
-
-                                             mapManager.putString( entityUuid.toString(), entityType );
-
-                                             if ( atomicLong.incrementAndGet() % 100 == 0 ) {
-                                                 observer.update( getMaxVersion(),
-                                                     String.format( "Updated %d entities", atomicLong.get() ) );
-                                             }
-
-            } ).subscribeOn( Schedulers.io() );
-        }, 100 ).count().toBlocking().last();
-
-
-        return getMaxVersion();
-
-
-    }
-
-
-    @Override
-    public boolean supports( final int currentVersion ) {
-        //we move from the migration version fix to the current version
-        return CoreDataVersions.INITIAL.getVersion() == currentVersion;
-    }
-
-
-    @Override
-    public int getMaxVersion() {
-        return CoreDataVersions.ID_MAP_FIX.getVersion();
-    }
-}

http://git-wip-us.apache.org/repos/asf/usergrid/blob/2689a015/stack/core/src/main/java/org/apache/usergrid/corepersistence/migration/Versions.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/migration/Versions.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/migration/Versions.java
deleted file mode 100644
index d921353..0000000
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/migration/Versions.java
+++ /dev/null
@@ -1,31 +0,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.
- *
- */
-
-package org.apache.usergrid.corepersistence.migration;
-
-
-/**
- * Simple class to hold the constants of all versions
- */
-public class Versions {
-
-
-}

http://git-wip-us.apache.org/repos/asf/usergrid/blob/2689a015/stack/core/src/test/java/org/apache/usergrid/corepersistence/migration/DeDupConnectionDataMigrationTest.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/corepersistence/migration/DeDupConnectionDataMigrationTest.java b/stack/core/src/test/java/org/apache/usergrid/corepersistence/migration/DeDupConnectionDataMigrationTest.java
new file mode 100644
index 0000000..c84ad2b
--- /dev/null
+++ b/stack/core/src/test/java/org/apache/usergrid/corepersistence/migration/DeDupConnectionDataMigrationTest.java
@@ -0,0 +1,144 @@
+/*
+ * 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.usergrid.corepersistence.migration;
+
+
+import java.util.List;
+
+import org.junit.Test;
+
+import org.apache.usergrid.corepersistence.rx.impl.AllApplicationsObservable;
+import org.apache.usergrid.corepersistence.service.ConnectionScope;
+import org.apache.usergrid.corepersistence.service.ConnectionService;
+import org.apache.usergrid.corepersistence.util.CpNamingUtils;
+import org.apache.usergrid.persistence.core.migration.data.TestProgressObserver;
+import org.apache.usergrid.persistence.core.scope.ApplicationScope;
+import org.apache.usergrid.persistence.core.scope.ApplicationScopeImpl;
+import org.apache.usergrid.persistence.graph.Edge;
+
+import rx.Observable;
+import rx.Subscriber;
+
+import static org.apache.usergrid.persistence.core.util.IdGenerator.createId;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+
+public class DeDupConnectionDataMigrationTest {
+
+    @Test
+    public void testVersion() {
+
+        //mock up an initial system state
+        final int version = 0;
+
+        final ConnectionService connectionService = mock( ConnectionService.class );
+
+        final AllApplicationsObservable allApplicationsObservable = mock( AllApplicationsObservable.class );
+
+
+        final DeDupConnectionDataMigration plugin =
+            new DeDupConnectionDataMigration( connectionService, allApplicationsObservable );
+
+
+        assertTrue( plugin.supports( version ) );
+
+        assertFalse( plugin.supports( plugin.getMaxVersion() ) );
+    }
+
+
+    /**
+     * Test
+     */
+    @Test
+    public void testEmitEdges() {
+
+        //mock up an initial system state
+        final int version = 0;
+
+        final ConnectionService connectionService = mock( ConnectionService.class );
+
+
+        final AllApplicationsObservable allApplicationsObservable = mock( AllApplicationsObservable.class );
+
+
+        final int count = 3000;
+
+        final Observable<ConnectionScope> edgeEmitter = Observable.create( new DupConnectionEmitter( count ) );
+
+        when( connectionService.deDupeConnections( any( Observable.class ) ) ).thenReturn( edgeEmitter );
+
+
+        final DeDupConnectionDataMigration plugin =
+            new DeDupConnectionDataMigration( connectionService, allApplicationsObservable );
+
+
+        final TestProgressObserver testProgressObserver = new TestProgressObserver();
+
+
+        plugin.migrate( version, testProgressObserver );
+
+        final List<String> updates = testProgressObserver.getUpdates();
+
+        assertEquals( "Expected 3 updates", 3, updates.size() );
+
+
+        assertEquals( "De duped 1000 edges", updates.get( 0 ) );
+        assertEquals( "De duped 2000 edges", updates.get( 1 ) );
+        assertEquals( "De duped 3000 edges", updates.get( 2 ) );
+
+
+        assertTrue( "Should complete", testProgressObserver.isComplete() );
+        assertTrue( "Should start", testProgressObserver.isStarted() );
+        assertFalse( "Should not fail", testProgressObserver.isFailed() );
+    }
+
+
+    private final class DupConnectionEmitter implements Observable.OnSubscribe<ConnectionScope> {
+
+
+        private final int count;
+
+
+        private DupConnectionEmitter( final int count ) {this.count = count;}
+
+
+        @Override
+        public void call( final Subscriber<? super ConnectionScope> subscriber ) {
+
+            final ApplicationScope applicationScope = new ApplicationScopeImpl( createId( "application" ) );
+            final Edge edge = CpNamingUtils.createConnectionEdge( createId( "source" ), "test", createId( "target" ) );
+
+
+            final ConnectionScope scope = new ConnectionScope( applicationScope, edge );
+
+
+            subscriber.onStart();
+
+            for ( int i = 0; i < count; i++ ) {
+                subscriber.onNext( scope );
+            }
+
+            subscriber.onCompleted();
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/usergrid/blob/2689a015/stack/core/src/test/java/org/apache/usergrid/corepersistence/migration/EntityTypeMappingMigrationIT.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/corepersistence/migration/EntityTypeMappingMigrationIT.java b/stack/core/src/test/java/org/apache/usergrid/corepersistence/migration/EntityTypeMappingMigrationIT.java
deleted file mode 100644
index 7d22abe..0000000
--- a/stack/core/src/test/java/org/apache/usergrid/corepersistence/migration/EntityTypeMappingMigrationIT.java
+++ /dev/null
@@ -1,125 +0,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.
- */
-
-package org.apache.usergrid.corepersistence.migration;
-
-
-import org.junit.Test;
-
-import org.apache.usergrid.AbstractCoreIT;
-import org.apache.usergrid.corepersistence.ManagerCache;
-import org.apache.usergrid.corepersistence.util.CpNamingUtils;
-import org.apache.usergrid.persistence.collection.serialization.impl.migration.EntityIdScope;
-import org.apache.usergrid.persistence.core.migration.data.TestMigrationDataProvider;
-import org.apache.usergrid.persistence.core.migration.data.TestProgressObserver;
-import org.apache.usergrid.persistence.core.scope.ApplicationScope;
-import org.apache.usergrid.persistence.core.scope.ApplicationScopeImpl;
-import org.apache.usergrid.persistence.map.MapManager;
-import org.apache.usergrid.persistence.map.MapScope;
-import org.apache.usergrid.persistence.map.impl.MapScopeImpl;
-import org.apache.usergrid.persistence.model.entity.Id;
-
-import rx.Observable;
-
-import static org.apache.usergrid.persistence.core.util.IdGenerator.createId;
-import static org.junit.Assert.assertEquals;
-import static org.mockito.Matchers.eq;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-
-/**
- * Test for our entity type mapping
- */
-public class EntityTypeMappingMigrationIT  {
-
-
-    @Test
-    public void testIdMapping() throws Throwable {
-
-        final Id applicationId = createId("application");
-
-        final ApplicationScope scope1 = new ApplicationScopeImpl( applicationId );
-
-        final Id entityId1 = createId("thing");
-
-        final EntityIdScope idScope1 = new EntityIdScope(scope1, entityId1 );
-
-        final MapScope mapScope1 = new MapScopeImpl(applicationId, CpNamingUtils.TYPES_BY_UUID_MAP );
-
-
-
-        final ApplicationScope scope2 = new ApplicationScopeImpl( applicationId);
-
-        final Id entityId2 = createId("foo");
-
-        final EntityIdScope idScope2 = new EntityIdScope( scope2, entityId2 );
-
-        final MapScope mapScope2 = new MapScopeImpl(applicationId, CpNamingUtils.TYPES_BY_UUID_MAP );
-
-
-        final Observable<EntityIdScope> scopes = Observable.just(idScope1, idScope2);
-
-        final TestMigrationDataProvider<EntityIdScope> migrationDataProvider = new TestMigrationDataProvider<>();
-
-        //set our scopes
-        migrationDataProvider.setObservable( scopes );
-
-
-
-
-        //mock up returning our map manager
-        final MapManager mapManager = mock(MapManager.class);
-        final ManagerCache managerCache = mock(ManagerCache.class);
-
-        when(managerCache.getMapManager( eq( mapScope1 ) )).thenReturn( mapManager );
-
-        when(managerCache.getMapManager( eq( mapScope2 ) )).thenReturn( mapManager );
-
-        final TestProgressObserver progressObserver = new TestProgressObserver();
-
-
-        //wire it up
-        final EntityTypeMappingMigration migration = new EntityTypeMappingMigration( managerCache, migrationDataProvider );
-
-        //run it
-
-        final int returnedVersion = migration.migrate(CoreDataVersions.INITIAL.getVersion(), progressObserver );
-
-
-        assertEquals(CoreDataVersions.ID_MAP_FIX.getVersion(), returnedVersion);
-
-        //verify we saved it
-
-        verify(mapManager).putString(entityId1.getUuid().toString(), entityId1.getType()  );
-
-        verify(mapManager).putString(entityId2.getUuid().toString(), entityId2.getType()  );
-
-
-
-
-
-
-
-
-
-
-    }
-}

http://git-wip-us.apache.org/repos/asf/usergrid/blob/2689a015/stack/corepersistence/common/src/test/java/org/apache/usergrid/persistence/core/migration/data/TestProgressObserver.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/common/src/test/java/org/apache/usergrid/persistence/core/migration/data/TestProgressObserver.java b/stack/corepersistence/common/src/test/java/org/apache/usergrid/persistence/core/migration/data/TestProgressObserver.java
index 7f59151..21d6013 100644
--- a/stack/corepersistence/common/src/test/java/org/apache/usergrid/persistence/core/migration/data/TestProgressObserver.java
+++ b/stack/corepersistence/common/src/test/java/org/apache/usergrid/persistence/core/migration/data/TestProgressObserver.java
@@ -30,19 +30,21 @@ public class TestProgressObserver implements ProgressObserver {
 
     private boolean started = false;
 
+    private boolean complete = false;
+
 
     private List<String> updates = new ArrayList<>( 100 );
 
 
     @Override
     public void start() {
-         started = true;
+        started = true;
     }
 
 
     @Override
     public void complete() {
-        started = false;
+        complete = true;
     }
 
 
@@ -66,7 +68,6 @@ public class TestProgressObserver implements ProgressObserver {
 
     /**
      * Get if we failed
-     * @return
      */
     public boolean isFailed() {
         return failed;
@@ -78,10 +79,11 @@ public class TestProgressObserver implements ProgressObserver {
     }
 
 
+    public boolean isComplete() { return complete;}
+
 
     /**
      * Get update messages
-     * @return
      */
     public List<String> getUpdates() {
         return updates;


[38/54] usergrid git commit: Fixing weird formatting in license headers, no code changes. This closes #385.

Posted by sn...@apache.org.
Fixing weird formatting in license headers, no code changes. This closes #385.


Project: http://git-wip-us.apache.org/repos/asf/usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/usergrid/commit/65d2608e
Tree: http://git-wip-us.apache.org/repos/asf/usergrid/tree/65d2608e
Diff: http://git-wip-us.apache.org/repos/asf/usergrid/diff/65d2608e

Branch: refs/heads/usergrid-1007-shiro-cache
Commit: 65d2608e8fd18ecec1edfce4d41cf2296bf3cc1a
Parents: a562079
Author: Dave Johnson <sn...@apache.org>
Authored: Wed Sep 16 10:45:12 2015 -0400
Committer: Dave Johnson <sn...@apache.org>
Committed: Wed Sep 16 10:45:12 2015 -0400

----------------------------------------------------------------------
 .../persistence/index/CandidateResult.java      | 32 ++++++++---------
 .../persistence/index/CandidateResults.java     | 34 ++++++++----------
 .../SearchRequestBuilderStrategyV2.java         | 30 ++++++++--------
 .../usergrid/persistence/index/IndexEdge.java   | 36 ++++++++++----------
 .../index/IndexLocationStrategy.java            | 30 ++++++++--------
 .../persistence/index/IndexRefreshCommand.java  | 30 ++++++++--------
 .../usergrid/persistence/index/SearchType.java  | 30 ++++++++--------
 .../usergrid/persistence/index/SearchTypes.java | 32 ++++++++---------
 .../persistence/index/SelectFieldMapping.java   | 36 ++++++++++----------
 .../persistence/index/impl/EntityField.java     | 32 ++++++++---------
 .../index/impl/EntityMappingParser.java         | 35 +++++++++----------
 .../index/impl/EsEntityIndexFactoryImpl.java    | 29 ++++++++--------
 .../index/impl/EsIndexBufferConsumerImpl.java   | 28 +++++++--------
 .../index/impl/EsIndexCacheImpl.java            | 29 ++++++++--------
 .../persistence/index/impl/FailureMonitor.java  | 30 ++++++++--------
 .../index/impl/FailureMonitorImpl.java          | 32 ++++++++---------
 .../persistence/index/impl/FieldParser.java     | 36 ++++++++++----------
 .../persistence/index/impl/GeoSortFields.java   | 36 ++++++++++----------
 .../index/impl/IndexBufferConsumer.java         | 28 +++++++--------
 .../persistence/index/impl/IndexCache.java      | 30 ++++++++--------
 .../persistence/index/impl/IndexEdgeImpl.java   | 36 ++++++++++----------
 .../index/impl/IndexIdentifierv2Impl.java       | 30 ++++++++--------
 .../index/impl/IndexRefreshCommandImpl.java     | 30 ++++++++--------
 .../index/impl/NoOpFilterBuilder.java           | 32 ++++++++---------
 .../index/impl/NoOpQueryBuilder.java            | 32 ++++++++---------
 .../impl/SearchRequestBuilderStrategy.java      | 30 ++++++++--------
 .../persistence/index/impl/SortBuilder.java     | 36 ++++++++++----------
 .../EsIndexMappingMigrationPlugin.java          | 28 +++++++--------
 .../index/migration/IndexDataVersions.java      | 30 ++++++++--------
 .../persistence/index/query/ParsedQuery.java    | 36 ++++++++++----------
 .../index/query/ParsedQueryBuilder.java         | 36 ++++++++++----------
 .../persistence/index/query/SortPredicate.java  | 36 ++++++++++----------
 .../index/impl/EntityToMapConverterTest.java    | 36 ++++++++++----------
 .../impl/EsIndexMappingMigrationPluginTest.java | 30 ++++++++--------
 .../persistence/index/impl/EsRunner.java        | 32 ++++++++---------
 .../persistence/index/impl/GeoPagingTest.java   | 36 ++++++++++----------
 .../index/impl/TestIndexIdentifier.java         | 30 ++++++++--------
 37 files changed, 579 insertions(+), 612 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/usergrid/blob/65d2608e/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/CandidateResult.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/CandidateResult.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/CandidateResult.java
index 27d5620..2375509 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/CandidateResult.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/CandidateResult.java
@@ -1,24 +1,20 @@
 /*
+ * 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
  *
- *  *
- *  * 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.
- *  *
+ *    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.usergrid.persistence.index;

http://git-wip-us.apache.org/repos/asf/usergrid/blob/65d2608e/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/CandidateResults.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/CandidateResults.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/CandidateResults.java
index 9de263f..b8f87b6 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/CandidateResults.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/CandidateResults.java
@@ -1,24 +1,20 @@
 /*
+ * 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
  *
- *  *
- *  * 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.
- *  *
+ *    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.usergrid.persistence.index;
@@ -49,7 +45,7 @@ public class CandidateResults implements Iterable<CandidateResult> {
         offset = Optional.absent();
     }
 
-    
+
     public void initializeOffset( int offset ){
         this.offset = Optional.of(offset);
     }

http://git-wip-us.apache.org/repos/asf/usergrid/blob/65d2608e/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/ElasticSearchQueryBuilder/SearchRequestBuilderStrategyV2.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/ElasticSearchQueryBuilder/SearchRequestBuilderStrategyV2.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/ElasticSearchQueryBuilder/SearchRequestBuilderStrategyV2.java
index 4d18cef..732bec1 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/ElasticSearchQueryBuilder/SearchRequestBuilderStrategyV2.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/ElasticSearchQueryBuilder/SearchRequestBuilderStrategyV2.java
@@ -1,20 +1,20 @@
 /*
  *
- *  * Licensed to the Apache Software Foundation (ASF) under one or more
- *  *  contributor license agreements.  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.  For additional information regarding
- *  * copyright in this work, please see the NOTICE file in the top level
- *  * directory of this distribution.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  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.  For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
  *
  */
 package org.apache.usergrid.persistence.index.ElasticSearchQueryBuilder;

http://git-wip-us.apache.org/repos/asf/usergrid/blob/65d2608e/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/IndexEdge.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/IndexEdge.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/IndexEdge.java
index 36aa240..49a1b87 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/IndexEdge.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/IndexEdge.java
@@ -1,23 +1,23 @@
 /*
  *
- *  *
- *  * 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.
+ *
  *
  */
 package org.apache.usergrid.persistence.index;

http://git-wip-us.apache.org/repos/asf/usergrid/blob/65d2608e/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/IndexLocationStrategy.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/IndexLocationStrategy.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/IndexLocationStrategy.java
index e5c8f8f..8039610 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/IndexLocationStrategy.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/IndexLocationStrategy.java
@@ -1,20 +1,20 @@
 /*
  *
- *  * Licensed to the Apache Software Foundation (ASF) under one or more
- *  *  contributor license agreements.  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.  For additional information regarding
- *  * copyright in this work, please see the NOTICE file in the top level
- *  * directory of this distribution.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  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.  For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
  *
  */
 package org.apache.usergrid.persistence.index;

http://git-wip-us.apache.org/repos/asf/usergrid/blob/65d2608e/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/IndexRefreshCommand.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/IndexRefreshCommand.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/IndexRefreshCommand.java
index 435a94a..2226d89 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/IndexRefreshCommand.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/IndexRefreshCommand.java
@@ -1,20 +1,20 @@
 /*
  *
- *  * Licensed to the Apache Software Foundation (ASF) under one or more
- *  *  contributor license agreements.  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.  For additional information regarding
- *  * copyright in this work, please see the NOTICE file in the top level
- *  * directory of this distribution.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  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.  For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
  *
  */
 package org.apache.usergrid.persistence.index;

http://git-wip-us.apache.org/repos/asf/usergrid/blob/65d2608e/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/SearchType.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/SearchType.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/SearchType.java
index 786219a..7a353c7 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/SearchType.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/SearchType.java
@@ -1,20 +1,20 @@
 /*
  *
- *  * Licensed to the Apache Software Foundation (ASF) under one or more
- *  *  contributor license agreements.  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.  For additional information regarding
- *  * copyright in this work, please see the NOTICE file in the top level
- *  * directory of this distribution.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  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.  For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
  *
  */
 package org.apache.usergrid.persistence.index;

http://git-wip-us.apache.org/repos/asf/usergrid/blob/65d2608e/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/SearchTypes.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/SearchTypes.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/SearchTypes.java
index 0fce4c8..5ed2d6d 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/SearchTypes.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/SearchTypes.java
@@ -1,21 +1,21 @@
 package org.apache.usergrid.persistence.index;/*
  *
- *  * 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.
  *
  */
 

http://git-wip-us.apache.org/repos/asf/usergrid/blob/65d2608e/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/SelectFieldMapping.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/SelectFieldMapping.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/SelectFieldMapping.java
index 8d0816a..5a92655 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/SelectFieldMapping.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/SelectFieldMapping.java
@@ -1,23 +1,23 @@
 /*
  *
- *  *
- *  * 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.
+ *
  *
  */
 

http://git-wip-us.apache.org/repos/asf/usergrid/blob/65d2608e/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EntityField.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EntityField.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EntityField.java
index a1eec91..39f0287 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EntityField.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EntityField.java
@@ -1,24 +1,20 @@
 /*
+ * 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
  *
- *  *
- *  * 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.
- *  *
+ *    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.usergrid.persistence.index.impl;

http://git-wip-us.apache.org/repos/asf/usergrid/blob/65d2608e/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EntityMappingParser.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EntityMappingParser.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EntityMappingParser.java
index e328d29..63cef04 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EntityMappingParser.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EntityMappingParser.java
@@ -1,24 +1,20 @@
 /*
+ * 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
  *
- *  *
- *  * 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.
- *  *
+ *    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.usergrid.persistence.index.impl;
@@ -111,7 +107,8 @@ public class EntityMappingParser implements FieldParser {
 
         //we don't support indexing 2 dimensional arrays.  Short circuit with a warning so we can track operationally
         if(!lastCollection.isEmpty() && lastCollection.peek() instanceof Collection){
-            log.warn( "Encountered 2 collections consecutively.  N+1 dimensional arrays are unsupported, only arrays of depth 1 are supported" );
+            log.warn( "Encountered 2 collections consecutively.  " +
+                "N+1 dimensional arrays are unsupported, only arrays of depth 1 are supported" );
             return;
         }
 

http://git-wip-us.apache.org/repos/asf/usergrid/blob/65d2608e/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexFactoryImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexFactoryImpl.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexFactoryImpl.java
index 5f6b4fd..869d079 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexFactoryImpl.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexFactoryImpl.java
@@ -1,21 +1,20 @@
 /*
+ * 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
  *
- *  * Licensed to the Apache Software Foundation (ASF) under one or more
- *  *  contributor license agreements.  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.  For additional information regarding
- *  * copyright in this work, please see the NOTICE file in the top level
- *  * directory of this distribution.
+ *    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.usergrid.persistence.index.impl;
 

http://git-wip-us.apache.org/repos/asf/usergrid/blob/65d2608e/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsIndexBufferConsumerImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsIndexBufferConsumerImpl.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsIndexBufferConsumerImpl.java
index 2c7122b..14f2b6f 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsIndexBufferConsumerImpl.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsIndexBufferConsumerImpl.java
@@ -1,21 +1,19 @@
 /*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  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
  *
- *  * Licensed to the Apache Software Foundation (ASF) under one or more
- *  *  contributor license agreements.  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.  For additional information regarding
- *  * copyright in this work, please see the NOTICE file in the top level
- *  * directory of this distribution.
+ *     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.  For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
  */
 package org.apache.usergrid.persistence.index.impl;
 

http://git-wip-us.apache.org/repos/asf/usergrid/blob/65d2608e/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsIndexCacheImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsIndexCacheImpl.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsIndexCacheImpl.java
index 7bc92a8..a2e3743 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsIndexCacheImpl.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsIndexCacheImpl.java
@@ -1,21 +1,20 @@
 /*
+ * 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
  *
- *  * Licensed to the Apache Software Foundation (ASF) under one or more
- *  *  contributor license agreements.  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.  For additional information regarding
- *  * copyright in this work, please see the NOTICE file in the top level
- *  * directory of this distribution.
+ *    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.usergrid.persistence.index.impl;

http://git-wip-us.apache.org/repos/asf/usergrid/blob/65d2608e/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/FailureMonitor.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/FailureMonitor.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/FailureMonitor.java
index b351699..ed9eeff 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/FailureMonitor.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/FailureMonitor.java
@@ -1,22 +1,20 @@
 /*
+ * 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
  *
- *  * 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.
+ *    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.usergrid.persistence.index.impl;

http://git-wip-us.apache.org/repos/asf/usergrid/blob/65d2608e/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/FailureMonitorImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/FailureMonitorImpl.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/FailureMonitorImpl.java
index fed9a50..7de3a7c 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/FailureMonitorImpl.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/FailureMonitorImpl.java
@@ -1,21 +1,21 @@
 /*
  *
- *  * 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.
  *
  */
 

http://git-wip-us.apache.org/repos/asf/usergrid/blob/65d2608e/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/FieldParser.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/FieldParser.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/FieldParser.java
index 663d2a5..b0a16a6 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/FieldParser.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/FieldParser.java
@@ -1,23 +1,23 @@
 /*
  *
- *  *
- *  * 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.
+ *
  *
  */
 

http://git-wip-us.apache.org/repos/asf/usergrid/blob/65d2608e/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/GeoSortFields.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/GeoSortFields.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/GeoSortFields.java
index fcafcd2..2ed57a0 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/GeoSortFields.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/GeoSortFields.java
@@ -1,23 +1,23 @@
 /*
  *
- *  *
- *  * 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.
+ *
  *
  */
 

http://git-wip-us.apache.org/repos/asf/usergrid/blob/65d2608e/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/IndexBufferConsumer.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/IndexBufferConsumer.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/IndexBufferConsumer.java
index 2906570..e769455 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/IndexBufferConsumer.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/IndexBufferConsumer.java
@@ -1,21 +1,19 @@
 /*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  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
  *
- *  * Licensed to the Apache Software Foundation (ASF) under one or more
- *  *  contributor license agreements.  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.  For additional information regarding
- *  * copyright in this work, please see the NOTICE file in the top level
- *  * directory of this distribution.
+ *     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.  For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
  */
 package org.apache.usergrid.persistence.index.impl;
 

http://git-wip-us.apache.org/repos/asf/usergrid/blob/65d2608e/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/IndexCache.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/IndexCache.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/IndexCache.java
index cbcb413..a19216e 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/IndexCache.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/IndexCache.java
@@ -1,20 +1,20 @@
 /*
  *
- *  * Licensed to the Apache Software Foundation (ASF) under one or more
- *  *  contributor license agreements.  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.  For additional information regarding
- *  * copyright in this work, please see the NOTICE file in the top level
- *  * directory of this distribution.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  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.  For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
  *
  */
 package org.apache.usergrid.persistence.index.impl;

http://git-wip-us.apache.org/repos/asf/usergrid/blob/65d2608e/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/IndexEdgeImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/IndexEdgeImpl.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/IndexEdgeImpl.java
index c3e7c9d..5b525cb 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/IndexEdgeImpl.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/IndexEdgeImpl.java
@@ -1,23 +1,23 @@
 /*
  *
- *  *
- *  * 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.
+ *
  *
  */
 

http://git-wip-us.apache.org/repos/asf/usergrid/blob/65d2608e/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/IndexIdentifierv2Impl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/IndexIdentifierv2Impl.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/IndexIdentifierv2Impl.java
index b36eac5..8bbc2ae 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/IndexIdentifierv2Impl.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/IndexIdentifierv2Impl.java
@@ -1,20 +1,20 @@
 /*
  *
- *  * Licensed to the Apache Software Foundation (ASF) under one or more
- *  *  contributor license agreements.  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.  For additional information regarding
- *  * copyright in this work, please see the NOTICE file in the top level
- *  * directory of this distribution.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  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.  For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
  *
  */
 

http://git-wip-us.apache.org/repos/asf/usergrid/blob/65d2608e/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/IndexRefreshCommandImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/IndexRefreshCommandImpl.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/IndexRefreshCommandImpl.java
index 9a2f2dc..70220d0 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/IndexRefreshCommandImpl.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/IndexRefreshCommandImpl.java
@@ -1,20 +1,20 @@
 /*
  *
- *  * Licensed to the Apache Software Foundation (ASF) under one or more
- *  *  contributor license agreements.  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.  For additional information regarding
- *  * copyright in this work, please see the NOTICE file in the top level
- *  * directory of this distribution.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  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.  For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
  *
  */
 package org.apache.usergrid.persistence.index.impl;

http://git-wip-us.apache.org/repos/asf/usergrid/blob/65d2608e/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/NoOpFilterBuilder.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/NoOpFilterBuilder.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/NoOpFilterBuilder.java
index 9d3c95c..9eca433 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/NoOpFilterBuilder.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/NoOpFilterBuilder.java
@@ -1,24 +1,20 @@
 /*
+ * 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
  *
- *  *
- *  * 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.
- *  *
+ *    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.usergrid.persistence.index.impl;

http://git-wip-us.apache.org/repos/asf/usergrid/blob/65d2608e/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/NoOpQueryBuilder.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/NoOpQueryBuilder.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/NoOpQueryBuilder.java
index acad20c..2498812 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/NoOpQueryBuilder.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/NoOpQueryBuilder.java
@@ -1,24 +1,20 @@
 /*
+ * 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
  *
- *  *
- *  * 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.
- *  *
+ *    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.usergrid.persistence.index.impl;

http://git-wip-us.apache.org/repos/asf/usergrid/blob/65d2608e/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/SearchRequestBuilderStrategy.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/SearchRequestBuilderStrategy.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/SearchRequestBuilderStrategy.java
index 506ba2b..a5c1af3 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/SearchRequestBuilderStrategy.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/SearchRequestBuilderStrategy.java
@@ -1,20 +1,20 @@
 /*
  *
- *  * Licensed to the Apache Software Foundation (ASF) under one or more
- *  *  contributor license agreements.  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.  For additional information regarding
- *  * copyright in this work, please see the NOTICE file in the top level
- *  * directory of this distribution.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  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.  For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
  *
  */
 package org.apache.usergrid.persistence.index.impl;

http://git-wip-us.apache.org/repos/asf/usergrid/blob/65d2608e/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/SortBuilder.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/SortBuilder.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/SortBuilder.java
index 5a3123a..ad78be7 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/SortBuilder.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/SortBuilder.java
@@ -1,23 +1,23 @@
 /*
  *
- *  *
- *  * 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.
+ *
  *
  */
 

http://git-wip-us.apache.org/repos/asf/usergrid/blob/65d2608e/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/migration/EsIndexMappingMigrationPlugin.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/migration/EsIndexMappingMigrationPlugin.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/migration/EsIndexMappingMigrationPlugin.java
index 10acc46..6d46beb 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/migration/EsIndexMappingMigrationPlugin.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/migration/EsIndexMappingMigrationPlugin.java
@@ -1,21 +1,19 @@
 /*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  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
  *
- *  * Licensed to the Apache Software Foundation (ASF) under one or more
- *  *  contributor license agreements.  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.  For additional information regarding
- *  * copyright in this work, please see the NOTICE file in the top level
- *  * directory of this distribution.
+ *     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.  For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
  */
 package org.apache.usergrid.persistence.index.migration;
 

http://git-wip-us.apache.org/repos/asf/usergrid/blob/65d2608e/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/migration/IndexDataVersions.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/migration/IndexDataVersions.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/migration/IndexDataVersions.java
index 6558339..230d53b 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/migration/IndexDataVersions.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/migration/IndexDataVersions.java
@@ -1,20 +1,20 @@
 /*
  *
- *  * Licensed to the Apache Software Foundation (ASF) under one or more
- *  *  contributor license agreements.  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.  For additional information regarding
- *  * copyright in this work, please see the NOTICE file in the top level
- *  * directory of this distribution.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  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.  For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
  *
  */
 

http://git-wip-us.apache.org/repos/asf/usergrid/blob/65d2608e/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/ParsedQuery.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/ParsedQuery.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/ParsedQuery.java
index 7172447..bb87dcc 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/ParsedQuery.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/ParsedQuery.java
@@ -1,23 +1,23 @@
 /*
  *
- *  *
- *  * 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.
+ *
  *
  */
 

http://git-wip-us.apache.org/repos/asf/usergrid/blob/65d2608e/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/ParsedQueryBuilder.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/ParsedQueryBuilder.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/ParsedQueryBuilder.java
index aa279fc..bb79e37 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/ParsedQueryBuilder.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/ParsedQueryBuilder.java
@@ -1,23 +1,23 @@
 /*
  *
- *  *
- *  * 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.
+ *
  *
  */
 

http://git-wip-us.apache.org/repos/asf/usergrid/blob/65d2608e/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/SortPredicate.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/SortPredicate.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/SortPredicate.java
index 92636fb..c350a92 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/SortPredicate.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/SortPredicate.java
@@ -1,23 +1,23 @@
 /*
  *
- *  *
- *  * 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.
+ *
  *
  */
 

http://git-wip-us.apache.org/repos/asf/usergrid/blob/65d2608e/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EntityToMapConverterTest.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EntityToMapConverterTest.java b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EntityToMapConverterTest.java
index 5ebe14e..c412cf4 100644
--- a/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EntityToMapConverterTest.java
+++ b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EntityToMapConverterTest.java
@@ -1,23 +1,23 @@
 /*
  *
- *  *
- *  * 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.
+ *
  *
  */
 


[41/54] usergrid git commit: Refactored migrations to read their own data sets rather than be passed with an invocation

Posted by sn...@apache.org.
Refactored migrations to read their own data sets rather than be passed with an invocation


Project: http://git-wip-us.apache.org/repos/asf/usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/usergrid/commit/d971ec50
Tree: http://git-wip-us.apache.org/repos/asf/usergrid/tree/d971ec50
Diff: http://git-wip-us.apache.org/repos/asf/usergrid/diff/d971ec50

Branch: refs/heads/usergrid-1007-shiro-cache
Commit: d971ec509528fa24977a15501776ebb356e6e1c7
Parents: fb1cf2e
Author: Todd Nine <tn...@apigee.com>
Authored: Wed Sep 16 16:44:02 2015 -0600
Committer: Todd Nine <tn...@apigee.com>
Committed: Wed Sep 16 16:44:02 2015 -0600

----------------------------------------------------------------------
 .../usergrid/corepersistence/CoreModule.java    |  4 +-
 .../migration/CoreMigrationPlugin.java          |  9 +--
 .../migration/EntityTypeMappingMigration.java   |  4 +-
 .../migration/MigrationModuleVersionPlugin.java |  5 --
 .../migration/EntityTypeMappingMigrationIT.java |  2 +-
 .../serialization/impl/SerializationModule.java |  4 +-
 .../migration/CollectionMigrationPlugin.java    |  8 +--
 .../migration/MvccEntityDataMigrationImpl.java  | 10 ++--
 ...ctMvccEntityDataMigrationV1ToV3ImplTest.java |  9 +--
 .../migration/data/AbstractMigrationPlugin.java | 17 +++---
 .../core/migration/data/DataMigration.java      | 11 ++--
 .../migration/data/MigrationDataProvider.java   |  2 +-
 .../core/migration/data/MigrationPlugin.java    |  4 +-
 .../persistence/graph/guice/GraphModule.java    |  4 +-
 .../impl/migration/EdgeDataMigrationImpl.java   | 12 ++--
 .../impl/migration/GraphMigrationPlugin.java    |  8 +--
 .../migration/EdgeDataMigrationImplTest.java    | 59 +++++++++++---------
 .../persistence/index/guice/IndexModule.java    |  4 +-
 .../index/migration/EsIndexMigrationPlugin.java |  8 +--
 19 files changed, 86 insertions(+), 98 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/usergrid/blob/d971ec50/stack/core/src/main/java/org/apache/usergrid/corepersistence/CoreModule.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CoreModule.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CoreModule.java
index e290cfe..7ed95e2 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CoreModule.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CoreModule.java
@@ -100,9 +100,9 @@ public class CoreModule  extends AbstractModule {
         /**
          * Create our migrations for within our core plugin
          */
-        Multibinder<DataMigration<EntityIdScope>> dataMigrationMultibinder =
+        Multibinder<DataMigration> dataMigrationMultibinder =
                     Multibinder.newSetBinder( binder(),
-                        new TypeLiteral<DataMigration<EntityIdScope>>() {}, CoreMigration.class );
+                        new TypeLiteral<DataMigration>() {}, CoreMigration.class );
 
 
         dataMigrationMultibinder.addBinding().to( EntityTypeMappingMigration.class );

http://git-wip-us.apache.org/repos/asf/usergrid/blob/d971ec50/stack/core/src/main/java/org/apache/usergrid/corepersistence/migration/CoreMigrationPlugin.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/migration/CoreMigrationPlugin.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/migration/CoreMigrationPlugin.java
index 58233e0..810f9fb 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/migration/CoreMigrationPlugin.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/migration/CoreMigrationPlugin.java
@@ -22,11 +22,9 @@ package org.apache.usergrid.corepersistence.migration;
 
 import java.util.Set;
 
-import org.apache.usergrid.persistence.collection.serialization.impl.migration.EntityIdScope;
 import org.apache.usergrid.persistence.core.migration.data.MigrationInfoSerialization;
 import org.apache.usergrid.persistence.core.migration.data.AbstractMigrationPlugin;
 import org.apache.usergrid.persistence.core.migration.data.DataMigration;
-import org.apache.usergrid.persistence.core.migration.data.MigrationDataProvider;
 import org.apache.usergrid.persistence.core.migration.data.PluginPhase;
 
 import com.google.inject.Inject;
@@ -37,17 +35,16 @@ import com.google.inject.Singleton;
  * Migration plugin for the collection module
  */
 @Singleton
-public class CoreMigrationPlugin extends AbstractMigrationPlugin<EntityIdScope> {
+public class CoreMigrationPlugin extends AbstractMigrationPlugin {
 
     public static final String PLUGIN_NAME = "core-data";
 
 
 
     @Inject
-    public CoreMigrationPlugin( @CoreMigration final Set<DataMigration<EntityIdScope>> entityDataMigrations,
-                                final MigrationDataProvider<EntityIdScope> entityIdScopeDataMigrationProvider,
+    public CoreMigrationPlugin( @CoreMigration final Set<DataMigration> entityDataMigrations,
                                 final MigrationInfoSerialization migrationInfoSerialization ) {
-        super( entityDataMigrations, entityIdScopeDataMigrationProvider, migrationInfoSerialization );
+        super( entityDataMigrations, migrationInfoSerialization );
     }
 
 

http://git-wip-us.apache.org/repos/asf/usergrid/blob/d971ec50/stack/core/src/main/java/org/apache/usergrid/corepersistence/migration/EntityTypeMappingMigration.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/migration/EntityTypeMappingMigration.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/migration/EntityTypeMappingMigration.java
index 47ad30a..ef65ff2 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/migration/EntityTypeMappingMigration.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/migration/EntityTypeMappingMigration.java
@@ -41,7 +41,7 @@ import rx.schedulers.Schedulers;
 /**
  * Migration to ensure that our entity id is written into our map data
  */
-public class EntityTypeMappingMigration implements DataMigration<EntityIdScope> {
+public class EntityTypeMappingMigration implements DataMigration {
 
     private final ManagerCache managerCache;
     private final MigrationDataProvider<EntityIdScope> allEntitiesInSystemObservable;
@@ -56,7 +56,7 @@ public class EntityTypeMappingMigration implements DataMigration<EntityIdScope>
 
 
     @Override
-    public int migrate( final int currentVersion, final MigrationDataProvider<EntityIdScope> migrationDataProvider,
+    public int migrate( final int currentVersion,
                         final ProgressObserver observer ) {
 
         final AtomicLong atomicLong = new AtomicLong();

http://git-wip-us.apache.org/repos/asf/usergrid/blob/d971ec50/stack/core/src/main/java/org/apache/usergrid/corepersistence/migration/MigrationModuleVersionPlugin.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/migration/MigrationModuleVersionPlugin.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/migration/MigrationModuleVersionPlugin.java
index 2ffe335..145e76f 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/migration/MigrationModuleVersionPlugin.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/migration/MigrationModuleVersionPlugin.java
@@ -56,11 +56,6 @@ public class MigrationModuleVersionPlugin implements MigrationPlugin{
      */
     private static final int ENTITY_V2_MIGRATION = 3;
 
-    /**
-     * Appinfo to application_info migration.
-     */
-    private static final int APPINFO_MIGRATION = 4;
-
 
     /**
      * Get versions directly from impls so we know they're accurate

http://git-wip-us.apache.org/repos/asf/usergrid/blob/d971ec50/stack/core/src/test/java/org/apache/usergrid/corepersistence/migration/EntityTypeMappingMigrationIT.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/corepersistence/migration/EntityTypeMappingMigrationIT.java b/stack/core/src/test/java/org/apache/usergrid/corepersistence/migration/EntityTypeMappingMigrationIT.java
index 84215a1..7d22abe 100644
--- a/stack/core/src/test/java/org/apache/usergrid/corepersistence/migration/EntityTypeMappingMigrationIT.java
+++ b/stack/core/src/test/java/org/apache/usergrid/corepersistence/migration/EntityTypeMappingMigrationIT.java
@@ -101,7 +101,7 @@ public class EntityTypeMappingMigrationIT  {
 
         //run it
 
-        final int returnedVersion = migration.migrate(CoreDataVersions.INITIAL.getVersion(), migrationDataProvider, progressObserver );
+        final int returnedVersion = migration.migrate(CoreDataVersions.INITIAL.getVersion(), progressObserver );
 
 
         assertEquals(CoreDataVersions.ID_MAP_FIX.getVersion(), returnedVersion);

http://git-wip-us.apache.org/repos/asf/usergrid/blob/d971ec50/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/SerializationModule.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/SerializationModule.java b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/SerializationModule.java
index bd2728b..3a6fd14 100644
--- a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/SerializationModule.java
+++ b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/SerializationModule.java
@@ -96,8 +96,8 @@ public class SerializationModule extends AbstractModule {
 
         //migrations
         //we want to make sure our generics are retained, so we use a typeliteral
-        Multibinder<DataMigration<EntityIdScope>> dataMigrationMultibinder = Multibinder
-            .newSetBinder( binder(), new TypeLiteral<DataMigration<EntityIdScope>>() {}, CollectionMigration.class );
+        Multibinder<DataMigration> dataMigrationMultibinder = Multibinder
+            .newSetBinder( binder(), new TypeLiteral<DataMigration>() {}, CollectionMigration.class );
 
 
         dataMigrationMultibinder.addBinding().to( MvccEntityDataMigrationImpl.class );

http://git-wip-us.apache.org/repos/asf/usergrid/blob/d971ec50/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/migration/CollectionMigrationPlugin.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/migration/CollectionMigrationPlugin.java b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/migration/CollectionMigrationPlugin.java
index c757d28..4e92d3c 100644
--- a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/migration/CollectionMigrationPlugin.java
+++ b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/migration/CollectionMigrationPlugin.java
@@ -28,7 +28,6 @@ import java.util.Set;
 
 import org.apache.usergrid.persistence.core.migration.data.AbstractMigrationPlugin;
 import org.apache.usergrid.persistence.core.migration.data.DataMigration;
-import org.apache.usergrid.persistence.core.migration.data.MigrationDataProvider;
 import org.apache.usergrid.persistence.core.migration.data.MigrationInfoSerialization;
 import org.apache.usergrid.persistence.core.migration.data.PluginPhase;
 
@@ -40,7 +39,7 @@ import com.google.inject.Singleton;
  * Migration plugin for the collection module
  */
 @Singleton
-public class CollectionMigrationPlugin extends AbstractMigrationPlugin<EntityIdScope> {
+public class CollectionMigrationPlugin extends AbstractMigrationPlugin {
 
     public static final String PLUGIN_NAME = "collections-entity-data";
 
@@ -48,10 +47,9 @@ public class CollectionMigrationPlugin extends AbstractMigrationPlugin<EntityIdS
 
     @Inject
     public CollectionMigrationPlugin( @CollectionMigration
-                                          final Set<DataMigration<EntityIdScope>> entityDataMigrations,
-                                      final MigrationDataProvider<EntityIdScope> entityIdScopeDataMigrationProvider,
+                                          final Set<DataMigration> entityDataMigrations,
                                       final MigrationInfoSerialization migrationInfoSerialization ) {
-        super( entityDataMigrations, entityIdScopeDataMigrationProvider, migrationInfoSerialization );
+        super( entityDataMigrations, migrationInfoSerialization );
     }
 
 

http://git-wip-us.apache.org/repos/asf/usergrid/blob/d971ec50/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/migration/MvccEntityDataMigrationImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/migration/MvccEntityDataMigrationImpl.java b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/migration/MvccEntityDataMigrationImpl.java
index 86fd701..5143c49 100644
--- a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/migration/MvccEntityDataMigrationImpl.java
+++ b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/migration/MvccEntityDataMigrationImpl.java
@@ -65,7 +65,7 @@ import rx.schedulers.Schedulers;
  * Data migration strategy for entities
  */
 @Singleton
-public class MvccEntityDataMigrationImpl implements DataMigration<EntityIdScope> {
+public class MvccEntityDataMigrationImpl implements DataMigration{
 
 
     private static final Logger LOGGER = LoggerFactory.getLogger( MvccEntityDataMigrationImpl.class );
@@ -75,6 +75,7 @@ public class MvccEntityDataMigrationImpl implements DataMigration<EntityIdScope>
     private final MvccEntitySerializationStrategyV3Impl mvccEntitySerializationStrategyV3;
     private final UniqueValueSerializationStrategy uniqueValueSerializationStrategy;
     private final MvccLogEntrySerializationStrategy mvccLogEntrySerializationStrategy;
+    private final MigrationDataProvider<EntityIdScope> migrationDataProvider;
 
 
     @Inject
@@ -82,12 +83,14 @@ public class MvccEntityDataMigrationImpl implements DataMigration<EntityIdScope>
                                         final VersionedMigrationSet<MvccEntitySerializationStrategy> allVersions,
                                         final MvccEntitySerializationStrategyV3Impl mvccEntitySerializationStrategyV3,
                                         final UniqueValueSerializationStrategy uniqueValueSerializationStrategy,
-                                        final MvccLogEntrySerializationStrategy mvccLogEntrySerializationStrategy ) {
+                                        final MvccLogEntrySerializationStrategy mvccLogEntrySerializationStrategy,
+                                        final MigrationDataProvider<EntityIdScope> migrationDataProvider ) {
         this.keyspace = keyspace;
         this.allVersions = allVersions;
         this.mvccEntitySerializationStrategyV3 = mvccEntitySerializationStrategyV3;
         this.uniqueValueSerializationStrategy = uniqueValueSerializationStrategy;
         this.mvccLogEntrySerializationStrategy = mvccLogEntrySerializationStrategy;
+        this.migrationDataProvider = migrationDataProvider;
     }
 
 
@@ -105,8 +108,7 @@ public class MvccEntityDataMigrationImpl implements DataMigration<EntityIdScope>
 
 
     @Override
-    public int migrate( final int currentVersion, final MigrationDataProvider<EntityIdScope> migrationDataProvider,
-                        final ProgressObserver observer ) {
+    public int migrate( final int currentVersion,  final ProgressObserver observer ) {
 
         final AtomicLong atomicLong = new AtomicLong();
 

http://git-wip-us.apache.org/repos/asf/usergrid/blob/d971ec50/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/migration/AbstractMvccEntityDataMigrationV1ToV3ImplTest.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/migration/AbstractMvccEntityDataMigrationV1ToV3ImplTest.java b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/migration/AbstractMvccEntityDataMigrationV1ToV3ImplTest.java
index 986b740..f51b339 100644
--- a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/migration/AbstractMvccEntityDataMigrationV1ToV3ImplTest.java
+++ b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/migration/AbstractMvccEntityDataMigrationV1ToV3ImplTest.java
@@ -121,13 +121,6 @@ public abstract class AbstractMvccEntityDataMigrationV1ToV3ImplTest implements D
             Observable.just( new EntityIdScope( scope, entity1.getId() ), new EntityIdScope( scope, entity2.getId() ) );
 
 
-        final MigrationDataProvider<EntityIdScope> migrationProvider = new MigrationDataProvider<EntityIdScope>() {
-            @Override
-            public Observable<EntityIdScope> getData() {
-                return entityIdScope;
-            }
-        };
-
         final TestProgressObserver progressObserver = new TestProgressObserver();
 
         final CollectionDataVersions startVersion = getSourceVersion();
@@ -141,7 +134,7 @@ public abstract class AbstractMvccEntityDataMigrationV1ToV3ImplTest implements D
 
         //now migration
         final int newVersion = mvccEntityDataMigrationImpl
-            .migrate( startVersion.getVersion(), migrationProvider, progressObserver );
+            .migrate( startVersion.getVersion(), progressObserver );
 
 
         final CollectionDataVersions expectedVersion = expectedTargetVersion();

http://git-wip-us.apache.org/repos/asf/usergrid/blob/d971ec50/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/data/AbstractMigrationPlugin.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/data/AbstractMigrationPlugin.java b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/data/AbstractMigrationPlugin.java
index 0cd26d4..9671bc5 100644
--- a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/data/AbstractMigrationPlugin.java
+++ b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/data/AbstractMigrationPlugin.java
@@ -34,23 +34,20 @@ import org.slf4j.LoggerFactory;
  * Standard implementation logic for plugins to extend
  * @param <T>
  */
-public abstract class AbstractMigrationPlugin<T> implements MigrationPlugin {
+public abstract class AbstractMigrationPlugin implements MigrationPlugin {
 
 
 
     private static final Logger LOG = LoggerFactory.getLogger( AbstractMigrationPlugin.class );
 
 
-    private final Set<DataMigration<T>> entityDataMigrations;
-    private final MigrationDataProvider<T> entityIdScopeDataMigrationProvider;
+    private final Set<DataMigration> entityDataMigrations;
     private final MigrationInfoSerialization migrationInfoSerialization;
 
 
-    protected AbstractMigrationPlugin( final Set<DataMigration<T>> entityDataMigrations,
-                                       final MigrationDataProvider<T> entityIdScopeDataMigrationProvider,
+    protected AbstractMigrationPlugin( final Set<DataMigration>entityDataMigrations,
                                        final MigrationInfoSerialization migrationInfoSerialization ) {
         this.entityDataMigrations = entityDataMigrations;
-        this.entityIdScopeDataMigrationProvider = entityIdScopeDataMigrationProvider;
         this.migrationInfoSerialization = migrationInfoSerialization;
     }
 
@@ -71,7 +68,7 @@ public abstract class AbstractMigrationPlugin<T> implements MigrationPlugin {
 
         int max = 0;
 
-        for(DataMigration<T> entityMigration: entityDataMigrations){
+        for(DataMigration entityMigration: entityDataMigrations){
             max = Math.max( max, entityMigration.getMaxVersion() );
         }
 
@@ -85,12 +82,12 @@ public abstract class AbstractMigrationPlugin<T> implements MigrationPlugin {
      * @return True if we ran a migration
      */
     private boolean runMigration( final ProgressObserver po ) {
-        DataMigration<T> migrationToExecute = null;
+        DataMigration migrationToExecute = null;
 
 
         final int version = migrationInfoSerialization.getVersion( getName() );
 
-        for ( DataMigration<T> entityMigration : entityDataMigrations ) {
+        for ( DataMigration entityMigration : entityDataMigrations ) {
             if ( entityMigration.supports( version ) ) {
                 if ( migrationToExecute != null ) {
                     throw new DataMigrationException(
@@ -113,7 +110,7 @@ public abstract class AbstractMigrationPlugin<T> implements MigrationPlugin {
 
 
         //run the migration
-        final int newSystemVersion = migrationToExecute.migrate( version, entityIdScopeDataMigrationProvider, po );
+        final int newSystemVersion = migrationToExecute.migrate( version, po );
 
         //write the version
         migrationInfoSerialization.setVersion( getName(), newSystemVersion );

http://git-wip-us.apache.org/repos/asf/usergrid/blob/d971ec50/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/data/DataMigration.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/data/DataMigration.java b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/data/DataMigration.java
index ce250cc..a3ee675 100644
--- a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/data/DataMigration.java
+++ b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/data/DataMigration.java
@@ -27,32 +27,31 @@ package org.apache.usergrid.persistence.core.migration.data;
 /**
  * Data migration.  The internal version to migrate
  *
- * @param <T>
+ * @param
  */
-public interface DataMigration<T> {
+public interface DataMigration {
 
     /**
      * Perform the migration, returning an observable with a single emitted value
      * @param currentVersion the current version of the system
-     * @param migrationDataProvider
      * @param observer The observer to receive updates of the progress
      *
      * @return The version that the system is now running
      */
-    public int migrate(final int currentVersion, MigrationDataProvider<T> migrationDataProvider, ProgressObserver observer);
+    int migrate( final int currentVersion, ProgressObserver observer );
 
     /**
      * Check if this version supports migration from the current system version.  If this returns false,
      * migrate will not be invoked
      * @return
      */
-    public boolean supports(final int currentVersion);
+    boolean supports( final int currentVersion );
 
     /**
      * Get the max version this migration can migrate to
      * @return
      */
-    public int getMaxVersion();
+    int getMaxVersion();
 
 
 }

http://git-wip-us.apache.org/repos/asf/usergrid/blob/d971ec50/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/data/MigrationDataProvider.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/data/MigrationDataProvider.java b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/data/MigrationDataProvider.java
index e232d7b..1608742 100644
--- a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/data/MigrationDataProvider.java
+++ b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/data/MigrationDataProvider.java
@@ -38,6 +38,6 @@ public interface MigrationDataProvider<T> {
      * Get data that can be used in the migration
      * @return
      */
-    public Observable<T> getData();
+    Observable<T> getData();
 
 }

http://git-wip-us.apache.org/repos/asf/usergrid/blob/d971ec50/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/data/MigrationPlugin.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/data/MigrationPlugin.java b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/data/MigrationPlugin.java
index 4953f25..cb9297d 100644
--- a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/data/MigrationPlugin.java
+++ b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/data/MigrationPlugin.java
@@ -34,12 +34,12 @@ public interface MigrationPlugin {
      * Get the name of the plugin.  Must be unique
      * @return
      */
-    public String getName();
+    String getName();
 
     /**
      * Run any migrations that may need to be run in this plugin
      */
-    public void run(ProgressObserver observer);
+    void run( ProgressObserver observer );
 
 
     /**

http://git-wip-us.apache.org/repos/asf/usergrid/blob/d971ec50/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/guice/GraphModule.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/guice/GraphModule.java b/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/guice/GraphModule.java
index 4b628d1..6280c7c 100644
--- a/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/guice/GraphModule.java
+++ b/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/guice/GraphModule.java
@@ -128,8 +128,8 @@ public abstract class GraphModule extends AbstractModule {
 
 
         //wire up the edg migration
-        Multibinder<DataMigration<GraphNode>> dataMigrationMultibinder =
-                Multibinder.newSetBinder( binder(), new TypeLiteral<DataMigration<GraphNode>>() {}, GraphMigration.class );
+        Multibinder<DataMigration> dataMigrationMultibinder =
+                Multibinder.newSetBinder( binder(), new TypeLiteral<DataMigration>() {}, GraphMigration.class );
 
 
         dataMigrationMultibinder.addBinding().to( EdgeDataMigrationImpl.class );

http://git-wip-us.apache.org/repos/asf/usergrid/blob/d971ec50/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/serialization/impl/migration/EdgeDataMigrationImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/serialization/impl/migration/EdgeDataMigrationImpl.java b/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/serialization/impl/migration/EdgeDataMigrationImpl.java
index d6c42e3..15ff337 100644
--- a/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/serialization/impl/migration/EdgeDataMigrationImpl.java
+++ b/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/serialization/impl/migration/EdgeDataMigrationImpl.java
@@ -49,7 +49,7 @@ import java.util.concurrent.atomic.AtomicLong;
  * The migration data provider assumes that is will visit every node in the graph
  * all edges from these source node will then be re-indexed.
  */
-public class EdgeDataMigrationImpl implements DataMigration<GraphNode> {
+public class EdgeDataMigrationImpl implements DataMigration {
 
     private static final Logger logger = LoggerFactory.getLogger(EdgeDataMigrationImpl.class);
 
@@ -58,24 +58,26 @@ public class EdgeDataMigrationImpl implements DataMigration<GraphNode> {
     private final EdgesObservable edgesFromSourceObservable;
     private final VersionedMigrationSet<EdgeMetadataSerialization> allVersions;
     private final EdgeMetadataSerializationV2Impl edgeMetadataSerializationV2;
+    private final MigrationDataProvider<GraphNode> migrationDataProvider;
 
     @Inject
-    public EdgeDataMigrationImpl( final Keyspace keyspace,
-                                  final GraphManagerFactory graphManagerFactory,
+    public EdgeDataMigrationImpl( final Keyspace keyspace, final GraphManagerFactory graphManagerFactory,
                                   final EdgesObservable edgesFromSourceObservable,
                                   final VersionedMigrationSet<EdgeMetadataSerialization> allVersions,
-                                  final EdgeMetadataSerializationV2Impl edgeMetadataSerializationV2 ) {
+                                  final EdgeMetadataSerializationV2Impl edgeMetadataSerializationV2,
+                                  final MigrationDataProvider<GraphNode> migrationDataProvider ) {
 
         this.keyspace = keyspace;
         this.graphManagerFactory = graphManagerFactory;
         this.edgesFromSourceObservable = edgesFromSourceObservable;
         this.allVersions = allVersions;
         this.edgeMetadataSerializationV2 = edgeMetadataSerializationV2;
+        this.migrationDataProvider = migrationDataProvider;
     }
 
 
     @Override
-    public int migrate( final int currentVersion, final MigrationDataProvider<GraphNode> migrationDataProvider,
+    public int migrate( final int currentVersion,
                         final ProgressObserver observer ) {
 
         final AtomicLong counter = new AtomicLong();

http://git-wip-us.apache.org/repos/asf/usergrid/blob/d971ec50/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/serialization/impl/migration/GraphMigrationPlugin.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/serialization/impl/migration/GraphMigrationPlugin.java b/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/serialization/impl/migration/GraphMigrationPlugin.java
index ed51c27..97edf3b 100644
--- a/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/serialization/impl/migration/GraphMigrationPlugin.java
+++ b/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/serialization/impl/migration/GraphMigrationPlugin.java
@@ -29,7 +29,6 @@ import java.util.Set;
 import org.apache.usergrid.persistence.core.migration.data.MigrationInfoSerialization;
 import org.apache.usergrid.persistence.core.migration.data.AbstractMigrationPlugin;
 import org.apache.usergrid.persistence.core.migration.data.DataMigration;
-import org.apache.usergrid.persistence.core.migration.data.MigrationDataProvider;
 import org.apache.usergrid.persistence.core.migration.data.PluginPhase;
 
 import com.google.inject.Inject;
@@ -41,7 +40,7 @@ import com.google.inject.Singleton;
  * Migration plugin for the collection module
  */
 @Singleton
-public class GraphMigrationPlugin extends AbstractMigrationPlugin<GraphNode> {
+public class GraphMigrationPlugin extends AbstractMigrationPlugin {
 
     public static final String PLUGIN_NAME = "graph-data";
 
@@ -49,10 +48,9 @@ public class GraphMigrationPlugin extends AbstractMigrationPlugin<GraphNode> {
 
     @Inject
     public GraphMigrationPlugin(@GraphMigration
-                                    final Set<DataMigration<GraphNode>> entityDataMigrations,
-                                      final MigrationDataProvider<GraphNode> entityIdScopeDataMigrationProvider,
+                                    final Set<DataMigration> entityDataMigrations,
                                       final MigrationInfoSerialization migrationInfoSerialization ) {
-        super( entityDataMigrations, entityIdScopeDataMigrationProvider, migrationInfoSerialization );
+        super( entityDataMigrations, migrationInfoSerialization );
     }
 
 

http://git-wip-us.apache.org/repos/asf/usergrid/blob/d971ec50/stack/corepersistence/graph/src/test/java/org/apache/usergrid/persistence/graph/serialization/impl/migration/EdgeDataMigrationImplTest.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/graph/src/test/java/org/apache/usergrid/persistence/graph/serialization/impl/migration/EdgeDataMigrationImplTest.java b/stack/corepersistence/graph/src/test/java/org/apache/usergrid/persistence/graph/serialization/impl/migration/EdgeDataMigrationImplTest.java
index 049c3d2..bc2afdc 100644
--- a/stack/corepersistence/graph/src/test/java/org/apache/usergrid/persistence/graph/serialization/impl/migration/EdgeDataMigrationImplTest.java
+++ b/stack/corepersistence/graph/src/test/java/org/apache/usergrid/persistence/graph/serialization/impl/migration/EdgeDataMigrationImplTest.java
@@ -28,8 +28,9 @@ import org.junit.runner.RunWith;
 
 import org.apache.usergrid.persistence.core.guice.DataMigrationResetRule;
 import org.apache.usergrid.persistence.core.migration.data.DataMigrationManager;
-import org.apache.usergrid.persistence.core.migration.data.TestProgressObserver;
 import org.apache.usergrid.persistence.core.migration.data.MigrationDataProvider;
+import org.apache.usergrid.persistence.core.migration.data.TestProgressObserver;
+import org.apache.usergrid.persistence.core.migration.data.VersionedMigrationSet;
 import org.apache.usergrid.persistence.core.scope.ApplicationScope;
 import org.apache.usergrid.persistence.core.scope.ApplicationScopeImpl;
 import org.apache.usergrid.persistence.core.test.ITRunner;
@@ -40,25 +41,28 @@ import org.apache.usergrid.persistence.graph.GraphManager;
 import org.apache.usergrid.persistence.graph.GraphManagerFactory;
 import org.apache.usergrid.persistence.graph.guice.TestGraphModule;
 import org.apache.usergrid.persistence.graph.impl.SimpleSearchEdgeType;
+import org.apache.usergrid.persistence.graph.serialization.EdgeMetadataSerialization;
+import org.apache.usergrid.persistence.graph.serialization.EdgesObservable;
+import org.apache.usergrid.persistence.graph.serialization.impl.EdgeMetadataSerializationV2Impl;
 import org.apache.usergrid.persistence.graph.serialization.impl.GraphDataVersions;
 import org.apache.usergrid.persistence.model.entity.Id;
 
 import com.google.inject.Inject;
+import com.netflix.astyanax.Keyspace;
 
 import net.jcip.annotations.NotThreadSafe;
 
 import rx.Observable;
 
 import static org.apache.usergrid.persistence.graph.test.util.EdgeTestUtils.createEdge;
-import static org.apache.usergrid.persistence.core.util.IdGenerator.createId;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
 
 
 @NotThreadSafe
-@RunWith(ITRunner.class)
-@UseModules({ TestGraphModule.class })
+@RunWith( ITRunner.class )
+@UseModules( { TestGraphModule.class } )
 public class EdgeDataMigrationImplTest implements DataMigrationResetRule.DataMigrationManagerProvider {
 
 
@@ -68,16 +72,26 @@ public class EdgeDataMigrationImplTest implements DataMigrationResetRule.DataMig
     @Inject
     public GraphManagerFactory graphManagerFactory;
 
+
+    @Inject
+    public Keyspace keyspace;
+
     @Inject
-    public EdgeDataMigrationImpl edgeDataMigrationImpl;
+    public EdgesObservable edgesFromSourceObservable;
+
+    @Inject
+    public VersionedMigrationSet<EdgeMetadataSerialization> allVersions;
+
+    @Inject
+    public EdgeMetadataSerializationV2Impl edgeMetadataSerializationV2;
+
 
     /**
      * Rule to do the resets we need
      */
     @Rule
-    public DataMigrationResetRule migrationTestRule = new DataMigrationResetRule(this, GraphMigrationPlugin.PLUGIN_NAME,  GraphDataVersions.INITIAL.getVersion());
-
-
+    public DataMigrationResetRule migrationTestRule =
+        new DataMigrationResetRule( this, GraphMigrationPlugin.PLUGIN_NAME, GraphDataVersions.INITIAL.getVersion() );
 
 
     @Test
@@ -90,7 +104,7 @@ public class EdgeDataMigrationImplTest implements DataMigrationResetRule.DataMig
         final ApplicationScope applicationScope = new ApplicationScopeImpl( IdGenerator.createId( "application" ) );
 
 
-        GraphManager gm = graphManagerFactory.createEdgeManager(applicationScope );
+        GraphManager gm = graphManagerFactory.createEdgeManager( applicationScope );
 
 
         final Id sourceId1 = IdGenerator.createId( "source1" );
@@ -103,17 +117,15 @@ public class EdgeDataMigrationImplTest implements DataMigrationResetRule.DataMig
         final Id target2 = IdGenerator.createId( "target2" );
 
 
-        Edge s1t1 = createEdge(sourceId1, "test", target1 );
+        Edge s1t1 = createEdge( sourceId1, "test", target1 );
 
         Edge s1t2 = createEdge( sourceId1, "baz", target2 );
 
-        Edge s2t1 = createEdge(sourceId2, "foo", target1);
+        Edge s2t1 = createEdge( sourceId2, "foo", target1 );
 
         Edge s2t2 = createEdge( sourceId2, "bar", target2 );
 
 
-
-
         gm.writeEdge( s1t1 ).toBlocking().last();
         gm.writeEdge( s1t2 ).toBlocking().last();
         gm.writeEdge( s2t1 ).toBlocking().last();
@@ -121,24 +133,24 @@ public class EdgeDataMigrationImplTest implements DataMigrationResetRule.DataMig
 
 
         //walk from s1 and s2
-        final Observable<GraphNode> graphNodes = Observable.just( new GraphNode( applicationScope, sourceId1), new GraphNode(applicationScope, sourceId2 ) );
+        final Observable<GraphNode> graphNodes = Observable
+            .just( new GraphNode( applicationScope, sourceId1 ), new GraphNode( applicationScope, sourceId2 ) );
 
-        final MigrationDataProvider<GraphNode> testMigrationProvider = new MigrationDataProvider<GraphNode>() {
-            @Override
-            public Observable<GraphNode> getData() {
-                return graphNodes;
-            }
-        };
+        final MigrationDataProvider<GraphNode> testMigrationProvider = () -> graphNodes;
 
 
         final TestProgressObserver progressObserver = new TestProgressObserver();
 
 
-
         //read everything in previous version format and put it into our types.
 
 
-        final int returned = edgeDataMigrationImpl.migrate( GraphDataVersions.INITIAL.getVersion() , testMigrationProvider, progressObserver );
+        EdgeDataMigrationImpl edgeDataMigrationImpl =
+            new EdgeDataMigrationImpl( keyspace, graphManagerFactory, edgesFromSourceObservable, allVersions,
+                edgeMetadataSerializationV2, testMigrationProvider );
+
+
+        final int returned = edgeDataMigrationImpl.migrate( GraphDataVersions.INITIAL.getVersion(), progressObserver );
         //perform the migration
 
         assertEquals( "Correct version returned", returned, GraphDataVersions.META_SHARDING.getVersion() );
@@ -164,9 +176,6 @@ public class EdgeDataMigrationImplTest implements DataMigrationResetRule.DataMig
 
         assertTrue( "Edge type present", source2Edges.contains( "foo" ) );
         assertTrue( "Edge type present", source2Edges.contains( "bar" ) );
-
-
-
     }
 
 

http://git-wip-us.apache.org/repos/asf/usergrid/blob/d971ec50/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/guice/IndexModule.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/guice/IndexModule.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/guice/IndexModule.java
index d03bbf8..7279174 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/guice/IndexModule.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/guice/IndexModule.java
@@ -56,8 +56,8 @@ public abstract class IndexModule extends AbstractModule {
 
 
         //wire up the edg migration. A no-op ATM, but retained for future development
-        Multibinder<DataMigration<ApplicationScope>> dataMigrationMultibinder =
-                Multibinder.newSetBinder( binder(), new TypeLiteral<DataMigration<ApplicationScope>>() {}, IndexMigration.class );
+        Multibinder<DataMigration> dataMigrationMultibinder =
+                Multibinder.newSetBinder( binder(), new TypeLiteral<DataMigration>() {}, IndexMigration.class );
 
 
 

http://git-wip-us.apache.org/repos/asf/usergrid/blob/d971ec50/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/migration/EsIndexMigrationPlugin.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/migration/EsIndexMigrationPlugin.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/migration/EsIndexMigrationPlugin.java
index a28c701..c8e353d 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/migration/EsIndexMigrationPlugin.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/migration/EsIndexMigrationPlugin.java
@@ -18,20 +18,18 @@ package org.apache.usergrid.persistence.index.migration;
 
 import com.google.inject.Inject;
 import org.apache.usergrid.persistence.core.migration.data.*;
-import org.apache.usergrid.persistence.core.scope.ApplicationScope;
 
 import java.util.Set;
 
 /**
  * Classy class class.
  */
-public class EsIndexMigrationPlugin  extends AbstractMigrationPlugin<ApplicationScope>{
+public class EsIndexMigrationPlugin  extends AbstractMigrationPlugin {
 
     @Inject
-    public EsIndexMigrationPlugin(@IndexMigration final Set<DataMigration<ApplicationScope>> entityDataMigrations,
-                                  final MigrationDataProvider<ApplicationScope> entityIdScopeDataMigrationProvider,
+    public EsIndexMigrationPlugin(@IndexMigration final Set<DataMigration> entityDataMigrations,
                                   final MigrationInfoSerialization migrationInfoSerialization ){
-        super(entityDataMigrations,entityIdScopeDataMigrationProvider,migrationInfoSerialization);
+        super(entityDataMigrations,migrationInfoSerialization);
     }
 
     @Override


[24/54] usergrid git commit: Merge branch 'two-dot-o-dev' into usergrid-103-upgrade-jersey

Posted by sn...@apache.org.
Merge branch 'two-dot-o-dev' into usergrid-103-upgrade-jersey


Project: http://git-wip-us.apache.org/repos/asf/usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/usergrid/commit/3343e2d9
Tree: http://git-wip-us.apache.org/repos/asf/usergrid/tree/3343e2d9
Diff: http://git-wip-us.apache.org/repos/asf/usergrid/diff/3343e2d9

Branch: refs/heads/usergrid-1007-shiro-cache
Commit: 3343e2d939c3be681416dff73b6b6c9c92656473
Parents: 1bfa32a 929528a
Author: Dave Johnson <sn...@apache.org>
Authored: Thu Sep 10 15:22:20 2015 -0400
Committer: Dave Johnson <sn...@apache.org>
Committed: Thu Sep 10 15:22:20 2015 -0400

----------------------------------------------------------------------
 .../persistence/entities/Notification.java         |  9 +++++++++
 .../model/entity/EntityToMapConverter.java         | 17 +++++++++++++----
 2 files changed, 22 insertions(+), 4 deletions(-)
----------------------------------------------------------------------



[28/54] usergrid git commit: Corrects test setup and adds debug logging

Posted by sn...@apache.org.
Corrects test setup and adds debug logging


Project: http://git-wip-us.apache.org/repos/asf/usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/usergrid/commit/85e1e7c1
Tree: http://git-wip-us.apache.org/repos/asf/usergrid/tree/85e1e7c1
Diff: http://git-wip-us.apache.org/repos/asf/usergrid/diff/85e1e7c1

Branch: refs/heads/usergrid-1007-shiro-cache
Commit: 85e1e7c1e17470bf012308011950a7ae43565b5f
Parents: b625ed2
Author: Todd Nine <tn...@apigee.com>
Authored: Mon Sep 14 19:07:28 2015 -0600
Committer: Todd Nine <tn...@apigee.com>
Committed: Mon Sep 14 19:07:28 2015 -0600

----------------------------------------------------------------------
 .../service/ConnectionServiceImpl.java          | 26 ++++++++++++++++++--
 .../service/ConnectionServiceImplTest.java      | 12 ++++++---
 2 files changed, 33 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/usergrid/blob/85e1e7c1/stack/core/src/main/java/org/apache/usergrid/corepersistence/service/ConnectionServiceImpl.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/service/ConnectionServiceImpl.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/service/ConnectionServiceImpl.java
index 82c1038..41e6f80 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/service/ConnectionServiceImpl.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/service/ConnectionServiceImpl.java
@@ -18,6 +18,9 @@
 package org.apache.usergrid.corepersistence.service;
 
 
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
 import org.apache.usergrid.corepersistence.pipeline.builder.EntityBuilder;
 import org.apache.usergrid.corepersistence.pipeline.builder.IdBuilder;
 import org.apache.usergrid.corepersistence.pipeline.builder.PipelineBuilderFactory;
@@ -47,6 +50,9 @@ import rx.Observable;
 @Singleton
 public class ConnectionServiceImpl implements ConnectionService {
 
+
+    private static final Logger logger = LoggerFactory.getLogger( ConnectionServiceImpl.class );
+
     private final PipelineBuilderFactory pipelineBuilderFactory;
     private final AllEntityIdsObservable allEntityIdsObservable;
     private final GraphManagerFactory graphManagerFactory;
@@ -152,11 +158,16 @@ public class ConnectionServiceImpl implements ConnectionService {
 
             final GraphManager gm = graphManagerFactory.createEdgeManager(applicationScope );
 
+           logger.debug( "Checking connections of id {} in application {}", entityId, applicationScope );
+
             return gm.getEdgeTypesFromSource(
                 new SimpleSearchEdgeType( entityId, CpNamingUtils.EDGE_CONN_PREFIX, Optional.absent() ) )
 
                 //now load all edges from this node of this type
                 .flatMap( edgeType -> {
+
+                    logger.debug( "Found edge of types of {}, searching for edges", edgeType );
+
                     final SearchByEdgeType searchByEdge =
                         new SimpleSearchByEdgeType( entityId, edgeType, Long.MAX_VALUE,
                             SearchByEdgeType.Order.ASCENDING, Optional.absent() );
@@ -167,6 +178,9 @@ public class ConnectionServiceImpl implements ConnectionService {
 
                 //now that we have a stream of edges, stream all versions
                 .flatMap( edge -> {
+
+                    logger.debug( "Found edge {}, searching for multiple versions of edge", edge );
+
                     final SearchByEdge searchByEdge =
                         new SimpleSearchByEdge( edge.getSourceNode(), edge.getType(), edge.getTargetNode(),
                             Long.MAX_VALUE, SearchByEdgeType.Order.ASCENDING, Optional.absent() );
@@ -176,8 +190,16 @@ public class ConnectionServiceImpl implements ConnectionService {
             //skip the first version since it's the one we want to retain
             // validate there is only 1 version of it, delete anything > than the min
                 .skip( 1 )
-                .flatMap( edgeToDelete -> gm.deleteEdge( edgeToDelete ) )
-                .map(deletedEdge ->  new ConnectionScope( applicationScope, deletedEdge ) ) ;
+                .flatMap( edgeToDelete -> {
+
+                    logger.debug( "Deleting edge {}", edgeToDelete );
+
+                    //mark the edge and ignore the cleanup result
+                    return gm.markEdge( edgeToDelete )
+                             //delete the edge
+                             .flatMap( edge -> gm.deleteEdge( edgeToDelete ));
+                } )
+                .map( deletedEdge -> new ConnectionScope( applicationScope, deletedEdge ) ) ;
         });
     }
 }

http://git-wip-us.apache.org/repos/asf/usergrid/blob/85e1e7c1/stack/core/src/test/java/org/apache/usergrid/corepersistence/service/ConnectionServiceImplTest.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/corepersistence/service/ConnectionServiceImplTest.java b/stack/core/src/test/java/org/apache/usergrid/corepersistence/service/ConnectionServiceImplTest.java
index 0a29286..e03a9b3 100644
--- a/stack/core/src/test/java/org/apache/usergrid/corepersistence/service/ConnectionServiceImplTest.java
+++ b/stack/core/src/test/java/org/apache/usergrid/corepersistence/service/ConnectionServiceImplTest.java
@@ -132,9 +132,6 @@ public class ConnectionServiceImplTest {
 
         final Id source = new SimpleId( "source" );
 
-        final Id target = new SimpleId( "target" );
-
-        final String connectionType = "testConnection";
 
 
           //add to a collection
@@ -147,6 +144,15 @@ public class ConnectionServiceImplTest {
 
         assertNotNull("Collection edge written", writtenCollection);
 
+
+        //now write 3 connections between the same nodes.
+
+        final Id target = new SimpleId( "target" );
+
+        final String connectionType = "testConnection";
+
+
+
         //write our first connection
         final Edge connection1 = CpNamingUtils.createConnectionEdge( source, connectionType, target );
 


[54/54] usergrid git commit: Merge branch 'two-dot-o-dev' into usergrid-1007-shiro-cache

Posted by sn...@apache.org.
Merge branch 'two-dot-o-dev' into usergrid-1007-shiro-cache

Conflicts:
	stack/rest/src/test/resources/log4j.properties


Project: http://git-wip-us.apache.org/repos/asf/usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/usergrid/commit/af5d260e
Tree: http://git-wip-us.apache.org/repos/asf/usergrid/tree/af5d260e
Diff: http://git-wip-us.apache.org/repos/asf/usergrid/diff/af5d260e

Branch: refs/heads/usergrid-1007-shiro-cache
Commit: af5d260ef9b33cd4001b831f01b10b175eb16351
Parents: 0149864 a2389e6
Author: Dave Johnson <sn...@apache.org>
Authored: Sun Sep 20 16:43:46 2015 -0400
Committer: Dave Johnson <sn...@apache.org>
Committed: Sun Sep 20 16:43:46 2015 -0400

----------------------------------------------------------------------
 docs/jersey2skeleton/README.md                  |   9 +
 docs/jersey2skeleton/pom.xml                    | 387 ++++++++++++
 .../usergrid/testapp/AbstractResource.java      |  51 ++
 .../apache/usergrid/testapp/ApiResponse.java    |  52 ++
 .../org/apache/usergrid/testapp/Entity.java     |  55 ++
 .../usergrid/testapp/ManagementResource.java    |  56 ++
 .../usergrid/testapp/OrganizationResource.java  |  64 ++
 .../usergrid/testapp/OrganizationsResource.java |  76 +++
 .../apache/usergrid/testapp/StatusResource.java |  34 +
 .../java/org/apache/usergrid/testapp/User.java  |  28 +
 .../src/main/resources/applicationContext.xml   |  28 +
 .../main/resources/jersey2skeleton-context.xml  |  28 +
 .../src/main/webapp/WEB-INF/web.xml             |  95 +++
 .../usergrid/testapp/AvailablePortFinder.java   | 208 ++++++
 .../usergrid/testapp/OrganizationTest.java      | 127 ++++
 .../org/apache/usergrid/testapp/TomcatMain.java |  57 ++
 .../apache/usergrid/testapp/TomcatRuntime.java  | 185 ++++++
 .../src/test/resources/log4j.properties         |  31 +
 .../src/test/resources/logging.properties       |  26 +
 docs/jersey2skeleton/templates/markdown.hbs     | 108 ++++
 docs/jersey2skeleton/templates/operation.hbs    |  73 +++
 docs/jersey2skeleton/templates/security.hbs     |  88 +++
 .../templates/strapdown.html.hbs                |  10 +
 stack/build-tools/pom.xml                       |   2 +-
 stack/config/pom.xml                            |   2 +-
 stack/core/pom.xml                              |  14 +-
 .../usergrid/corepersistence/CoreModule.java    |  51 +-
 .../corepersistence/CpRelationManager.java      |  23 +-
 .../asyncevents/AsyncEventService.java          |   2 +
 .../migration/CoreMigration.java                |  45 +-
 .../migration/CoreMigrationPlugin.java          |  38 +-
 .../migration/DeDupConnectionDataMigration.java |  93 +++
 .../migration/EntityTypeMappingMigration.java   | 104 ---
 .../migration/MigrationModuleVersionPlugin.java |   5 -
 .../corepersistence/migration/Versions.java     |  31 -
 .../builder/PipelineBuilderFactory.java         |   3 +
 .../service/ConnectionScope.java                |  53 ++
 .../service/ConnectionService.java              |  10 +
 .../service/ConnectionServiceImpl.java          |  89 ++-
 .../corepersistence/util/CpNamingUtils.java     |  13 +-
 .../corepersistence/TestCoreModule.java         |  34 +
 .../DeDupConnectionDataMigrationTest.java       | 145 +++++
 .../migration/EntityTypeMappingMigrationIT.java | 125 ----
 .../service/ConnectionServiceImplTest.java      | 235 +++++++
 stack/core/src/test/resources/log4j.properties  |   6 +-
 stack/corepersistence/collection/pom.xml        |   2 +-
 .../serialization/impl/SerializationModule.java |   4 +-
 .../migration/CollectionMigrationPlugin.java    |   8 +-
 .../migration/MvccEntityDataMigrationImpl.java  |  10 +-
 ...ctMvccEntityDataMigrationV1ToV3ImplTest.java |  39 +-
 stack/corepersistence/common/pom.xml            |   2 +-
 .../migration/data/AbstractMigrationPlugin.java |  17 +-
 .../core/migration/data/DataMigration.java      |  11 +-
 .../migration/data/MigrationDataProvider.java   |   2 +-
 .../core/migration/data/MigrationPlugin.java    |   4 +-
 .../migration/schema/MigrationManagerFig.java   |   1 +
 .../migration/data/TestProgressObserver.java    |  10 +-
 stack/corepersistence/graph/pom.xml             |   2 +-
 .../persistence/graph/guice/GraphModule.java    |   4 +-
 .../graph/impl/GraphManagerImpl.java            |   4 +-
 .../impl/stage/EdgeDeleteListenerImpl.java      |   4 +-
 .../graph/impl/stage/EdgeDeleteRepairImpl.java  |  61 +-
 .../impl/TargetIdObservableImpl.java            |  13 +-
 .../impl/migration/EdgeDataMigrationImpl.java   |  12 +-
 .../impl/migration/GraphMigrationPlugin.java    |   8 +-
 .../impl/shard/impl/EdgeSearcher.java           |  14 +-
 .../impl/ShardedEdgeSerializationImpl.java      |  59 +-
 .../shard/impl/serialize/EdgeSerializer.java    |  21 +-
 .../persistence/graph/GraphManagerIT.java       |  73 ++-
 .../migration/EdgeDataMigrationImplTest.java    |  59 +-
 stack/corepersistence/map/pom.xml               |   2 +-
 stack/corepersistence/model/pom.xml             |   2 +-
 stack/corepersistence/pom.xml                   |   2 +-
 stack/corepersistence/queryindex/pom.xml        |   2 +-
 .../persistence/index/CandidateResult.java      |  32 +-
 .../persistence/index/CandidateResults.java     |  34 +-
 .../SearchRequestBuilderStrategyV2.java         |  30 +-
 .../usergrid/persistence/index/IndexEdge.java   |  36 +-
 .../index/IndexLocationStrategy.java            |  30 +-
 .../persistence/index/IndexRefreshCommand.java  |  30 +-
 .../usergrid/persistence/index/SearchType.java  |  30 +-
 .../usergrid/persistence/index/SearchTypes.java |  32 +-
 .../persistence/index/SelectFieldMapping.java   |  36 +-
 .../persistence/index/guice/IndexModule.java    |   4 +-
 .../persistence/index/impl/EntityField.java     |  32 +-
 .../index/impl/EntityMappingParser.java         |  37 +-
 .../index/impl/EsEntityIndexFactoryImpl.java    |  29 +-
 .../index/impl/EsIndexBufferConsumerImpl.java   |  28 +-
 .../index/impl/EsIndexCacheImpl.java            |  29 +-
 .../persistence/index/impl/EsQueryVistor.java   |  50 +-
 .../persistence/index/impl/FailureMonitor.java  |  30 +-
 .../index/impl/FailureMonitorImpl.java          |  32 +-
 .../persistence/index/impl/FieldParser.java     |  36 +-
 .../persistence/index/impl/GeoSortFields.java   |  36 +-
 .../index/impl/IndexBufferConsumer.java         |  28 +-
 .../persistence/index/impl/IndexCache.java      |  30 +-
 .../persistence/index/impl/IndexEdgeImpl.java   |  36 +-
 .../index/impl/IndexIdentifierv2Impl.java       |  30 +-
 .../index/impl/IndexRefreshCommandImpl.java     |  30 +-
 .../index/impl/NoOpFilterBuilder.java           |  32 +-
 .../index/impl/NoOpQueryBuilder.java            |  32 +-
 .../impl/SearchRequestBuilderStrategy.java      |  30 +-
 .../persistence/index/impl/SortBuilder.java     |  36 +-
 .../EsIndexMappingMigrationPlugin.java          |  30 +-
 .../index/migration/EsIndexMigrationPlugin.java |   8 +-
 .../index/migration/IndexDataVersions.java      |  30 +-
 .../persistence/index/query/ParsedQuery.java    |  36 +-
 .../index/query/ParsedQueryBuilder.java         |  36 +-
 .../persistence/index/query/SortPredicate.java  |  36 +-
 .../persistence/index/usergrid-mappings.json    |   5 -
 .../persistence/index/impl/EntityIndexTest.java |  13 +-
 .../index/impl/EntityToMapConverterTest.java    |  38 +-
 .../impl/EsIndexMappingMigrationPluginTest.java |  30 +-
 .../persistence/index/impl/EsRunner.java        |  32 +-
 .../persistence/index/impl/GeoPagingTest.java   |  36 +-
 .../index/impl/TestIndexIdentifier.java         |  30 +-
 stack/corepersistence/queue/pom.xml             |   2 +-
 stack/pom.xml                                   | 252 ++++----
 stack/rest/pom.xml                              | 141 +++--
 .../usergrid/rest/AbstractContextResource.java  |  45 +-
 .../usergrid/rest/ApplicationsResource.java     |  40 +-
 .../apache/usergrid/rest/DatabaseResource.java  |  17 +-
 .../org/apache/usergrid/rest/IndexResource.java |  54 +-
 .../apache/usergrid/rest/MigrateResource.java   |  61 +-
 .../org/apache/usergrid/rest/RootResource.java  |  92 ++-
 .../apache/usergrid/rest/SwaggerServlet.java    |   5 +-
 .../apache/usergrid/rest/SystemResource.java    |  29 +-
 .../usergrid/rest/TextToJsonSwapWriter.java     | 182 +++---
 .../rest/applications/ApplicationResource.java  |  30 +-
 .../rest/applications/ServiceResource.java      | 111 ++--
 .../applications/assets/AssetsResource.java     |  13 +-
 .../applications/events/EventsResource.java     |  36 +-
 .../notifiers/NotifierResource.java             |  29 +-
 .../notifiers/NotifiersResource.java            |  29 +-
 .../rest/applications/queues/QueueResource.java |  86 ++-
 .../queues/QueueSubscriberResource.java         |  63 +-
 .../queues/QueueSubscriptionResource.java       |  63 +-
 .../queues/QueueTransactionsResource.java       |  40 +-
 .../rest/applications/users/UserResource.java   | 134 ++--
 .../rest/applications/users/UsersResource.java  |  51 +-
 .../exceptions/NotFoundExceptionMapper.java     |   3 +-
 .../rest/exceptions/SecurityException.java      |  31 +-
 .../exceptions/SecurityExceptionMapper.java     |   3 +-
 .../exceptions/UnsupportedMediaTypeMapper.java  |  43 ++
 .../rest/filters/ContentTypeFilter.java         |  74 +--
 .../rest/filters/JSONPCallbackFilter.java       |  26 +-
 .../usergrid/rest/filters/MeteringFilter.java   | 632 ++++++++++---------
 .../usergrid/rest/filters/TracingFilter.java    |  37 +-
 .../rest/management/ManagementResource.java     |  53 +-
 .../management/metrics/MetricsResource.java     |   9 +-
 .../organizations/OrganizationResource.java     |  64 +-
 .../organizations/OrganizationsResource.java    |  66 +-
 .../applications/ApplicationResource.java       |  56 +-
 .../applications/ApplicationsResource.java      |  20 +-
 .../imports/FileErrorsResource.java             |  41 +-
 .../imports/FileIncludesResource.java           |  15 +-
 .../applications/imports/ImportsResource.java   |  57 +-
 .../organizations/users/UsersResource.java      |  88 +--
 .../rest/management/users/UserResource.java     |  95 +--
 .../rest/management/users/UsersResource.java    |  11 +-
 .../organizations/OrganizationsResource.java    |  76 +--
 .../organizations/OrganizationResource.java     |  28 +-
 .../rest/security/CrossOriginRequestFilter.java |  18 +-
 .../security/SecuredResourceFilterFactory.java  | 181 +++---
 .../ShiroAuthenticationExceptionMapper.java     |   3 +-
 .../shiro/filters/BasicAuthSecurityFilter.java  |  35 +-
 .../ClientCredentialsSecurityFilter.java        |  25 +-
 .../OAuth2AccessTokenSecurityFilter.java        | 168 +++--
 .../security/shiro/filters/SecurityFilter.java  |  33 +-
 .../apache/usergrid/rest/utils/CORSUtils.java   |  42 +-
 stack/rest/src/main/webapp/WEB-INF/web.xml      |  63 +-
 .../java/org/apache/usergrid/rest/BasicIT.java  |  22 +-
 .../usergrid/rest/CollectionMetadataIT.java     |   7 +-
 .../apache/usergrid/rest/IndexResourceIT.java   |  43 +-
 .../apache/usergrid/rest/NotificationsIT.java   |   6 +-
 .../apache/usergrid/rest/PartialUpdateTest.java |  16 +-
 .../apache/usergrid/rest/SystemResourceIT.java  |   7 +-
 .../org/apache/usergrid/rest/TomcatRuntime.java |  12 +-
 .../rest/applications/ApplicationCreateIT.java  |  14 +-
 .../rest/applications/ApplicationDeleteIT.java  | 206 +++---
 .../applications/ApplicationResourceIT.java     | 266 ++++----
 .../applications/assets/AssetResourceIT.java    |  21 +-
 .../applications/assets/AwsAssetResourceIT.java |  53 +-
 .../applications/assets/aws/NoAWSCredsRule.java |  15 +-
 .../collection/CollectionsResourceIT.java       |  26 +-
 .../collection/DuplicateNameIT.java             |   5 +-
 .../activities/ActivityResourceIT.java          |   5 +-
 .../collection/devices/DevicesResourceIT.java   |   4 +-
 .../collection/groups/GroupResourceIT.java      |  28 +-
 .../users/ConnectionResourceTest.java           |   8 +-
 .../collection/users/OwnershipResourceIT.java   |  15 +-
 .../collection/users/PermissionsResourceIT.java |  34 +-
 .../collection/users/UserResourceIT.java        | 126 ++--
 .../queries/BadGrammarQueryTest.java            |  15 +-
 .../applications/queries/BasicGeoTests.java     |  45 +-
 .../rest/filters/ContentTypeResourceIT.java     |  70 +-
 .../usergrid/rest/management/AccessTokenIT.java |  42 +-
 .../usergrid/rest/management/AdminUsersIT.java  |  48 +-
 .../rest/management/ExportResourceIT.java       | 137 ++--
 .../rest/management/ImportResourceIT.java       |  50 +-
 .../rest/management/ManagementResourceIT.java   | 149 +++--
 .../rest/management/OrganizationsIT.java        |  60 +-
 .../rest/management/RegistrationIT.java         |  32 +-
 .../organizations/AdminEmailEncodingIT.java     |   5 +-
 .../rest/test/resource/AbstractRestIT.java      |  79 ++-
 .../rest/test/resource/ClientSetup.java         |   4 +-
 .../usergrid/rest/test/resource/RestClient.java |  44 +-
 .../test/resource/TestPropertiesResource.java   |  14 +-
 .../endpoints/ApplicationsResource.java         |   8 +-
 .../resource/endpoints/BoostrapResource.java    |  19 +-
 .../resource/endpoints/CollectionEndpoint.java  | 109 ++--
 .../test/resource/endpoints/EntityEndpoint.java |  40 +-
 .../test/resource/endpoints/NamedResource.java  | 164 +++--
 .../test/resource/endpoints/RootResource.java   |   4 +-
 .../test/resource/endpoints/SetupResource.java  |  20 +-
 .../test/resource/endpoints/SystemResource.java |  46 +-
 .../test/resource/endpoints/TokenResource.java  |  15 +-
 .../test/resource/endpoints/UrlResource.java    |   7 +-
 .../endpoints/mgmt/ApplicationResource.java     |  27 +-
 .../endpoints/mgmt/ApplicationsResource.java    |   4 +-
 .../endpoints/mgmt/AuthorizeResource.java       |   7 +-
 .../endpoints/mgmt/ConfirmResource.java         |  12 +-
 .../endpoints/mgmt/CredentialsResource.java     |   7 +-
 .../resource/endpoints/mgmt/FeedResource.java   |   5 +-
 .../resource/endpoints/mgmt/OrgResource.java    |  68 +-
 .../endpoints/mgmt/OrganizationResource.java    |  15 +-
 .../endpoints/mgmt/PasswordResource.java        |   8 -
 .../endpoints/mgmt/ReactivateResource.java      |  10 +-
 .../resource/endpoints/mgmt/ResetResource.java  |  10 +-
 .../resource/endpoints/mgmt/TokenResource.java  |   7 +-
 .../resource/endpoints/mgmt/UserResource.java   |  20 +-
 .../resource/endpoints/mgmt/UsersResource.java  |   6 -
 stack/rest/src/test/resources/log4j.properties  |  33 +-
 .../rest/src/test/resources/logging.properties  |  13 +-
 stack/services/pom.xml                          |  51 +-
 .../management/AppInfoMigrationPlugin.java      | 234 ++++---
 .../security/providers/AbstractProvider.java    |  16 +-
 .../security/providers/FacebookProvider.java    |   7 +-
 .../security/providers/FoursquareProvider.java  |  38 +-
 .../providers/PingIdentityProvider.java         |  38 +-
 .../usergrid/management/OrganizationIT.java     |  18 +-
 stack/test-utils/pom.xml                        |   2 +-
 .../org/apache/usergrid/tools/ExportAdmins.java |  17 +-
 243 files changed, 6897 insertions(+), 4370 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/usergrid/blob/af5d260e/stack/corepersistence/pom.xml
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/usergrid/blob/af5d260e/stack/rest/src/test/resources/log4j.properties
----------------------------------------------------------------------
diff --cc stack/rest/src/test/resources/log4j.properties
index 43c6e85,201550b..0288842
--- a/stack/rest/src/test/resources/log4j.properties
+++ b/stack/rest/src/test/resources/log4j.properties
@@@ -26,14 -26,12 +26,17 @@@ log4j.appender.stdout=org.apache.log4j.
  log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
  log4j.appender.stdout.layout.ConversionPattern=%d %p (%t) %c{1} - %m%n
  
+ log4j.logger.org.glassfish=DEBUG
+ log4j.logger.org.apache.shiro=DEBUG
  log4j.logger.org.apache.usergrid=INFO
+ 
  #log4j.logger.org.apache.usergrid.cassandra=DEBUG
  #log4j.logger.org.apache.usergrid.persistence.cassandra=DEBUG
 +log4j.category.org.apache=ERROR
 +log4j.category.org.apache.usergrid=WARN
 +log4j.category.org.apache.usergrid.rest=INFO
 +log4j.category.org.apache.shiro=DEBUG
 +log4j.category.org.apache.usergrid.rest.security.shiro=DEBUG
  
  log4j.logger.org.apache.usergrid.persistence.cassandra.CounterUtils=ERROR
  log4j.logger.org.apache.usergrid.persistence.cassandra.DB=WARN


[19/54] usergrid git commit: Moving superuser token get out of try-catch causes some test failures.

Posted by sn...@apache.org.
Moving superuser token get out of try-catch causes some test failures.


Project: http://git-wip-us.apache.org/repos/asf/usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/usergrid/commit/2aaa37f8
Tree: http://git-wip-us.apache.org/repos/asf/usergrid/tree/2aaa37f8
Diff: http://git-wip-us.apache.org/repos/asf/usergrid/diff/2aaa37f8

Branch: refs/heads/usergrid-1007-shiro-cache
Commit: 2aaa37f862bb78869f65aa2481884c1758b41768
Parents: 31bacc8
Author: Dave Johnson <sn...@apache.org>
Authored: Wed Sep 9 11:09:43 2015 -0400
Committer: Dave Johnson <sn...@apache.org>
Committed: Wed Sep 9 11:09:43 2015 -0400

----------------------------------------------------------------------
 .../java/org/apache/usergrid/rest/test/resource/ClientSetup.java | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/usergrid/blob/2aaa37f8/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/ClientSetup.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/ClientSetup.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/ClientSetup.java
index 57cb7e8..853945d 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/ClientSetup.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/ClientSetup.java
@@ -94,9 +94,8 @@ public class ClientSetup implements TestRule {
         String name = testClass + "." + methodName;
 
         try {
-
             restClient.superuserSetup();
-
+            superuserToken = restClient.management().token().get(superuserName, superuserPassword);
         } catch ( BadRequestException e ) {
             if ( logger.isDebugEnabled() ) {
                 logger.debug( "Error creating superuser, may already exist", e );
@@ -105,7 +104,6 @@ public class ClientSetup implements TestRule {
             }
         }
 
-        superuserToken = restClient.management().token().get(superuserName, superuserPassword);
 
         username = "user_"+name + UUIDUtils.newTimeUUID();
         password = username;


[02/54] usergrid git commit: Switch to Jersey 2, fix all compilation errors. TODO: new MeteringFilter, new JSON-HTMP swap logic and correct use of dependency management.

Posted by sn...@apache.org.
http://git-wip-us.apache.org/repos/asf/usergrid/blob/0578d987/stack/rest/src/test/java/org/apache/usergrid/rest/management/ImportResourceIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/management/ImportResourceIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/management/ImportResourceIT.java
index a754eb0..c55f953 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/management/ImportResourceIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/management/ImportResourceIT.java
@@ -21,8 +21,6 @@ import com.amazonaws.SDKGlobalConfiguration;
 import com.google.common.collect.ImmutableSet;
 import com.google.common.util.concurrent.Service;
 import com.google.inject.Module;
-import com.sun.jersey.api.client.ClientResponse;
-import com.sun.jersey.api.client.UniformInterfaceException;
 import org.apache.commons.lang.RandomStringUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.usergrid.ServiceITSetup;
@@ -51,6 +49,8 @@ import org.junit.*;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import javax.ws.rs.client.ResponseProcessingException;
+import javax.ws.rs.core.Response;
 import java.io.File;
 import java.util.ArrayList;
 import java.util.HashMap;
@@ -211,7 +211,7 @@ public class ImportResourceIT extends AbstractRestIT {
             this.management().orgs().org( org ).app().addToPath(app)
                 .addToPath("imports").addToPath(entity.getUuid().toString()).get();
             fail("Should not be able to read import job with unauthorized token");
-        } catch (UniformInterfaceException ex) {
+        } catch (ResponseProcessingException ex) {
             errorParse(401, "unauthorized", ex);
         }
 
@@ -223,16 +223,16 @@ public class ImportResourceIT extends AbstractRestIT {
     public void importPostApplicationNullPointerProperties() throws Exception {
         String org = clientSetup.getOrganizationName();
         String app = clientSetup.getAppName();
-        ClientResponse.Status responseStatus = ClientResponse.Status.OK;
+        Response.Status responseStatus = Response.Status.OK;
 
         Entity payload = new Entity();
 
         try {
             this.management().orgs().org( org ).app().addToPath(app).addToPath("imports").post(Entity.class,payload);
-        } catch (UniformInterfaceException uie) {
-            responseStatus = uie.getResponse().getClientResponseStatus();
+        } catch (ResponseProcessingException uie) {
+            responseStatus = Response.Status.fromStatusCode( uie.getResponse().getStatus() );
         }
-        assertEquals(ClientResponse.Status.BAD_REQUEST, responseStatus);
+        assertEquals(Response.Status.BAD_REQUEST, responseStatus);
     }
 
     @Ignore
@@ -240,7 +240,7 @@ public class ImportResourceIT extends AbstractRestIT {
     public void importPostApplicationNullPointerStorageInfo() throws Exception {
         String org = clientSetup.getOrganizationName();
         String app = clientSetup.getAppName();
-        ClientResponse.Status responseStatus = ClientResponse.Status.OK;
+        Response.Status responseStatus = Response.Status.OK;
 
         Entity payload = payloadBuilder();
         Entity properties = (Entity) payload.get("properties");
@@ -249,10 +249,10 @@ public class ImportResourceIT extends AbstractRestIT {
 
         try {
             this.management().orgs().org( org ).app().addToPath(app).addToPath("imports").post(Entity.class,payload);
-        } catch (UniformInterfaceException uie) {
-            responseStatus = uie.getResponse().getClientResponseStatus();
+        } catch (ResponseProcessingException uie) {
+            responseStatus = Response.Status.fromStatusCode( uie.getResponse().getStatus() );
         }
-        assertEquals(ClientResponse.Status.BAD_REQUEST, responseStatus);
+        assertEquals(Response.Status.BAD_REQUEST, responseStatus);
     }
 
 
@@ -261,7 +261,7 @@ public class ImportResourceIT extends AbstractRestIT {
     public void importPostApplicationNullPointerStorageProvider() throws Exception {
         String org = clientSetup.getOrganizationName();
         String app = clientSetup.getAppName();
-        ClientResponse.Status responseStatus = ClientResponse.Status.OK;
+        Response.Status responseStatus = Response.Status.OK;
 
         Entity payload = payloadBuilder();
         Entity properties = (Entity) payload.get("properties");
@@ -271,10 +271,10 @@ public class ImportResourceIT extends AbstractRestIT {
 
         try {
             this.management().orgs().org( org ).app().addToPath(app).addToPath("imports").post(Entity.class,payload);
-        } catch (UniformInterfaceException uie) {
-            responseStatus = uie.getResponse().getClientResponseStatus();
+        } catch (ResponseProcessingException uie) {
+            responseStatus = Response.Status.fromStatusCode( uie.getResponse().getStatus() );
         }
-        assertEquals(ClientResponse.Status.BAD_REQUEST, responseStatus);
+        assertEquals(Response.Status.BAD_REQUEST, responseStatus);
     }
 
 
@@ -283,7 +283,7 @@ public class ImportResourceIT extends AbstractRestIT {
     public void importPostApplicationNullPointerStorageVerification() throws Exception {
         String org = clientSetup.getOrganizationName();
         String app = clientSetup.getAppName();
-        ClientResponse.Status responseStatus = ClientResponse.Status.OK;
+        Response.Status responseStatus = Response.Status.OK;
 
         Entity payload = payloadBuilder();
 
@@ -294,10 +294,10 @@ public class ImportResourceIT extends AbstractRestIT {
 
         try {
             this.management().orgs().org( org ).app().addToPath(app).addToPath("imports").post(Entity.class,payload);
-        } catch (UniformInterfaceException uie) {
-            responseStatus = uie.getResponse().getClientResponseStatus();
+        } catch (ResponseProcessingException uie) {
+            responseStatus = Response.Status.fromStatusCode( uie.getResponse().getStatus() );
         }
-        assertEquals(ClientResponse.Status.BAD_REQUEST, responseStatus);
+        assertEquals(Response.Status.BAD_REQUEST, responseStatus);
 
         payload = payloadBuilder();
         properties = (Entity) payload.get("properties");
@@ -307,10 +307,10 @@ public class ImportResourceIT extends AbstractRestIT {
 
         try {
             this.management().orgs().org( org ).app().addToPath(app).addToPath("imports").post(Entity.class,payload);
-        } catch (UniformInterfaceException uie) {
-            responseStatus = uie.getResponse().getClientResponseStatus();
+        } catch (ResponseProcessingException uie) {
+            responseStatus = Response.Status.fromStatusCode( uie.getResponse().getStatus() );
         }
-        assertEquals(ClientResponse.Status.BAD_REQUEST, responseStatus);
+        assertEquals(Response.Status.BAD_REQUEST, responseStatus);
 
         payload = payloadBuilder();
         properties = (Entity) payload.get("properties");
@@ -320,10 +320,10 @@ public class ImportResourceIT extends AbstractRestIT {
 
         try {
             this.management().orgs().org( org ).app().addToPath(app).addToPath("imports").post(Entity.class,payload);
-        } catch (UniformInterfaceException uie) {
-            responseStatus = uie.getResponse().getClientResponseStatus();
+        } catch (ResponseProcessingException uie) {
+            responseStatus = Response.Status.fromStatusCode( uie.getResponse().getStatus() );
         }
-        assertEquals(ClientResponse.Status.BAD_REQUEST, responseStatus);
+        assertEquals(Response.Status.BAD_REQUEST, responseStatus);
     }
 
 //    @Test

http://git-wip-us.apache.org/repos/asf/usergrid/blob/0578d987/stack/rest/src/test/java/org/apache/usergrid/rest/management/ManagementResourceIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/management/ManagementResourceIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/management/ManagementResourceIT.java
index 1fe4974..386f3b9 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/management/ManagementResourceIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/management/ManagementResourceIT.java
@@ -18,9 +18,6 @@ package org.apache.usergrid.rest.management;
 
 
 import com.fasterxml.jackson.databind.JsonNode;
-import com.sun.jersey.api.client.ClientResponse.Status;
-import com.sun.jersey.api.client.UniformInterfaceException;
-import com.sun.jersey.api.representation.Form;
 import net.jcip.annotations.NotThreadSafe;
 import org.apache.commons.lang.RandomStringUtils;
 import org.apache.usergrid.persistence.index.utils.UUIDUtils;
@@ -33,7 +30,10 @@ import org.junit.Test;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import javax.ws.rs.client.ResponseProcessingException;
+import javax.ws.rs.core.Form;
 import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
 import java.io.IOException;
 import java.util.*;
 
@@ -115,26 +115,26 @@ public class ManagementResourceIT extends AbstractRestIT {
 
         // check that the test admin cannot access the new org info
 
-        Status status = null;
+        Response.Status status = null;
         String returnVal = "";
 
         try {
             returnVal = this.management().orgs().org( orgName ).get(String.class);
         }
-        catch ( UniformInterfaceException uie ) {
-            status = uie.getResponse().getClientResponseStatus();
+        catch ( ResponseProcessingException uie ) {
+            status = Response.Status.fromStatusCode( uie.getResponse().getStatus() );
         }
 
         assertNotNull( status );
-        assertEquals( Status.UNAUTHORIZED, status );
+        assertEquals( Response.Status.UNAUTHORIZED, status );
 
         // this admin should have access to test org
         status = null;
         try {
             this.management().orgs().org( this.clientSetup.getOrganizationName() ).get( String.class );
         }
-        catch ( UniformInterfaceException uie ) {
-            status = uie.getResponse().getClientResponseStatus();
+        catch ( ResponseProcessingException uie ) {
+            status = Response.Status.fromStatusCode( uie.getResponse().getStatus() );
         }
 
         assertNull( status );
@@ -145,8 +145,8 @@ public class ManagementResourceIT extends AbstractRestIT {
         try {
             this.management().orgs().org( this.clientSetup.getOrganizationName() ).get( String.class );
         }
-        catch ( UniformInterfaceException uie ) {
-            status = uie.getResponse().getClientResponseStatus();
+        catch ( ResponseProcessingException uie ) {
+            status = Response.Status.fromStatusCode( uie.getResponse().getStatus() );
         }
 
         assertNull( status );
@@ -332,15 +332,15 @@ public class ManagementResourceIT extends AbstractRestIT {
         // wait for the token to expire
         Thread.sleep(  (System.currentTimeMillis() - startTime) + ttl );
 
-        Status responseStatus = null;
+        Response.Status responseStatus = null;
         try {
             userdata = management.users().user(clientSetup.getEmail()).get();
         }
-        catch ( UniformInterfaceException uie ) {
-            responseStatus = uie.getResponse().getClientResponseStatus();
+        catch ( ResponseProcessingException uie ) {
+            responseStatus = Response.Status.fromStatusCode( uie.getResponse().getStatus() );
         }
 
-        assertEquals( Status.UNAUTHORIZED, responseStatus );
+        assertEquals( Response.Status.UNAUTHORIZED, responseStatus );
     }
 
 
@@ -423,19 +423,21 @@ public class ManagementResourceIT extends AbstractRestIT {
     public void meTokenPostForm() {
 
         Form form = new Form();
-        form.add( "grant_type", "password" );
-        form.add( "username", clientSetup.getUsername() );
-        form.add( "password", clientSetup.getPassword() );
+        form.param( "grant_type", "password" );
+        form.param( "username", clientSetup.getUsername() );
+        form.param( "password", clientSetup.getPassword() );
 
         JsonNode node = management.me().post( JsonNode.class, form );
-        logger.info("node:", node);
+        logger.info( "node:", node);
 
         String token = node.get( "access_token" ).textValue();
 
         assertNotNull( token );
 
-        node = resource().path( "/management/me" ).queryParam( "access_token", token )
-                         .accept( MediaType.APPLICATION_JSON ).get( JsonNode.class );
+        node = target().path( "/management/me" )
+            .queryParam( "access_token", token ).request()
+            .accept( MediaType.APPLICATION_JSON )
+            .get( JsonNode.class );
         logger.info("node:", node );
 
     }
@@ -449,15 +451,15 @@ public class ManagementResourceIT extends AbstractRestIT {
             .map( "password", clientSetup.getPassword() )
             .map( "ttl", "derp" );
 
-        Status responseStatus = null;
+        Response.Status responseStatus = null;
         try {
            management.token().post( JsonNode.class, payload );
         }
-        catch ( UniformInterfaceException uie ) {
-            responseStatus = uie.getResponse().getClientResponseStatus();
+        catch ( ResponseProcessingException uie ) {
+            responseStatus = Response.Status.fromStatusCode( uie.getResponse().getStatus());
         }
 
-        assertEquals( Status.BAD_REQUEST, responseStatus );
+        assertEquals( Response.Status.BAD_REQUEST, responseStatus );
     }
 
 
@@ -469,16 +471,16 @@ public class ManagementResourceIT extends AbstractRestIT {
             .map( "password", clientSetup.getPassword() )
             .map( "ttl", Long.MAX_VALUE + "" );
 
-        Status responseStatus = null;
+        Response.Status responseStatus = null;
 
         try {
             management.token().post( JsonNode.class, payload );
         }
-        catch ( UniformInterfaceException uie ) {
-            responseStatus = uie.getResponse().getClientResponseStatus();
+        catch ( ResponseProcessingException uie ) {
+            responseStatus = Response.Status.fromStatusCode( uie.getResponse().getStatus() );
         }
 
-        assertEquals( Status.BAD_REQUEST, responseStatus );
+        assertEquals( Response.Status.BAD_REQUEST, responseStatus );
     }
 
 
@@ -500,16 +502,16 @@ public class ManagementResourceIT extends AbstractRestIT {
 
         // the tokens shouldn't work
 
-        Status status = null;
+        Response.Status status = null;
 
         try {
             response = management.users().user(clientSetup.getUsername()).get();
         }
-        catch ( UniformInterfaceException uie ) {
-            status = uie.getResponse().getClientResponseStatus();
+        catch ( ResponseProcessingException uie ) {
+            status = Response.Status.fromStatusCode( uie.getResponse().getStatus() );
         }
 
-        assertEquals( Status.UNAUTHORIZED, status );
+        assertEquals( Response.Status.UNAUTHORIZED, status );
 
         Token token3 = management.token().get(clientSetup.getUsername(), clientSetup.getPassword());
 
@@ -528,11 +530,11 @@ public class ManagementResourceIT extends AbstractRestIT {
         try {
             management.users().user(clientSetup.getUsername()).get();
         }
-        catch ( UniformInterfaceException uie ) {
-            status = uie.getResponse().getClientResponseStatus();
+        catch ( ResponseProcessingException uie ) {
+            status = Response.Status.fromStatusCode( uie.getResponse().getStatus() );
         }
 
-        assertEquals( Status.UNAUTHORIZED, status );
+        assertEquals( Response.Status.UNAUTHORIZED, status );
 
     }
 
@@ -587,10 +589,10 @@ public class ManagementResourceIT extends AbstractRestIT {
 
                 fail( "Validation should have failed" );
 
-            } catch (UniformInterfaceException actual) {
+            } catch (ResponseProcessingException actual) {
                 assertEquals( 404, actual.getResponse().getStatus() );
-                String errorMsg = actual.getResponse().getEntity(
-                    JsonNode.class ).get( "error_description" ).toString();
+                String errorMsg = actual.getResponse().readEntity( JsonNode.class )
+                    .get( "error_description" ).toString();
                 logger.error( "ERROR: " + errorMsg );
                 assertTrue( errorMsg.contains( "Cannot find Admin User" ) );
             }
@@ -638,15 +640,15 @@ public class ManagementResourceIT extends AbstractRestIT {
                 ApiResponse postResponse = pathResource( "management/token" ).post( false, ApiResponse.class, loginInfo );
                 fail( "Login as Admin User must fail when validate external tokens is enabled" );
 
-            } catch (UniformInterfaceException actual) {
+            } catch (ResponseProcessingException actual) {
                 assertEquals( 400, actual.getResponse().getStatus() );
-                String errorMsg = actual.getResponse()
-                    .getEntity( JsonNode.class ).get( "error_description" ).toString();
+                String errorMsg = actual.getResponse().readEntity( JsonNode.class )
+                    .get( "error_description" ).toString();
                 logger.error( "ERROR: " + errorMsg );
                 assertTrue( errorMsg.contains( "Admin Users must login via" ) );
 
             } catch (Exception e) {
-                fail( "We expected a UniformInterfaceException" );
+                fail( "We expected a ResponseProcessingException" );
             }
 
             // login as superuser must succeed

http://git-wip-us.apache.org/repos/asf/usergrid/blob/0578d987/stack/rest/src/test/java/org/apache/usergrid/rest/management/OrganizationsIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/management/OrganizationsIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/management/OrganizationsIT.java
index 782c8cd..a0ebf6e 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/management/OrganizationsIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/management/OrganizationsIT.java
@@ -29,9 +29,9 @@ import org.apache.usergrid.persistence.index.utils.UUIDUtils;
 import org.apache.usergrid.rest.test.resource.AbstractRestIT;
 import org.apache.usergrid.rest.test.resource.RestClient;
 
-import com.sun.jersey.api.client.ClientResponse;
-import com.sun.jersey.api.client.UniformInterfaceException;
-import com.sun.jersey.api.representation.Form;
+import javax.ws.rs.client.ResponseProcessingException;
+import javax.ws.rs.core.Form;
+import javax.ws.rs.core.Response;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
@@ -123,7 +123,7 @@ public class OrganizationsIT extends AbstractRestIT {
             clientSetup.getRestClient().management().orgs().post( orgTestDuplicatePayload );
             fail("Should not have been able to create duplicate organization");
         }
-        catch ( UniformInterfaceException ex ) {
+        catch ( ResponseProcessingException ex ) {
             errorParse( 400,duplicateUniquePropertyExistsErrorMessage, ex );
         }
 
@@ -135,7 +135,7 @@ public class OrganizationsIT extends AbstractRestIT {
             tokenError = clientSetup.getRestClient().management().token().post(false,Token.class, tokenPayload,null );
             fail( "Should not have created user" );
         }
-        catch ( UniformInterfaceException ex ) {
+        catch ( ResponseProcessingException ex ) {
             errorParse( 400,invalidGrantErrorMessage, ex );
 
         }
@@ -179,7 +179,7 @@ public class OrganizationsIT extends AbstractRestIT {
             clientSetup.getRestClient().management().orgs().post( orgDuplicatePayload );
             fail( "Should not have created organization" );
         }
-        catch ( UniformInterfaceException ex ) {
+        catch ( ResponseProcessingException ex ) {
             errorParse( 400,duplicateUniquePropertyExistsErrorMessage,ex);
         }
 
@@ -190,7 +190,7 @@ public class OrganizationsIT extends AbstractRestIT {
             tokenError = clientSetup.getRestClient().management().token().post(false,Token.class, tokenPayload,null );
             fail( "Should not have created organization" );
         }
-        catch ( UniformInterfaceException ex ) {
+        catch ( ResponseProcessingException ex ) {
             errorParse( 400,invalidGrantErrorMessage,ex );
         }
 
@@ -222,7 +222,7 @@ public class OrganizationsIT extends AbstractRestIT {
         try{
             Organization organizationReturned = clientSetup.getRestClient().management().orgs().post(queryParameters);
             fail();
-        }catch (UniformInterfaceException e){
+        }catch (ResponseProcessingException e){
             assertEquals("ensure bad request",e.getResponse().getStatus(), 400);
         }
 
@@ -254,12 +254,12 @@ public class OrganizationsIT extends AbstractRestIT {
 
         //create the form to hold the organization
         Form form = new Form();
-        form.add( "organization", organization.getOrganization() );
-        form.add("username", organization.getUsername());
-        form.add( "grant_type", "password" );
-        form.add( "email", organization.getEmail() );
-        form.add( "name", organization.getName() );
-        form.add("password", organization.getPassword());
+        form.param( "organization", organization.getOrganization() );
+        form.param( "username", organization.getUsername() );
+        form.param( "grant_type", "password" );
+        form.param( "email", organization.getEmail() );
+        form.param( "name", organization.getName() );
+        form.param( "password", organization.getPassword() );
 
         //Post the organization and verify it worked.
         Organization organizationReturned = clientSetup.getRestClient().management().orgs().post( form );
@@ -295,8 +295,8 @@ public class OrganizationsIT extends AbstractRestIT {
             //Delete default organization
             clientSetup.getRestClient().management().orgs().org( clientSetup.getOrganizationName() ).delete();
             fail( "Delete is not implemented yet" );
-        }catch(UniformInterfaceException uie){
-            assertEquals( ClientResponse.Status.NOT_IMPLEMENTED ,uie.getResponse().getStatus());
+        }catch(ResponseProcessingException uie){
+            assertEquals( Response.Status.NOT_IMPLEMENTED ,uie.getResponse().getStatus());
         }
     }
 

http://git-wip-us.apache.org/repos/asf/usergrid/blob/0578d987/stack/rest/src/test/java/org/apache/usergrid/rest/management/RegistrationIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/management/RegistrationIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/management/RegistrationIT.java
index abe2230..fc18292 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/management/RegistrationIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/management/RegistrationIT.java
@@ -17,8 +17,6 @@
 package org.apache.usergrid.rest.management;
 
 
-import com.sun.jersey.api.client.UniformInterfaceException;
-import com.sun.jersey.api.representation.Form;
 import org.apache.commons.lang.StringUtils;
 import org.apache.usergrid.persistence.model.util.UUIDGenerator;
 import org.apache.usergrid.rest.test.resource.AbstractRestIT;
@@ -32,6 +30,8 @@ import org.slf4j.LoggerFactory;
 
 import javax.mail.*;
 import javax.mail.internet.MimeMultipart;
+import javax.ws.rs.client.ResponseProcessingException;
+import javax.ws.rs.core.Form;
 import javax.ws.rs.core.MediaType;
 import java.io.IOException;
 import java.util.Map;
@@ -102,12 +102,14 @@ public class RegistrationIT extends AbstractRestIT {
 
             String t = this.getAdminToken().getAccessToken();
             Form form = new Form();
-            form.add("foo", "bar");
+            form.param( "foo", "bar" );
             try {
-                this.org().getResource(false).path("/users/test-admin-null@mockserver.com")
-                    .queryParam("access_token", t).accept(MediaType.APPLICATION_JSON)
-                    .type(MediaType.APPLICATION_FORM_URLENCODED).put(String.class, form);
-            } catch (UniformInterfaceException e) {
+                this.org().getTarget(false).path("/users/test-admin-null@mockserver.com")
+                    .queryParam("access_token", t)
+                    .request()
+                    .accept(MediaType.APPLICATION_JSON)
+                    .put( javax.ws.rs.client.Entity.form(form) );
+            } catch (ResponseProcessingException e) {
                 assertEquals("Should receive a 404 Not Found", 404, e.getResponse().getStatus());
             }
         } finally {
@@ -179,13 +181,9 @@ public class RegistrationIT extends AbstractRestIT {
 
             //reset token
             String token = getTokenFromMessage(msgs[0]);
-            this
-                .management()
-                .orgs()
-                .org( this.clientSetup.getOrganizationName() )
-                .users()
-                .getResource( false )
+            this.management().orgs().org( this.clientSetup.getOrganizationName() ).users().getTarget( false )
                 .queryParam( "access_token", token )
+                .request()
                 .get( String.class );
 
             //There is nothing in this test that should indicate why an admin access wouldn't be allowed.
@@ -218,10 +216,10 @@ public class RegistrationIT extends AbstractRestIT {
 
             //A form is REQUIRED to post a user to a management application
             Form userForm = new Form();
-            userForm.add( "username", adminUserEmail );
-            userForm.add( "name", adminUserEmail );
-            userForm.add( "email", adminUserEmail );
-            userForm.add( "password", "password1" );
+            userForm.param( "username", adminUserEmail );
+            userForm.param( "name", adminUserEmail );
+            userForm.param( "email", adminUserEmail );
+            userForm.param( "password", "password1" );
 
             //Disgusting data manipulation to parse the form response.
             Map adminUserPostResponse = (management().users().post( User.class, userForm ));

http://git-wip-us.apache.org/repos/asf/usergrid/blob/0578d987/stack/rest/src/test/java/org/apache/usergrid/rest/management/organizations/AdminEmailEncodingIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/management/organizations/AdminEmailEncodingIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/management/organizations/AdminEmailEncodingIT.java
index 1392749..c615b60 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/management/organizations/AdminEmailEncodingIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/management/organizations/AdminEmailEncodingIT.java
@@ -17,7 +17,6 @@
 package org.apache.usergrid.rest.management.organizations;
 
 
-import com.sun.jersey.api.client.UniformInterfaceException;
 import org.apache.usergrid.rest.test.resource.AbstractRestIT;
 import org.apache.usergrid.rest.test.resource.model.Application;
 import org.apache.usergrid.rest.test.resource.model.Entity;
@@ -89,9 +88,9 @@ public class AdminEmailEncodingIT extends AbstractRestIT {
      * the given string is a part of the admin email address
      *
      * @param symbol
-     * @throws UniformInterfaceException
+     * @throws Exception
      */
-    private void doTest(String symbol) throws UniformInterfaceException {
+    private void doTest(String symbol) throws Exception {
 
         String unique = UUID.randomUUID().toString();
         String org = "org_getTokenDash" + unique;

http://git-wip-us.apache.org/repos/asf/usergrid/blob/0578d987/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/AbstractRestIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/AbstractRestIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/AbstractRestIT.java
index 1d9c23e..cc5807e 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/AbstractRestIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/AbstractRestIT.java
@@ -19,14 +19,6 @@ package org.apache.usergrid.rest.test.resource;
 
 import com.fasterxml.jackson.databind.JsonNode;
 import com.fasterxml.jackson.databind.ObjectMapper;
-import com.sun.jersey.api.client.UniformInterfaceException;
-import com.sun.jersey.api.client.config.ClientConfig;
-import com.sun.jersey.api.client.config.DefaultClientConfig;
-import com.sun.jersey.api.json.JSONConfiguration;
-import com.sun.jersey.test.framework.AppDescriptor;
-import com.sun.jersey.test.framework.JerseyTest;
-import com.sun.jersey.test.framework.WebAppDescriptor;
-import com.sun.jersey.test.framework.spi.container.TestContainerFactory;
 import org.apache.usergrid.rest.TomcatRuntime;
 import org.apache.usergrid.rest.test.resource.endpoints.ApplicationsResource;
 import org.apache.usergrid.rest.test.resource.endpoints.NamedResource;
@@ -35,8 +27,12 @@ import org.apache.usergrid.rest.test.resource.endpoints.mgmt.ManagementResource;
 import org.apache.usergrid.rest.test.resource.model.Entity;
 import org.apache.usergrid.rest.test.resource.model.Token;
 import org.apache.usergrid.rest.test.resource.state.ClientContext;
+import org.glassfish.jersey.client.ClientConfig;
+import org.glassfish.jersey.jackson.JacksonFeature;
+import org.glassfish.jersey.test.JerseyTest;
 import org.junit.Rule;
 
+import javax.ws.rs.client.ResponseProcessingException;
 import java.net.URI;
 import java.net.URISyntaxException;
 import java.net.URLClassLoader;
@@ -53,26 +49,24 @@ import static org.junit.Assert.assertEquals;
 //@RunWith( Arquillian.class )
 public class AbstractRestIT extends JerseyTest {
 
-    private static ClientConfig clientConfig = new DefaultClientConfig();
+    private static ClientConfig clientConfig = new ClientConfig();
 
     public static TomcatRuntime tomcatRuntime = TomcatRuntime.getInstance();
 
     @Rule
     public ClientSetup clientSetup = new ClientSetup( this.getBaseURI().toString() );
 
-    protected static final AppDescriptor descriptor;
-
-    public AbstractRestIT() {
-        super( descriptor );
-    }
+//    protected static final Application descriptor;
+//
+//    public AbstractRestIT() {
+//        super( descriptor );
+//    }
 
 
     protected ObjectMapper mapper = new ObjectMapper();
 
     static {
-        clientConfig.getFeatures().put( JSONConfiguration.FEATURE_POJO_MAPPING, Boolean.TRUE );
-        descriptor = new WebAppDescriptor.Builder( "org.apache.usergrid.rest" )
-                .clientConfig( clientConfig ).build();
+        clientConfig.register( new JacksonFeature() );
         dumpClasspath( AbstractRestIT.class.getClassLoader() );
     }
 
@@ -107,7 +101,6 @@ public class AbstractRestIT extends JerseyTest {
         }
     }
 
-    @Override
     protected URI getBaseURI() {
         try {
             return new URI("http://localhost:" + tomcatRuntime.getPort());
@@ -116,10 +109,10 @@ public class AbstractRestIT extends JerseyTest {
         }
     }
 
-    @Override
-    protected TestContainerFactory getTestContainerFactory() {
-        return new com.sun.jersey.test.framework.spi.container.external.ExternalTestContainerFactory();
-    }
+//    @Override
+//    protected TestContainerFactory getTestContainerFactory() {
+//        return new ExternalTestContainerFactory();
+//    }
 
     ///myorg/
     protected OrganizationResource org(){
@@ -158,15 +151,15 @@ public class AbstractRestIT extends JerseyTest {
 
 
     /**
-     * Takes in the expectedStatus message and the expectedErrorMessage then compares it to the UniformInterfaceException
+     * Takes in the expectedStatus message and the expectedErrorMessage then compares it to the ResponseProcessingException
      * to make sure that we got what we expected.
      * @param expectedStatus
      * @param expectedErrorMessage
      * @param uie
      */
-    public void errorParse(int expectedStatus, String expectedErrorMessage, UniformInterfaceException uie){
+    public void errorParse(int expectedStatus, String expectedErrorMessage, ResponseProcessingException uie){
         assertEquals(expectedStatus,uie.getResponse().getStatus());
-        JsonNode errorJson = uie.getResponse().getEntity( JsonNode.class );
+        JsonNode errorJson = uie.getResponse().readEntity( JsonNode.class );
         assertEquals( expectedErrorMessage, errorJson.get( "error" ).asText() );
 
     }

http://git-wip-us.apache.org/repos/asf/usergrid/blob/0578d987/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/RestClient.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/RestClient.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/RestClient.java
index 30e008c..23fa6c3 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/RestClient.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/RestClient.java
@@ -17,15 +17,15 @@
 package org.apache.usergrid.rest.test.resource;
 
 import com.fasterxml.jackson.databind.JsonNode;
-import com.sun.jersey.api.client.Client;
-import com.sun.jersey.api.client.WebResource;
-import com.sun.jersey.api.client.config.ClientConfig;
-import com.sun.jersey.api.client.config.DefaultClientConfig;
-import com.sun.jersey.api.client.filter.HTTPBasicAuthFilter;
 import org.apache.usergrid.rest.test.resource.endpoints.*;
 import org.apache.usergrid.rest.test.resource.endpoints.mgmt.ManagementResource;
 import org.apache.usergrid.rest.test.resource.state.ClientContext;
+import org.glassfish.jersey.client.ClientConfig;
+import org.glassfish.jersey.client.authentication.HttpAuthenticationFeature;
 
+import javax.ws.rs.client.Client;
+import javax.ws.rs.client.ClientBuilder;
+import javax.ws.rs.client.WebTarget;
 import javax.ws.rs.core.MediaType;
 
 
@@ -38,9 +38,9 @@ public class RestClient implements UrlResource {
     private final String serverUrl;
     private ClientContext context;
 
-    public WebResource resource;
-    ClientConfig config = new DefaultClientConfig();
-    Client client = Client.create( config );
+    public WebTarget resource;
+    ClientConfig config = new ClientConfig();
+    Client client = ClientBuilder.newClient( config );
 
     /**
      *
@@ -49,7 +49,7 @@ public class RestClient implements UrlResource {
     public RestClient( final String serverUrl ) {
         this.serverUrl = serverUrl;
         this.context = new ClientContext();
-        resource = client.resource( serverUrl );
+        resource = client.target( serverUrl );
         resource.path( serverUrl );
     }
 
@@ -59,12 +59,12 @@ public class RestClient implements UrlResource {
      */
     @Override
     public String getPath() {
-        return resource.getURI().toString();
+        return resource.getUri().toString();
     }
 
     @Override
-    public WebResource getResource() {
-        return client.resource( serverUrl );
+    public WebTarget getTarget(){
+        return client.target( serverUrl );
     }
 
     public ClientContext getContext() {
@@ -98,11 +98,12 @@ public class RestClient implements UrlResource {
     }
     public void refreshIndex(String orgname, String appName, String appid) {
         //TODO: add error checking and logging
-        this.getResource().path( "/refreshindex" )
+        this.getTarget().path( "/refreshindex" )
                 .queryParam( "org_name", orgname )
                 .queryParam( "app_name",appName )
                 .queryParam("app_id", appid)
-            .accept( MediaType.APPLICATION_JSON ).post();
+            .request()
+            .accept( MediaType.APPLICATION_JSON ).post( javax.ws.rs.client.Entity.json(null) );
     }
 
     public NamedResource pathResource(String path){
@@ -110,13 +111,11 @@ public class RestClient implements UrlResource {
     }
 
     public void superuserSetup() {
-        //TODO: change this when we upgrade to new version of jersey
-        HTTPBasicAuthFilter httpBasicAuthFilter = new HTTPBasicAuthFilter( "superuser","superpassword" );
-        client.addFilter( httpBasicAuthFilter );
-
-        this.getResource().path( "system/superuser/setup" )
-            .accept( MediaType.APPLICATION_JSON ).type( MediaType.APPLICATION_JSON ).get( JsonNode.class );
-        client.removeFilter( httpBasicAuthFilter );
+        this.getTarget().path( "system/superuser/setup" ).request()
+            .property( HttpAuthenticationFeature.HTTP_AUTHENTICATION_BASIC_USERNAME, "superuser")
+            .property( HttpAuthenticationFeature.HTTP_AUTHENTICATION_BASIC_PASSWORD, "superpassword" )
+            .accept( MediaType.APPLICATION_JSON )
+            .get( JsonNode.class );
     }
 
     //todo:fix this method for the client.

http://git-wip-us.apache.org/repos/asf/usergrid/blob/0578d987/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/TestPropertiesResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/TestPropertiesResource.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/TestPropertiesResource.java
index ad08d94..21aece5 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/TestPropertiesResource.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/TestPropertiesResource.java
@@ -17,14 +17,14 @@
 package org.apache.usergrid.rest.test.resource;
 
 
-import javax.ws.rs.core.MediaType;
-
 import org.apache.usergrid.rest.test.resource.endpoints.NamedResource;
 import org.apache.usergrid.rest.test.resource.endpoints.UrlResource;
 import org.apache.usergrid.rest.test.resource.model.ApiResponse;
 import org.apache.usergrid.rest.test.resource.model.Entity;
 import org.apache.usergrid.rest.test.resource.state.ClientContext;
 
+import javax.ws.rs.core.MediaType;
+
 
 /**
  *Adds support for changing the management properties in the rest testing framework.
@@ -36,12 +36,14 @@ public class TestPropertiesResource extends NamedResource {
 
     public ApiResponse post(Entity testProperties){
 
-        return getResource(true).type( MediaType.APPLICATION_JSON_TYPE )
-                            .accept( MediaType.APPLICATION_JSON ).post( ApiResponse.class, testProperties );
+        return getTarget( true ).request()
+            .accept( MediaType.APPLICATION_JSON )
+            .post( javax.ws.rs.client.Entity.json( testProperties), ApiResponse.class);
     }
 
     public ApiResponse get(){
-        return getResource(true).type( MediaType.APPLICATION_JSON_TYPE )
-                       .accept( MediaType.APPLICATION_JSON ).get(ApiResponse.class );
+        return getTarget(true).request()
+            .accept( MediaType.APPLICATION_JSON )
+            .get( ApiResponse.class );
     }
 }

http://git-wip-us.apache.org/repos/asf/usergrid/blob/0578d987/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/ApplicationsResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/ApplicationsResource.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/ApplicationsResource.java
index 78f906f..709d1ad 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/ApplicationsResource.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/ApplicationsResource.java
@@ -50,8 +50,8 @@ public class ApplicationsResource extends NamedResource {
      * Delete this application.
      */
     public ApiResponse delete() {
-        return getResource(true)
-            .type( MediaType.APPLICATION_JSON_TYPE )
+        return getTarget( true ).request()
+            //.type( MediaType.APPLICATION_JSON_TYPE )
             .accept( MediaType.APPLICATION_JSON )
             .delete( ApiResponse.class );
     }
@@ -65,8 +65,8 @@ public class ApplicationsResource extends NamedResource {
      * Used to get an application entity.
      */
     public ApiResponse get() {
-        return getResource(true)
-            .type(MediaType.APPLICATION_JSON_TYPE)
+        return getTarget(true).request()
+            //.type(MediaType.APPLICATION_JSON_TYPE)
             .accept( MediaType.APPLICATION_JSON )
             .get(ApiResponse.class);
     }

http://git-wip-us.apache.org/repos/asf/usergrid/blob/0578d987/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/CollectionEndpoint.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/CollectionEndpoint.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/CollectionEndpoint.java
index 520bab3..6873955 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/CollectionEndpoint.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/CollectionEndpoint.java
@@ -17,19 +17,20 @@
 package org.apache.usergrid.rest.test.resource.endpoints;
 
 import com.fasterxml.jackson.databind.ObjectMapper;
-import com.sun.jersey.api.client.WebResource;
-import org.apache.usergrid.rest.test.resource.model.*;
 import org.apache.usergrid.rest.test.resource.model.Collection;
 import org.apache.usergrid.rest.test.resource.state.ClientContext;
-import org.apache.usergrid.services.ServiceParameter;
 import org.apache.usergrid.utils.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import javax.ws.rs.client.Entity;
+import javax.ws.rs.client.WebTarget;
 import javax.ws.rs.core.MediaType;
 import java.io.IOException;
 import java.io.StringReader;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.UUID;
 
 
 /**
@@ -114,20 +115,22 @@ public class CollectionEndpoint extends NamedResource {
         return get(parameters, true);
     }
 
-    public Collection get(final org.apache.usergrid.rest.test.resource.model.QueryParameters parameters, final boolean useToken){
+    public Collection get(
+        final org.apache.usergrid.rest.test.resource.model.QueryParameters parameters,
+        final boolean useToken){
 
         String acceptHeader = MediaType.APPLICATION_JSON;
         if (this.acceptHeaders.size() > 0) {
            acceptHeader = StringUtils.join(this.acceptHeaders, ',');
         }
 
-        WebResource resource  = getResource(useToken);
+        WebTarget resource  = getTarget( useToken );
         resource = addParametersToResource(resource, parameters);
 
-        logger.info("PATH is "+ resource.getURI().getRawPath()+"?"+resource.getURI().getRawQuery());
+        logger.info("PATH is "+ resource.getUri().getRawPath()+"?"+resource.getUri().getRawQuery());
         // use string type so we can log actual response from server
-        String responseString = resource.type( MediaType.APPLICATION_JSON_TYPE )
-            .accept(acceptHeader)
+        String responseString = resource.request()
+            .accept( acceptHeader )
             .get(String.class);
 
         logger.debug("Response from get: " + responseString);
@@ -135,7 +138,8 @@ public class CollectionEndpoint extends NamedResource {
         ObjectMapper mapper = new ObjectMapper();
         org.apache.usergrid.rest.test.resource.model.ApiResponse response;
         try {
-            response = mapper.readValue( new StringReader(responseString), org.apache.usergrid.rest.test.resource.model.ApiResponse.class);
+            response = mapper.readValue(
+                new StringReader(responseString), org.apache.usergrid.rest.test.resource.model.ApiResponse.class);
         } catch (IOException e) {
             throw new RuntimeException("Error parsing response", e);
         }
@@ -157,13 +161,16 @@ public class CollectionEndpoint extends NamedResource {
      * </pre>
      */
     //TODO: add queryParameters here
-    public Collection getNextPage(Collection collection, org.apache.usergrid.rest.test.resource.model.QueryParameters passedParameters ,final boolean useToken) {
+    public Collection getNextPage(Collection collection,
+             org.apache.usergrid.rest.test.resource.model.QueryParameters passedParameters ,
+             final boolean useToken) {
+
         String acceptHeader = MediaType.APPLICATION_JSON;
         if (this.acceptHeaders.size() > 0) {
             acceptHeader = StringUtils.join(this.acceptHeaders, ',');
         }
 
-        WebResource resource = getResource(useToken);
+        WebTarget resource = getTarget( useToken );
         org.apache.usergrid.rest.test.resource.model.QueryParameters queryParameters = passedParameters;
         if( queryParameters == null){
             queryParameters = new org.apache.usergrid.rest.test.resource.model.QueryParameters();
@@ -172,8 +179,10 @@ public class CollectionEndpoint extends NamedResource {
         queryParameters.setCursor(collection.getCursor());
         resource = addParametersToResource(resource, queryParameters);
 
-        org.apache.usergrid.rest.test.resource.model.ApiResponse response = resource.type( MediaType.APPLICATION_JSON_TYPE ).accept(acceptHeader)
-                .get(org.apache.usergrid.rest.test.resource.model.ApiResponse.class);
+        org.apache.usergrid.rest.test.resource.model.ApiResponse response =
+            resource.request()
+            .accept( acceptHeader )
+            .get(org.apache.usergrid.rest.test.resource.model.ApiResponse.class);
 
         return new Collection(response);
     }
@@ -206,10 +215,10 @@ public class CollectionEndpoint extends NamedResource {
             acceptHeader = StringUtils.join(this.acceptHeaders, ',');
         }
 
-        WebResource resource  = getResource(useToken);
+        WebTarget resource  = getTarget( useToken );
         resource = addParametersToResource(resource, parameters);
-        return resource.type( MediaType.APPLICATION_JSON_TYPE )
-            .accept(acceptHeader)
+        return resource.request()
+            .accept( acceptHeader )
             .delete(org.apache.usergrid.rest.test.resource.model.ApiResponse.class);
     }
 
@@ -229,10 +238,10 @@ public class CollectionEndpoint extends NamedResource {
         }
 
         // use string type so we can log actual response from server
-        String responseString = getResource(true)
-            .type( MediaType.APPLICATION_JSON_TYPE )
+        String responseString = getTarget( true )
+            .request()
             .accept(acceptHeader)
-            .post(String.class, payload);
+            .post( javax.ws.rs.client.Entity.json( payload ), String.class);
 
         logger.debug("Response from post: " + responseString);
 
@@ -256,10 +265,10 @@ public class CollectionEndpoint extends NamedResource {
         }
 
         // use string type so we can log actual response from server
-        String responseString = getResource(true)
-            .type( MediaType.APPLICATION_JSON_TYPE )
-            .accept(acceptHeader)
-            .post(String.class);
+        String responseString = getTarget( true )
+            .request()
+            .accept( acceptHeader )
+            .post( javax.ws.rs.client.Entity.json( null ), String.class);
 
         logger.debug("Response from post: " + responseString);
 
@@ -283,17 +292,18 @@ public class CollectionEndpoint extends NamedResource {
         }
 
         // use string type so we can log actual response from server
-        String responseString = getResource(true)
-            .type( MediaType.APPLICATION_JSON_TYPE )
-            .accept(acceptHeader)
-            .post(String.class, entityList );
+        String responseString = getTarget( true )
+            .request()
+            .accept( acceptHeader )
+            .post( javax.ws.rs.client.Entity.json( entityList ), String.class);
 
         logger.debug("Response from post: " + responseString);
 
         ObjectMapper mapper = new ObjectMapper();
         org.apache.usergrid.rest.test.resource.model.ApiResponse response;
         try {
-            response = mapper.readValue( new StringReader(responseString), org.apache.usergrid.rest.test.resource.model.ApiResponse.class);
+            response = mapper.readValue(
+                new StringReader(responseString), org.apache.usergrid.rest.test.resource.model.ApiResponse.class);
         } catch (IOException e) {
             throw new RuntimeException("Error parsing response", e);
         }
@@ -312,31 +322,37 @@ public class CollectionEndpoint extends NamedResource {
      * PUT /users?ql=select * where created > 0
      * </pre>
      */
-    public org.apache.usergrid.rest.test.resource.model.ApiResponse put( final org.apache.usergrid.rest.test.resource.model.QueryParameters parameters, org.apache.usergrid.rest.test.resource.model.Entity entity ){
+    public org.apache.usergrid.rest.test.resource.model.ApiResponse put(
+        final org.apache.usergrid.rest.test.resource.model.QueryParameters parameters,
+        org.apache.usergrid.rest.test.resource.model.Entity entity ){
         return put(parameters, true, entity);
     }
 
-    public org.apache.usergrid.rest.test.resource.model.ApiResponse put(final org.apache.usergrid.rest.test.resource.model.QueryParameters parameters, final boolean useToken, org.apache.usergrid.rest.test.resource.model.Entity entity) {
+    public org.apache.usergrid.rest.test.resource.model.ApiResponse put(
+        final org.apache.usergrid.rest.test.resource.model.QueryParameters parameters,
+        final boolean useToken,
+        org.apache.usergrid.rest.test.resource.model.Entity entity) {
 
         String acceptHeader = MediaType.APPLICATION_JSON;
         if (this.acceptHeaders.size() > 0) {
             acceptHeader = StringUtils.join(this.acceptHeaders, ',');
         }
 
-        WebResource resource  = getResource(useToken);
-        addParametersToResource(getResource(), parameters);
+        WebTarget resource  = getTarget( useToken );
+        addParametersToResource(getTarget(), parameters);
 
         // use string type so we can log actual response from server
-        String responseString = resource.type(MediaType.APPLICATION_JSON_TYPE)
+        String responseString = resource.request()
             .accept(acceptHeader)
-            .post(String.class, entity);
+            .post( javax.ws.rs.client.Entity.json( entity ), String.class);
 
         logger.debug("Response from put: " + responseString);
 
         ObjectMapper mapper = new ObjectMapper();
         org.apache.usergrid.rest.test.resource.model.ApiResponse response;
         try {
-            response = mapper.readValue( new StringReader(responseString), org.apache.usergrid.rest.test.resource.model.ApiResponse.class);
+            response = mapper.readValue(
+                new StringReader(responseString), org.apache.usergrid.rest.test.resource.model.ApiResponse.class);
         } catch (IOException e) {
             throw new RuntimeException("Error parsing response", e);
         }

http://git-wip-us.apache.org/repos/asf/usergrid/blob/0578d987/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/EntityEndpoint.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/EntityEndpoint.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/EntityEndpoint.java
index 70b2c3a..63949ec 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/EntityEndpoint.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/EntityEndpoint.java
@@ -20,14 +20,13 @@
 
 package org.apache.usergrid.rest.test.resource.endpoints;
 
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.sun.jersey.api.client.WebResource;
 import org.apache.usergrid.rest.test.resource.model.ApiResponse;
 import org.apache.usergrid.rest.test.resource.model.Entity;
 import org.apache.usergrid.rest.test.resource.model.QueryParameters;
 import org.apache.usergrid.rest.test.resource.model.Token;
 import org.apache.usergrid.rest.test.resource.state.ClientContext;
 
+import javax.ws.rs.client.WebTarget;
 import javax.ws.rs.core.MediaType;
 
 public class EntityEndpoint extends NamedResource {
@@ -63,19 +62,21 @@ public class EntityEndpoint extends NamedResource {
     }
 
     public Entity get(final boolean useToken, final Token token){
-        WebResource resource  = getResource(useToken,token);
-        ApiResponse response = resource.type( MediaType.APPLICATION_JSON_TYPE ).accept(MediaType.APPLICATION_JSON)
-                .get(ApiResponse.class);
+        WebTarget resource  = getTarget( useToken, token );
+        ApiResponse response = resource.request()
+            .accept( MediaType.APPLICATION_JSON )
+            .get(ApiResponse.class);
 
         return new Entity(response);
     }
 
     //For testing purposes only
     public Entity get(QueryParameters parameters, final boolean useToken){
-        WebResource resource  = getResource(useToken);
+        WebTarget resource  = getTarget(useToken);
         resource = addParametersToResource(resource, parameters);
-        ApiResponse response = resource.type( MediaType.APPLICATION_JSON_TYPE ).accept(MediaType.APPLICATION_JSON)
-                                       .get(ApiResponse.class);
+        ApiResponse response = resource.request()
+            .accept( MediaType.APPLICATION_JSON )
+            .get(ApiResponse.class);
 
         return new Entity(response);
     }
@@ -96,9 +97,10 @@ public class EntityEndpoint extends NamedResource {
     }
 
     public ApiResponse delete(final boolean useToken){
-        WebResource resource  = getResource(useToken);
-        return resource.type( MediaType.APPLICATION_JSON_TYPE ).accept(MediaType.APPLICATION_JSON)
-                .delete(ApiResponse.class);
+        WebTarget resource  = getTarget( useToken );
+        return resource.request()
+            .accept( MediaType.APPLICATION_JSON )
+            .delete(ApiResponse.class);
     }
 
     /**
@@ -113,9 +115,10 @@ public class EntityEndpoint extends NamedResource {
      * PUT /users/fred {"color":"red"}
      */
     public Entity put(Entity entity){
-        ApiResponse response = getResource(true).type( MediaType.APPLICATION_JSON_TYPE ).accept(MediaType.APPLICATION_JSON)
-                .put(ApiResponse.class, entity);
-        return new Entity(response);
+        ApiResponse response = getTarget( true ).request()
+            .accept(MediaType.APPLICATION_JSON)
+            .put( javax.ws.rs.client.Entity.json(entity), ApiResponse.class );
+        return new Entity( response);
     }
 
 
@@ -134,11 +137,12 @@ public class EntityEndpoint extends NamedResource {
     }
 
     public Entity post(final boolean useToken){
-        WebResource resource  = getResource(useToken);
-        ApiResponse response = resource.type(MediaType.APPLICATION_JSON_TYPE ).accept(MediaType.APPLICATION_JSON)
-                .post(ApiResponse.class);
+        WebTarget resource  = getTarget(useToken);
+        ApiResponse response = resource.request()
+            .accept(MediaType.APPLICATION_JSON)
+            .post( javax.ws.rs.client.Entity.json(null), ApiResponse.class );
 
-        return new Entity(response);
+        return new Entity( response);
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/usergrid/blob/0578d987/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/NamedResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/NamedResource.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/NamedResource.java
index 2258312..336d709 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/NamedResource.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/NamedResource.java
@@ -17,17 +17,18 @@
 package org.apache.usergrid.rest.test.resource.endpoints;
 
 
-import com.sun.jersey.api.client.GenericType;
-import com.sun.jersey.api.client.WebResource;
-import com.sun.jersey.api.client.filter.HTTPBasicAuthFilter;
-import com.sun.jersey.api.representation.Form;
-import com.sun.jersey.multipart.FormDataMultiPart;
 import org.apache.usergrid.rest.test.resource.model.ApiResponse;
 import org.apache.usergrid.rest.test.resource.model.Entity;
 import org.apache.usergrid.rest.test.resource.model.QueryParameters;
 import org.apache.usergrid.rest.test.resource.model.Token;
 import org.apache.usergrid.rest.test.resource.state.ClientContext;
+import org.glassfish.jersey.client.authentication.HttpAuthenticationFeature;
+import org.glassfish.jersey.media.multipart.FormDataMultiPart;
 
+import javax.ws.rs.client.Invocation;
+import javax.ws.rs.client.WebTarget;
+import javax.ws.rs.core.Form;
+import javax.ws.rs.core.GenericType;
 import javax.ws.rs.core.MediaType;
 import java.io.InputStream;
 import java.util.Iterator;
@@ -64,14 +65,14 @@ public class NamedResource implements UrlResource {
     }
 
     @Override
-    public WebResource getResource() {
-        return getResource(false);
+    public WebTarget getTarget() {
+        return getTarget( false );
     }
-    public WebResource getResource(boolean useToken) {
-        return getResource(useToken,null);
+    public WebTarget getTarget(boolean useToken) {
+        return getTarget( useToken, null );
     }
-    public WebResource getResource(boolean useToken,Token token) {
-        WebResource resource = parent.getResource().path( getPath() );
+    public WebTarget getTarget(boolean useToken,Token token) {
+        WebTarget resource = parent.getTarget().path( getPath() );
         token = token !=null ? token : this.context.getToken();
         //error checking
         if (token == null) {
@@ -80,7 +81,7 @@ public class NamedResource implements UrlResource {
         return  useToken    ? resource.queryParam("access_token",token.getAccessToken()) :  resource;
     }
 
-    protected WebResource addParametersToResource(WebResource resource, final QueryParameters parameters){
+    protected WebTarget addParametersToResource(WebTarget resource, final QueryParameters parameters){
 
         if(parameters == null){
             return resource;
@@ -178,11 +179,8 @@ public class NamedResource implements UrlResource {
     /**
      * Need to refactor all instances of tokens to either be passed in or manually set during the test.
      * There isn't any reason we would want a rest forwarding framework to set something on behave of the user.
-     * @param type
-     * @param <T>
-     * @return
+     * For edge cases like Organizations and Tokens
      */
-    //For edge cases like Organizations and Tokens
     public <T> T post(Class<T> type) {
         return post(true,type,null,null,false);
 
@@ -191,26 +189,18 @@ public class NamedResource implements UrlResource {
     /**
      * Need to refactor all instances of tokens to either be passed in or manually set during the test.
      * There isn't any reason we would want a rest forwarding framework to set something on behave of the user.
-     * @param type
-     * @param requestEntity
-     * @param <T>
-     * @return
+     * For edge cases like Organizations and Tokens.
      */
-    //For edge cases like Organizations and Tokens
     public <T> T post(Class<T> type, Entity requestEntity) {
-        return post(true,type,requestEntity,null,false);
+        return post( true, type, requestEntity, null, false);
 
     }
 
     /**
      * Need to refactor all instances of tokens to either be passed in or manually set during the test.
      * There isn't any reason we would want a rest forwarding framework to set something on behave of the user.
-     * @param type
-     * @param requestEntity
-     * @param <T>
-     * @return
+     * For edge cases like Organizations and Tokens
      */
-    //For edge cases like Organizations and Tokens
     public <T> T post(Class<T> type, Map requestEntity) {
         return post(true,type,requestEntity,null,false);
 
@@ -223,59 +213,46 @@ public class NamedResource implements UrlResource {
 
     /**
      * Used to test POST using form payloads.
-     * @param type
-     * @param requestEntity
-     * @param <T>
-     * @return
      */
-    public <T> T post(Class<T> type, Form requestEntity) {
+    public <T> T post(Class<T> type, Form form) {
         GenericType<T> gt = new GenericType<>((Class) type);
-        return getResource()
-            .accept(MediaType.APPLICATION_JSON)
-            .type(MediaType.APPLICATION_FORM_URLENCODED_TYPE)
-            .entity(requestEntity, MediaType.APPLICATION_FORM_URLENCODED_TYPE)
-            .post(gt.getRawClass());
-
+        return getTarget().request()
+            .accept( MediaType.APPLICATION_JSON )
+            .post( javax.ws.rs.client.Entity.entity( form, MediaType.APPLICATION_FORM_URLENCODED_TYPE ), gt );
     }
 
 
-    //Used for empty posts
+    // Used for empty posts
     public <T> T post( boolean useToken, Class<T> type, Map entity, final QueryParameters queryParameters) {
-        WebResource resource = getResource(useToken);
-        resource = addParametersToResource(resource, queryParameters);
-        WebResource.Builder builder = resource
-            .type(MediaType.APPLICATION_JSON_TYPE)
+        WebTarget resource = getTarget( useToken );
+        resource = addParametersToResource( resource, queryParameters );
+
+        Invocation.Builder builder = resource.request()
             .accept( MediaType.APPLICATION_JSON );
 
-        if(entity!=null){
-            builder.entity(entity);
-        }
+        // it's OK for the entity to be null
         GenericType<T> gt = new GenericType<>((Class) type);
-        return builder
-            .post(gt.getRawClass());
-
+        return builder.post( javax.ws.rs.client.Entity.json( entity ), gt );
     }
 
-    //Used for empty posts
-    public <T> T post( boolean useToken, Class<T> type, Map entity, final QueryParameters queryParameters, boolean useBasicAuthentication ) {
-        WebResource resource = getResource(useToken);
+    // Used for empty posts
+    public <T> T post( boolean useToken, Class<T> type, Map entity,
+                       final QueryParameters queryParameters, boolean useBasicAuthentication ) {
+
+        WebTarget resource = getTarget( useToken );
         resource = addParametersToResource(resource, queryParameters);
-        WebResource.Builder builder = resource
-            .type(MediaType.APPLICATION_JSON_TYPE)
+        Invocation.Builder builder = resource.request()
             .accept( MediaType.APPLICATION_JSON );
 
-        if(entity!=null){
-            builder.entity(entity);
-        }
 
-        if(useBasicAuthentication){
-            //added httpBasicauth filter to all setup calls because they all do verification this way.
-            HTTPBasicAuthFilter httpBasicAuthFilter = new HTTPBasicAuthFilter( "superuser","superpassword" );
-            resource.addFilter( httpBasicAuthFilter );
+        if ( useBasicAuthentication ) {
+            builder = builder.property( HttpAuthenticationFeature.HTTP_AUTHENTICATION_BASIC_USERNAME, "superuser")
+                             .property( HttpAuthenticationFeature.HTTP_AUTHENTICATION_BASIC_PASSWORD, "superpassword");
         }
 
+        // it's OK for the entity to be null
         GenericType<T> gt = new GenericType<>((Class) type);
-        return builder.post( gt.getRawClass() );
+        return builder.post( javax.ws.rs.client.Entity.json( entity ), gt );
 
     }
 
@@ -297,14 +274,14 @@ public class NamedResource implements UrlResource {
     }
 
     public <T> T get(Class<T> type,QueryParameters queryParameters, boolean useToken) {
-        WebResource resource = getResource(useToken);
+        WebTarget resource = getTarget( useToken );
         if(queryParameters!=null) {
             resource = addParametersToResource(resource, queryParameters);
         }
         GenericType<T> gt = new GenericType<>((Class) type);
-        return resource.type(MediaType.APPLICATION_JSON_TYPE)
+        return resource.request()
             .accept( MediaType.APPLICATION_JSON )
-            .get( gt.getRawClass() );
+            .get( gt );
 
     }
 
@@ -313,8 +290,9 @@ public class NamedResource implements UrlResource {
     }
 
     public ApiResponse post( boolean useToken, FormDataMultiPart multiPartForm ) {
-        WebResource resource = getResource( useToken );
-        return resource.type( MediaType.MULTIPART_FORM_DATA_TYPE ).post( ApiResponse.class, multiPartForm );
+        WebTarget resource = getTarget( useToken );
+        return resource.request().post(
+            javax.ws.rs.client.Entity.entity( multiPartForm, multiPartForm.getMediaType() ), ApiResponse.class );
     }
 
     public ApiResponse post( FormDataMultiPart multiPartForm ) {
@@ -322,8 +300,9 @@ public class NamedResource implements UrlResource {
     }
 
     public ApiResponse put( boolean useToken, byte[] data, MediaType type ) {
-        WebResource resource = getResource(useToken);
-        return resource.type( type ).put( ApiResponse.class, data );
+        WebTarget resource = getTarget(useToken );
+        return resource.request().put(
+            javax.ws.rs.client.Entity.entity(data, type), ApiResponse.class );
     }
 
     public ApiResponse put( byte[] data, MediaType type ) {
@@ -331,8 +310,9 @@ public class NamedResource implements UrlResource {
     }
 
     public ApiResponse put( boolean useToken, FormDataMultiPart multiPartForm ) {
-        WebResource resource = getResource(useToken);
-        return resource.type( MediaType.MULTIPART_FORM_DATA_TYPE ).put( ApiResponse.class, multiPartForm );
+        WebTarget resource = getTarget(useToken );
+        return resource.request().put(
+            javax.ws.rs.client.Entity.entity(multiPartForm, multiPartForm.getMediaType()), ApiResponse.class );
     }
 
     public ApiResponse put( FormDataMultiPart multiPartForm ) {
@@ -340,8 +320,8 @@ public class NamedResource implements UrlResource {
     }
 
     public InputStream getAssetAsStream( boolean useToken ) {
-        WebResource resource = getResource(useToken);
-        return resource.accept( MediaType.APPLICATION_OCTET_STREAM_TYPE ).get( InputStream.class );
+        WebTarget resource = getTarget(useToken );
+        return resource.request().accept( MediaType.APPLICATION_OCTET_STREAM_TYPE ).get( InputStream.class );
     }
 
     public InputStream getAssetAsStream() {
@@ -353,6 +333,6 @@ public class NamedResource implements UrlResource {
     }
 
     public ApiResponse delete( boolean useToken ) {
-        return getResource(useToken).delete( ApiResponse.class );
+        return getTarget(useToken).request().delete( ApiResponse.class );
     }
 }

http://git-wip-us.apache.org/repos/asf/usergrid/blob/0578d987/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/RootResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/RootResource.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/RootResource.java
index 8537251..88ec1c4 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/RootResource.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/RootResource.java
@@ -21,7 +21,7 @@ import org.apache.usergrid.rest.test.resource.endpoints.mgmt.ManagementResource;
 import org.apache.usergrid.rest.test.resource.model.Token;
 import org.apache.usergrid.rest.test.resource.state.ClientContext;
 
-import com.sun.jersey.api.client.WebResource;
+import javax.ws.rs.client.WebTarget;
 
 
 /**
@@ -61,7 +61,7 @@ public class RootResource implements UrlResource {
     }
 
     @Override
-    public WebResource getResource() {
+    public WebTarget getTarget() {
         //TODO: fix this to return the proper resource in the scope we expect it, might not be needed here.
         return null;
     }

http://git-wip-us.apache.org/repos/asf/usergrid/blob/0578d987/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/SetupResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/SetupResource.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/SetupResource.java
index b374cdc..75f1b6b 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/SetupResource.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/SetupResource.java
@@ -17,16 +17,13 @@
 package org.apache.usergrid.rest.test.resource.endpoints;
 
 
-import javax.ws.rs.core.MediaType;
-
 import org.apache.usergrid.rest.test.resource.model.Entity;
 import org.apache.usergrid.rest.test.resource.model.QueryParameters;
-import org.apache.usergrid.rest.test.resource.model.Token;
 import org.apache.usergrid.rest.test.resource.state.ClientContext;
+import org.glassfish.jersey.client.authentication.HttpAuthenticationFeature;
 
-import com.sun.jersey.api.client.WebResource;
-import com.sun.jersey.api.client.filter.HTTPBasicAuthFilter;
-
+import javax.ws.rs.client.WebTarget;
+import javax.ws.rs.core.MediaType;
 
 /**
  * Functions as the endpoint for all resources that hit /system/ * /setup
@@ -39,14 +36,13 @@ public class SetupResource extends NamedResource {
 
     public Entity get(QueryParameters queryParameters){
 
-        WebResource resource = getResource();
+        WebTarget resource = getTarget();
         resource = addParametersToResource( resource, queryParameters );
 
-        //added httpBasicauth filter to all setup calls because they all do verification this way.
-        HTTPBasicAuthFilter httpBasicAuthFilter = new HTTPBasicAuthFilter( "superuser","superpassword" );
-        resource.addFilter( httpBasicAuthFilter );
-
-        return resource.type( MediaType.APPLICATION_JSON_TYPE ).accept( MediaType.APPLICATION_JSON )
-                                .get( Entity.class);
+        return resource.request()
+            .property( HttpAuthenticationFeature.HTTP_AUTHENTICATION_BASIC_USERNAME, "superuser")
+            .property( HttpAuthenticationFeature.HTTP_AUTHENTICATION_BASIC_PASSWORD, "superpassword" )
+            .accept( MediaType.APPLICATION_JSON )
+            .get( Entity.class );
     }
 }

http://git-wip-us.apache.org/repos/asf/usergrid/blob/0578d987/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/SystemResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/SystemResource.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/SystemResource.java
index 6a97dad..35ffc21 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/SystemResource.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/SystemResource.java
@@ -18,12 +18,11 @@
 package org.apache.usergrid.rest.test.resource.endpoints;
 
 
-import javax.ws.rs.core.MediaType;
-
 import org.apache.usergrid.rest.test.resource.model.ApiResponse;
-import org.apache.usergrid.rest.test.resource.model.Entity;
 import org.apache.usergrid.rest.test.resource.state.ClientContext;
 
+import javax.ws.rs.core.MediaType;
+
 
 /**
  * Handles making rest calls to system resources.
@@ -50,8 +49,10 @@ public class SystemResource extends NamedResource {
 
     public ApiResponse put(){
         ApiResponse
-            response = getResource(true).type( MediaType.APPLICATION_JSON_TYPE ).accept(MediaType.APPLICATION_JSON)
-                                        .put(ApiResponse.class);
+            response = getTarget(true)
+                .request()
+                .accept(MediaType.APPLICATION_JSON)
+                .put( javax.ws.rs.client.Entity.json(null), ApiResponse.class);
         return response;
     }
 }

http://git-wip-us.apache.org/repos/asf/usergrid/blob/0578d987/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/TokenResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/TokenResource.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/TokenResource.java
index 59ad354..2c777dd 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/TokenResource.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/TokenResource.java
@@ -21,11 +21,12 @@
 package org.apache.usergrid.rest.test.resource.endpoints;
 
 
-import com.sun.jersey.api.client.WebResource;
 import org.apache.usergrid.rest.test.resource.model.QueryParameters;
 import org.apache.usergrid.rest.test.resource.model.Token;
 import org.apache.usergrid.rest.test.resource.state.ClientContext;
 
+import javax.ws.rs.client.Entity;
+import javax.ws.rs.client.WebTarget;
 import javax.ws.rs.core.MediaType;
 
 /**
@@ -43,9 +44,10 @@ public class TokenResource extends NamedResource {
      * @return
      */
     public Token post(QueryParameters params) {
-        WebResource resource = getResource(false);
+        WebTarget resource = getTarget( false );
         resource = addParametersToResource(resource, params);
-        Token token = resource.type(MediaType.APPLICATION_JSON_TYPE).accept(MediaType.APPLICATION_JSON)
+        Token token = resource.request()
+            .accept( MediaType.APPLICATION_JSON )
             .get(Token.class);
 
         this.context.setToken(token);
@@ -58,7 +60,7 @@ public class TokenResource extends NamedResource {
      * @return
      */
     public Token post() {
-        Token token = getResource().accept(MediaType.APPLICATION_JSON).post(Token.class);
+        Token token = getTarget().request().accept( MediaType.APPLICATION_JSON ).post( Entity.json(null), Token.class );
         this.context.setToken(token);
         return token;
     }
@@ -70,8 +72,9 @@ public class TokenResource extends NamedResource {
      * @return
      */
     public Token post(Token token) {
-        token = getResource(false).type(MediaType.APPLICATION_JSON_TYPE)
-            .accept(MediaType.APPLICATION_JSON).post(Token.class, token);
+        token = getTarget(false).request()
+            .accept(MediaType.APPLICATION_JSON)
+            .post( Entity.json( token ), Token.class);
         this.context.setToken(token);
         return token;
     }

http://git-wip-us.apache.org/repos/asf/usergrid/blob/0578d987/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/UrlResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/UrlResource.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/UrlResource.java
index eb16d4d..6e5ee1b 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/UrlResource.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/UrlResource.java
@@ -17,10 +17,7 @@
 package org.apache.usergrid.rest.test.resource.endpoints;
 
 
-import org.apache.usergrid.rest.test.resource.state.ClientContext;
-
-import com.sun.jersey.api.client.WebResource;
-
+import javax.ws.rs.client.WebTarget;
 
 /**
  * Interface that returns the path that is currently being pointed to.
@@ -38,7 +35,7 @@ public interface UrlResource {
      * Get the resource
      * @return
      */
-    public WebResource getResource();
+    public WebTarget getTarget();
 
 
 }

http://git-wip-us.apache.org/repos/asf/usergrid/blob/0578d987/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/mgmt/ApplicationResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/mgmt/ApplicationResource.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/mgmt/ApplicationResource.java
index dbf653d..4b9d195 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/mgmt/ApplicationResource.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/mgmt/ApplicationResource.java
@@ -59,23 +59,29 @@ public class ApplicationResource extends NamedResource {
 
 
     public org.apache.usergrid.rest.test.resource.model.ApiResponse post(Application application) {
-        org.apache.usergrid.rest.test.resource.model.ApiResponse apiResponse =getResource(true).type(MediaType.APPLICATION_JSON_TYPE)
-            .accept(MediaType.APPLICATION_JSON).post(org.apache.usergrid.rest.test.resource.model.ApiResponse.class, application);
+        org.apache.usergrid.rest.test.resource.model.ApiResponse apiResponse = getTarget(true)
+            .request()
+            .accept( MediaType.APPLICATION_JSON )
+            .post( javax.ws.rs.client.Entity.json(application),
+                org.apache.usergrid.rest.test.resource.model.ApiResponse.class);
         return apiResponse;
     }
 
-    public org.apache.usergrid.rest.test.resource.model.Entity post(org.apache.usergrid.rest.test.resource.model.Entity payload) {
+    public org.apache.usergrid.rest.test.resource.model.Entity post(
+        org.apache.usergrid.rest.test.resource.model.Entity payload) {
 
-        String responseString = getResource(true)
-            .type( MediaType.APPLICATION_JSON_TYPE )
+        String responseString = getTarget( true )
+            .request()
             .accept(MediaType.APPLICATION_JSON)
-            .post(String.class, payload);
+            .post( javax.ws.rs.client.Entity.json(payload), String.class);
 
         logger.debug("Response from post: " + responseString);
 
         org.apache.usergrid.rest.test.resource.model.ApiResponse response;
         try {
-            response = mapper.readValue(new StringReader(responseString), org.apache.usergrid.rest.test.resource.model.ApiResponse.class);
+            response = mapper.readValue(
+                new StringReader(responseString),
+                org.apache.usergrid.rest.test.resource.model.ApiResponse.class);
         } catch (IOException e) {
             throw new RuntimeException("Error parsing response", e);
         }
@@ -86,8 +92,8 @@ public class ApplicationResource extends NamedResource {
 
     public org.apache.usergrid.rest.test.resource.model.Entity get() {
 
-        String responseString = getResource(true)
-            .type( MediaType.APPLICATION_JSON_TYPE )
+        String responseString = getTarget(true)
+            .request()
             .accept(MediaType.APPLICATION_JSON)
             .get(String.class);
 
@@ -95,7 +101,8 @@ public class ApplicationResource extends NamedResource {
 
         org.apache.usergrid.rest.test.resource.model.ApiResponse response;
         try {
-            response = mapper.readValue(new StringReader(responseString), org.apache.usergrid.rest.test.resource.model.ApiResponse.class);
+            response = mapper.readValue(
+                new StringReader(responseString), org.apache.usergrid.rest.test.resource.model.ApiResponse.class);
         } catch (IOException e) {
             throw new RuntimeException("Error parsing response", e);
         }

http://git-wip-us.apache.org/repos/asf/usergrid/blob/0578d987/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/mgmt/ApplicationsResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/mgmt/ApplicationsResource.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/mgmt/ApplicationsResource.java
index caf93e8..bd0c824 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/mgmt/ApplicationsResource.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/mgmt/ApplicationsResource.java
@@ -45,9 +45,9 @@ public class ApplicationsResource extends NamedResource {
 
     public ManagementResponse getOrganizationApplications() throws IOException {
 
-        String responseString = this.getResource()
+        String responseString = this.getTarget()
             .queryParam( "access_token", context.getToken().getAccessToken() )
-            .type(MediaType.APPLICATION_JSON)
+            .request()
             .get(String.class);
 
         logger.info("Response: " + responseString);

http://git-wip-us.apache.org/repos/asf/usergrid/blob/0578d987/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/mgmt/AuthorizeResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/mgmt/AuthorizeResource.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/mgmt/AuthorizeResource.java
index 694f9c4..d93612a 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/mgmt/AuthorizeResource.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/mgmt/AuthorizeResource.java
@@ -19,7 +19,6 @@
  */
 package org.apache.usergrid.rest.test.resource.endpoints.mgmt;
 
-import com.sun.jersey.api.client.GenericType;
 import org.apache.usergrid.rest.test.resource.endpoints.NamedResource;
 import org.apache.usergrid.rest.test.resource.endpoints.UrlResource;
 import org.apache.usergrid.rest.test.resource.state.ClientContext;
@@ -39,7 +38,7 @@ public class AuthorizeResource extends NamedResource {
      * @return
      */
     public Object post(Object requestEntity) {
-        return getResource().post(Object.class, requestEntity);
+        return getTarget().request().post( javax.ws.rs.client.Entity.json(requestEntity), Object.class);
 
     }
 
@@ -51,9 +50,7 @@ public class AuthorizeResource extends NamedResource {
      * @return
      */
     public <T> T post(Class<T> type, Object requestEntity) {
-        GenericType<T> gt = new GenericType<>((Class) type);
-        return getResource().post(gt.getRawClass(), requestEntity);
-
+        return getTarget().request().post( javax.ws.rs.client.Entity.json( requestEntity ), type );
     }
 
 }

http://git-wip-us.apache.org/repos/asf/usergrid/blob/0578d987/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/mgmt/ConfirmResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/mgmt/ConfirmResource.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/mgmt/ConfirmResource.java
index 0a35353..9e0c443 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/mgmt/ConfirmResource.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/mgmt/ConfirmResource.java
@@ -17,15 +17,13 @@
 package org.apache.usergrid.rest.test.resource.endpoints.mgmt;
 
 
-import javax.ws.rs.core.MediaType;
-
 import org.apache.usergrid.rest.test.resource.endpoints.NamedResource;
 import org.apache.usergrid.rest.test.resource.endpoints.UrlResource;
-import org.apache.usergrid.rest.test.resource.model.ApiResponse;
 import org.apache.usergrid.rest.test.resource.model.QueryParameters;
 import org.apache.usergrid.rest.test.resource.state.ClientContext;
 
-import com.sun.jersey.api.client.WebResource;
+import javax.ws.rs.client.WebTarget;
+import javax.ws.rs.core.MediaType;
 
 
 /**
@@ -37,10 +35,8 @@ public class ConfirmResource extends NamedResource {
     }
 
     public void get(QueryParameters queryParameters){
-        WebResource resource = getResource();
+        WebTarget resource = getTarget();
         resource = addParametersToResource( resource, queryParameters );
-        String obj = resource.type( MediaType.TEXT_HTML_TYPE )
-                                       .accept( MediaType.TEXT_HTML).get( String.class );
-
+        String obj = resource.request().accept( MediaType.TEXT_HTML).get( String.class );
     }
 }

http://git-wip-us.apache.org/repos/asf/usergrid/blob/0578d987/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/mgmt/CredentialsResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/mgmt/CredentialsResource.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/mgmt/CredentialsResource.java
index 073d6d6..31df4ba 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/mgmt/CredentialsResource.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/mgmt/CredentialsResource.java
@@ -19,7 +19,6 @@
  */
 package org.apache.usergrid.rest.test.resource.endpoints.mgmt;
 
-import com.sun.jersey.api.client.WebResource;
 import org.apache.usergrid.rest.test.resource.endpoints.NamedResource;
 import org.apache.usergrid.rest.test.resource.endpoints.UrlResource;
 import org.apache.usergrid.rest.test.resource.model.ApiResponse;
@@ -27,6 +26,7 @@ import org.apache.usergrid.rest.test.resource.model.Credentials;
 import org.apache.usergrid.rest.test.resource.model.QueryParameters;
 import org.apache.usergrid.rest.test.resource.state.ClientContext;
 
+import javax.ws.rs.client.WebTarget;
 import javax.ws.rs.core.MediaType;
 
 /**
@@ -38,9 +38,10 @@ public class CredentialsResource extends NamedResource {
     }
 
     public Credentials get(final QueryParameters parameters, final boolean useToken) {
-        WebResource resource = getResource(useToken);
+        WebTarget resource = getTarget(useToken);
         resource = addParametersToResource(resource, parameters);
-        ApiResponse response = resource.type(MediaType.APPLICATION_JSON_TYPE).accept(MediaType.APPLICATION_JSON)
+        ApiResponse response = resource.request()
+            .accept(MediaType.APPLICATION_JSON)
             .get(ApiResponse.class);
         return new Credentials(response);
     }

http://git-wip-us.apache.org/repos/asf/usergrid/blob/0578d987/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/mgmt/FeedResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/mgmt/FeedResource.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/mgmt/FeedResource.java
index 8fd873b..4895659 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/mgmt/FeedResource.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/mgmt/FeedResource.java
@@ -41,8 +41,9 @@ public class FeedResource extends NamedResource {
     }
 
     public ApiResponse get() {
-        return getResource( true ).type( MediaType.APPLICATION_JSON_TYPE )
-            .accept( MediaType.APPLICATION_JSON ).get( ApiResponse.class);
+        return getTarget( true ).request()
+            .accept( MediaType.APPLICATION_JSON )
+            .get( ApiResponse.class);
 
 
     }


[27/54] usergrid git commit: Initial testing with guice wiring for test

Posted by sn...@apache.org.
Initial testing with guice wiring for test


Project: http://git-wip-us.apache.org/repos/asf/usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/usergrid/commit/b625ed24
Tree: http://git-wip-us.apache.org/repos/asf/usergrid/tree/b625ed24
Diff: http://git-wip-us.apache.org/repos/asf/usergrid/diff/b625ed24

Branch: refs/heads/usergrid-1007-shiro-cache
Commit: b625ed24a68d9c71fc30694c5dbeda26f1afb4d7
Parents: 2faa805
Author: Todd Nine <tn...@apigee.com>
Authored: Mon Sep 14 17:33:38 2015 -0600
Committer: Todd Nine <tn...@apigee.com>
Committed: Mon Sep 14 18:14:00 2015 -0600

----------------------------------------------------------------------
 .../corepersistence/CpRelationManager.java      |  23 ++-
 .../asyncevents/AsyncEventService.java          |   2 +
 .../builder/PipelineBuilderFactory.java         |   3 +
 .../service/ConnectionScope.java                |  53 +++++
 .../service/ConnectionService.java              |  10 +
 .../service/ConnectionServiceImpl.java          |  65 +++++-
 .../corepersistence/util/CpNamingUtils.java     |  13 +-
 .../corepersistence/TestCoreModule.java         |  34 ++++
 .../service/ConnectionServiceImplTest.java      | 198 +++++++++++++++++++
 stack/core/src/test/resources/log4j.properties  |   3 +-
 .../impl/TargetIdObservableImpl.java            |  13 +-
 11 files changed, 397 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/usergrid/blob/b625ed24/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpRelationManager.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpRelationManager.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpRelationManager.java
index 0c3b927..1da6f75 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpRelationManager.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpRelationManager.java
@@ -63,6 +63,7 @@ import org.apache.usergrid.persistence.graph.GraphManager;
 import org.apache.usergrid.persistence.graph.SearchByEdge;
 import org.apache.usergrid.persistence.graph.SearchByEdgeType;
 import org.apache.usergrid.persistence.graph.impl.SimpleEdge;
+import org.apache.usergrid.persistence.graph.impl.SimpleSearchByEdge;
 import org.apache.usergrid.persistence.graph.impl.SimpleSearchByEdgeType;
 import org.apache.usergrid.persistence.graph.impl.SimpleSearchEdgeType;
 import org.apache.usergrid.persistence.index.EntityIndex;
@@ -694,9 +695,27 @@ public class CpRelationManager implements RelationManager {
         final Edge edge = createConnectionEdge( cpHeadEntity.getId(), connectionType, targetEntity.getId() );
 
         final GraphManager gm = managerCache.getGraphManager( applicationScope );
-        gm.writeEdge( edge ).toBlocking().last();
 
-        indexService.queueNewEdge( applicationScope, targetEntity, edge );
+
+        //check if the edge exists
+
+
+        final SearchByEdge searchByEdge = new SimpleSearchByEdge(edge.getSourceNode(), edge.getType(), edge.getTargetNode(), Long.MAX_VALUE, SearchByEdgeType.Order.DESCENDING, Optional.absent()  );
+
+
+        //only take 1 and count it.  If we don't have anything, create the edge
+        final int count = gm.loadEdgeVersions( searchByEdge ).take( 1 ).count().toBlocking().last();
+
+        if(count == 0) {
+            if(logger.isDebugEnabled()) {
+                logger.debug( "No edge exists between {} and {} of type {}.  Creating",
+                    new Object[] { edge.getSourceNode(), edge.getTargetNode(), edge.getType() } );
+            }
+
+            gm.writeEdge( edge ).toBlocking().last();
+
+            indexService.queueNewEdge( applicationScope, targetEntity, edge );
+        }
 
         return connection;
     }

http://git-wip-us.apache.org/repos/asf/usergrid/blob/b625ed24/stack/core/src/main/java/org/apache/usergrid/corepersistence/asyncevents/AsyncEventService.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/asyncevents/AsyncEventService.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/asyncevents/AsyncEventService.java
index 6d51679..ae5688c 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/asyncevents/AsyncEventService.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/asyncevents/AsyncEventService.java
@@ -54,6 +54,8 @@ public interface AsyncEventService extends ReIndexAction {
     /**
      * Fired when a new edge is added to an entity. Such as initial entity creation, adding to a collection, or creating a connection
      *
+     * TODO: We shouldn't take an entity here, only the id.  It doesn't make sense in a distributed context to pass the entity
+     *
      * @param applicationScope
      * @param entity
      * @param newEdge

http://git-wip-us.apache.org/repos/asf/usergrid/blob/b625ed24/stack/core/src/main/java/org/apache/usergrid/corepersistence/pipeline/builder/PipelineBuilderFactory.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/pipeline/builder/PipelineBuilderFactory.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/pipeline/builder/PipelineBuilderFactory.java
index 6cb515b..ada1779 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/pipeline/builder/PipelineBuilderFactory.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/pipeline/builder/PipelineBuilderFactory.java
@@ -23,6 +23,9 @@ package org.apache.usergrid.corepersistence.pipeline.builder;
 import org.apache.usergrid.persistence.core.scope.ApplicationScope;
 
 
+/**
+ * Factory interface for creating our pipeline builders
+ */
 public interface PipelineBuilderFactory {
 
 

http://git-wip-us.apache.org/repos/asf/usergrid/blob/b625ed24/stack/core/src/main/java/org/apache/usergrid/corepersistence/service/ConnectionScope.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/service/ConnectionScope.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/service/ConnectionScope.java
new file mode 100644
index 0000000..3cc9ae5
--- /dev/null
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/service/ConnectionScope.java
@@ -0,0 +1,53 @@
+/*
+ * 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.usergrid.corepersistence.service;
+
+
+import java.io.Serializable;
+
+import org.apache.usergrid.persistence.core.scope.ApplicationScope;
+import org.apache.usergrid.persistence.graph.Edge;
+import org.apache.usergrid.persistence.model.entity.Id;
+
+
+/**
+ * Tuple containing our application scope, and an edge within that applications' graph
+ */
+public class ConnectionScope implements Serializable {
+    private final Edge edge;
+    private final ApplicationScope applicationScope;
+
+
+
+
+    public ConnectionScope( ApplicationScope applicationScope, final Edge edge ) {
+        this.edge = edge;
+        this.applicationScope = applicationScope;
+    }
+
+
+    public Edge getEdge() {
+        return edge;
+    }
+
+
+    public ApplicationScope getApplicationScope() {
+        return applicationScope;
+    }
+
+
+}

http://git-wip-us.apache.org/repos/asf/usergrid/blob/b625ed24/stack/core/src/main/java/org/apache/usergrid/corepersistence/service/ConnectionService.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/service/ConnectionService.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/service/ConnectionService.java
index 71a25c9..539c881 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/service/ConnectionService.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/service/ConnectionService.java
@@ -20,6 +20,7 @@ package org.apache.usergrid.corepersistence.service;
 
 import org.apache.usergrid.corepersistence.pipeline.read.ResultsPage;
 import org.apache.usergrid.persistence.ConnectionRef;
+import org.apache.usergrid.persistence.core.scope.ApplicationScope;
 import org.apache.usergrid.persistence.model.entity.Entity;
 import org.apache.usergrid.persistence.model.entity.Id;
 
@@ -46,4 +47,13 @@ public interface ConnectionService {
      * @return
      */
     Observable<ResultsPage<ConnectionRef>> searchConnectionAsRefs( final ConnectionSearch search );
+
+
+    /**
+     * An observable that will remove duplicate edges from the graph that represent connections.  All emitted scopes are scopes that have been deleted.
+     *
+     * @param applicationScopeObservable
+     * @return
+     */
+    Observable<ConnectionScope> deDupeConnections(final Observable<ApplicationScope> applicationScopeObservable);
 }

http://git-wip-us.apache.org/repos/asf/usergrid/blob/b625ed24/stack/core/src/main/java/org/apache/usergrid/corepersistence/service/ConnectionServiceImpl.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/service/ConnectionServiceImpl.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/service/ConnectionServiceImpl.java
index c7e0fee..82c1038 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/service/ConnectionServiceImpl.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/service/ConnectionServiceImpl.java
@@ -22,7 +22,18 @@ import org.apache.usergrid.corepersistence.pipeline.builder.EntityBuilder;
 import org.apache.usergrid.corepersistence.pipeline.builder.IdBuilder;
 import org.apache.usergrid.corepersistence.pipeline.builder.PipelineBuilderFactory;
 import org.apache.usergrid.corepersistence.pipeline.read.ResultsPage;
+import org.apache.usergrid.corepersistence.rx.impl.AllEntityIdsObservable;
+import org.apache.usergrid.corepersistence.util.CpNamingUtils;
 import org.apache.usergrid.persistence.ConnectionRef;
+import org.apache.usergrid.persistence.collection.serialization.impl.migration.EntityIdScope;
+import org.apache.usergrid.persistence.core.scope.ApplicationScope;
+import org.apache.usergrid.persistence.graph.GraphManager;
+import org.apache.usergrid.persistence.graph.GraphManagerFactory;
+import org.apache.usergrid.persistence.graph.SearchByEdge;
+import org.apache.usergrid.persistence.graph.SearchByEdgeType;
+import org.apache.usergrid.persistence.graph.impl.SimpleSearchByEdge;
+import org.apache.usergrid.persistence.graph.impl.SimpleSearchByEdgeType;
+import org.apache.usergrid.persistence.graph.impl.SimpleSearchEdgeType;
 import org.apache.usergrid.persistence.model.entity.Entity;
 import org.apache.usergrid.persistence.model.entity.Id;
 
@@ -37,11 +48,17 @@ import rx.Observable;
 public class ConnectionServiceImpl implements ConnectionService {
 
     private final PipelineBuilderFactory pipelineBuilderFactory;
+    private final AllEntityIdsObservable allEntityIdsObservable;
+    private final GraphManagerFactory graphManagerFactory;
 
 
     @Inject
-    public ConnectionServiceImpl( final PipelineBuilderFactory pipelineBuilderFactory ) {
+    public ConnectionServiceImpl( final PipelineBuilderFactory pipelineBuilderFactory,
+                                  final AllEntityIdsObservable allEntityIdsObservable,
+                                  final GraphManagerFactory graphManagerFactory ) {
         this.pipelineBuilderFactory = pipelineBuilderFactory;
+        this.allEntityIdsObservable = allEntityIdsObservable;
+        this.graphManagerFactory = graphManagerFactory;
     }
 
 
@@ -117,4 +134,50 @@ public class ConnectionServiceImpl implements ConnectionService {
 
         return results;
     }
+
+
+    @Override
+    public Observable<ConnectionScope> deDupeConnections(
+        final Observable<ApplicationScope> applicationScopeObservable ) {
+
+
+        final Observable<EntityIdScope> entityIds =allEntityIdsObservable.getEntities( applicationScopeObservable );
+        //now we have an observable of entityIds.  Walk each connection type
+
+        //get all edge types for connections
+       return  entityIds.flatMap( entityIdScope -> {
+
+            final ApplicationScope applicationScope = entityIdScope.getApplicationScope();
+            final Id entityId = entityIdScope.getId();
+
+            final GraphManager gm = graphManagerFactory.createEdgeManager(applicationScope );
+
+            return gm.getEdgeTypesFromSource(
+                new SimpleSearchEdgeType( entityId, CpNamingUtils.EDGE_CONN_PREFIX, Optional.absent() ) )
+
+                //now load all edges from this node of this type
+                .flatMap( edgeType -> {
+                    final SearchByEdgeType searchByEdge =
+                        new SimpleSearchByEdgeType( entityId, edgeType, Long.MAX_VALUE,
+                            SearchByEdgeType.Order.ASCENDING, Optional.absent() );
+
+                    //load edges from the source the with type specified
+                    return gm.loadEdgesFromSource( searchByEdge );
+                } )
+
+                //now that we have a stream of edges, stream all versions
+                .flatMap( edge -> {
+                    final SearchByEdge searchByEdge =
+                        new SimpleSearchByEdge( edge.getSourceNode(), edge.getType(), edge.getTargetNode(),
+                            Long.MAX_VALUE, SearchByEdgeType.Order.ASCENDING, Optional.absent() );
+                    return gm.loadEdgeVersions( searchByEdge );
+                } )
+
+            //skip the first version since it's the one we want to retain
+            // validate there is only 1 version of it, delete anything > than the min
+                .skip( 1 )
+                .flatMap( edgeToDelete -> gm.deleteEdge( edgeToDelete ) )
+                .map(deletedEdge ->  new ConnectionScope( applicationScope, deletedEdge ) ) ;
+        });
+    }
 }

http://git-wip-us.apache.org/repos/asf/usergrid/blob/b625ed24/stack/core/src/main/java/org/apache/usergrid/corepersistence/util/CpNamingUtils.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/util/CpNamingUtils.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/util/CpNamingUtils.java
index f32e9d7..55bc49a 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/util/CpNamingUtils.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/util/CpNamingUtils.java
@@ -21,8 +21,6 @@ package org.apache.usergrid.corepersistence.util;
 
 import java.util.UUID;
 
-import com.google.common.base.Optional;
-import com.google.common.base.Preconditions;
 import org.apache.usergrid.persistence.core.scope.ApplicationScope;
 import org.apache.usergrid.persistence.core.scope.ApplicationScopeImpl;
 import org.apache.usergrid.persistence.entities.Application;
@@ -42,7 +40,8 @@ import org.apache.usergrid.persistence.map.impl.MapScopeImpl;
 import org.apache.usergrid.persistence.model.entity.Id;
 import org.apache.usergrid.persistence.model.entity.SimpleId;
 import org.apache.usergrid.persistence.model.util.UUIDGenerator;
-import org.apache.usergrid.utils.UUIDUtils;
+
+import com.google.common.base.Optional;
 
 
 /**
@@ -257,6 +256,7 @@ public class CpNamingUtils {
     }
 
 
+
     /**
      * Get the application scope from the given uuid
      *
@@ -309,6 +309,8 @@ public class CpNamingUtils {
     }
 
 
+
+
     private static boolean isCollectionEdgeType( String type ) {
         return type.startsWith( EDGE_COLL_PREFIX );
     }
@@ -326,8 +328,5 @@ public class CpNamingUtils {
     }
 
 
-    public static boolean isApplication(Id id) {
-        Preconditions.checkNotNull(id);
-        return id.getType().equals("application");
-    }
+
 }

http://git-wip-us.apache.org/repos/asf/usergrid/blob/b625ed24/stack/core/src/test/java/org/apache/usergrid/corepersistence/TestCoreModule.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/corepersistence/TestCoreModule.java b/stack/core/src/test/java/org/apache/usergrid/corepersistence/TestCoreModule.java
new file mode 100644
index 0000000..32b9845
--- /dev/null
+++ b/stack/core/src/test/java/org/apache/usergrid/corepersistence/TestCoreModule.java
@@ -0,0 +1,34 @@
+/*
+ * 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.usergrid.corepersistence;
+
+
+import org.apache.usergrid.persistence.core.guice.TestModule;
+
+
+/**
+ * Test guice module for our core guice configuration
+ */
+public class TestCoreModule extends TestModule {
+
+    @Override
+    protected void configure() {
+
+        install( new CoreModule() );
+    }
+}

http://git-wip-us.apache.org/repos/asf/usergrid/blob/b625ed24/stack/core/src/test/java/org/apache/usergrid/corepersistence/service/ConnectionServiceImplTest.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/corepersistence/service/ConnectionServiceImplTest.java b/stack/core/src/test/java/org/apache/usergrid/corepersistence/service/ConnectionServiceImplTest.java
new file mode 100644
index 0000000..0a29286
--- /dev/null
+++ b/stack/core/src/test/java/org/apache/usergrid/corepersistence/service/ConnectionServiceImplTest.java
@@ -0,0 +1,198 @@
+/*
+ * 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.usergrid.corepersistence.service;
+
+
+import java.util.List;
+
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import org.apache.usergrid.corepersistence.TestCoreModule;
+import org.apache.usergrid.corepersistence.util.CpNamingUtils;
+import org.apache.usergrid.persistence.core.guice.MigrationManagerRule;
+import org.apache.usergrid.persistence.core.scope.ApplicationScope;
+import org.apache.usergrid.persistence.core.scope.ApplicationScopeImpl;
+import org.apache.usergrid.persistence.core.test.ITRunner;
+import org.apache.usergrid.persistence.core.test.UseModules;
+import org.apache.usergrid.persistence.graph.Edge;
+import org.apache.usergrid.persistence.graph.GraphManager;
+import org.apache.usergrid.persistence.graph.GraphManagerFactory;
+import org.apache.usergrid.persistence.graph.SearchByEdge;
+import org.apache.usergrid.persistence.graph.SearchByEdgeType;
+import org.apache.usergrid.persistence.graph.impl.SimpleSearchByEdge;
+import org.apache.usergrid.persistence.model.entity.Id;
+import org.apache.usergrid.persistence.model.entity.SimpleId;
+
+import com.google.common.base.Optional;
+import com.google.inject.Inject;
+
+import rx.Observable;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+
+@RunWith( ITRunner.class )
+@UseModules( TestCoreModule.class )
+public class ConnectionServiceImplTest {
+
+    @Inject
+    private GraphManagerFactory graphManagerFactory;
+
+    @Inject
+    private ConnectionService connectionService;
+
+    @Inject
+    @Rule
+    public MigrationManagerRule migrationManagerRule;
+
+
+    @Test
+    public void testSingleConnection() {
+
+        final ApplicationScope applicationScope = new ApplicationScopeImpl( new SimpleId( "application" ) );
+
+
+        final GraphManager gm = graphManagerFactory.createEdgeManager( applicationScope );
+
+        //now write a single connection
+
+        final Id source = new SimpleId( "source" );
+
+
+        //add to a collection
+
+        final String collectionName = "testCollection";
+
+        final Edge collectionEdge = CpNamingUtils.createCollectionEdge( applicationScope.getApplication(), collectionName, source );
+
+        final Edge writtenCollection = gm.writeEdge( collectionEdge ).toBlocking().last();
+
+        assertNotNull("Collection edge written", writtenCollection);
+
+
+
+
+        final Id target = new SimpleId( "target" );
+
+        final String connectionType = "testConnection";
+
+        final Edge connectionEdge = CpNamingUtils.createConnectionEdge( source, connectionType, target );
+
+        final Edge writtenConnection = gm.writeEdge( connectionEdge ).toBlocking().last();
+
+
+        //now run the cleanup
+
+        final int count =
+            connectionService.deDupeConnections( Observable.just( applicationScope ) ).count().toBlocking().last();
+
+        assertEquals( "No edges deleted", 0, count );
+
+        //now ensure we can read the edge.
+
+        final SearchByEdge simpleSearchByEdge =
+            new SimpleSearchByEdge( source, connectionEdge.getType(), target, Long.MAX_VALUE,
+                SearchByEdgeType.Order.DESCENDING, Optional.absent() );
+
+        final List<Edge> edges = gm.loadEdgeVersions( simpleSearchByEdge ).toList().toBlocking().last();
+
+        assertEquals( 1, edges.size() );
+
+        assertEquals( writtenConnection, edges.get( 0 ) );
+    }
+
+
+    @Test
+    public void testDuplicateConnections() {
+
+        final ApplicationScope applicationScope = new ApplicationScopeImpl( new SimpleId( "application" ) );
+
+
+        final GraphManager gm = graphManagerFactory.createEdgeManager( applicationScope );
+
+        //now write a single connection
+
+        final Id source = new SimpleId( "source" );
+
+        final Id target = new SimpleId( "target" );
+
+        final String connectionType = "testConnection";
+
+
+          //add to a collection
+
+        final String collectionName = "testCollection";
+
+        final Edge collectionEdge = CpNamingUtils.createCollectionEdge( applicationScope.getApplication(), collectionName, source );
+
+        final Edge writtenCollection = gm.writeEdge( collectionEdge ).toBlocking().last();
+
+        assertNotNull("Collection edge written", writtenCollection);
+
+        //write our first connection
+        final Edge connection1 = CpNamingUtils.createConnectionEdge( source, connectionType, target );
+
+        final Edge written1 = gm.writeEdge( connection1 ).toBlocking().last();
+
+
+        //write the second
+        final Edge connection2 = CpNamingUtils.createConnectionEdge( source, connectionType, target );
+
+        final Edge written2 = gm.writeEdge( connection2 ).toBlocking().last();
+
+
+        //write the 3rd
+        final Edge connection3 = CpNamingUtils.createConnectionEdge( source, connectionType, target );
+
+        final Edge written3 = gm.writeEdge( connection3 ).toBlocking().last();
+
+
+
+
+        //now run the cleanup
+
+        final List<ConnectionScope> deletedConnections =
+            connectionService.deDupeConnections( Observable.just( applicationScope ) ).toList().toBlocking().last();
+
+        assertEquals( "2 edges deleted", 2, deletedConnections.size() );
+
+        //check our oldest was deleted first
+
+        assertEquals(written2, deletedConnections.get( 0 ));
+
+        assertEquals(written3, deletedConnections.get( 1 ));
+
+
+
+        //now ensure we can read the edge.
+
+        final SearchByEdge simpleSearchByEdge =
+            new SimpleSearchByEdge( source, connection1.getType(), target, Long.MAX_VALUE,
+                SearchByEdgeType.Order.DESCENDING, Optional.absent() );
+
+        //check only 1 exists
+        final List<Edge> edges = gm.loadEdgeVersions( simpleSearchByEdge ).toList().toBlocking().last();
+
+        assertEquals( 1, edges.size() );
+
+        assertEquals( written1, edges.get( 0 ) );
+    }
+}

http://git-wip-us.apache.org/repos/asf/usergrid/blob/b625ed24/stack/core/src/test/resources/log4j.properties
----------------------------------------------------------------------
diff --git a/stack/core/src/test/resources/log4j.properties b/stack/core/src/test/resources/log4j.properties
index dfcb260..dd29671 100644
--- a/stack/core/src/test/resources/log4j.properties
+++ b/stack/core/src/test/resources/log4j.properties
@@ -18,7 +18,8 @@
 # and the pattern to %c instead of %l.  (%l is slower.)
 
 # output messages into a rolling log file as well as stdout
-log4j.rootLogger=ERROR,stdout
+#log4j.rootLogger=ERROR,stdout\
+log4j.rootLogger=DEBUG,stdout
 
 # stdout
 log4j.appender.stdout=org.apache.log4j.ConsoleAppender

http://git-wip-us.apache.org/repos/asf/usergrid/blob/b625ed24/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/serialization/impl/TargetIdObservableImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/serialization/impl/TargetIdObservableImpl.java b/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/serialization/impl/TargetIdObservableImpl.java
index 82c7d54..bd8cd3c 100644
--- a/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/serialization/impl/TargetIdObservableImpl.java
+++ b/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/serialization/impl/TargetIdObservableImpl.java
@@ -55,18 +55,13 @@ public class TargetIdObservableImpl implements TargetIdObservable {
     public Observable<Id> getTargetNodes(final GraphManager gm, final Id sourceNode) {
 
         //only search edge types that start with collections
-        return edgesFromSourceObservable.edgesFromSourceDescending( gm, sourceNode ).map( new Func1<Edge, Id>() {
+        return edgesFromSourceObservable.edgesFromSourceDescending( gm, sourceNode ).map( edge -> {
+            final Id targetNode = edge.getTargetNode();
 
+            logger.debug( "Emitting targetId of {}", edge );
 
-            @Override
-            public Id call( final Edge edge ) {
-                final Id targetNode = edge.getTargetNode();
 
-                logger.debug( "Emitting targetId of {}", edge );
-
-
-                return targetNode;
-            }
+            return targetNode;
         } );
     }
 }


[50/54] usergrid git commit: Fixes issues found during review

Posted by sn...@apache.org.
Fixes issues found during review


Project: http://git-wip-us.apache.org/repos/asf/usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/usergrid/commit/0d4dd116
Tree: http://git-wip-us.apache.org/repos/asf/usergrid/tree/0d4dd116
Diff: http://git-wip-us.apache.org/repos/asf/usergrid/diff/0d4dd116

Branch: refs/heads/usergrid-1007-shiro-cache
Commit: 0d4dd1161e0ffacbfe056de205da0860652b0e17
Parents: 901d7c6
Author: Todd Nine <tn...@apigee.com>
Authored: Thu Sep 17 17:10:24 2015 -0600
Committer: Todd Nine <tn...@apigee.com>
Committed: Thu Sep 17 17:10:24 2015 -0600

----------------------------------------------------------------------
 .../usergrid/corepersistence/CoreModule.java    |  6 ------
 .../migration/DeDupConnectionDataMigration.java | 22 ++++++++++----------
 .../DeDupConnectionDataMigrationTest.java       |  7 ++++---
 .../core/astyanax/MultiRowColumnIterator.java   |  2 +-
 .../persistence/graph/GraphManagerIT.java       |  6 +++---
 5 files changed, 19 insertions(+), 24 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/usergrid/blob/0d4dd116/stack/core/src/main/java/org/apache/usergrid/corepersistence/CoreModule.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CoreModule.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CoreModule.java
index 11707be..486aa6f 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CoreModule.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CoreModule.java
@@ -190,12 +190,6 @@ public class CoreModule  extends AbstractModule {
 
         bind( StatusService.class ).to( StatusServiceImpl.class );
 
-        /**
-         * Install migration services
-         */
-
-          //migrations
-        //we want to make sure our generics are retained, so we use a typeliteral
 
     }
 

http://git-wip-us.apache.org/repos/asf/usergrid/blob/0d4dd116/stack/core/src/main/java/org/apache/usergrid/corepersistence/migration/DeDupConnectionDataMigration.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/migration/DeDupConnectionDataMigration.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/migration/DeDupConnectionDataMigration.java
index f65864a..bec8d6c 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/migration/DeDupConnectionDataMigration.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/migration/DeDupConnectionDataMigration.java
@@ -56,24 +56,23 @@ public class DeDupConnectionDataMigration implements DataMigration {
 
         observer.start();
 
-        connectionService.deDupeConnections( allApplicationsObservable.getData() ).reduce( 0l, (count, deDuped) ->{
+        connectionService.deDupeConnections( allApplicationsObservable.getData() ).reduce( 0l, ( count, deDuped ) -> {
 
-            final long newCount = count+1;
+            final long newCount = count + 1;
 
             /**
              * Update our progress observer
              */
-            if(newCount % UPDATE_COUNT == 0){
+            if ( newCount % UPDATE_COUNT == 0 ) {
                 logger.info( "De duped {} edges", newCount );
-                observer.update( migrationVersion, String.format("De duped %d edges", newCount) );
+                observer.update( migrationVersion, String.format( "De duped %d edges", newCount ) );
             }
 
             return newCount;
-
-        }).doOnNext( total -> {
-            logger.info("Completed de-duping {} edges", total );
-            observer.complete();;
-        }).subscribe();
+        } ).doOnNext( total -> {
+            logger.info( "Completed de-duping {} edges", total );
+            observer.complete();
+        } ).subscribe();
 
         return migrationVersion;
 
@@ -82,12 +81,13 @@ public class DeDupConnectionDataMigration implements DataMigration {
 
     @Override
     public boolean supports( final int currentVersion ) {
-        return currentVersion == getMaxVersion() - 1;
+        return currentVersion <= getMaxVersion() - 1;
     }
 
 
     @Override
     public int getMaxVersion() {
-        return 1;
+        //needs to be 2 b/c our obsolete EntityTypeMappingMigration was 1
+        return 2;
     }
 }

http://git-wip-us.apache.org/repos/asf/usergrid/blob/0d4dd116/stack/core/src/test/java/org/apache/usergrid/corepersistence/migration/DeDupConnectionDataMigrationTest.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/corepersistence/migration/DeDupConnectionDataMigrationTest.java b/stack/core/src/test/java/org/apache/usergrid/corepersistence/migration/DeDupConnectionDataMigrationTest.java
index c84ad2b..aad6259 100644
--- a/stack/core/src/test/java/org/apache/usergrid/corepersistence/migration/DeDupConnectionDataMigrationTest.java
+++ b/stack/core/src/test/java/org/apache/usergrid/corepersistence/migration/DeDupConnectionDataMigrationTest.java
@@ -49,8 +49,6 @@ public class DeDupConnectionDataMigrationTest {
     public void testVersion() {
 
         //mock up an initial system state
-        final int version = 0;
-
         final ConnectionService connectionService = mock( ConnectionService.class );
 
         final AllApplicationsObservable allApplicationsObservable = mock( AllApplicationsObservable.class );
@@ -60,7 +58,10 @@ public class DeDupConnectionDataMigrationTest {
             new DeDupConnectionDataMigration( connectionService, allApplicationsObservable );
 
 
-        assertTrue( plugin.supports( version ) );
+        //anything less than 2 should be supported
+        assertTrue( plugin.supports( 0 ) );
+
+        assertTrue( plugin.supports( 1 ) );
 
         assertFalse( plugin.supports( plugin.getMaxVersion() ) );
     }

http://git-wip-us.apache.org/repos/asf/usergrid/blob/0d4dd116/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/MultiRowColumnIterator.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/MultiRowColumnIterator.java b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/MultiRowColumnIterator.java
index 16249ae..667992c 100644
--- a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/MultiRowColumnIterator.java
+++ b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/MultiRowColumnIterator.java
@@ -201,7 +201,7 @@ public class MultiRowColumnIterator<R, C, T> implements Iterator<T> {
         final List<T> mergedResults;
 
         if ( containsSingleRowOnly( result ) ) {
-               mergedResults = singleRowResult( result );
+            mergedResults = singleRowResult( result );
         }
         else {
             mergedResults = mergeResults( result, selectSize );

http://git-wip-us.apache.org/repos/asf/usergrid/blob/0d4dd116/stack/corepersistence/graph/src/test/java/org/apache/usergrid/persistence/graph/GraphManagerIT.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/graph/src/test/java/org/apache/usergrid/persistence/graph/GraphManagerIT.java b/stack/corepersistence/graph/src/test/java/org/apache/usergrid/persistence/graph/GraphManagerIT.java
index eaded15..eda3a02 100644
--- a/stack/corepersistence/graph/src/test/java/org/apache/usergrid/persistence/graph/GraphManagerIT.java
+++ b/stack/corepersistence/graph/src/test/java/org/apache/usergrid/persistence/graph/GraphManagerIT.java
@@ -2339,15 +2339,15 @@ public class GraphManagerIT {
         //write 3 edges with 3 different timestamp
         final Edge edge1 = createEdge( sourceId, "test", target, 1, false );
 
-        gm.writeEdge( edge1 ).toBlocking().last();
+        gm.writeEdge( edge1 ).subscribe();
 
         final Edge edge2 = createEdge( sourceId, "test", target, 2, false );
 
-        gm.writeEdge( edge2 ).toBlocking().last();
+        gm.writeEdge( edge2 ).subscribe();
 
         final Edge edge3 = createEdge( sourceId, "test", target, 3, false );
 
-        gm.writeEdge( edge3 ).toBlocking().last();
+        gm.writeEdge( edge3 ).subscribe();
 
         //now test retrieving it
 


[53/54] usergrid git commit: Merge branch 'two-dot-o-dev' into usergrid-103-upgrade-jersey

Posted by sn...@apache.org.
Merge branch 'two-dot-o-dev' into usergrid-103-upgrade-jersey


Project: http://git-wip-us.apache.org/repos/asf/usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/usergrid/commit/a2389e6d
Tree: http://git-wip-us.apache.org/repos/asf/usergrid/tree/a2389e6d
Diff: http://git-wip-us.apache.org/repos/asf/usergrid/diff/a2389e6d

Branch: refs/heads/usergrid-1007-shiro-cache
Commit: a2389e6dc20aefeeae6eb335f36bd6f450597cac
Parents: 6ea6685 327ccc6
Author: Dave Johnson <sn...@apache.org>
Authored: Fri Sep 18 18:49:09 2015 -0400
Committer: Dave Johnson <sn...@apache.org>
Committed: Fri Sep 18 18:49:09 2015 -0400

----------------------------------------------------------------------
 .../usergrid/corepersistence/CoreModule.java    |  51 +++-
 .../corepersistence/CpRelationManager.java      |  23 +-
 .../asyncevents/AsyncEventService.java          |   2 +
 .../migration/CoreMigration.java                |  45 +---
 .../migration/CoreMigrationPlugin.java          |  38 ++-
 .../migration/DeDupConnectionDataMigration.java |  93 ++++++++
 .../migration/EntityTypeMappingMigration.java   | 104 --------
 .../migration/MigrationModuleVersionPlugin.java |   5 -
 .../corepersistence/migration/Versions.java     |  31 ---
 .../builder/PipelineBuilderFactory.java         |   3 +
 .../service/ConnectionScope.java                |  53 +++++
 .../service/ConnectionService.java              |  10 +
 .../service/ConnectionServiceImpl.java          |  89 ++++++-
 .../corepersistence/util/CpNamingUtils.java     |  13 +-
 .../corepersistence/TestCoreModule.java         |  34 +++
 .../DeDupConnectionDataMigrationTest.java       | 145 ++++++++++++
 .../migration/EntityTypeMappingMigrationIT.java | 125 ----------
 .../service/ConnectionServiceImplTest.java      | 235 +++++++++++++++++++
 stack/core/src/test/resources/log4j.properties  |   6 +-
 .../serialization/impl/SerializationModule.java |   4 +-
 .../migration/CollectionMigrationPlugin.java    |   8 +-
 .../migration/MvccEntityDataMigrationImpl.java  |  10 +-
 ...ctMvccEntityDataMigrationV1ToV3ImplTest.java |  39 +--
 .../migration/data/AbstractMigrationPlugin.java |  17 +-
 .../core/migration/data/DataMigration.java      |  11 +-
 .../migration/data/MigrationDataProvider.java   |   2 +-
 .../core/migration/data/MigrationPlugin.java    |   4 +-
 .../migration/schema/MigrationManagerFig.java   |   1 +
 .../migration/data/TestProgressObserver.java    |  10 +-
 .../persistence/graph/guice/GraphModule.java    |   4 +-
 .../graph/impl/GraphManagerImpl.java            |   4 +-
 .../impl/stage/EdgeDeleteListenerImpl.java      |   4 +-
 .../graph/impl/stage/EdgeDeleteRepairImpl.java  |  61 ++---
 .../impl/TargetIdObservableImpl.java            |  13 +-
 .../impl/migration/EdgeDataMigrationImpl.java   |  12 +-
 .../impl/migration/GraphMigrationPlugin.java    |   8 +-
 .../impl/shard/impl/EdgeSearcher.java           |  14 +-
 .../impl/ShardedEdgeSerializationImpl.java      |  59 +++--
 .../shard/impl/serialize/EdgeSerializer.java    |  21 +-
 .../persistence/graph/GraphManagerIT.java       |  73 +++++-
 .../migration/EdgeDataMigrationImplTest.java    |  59 +++--
 .../persistence/index/CandidateResult.java      |  32 ++-
 .../persistence/index/CandidateResults.java     |  34 ++-
 .../SearchRequestBuilderStrategyV2.java         |  30 +--
 .../usergrid/persistence/index/IndexEdge.java   |  36 +--
 .../index/IndexLocationStrategy.java            |  30 +--
 .../persistence/index/IndexRefreshCommand.java  |  30 +--
 .../usergrid/persistence/index/SearchType.java  |  30 +--
 .../usergrid/persistence/index/SearchTypes.java |  32 +--
 .../persistence/index/SelectFieldMapping.java   |  36 +--
 .../persistence/index/guice/IndexModule.java    |   4 +-
 .../persistence/index/impl/EntityField.java     |  32 ++-
 .../index/impl/EntityMappingParser.java         |  37 ++-
 .../index/impl/EsEntityIndexFactoryImpl.java    |  29 ++-
 .../index/impl/EsIndexBufferConsumerImpl.java   |  28 +--
 .../index/impl/EsIndexCacheImpl.java            |  29 ++-
 .../persistence/index/impl/EsQueryVistor.java   |  50 ++--
 .../persistence/index/impl/FailureMonitor.java  |  30 ++-
 .../index/impl/FailureMonitorImpl.java          |  32 +--
 .../persistence/index/impl/FieldParser.java     |  36 +--
 .../persistence/index/impl/GeoSortFields.java   |  36 +--
 .../index/impl/IndexBufferConsumer.java         |  28 +--
 .../persistence/index/impl/IndexCache.java      |  30 +--
 .../persistence/index/impl/IndexEdgeImpl.java   |  36 +--
 .../index/impl/IndexIdentifierv2Impl.java       |  30 +--
 .../index/impl/IndexRefreshCommandImpl.java     |  30 +--
 .../index/impl/NoOpFilterBuilder.java           |  32 ++-
 .../index/impl/NoOpQueryBuilder.java            |  32 ++-
 .../impl/SearchRequestBuilderStrategy.java      |  30 +--
 .../persistence/index/impl/SortBuilder.java     |  36 +--
 .../EsIndexMappingMigrationPlugin.java          |  30 ++-
 .../index/migration/EsIndexMigrationPlugin.java |   8 +-
 .../index/migration/IndexDataVersions.java      |  30 +--
 .../persistence/index/query/ParsedQuery.java    |  36 +--
 .../index/query/ParsedQueryBuilder.java         |  36 +--
 .../persistence/index/query/SortPredicate.java  |  36 +--
 .../persistence/index/usergrid-mappings.json    |   5 -
 .../persistence/index/impl/EntityIndexTest.java |  13 +-
 .../index/impl/EntityToMapConverterTest.java    |  38 +--
 .../impl/EsIndexMappingMigrationPluginTest.java |  30 +--
 .../persistence/index/impl/EsRunner.java        |  32 +--
 .../persistence/index/impl/GeoPagingTest.java   |  36 +--
 .../index/impl/TestIndexIdentifier.java         |  30 +--
 .../management/AppInfoMigrationPlugin.java      | 234 +++++++++---------
 .../org/apache/usergrid/tools/ExportAdmins.java |  17 +-
 85 files changed, 1773 insertions(+), 1298 deletions(-)
----------------------------------------------------------------------



[29/54] usergrid git commit: Merge branch 'two-dot-o-dev' into usergrid-103-upgrade-jersey

Posted by sn...@apache.org.
Merge branch 'two-dot-o-dev' into usergrid-103-upgrade-jersey


Project: http://git-wip-us.apache.org/repos/asf/usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/usergrid/commit/ed053ede
Tree: http://git-wip-us.apache.org/repos/asf/usergrid/tree/ed053ede
Diff: http://git-wip-us.apache.org/repos/asf/usergrid/diff/ed053ede

Branch: refs/heads/usergrid-1007-shiro-cache
Commit: ed053edef8f0d2066e984043cdc0a6682ebb96b3
Parents: d4e8be8 723ee3a
Author: Dave Johnson <sn...@apache.org>
Authored: Tue Sep 15 08:16:28 2015 -0400
Committer: Dave Johnson <sn...@apache.org>
Committed: Tue Sep 15 08:16:28 2015 -0400

----------------------------------------------------------------------
 .../rx/impl/AllApplicationsObservableImpl.java  | 36 +++-----
 .../corepersistence/CpEntityMapUtilsTest.java   |  4 +-
 .../org/apache/usergrid/persistence/GeoIT.java  | 52 ++++++++++-
 .../migration/MvccEntityDataMigrationImpl.java  | 94 +++++++++++---------
 .../model/entity/MapToEntityConverter.java      |  8 +-
 5 files changed, 119 insertions(+), 75 deletions(-)
----------------------------------------------------------------------



[47/54] usergrid git commit: Merge branch 'two-dot-o-dev' of https://git-wip-us.apache.org/repos/asf/usergrid into two-dot-o-dev

Posted by sn...@apache.org.
Merge branch 'two-dot-o-dev' of https://git-wip-us.apache.org/repos/asf/usergrid into two-dot-o-dev


Project: http://git-wip-us.apache.org/repos/asf/usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/usergrid/commit/a4fa0941
Tree: http://git-wip-us.apache.org/repos/asf/usergrid/tree/a4fa0941
Diff: http://git-wip-us.apache.org/repos/asf/usergrid/diff/a4fa0941

Branch: refs/heads/usergrid-1007-shiro-cache
Commit: a4fa0941aa9d2a3878a7f8d47535018af0ee6655
Parents: 5acb42b 61dd559
Author: Dave Johnson <sn...@apache.org>
Authored: Thu Sep 17 17:48:22 2015 -0400
Committer: Dave Johnson <sn...@apache.org>
Committed: Thu Sep 17 17:48:22 2015 -0400

----------------------------------------------------------------------
 .../EsIndexMappingMigrationPlugin.java          |   2 +-
 .../persistence/index/usergrid-mappings.json    |   5 -
 .../management/AppInfoMigrationPlugin.java      | 234 +++++++++----------
 3 files changed, 117 insertions(+), 124 deletions(-)
----------------------------------------------------------------------



[31/54] usergrid git commit: Fixes incorrect Cassandra range scanning in serialization with min/max values

Posted by sn...@apache.org.
Fixes incorrect Cassandra range scanning in serialization with min/max values


Project: http://git-wip-us.apache.org/repos/asf/usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/usergrid/commit/6233bf0b
Tree: http://git-wip-us.apache.org/repos/asf/usergrid/tree/6233bf0b
Diff: http://git-wip-us.apache.org/repos/asf/usergrid/diff/6233bf0b

Branch: refs/heads/usergrid-1007-shiro-cache
Commit: 6233bf0b23e6f86b0d57607d2dd423599c27e726
Parents: 13d2594
Author: Todd Nine <tn...@apigee.com>
Authored: Tue Sep 15 17:20:24 2015 -0600
Committer: Todd Nine <tn...@apigee.com>
Committed: Tue Sep 15 17:20:24 2015 -0600

----------------------------------------------------------------------
 .../service/ConnectionServiceImpl.java          | 30 +++++-----
 .../service/ConnectionServiceImplTest.java      | 19 ++++---
 .../core/astyanax/MultiRowColumnIterator.java   |  2 +-
 .../graph/impl/GraphManagerImpl.java            |  4 +-
 .../impl/shard/impl/EdgeSearcher.java           | 14 ++++-
 .../impl/ShardedEdgeSerializationImpl.java      | 59 ++++++++++++++------
 .../shard/impl/serialize/EdgeSerializer.java    | 21 ++++++-
 .../persistence/graph/GraphManagerIT.java       |  4 +-
 8 files changed, 105 insertions(+), 48 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/usergrid/blob/6233bf0b/stack/core/src/main/java/org/apache/usergrid/corepersistence/service/ConnectionServiceImpl.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/service/ConnectionServiceImpl.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/service/ConnectionServiceImpl.java
index d60426c..1b36321 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/service/ConnectionServiceImpl.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/service/ConnectionServiceImpl.java
@@ -170,7 +170,7 @@ public class ConnectionServiceImpl implements ConnectionService {
 
                     final SearchByEdgeType searchByEdge =
                         new SimpleSearchByEdgeType( entityId, edgeType, Long.MAX_VALUE,
-                            SearchByEdgeType.Order.ASCENDING, Optional.absent() );
+                            SearchByEdgeType.Order.DESCENDING, Optional.absent() );
 
                     //load edges from the source the with type specified
                     return gm.loadEdgesFromSource( searchByEdge );
@@ -182,21 +182,25 @@ public class ConnectionServiceImpl implements ConnectionService {
                     logger.debug( "Found edge {}, searching for multiple versions of edge", edge );
 
                     final SearchByEdge searchByEdge =
-                        new SimpleSearchByEdge( edge.getSourceNode(), edge.getType(), edge.getTargetNode(),
-                            Long.MAX_VALUE, SearchByEdgeType.Order.ASCENDING, Optional.absent() );
-                    return gm.loadEdgeVersions( searchByEdge );
-                } )
+                        new SimpleSearchByEdge( edge.getSourceNode(), edge.getType(), edge.getTargetNode(), 0,
+                            SearchByEdgeType.Order.ASCENDING, Optional.absent() );
+                    return gm.loadEdgeVersions( searchByEdge )
+                        //skip the first version since it's the one we want to retain
+                        .skip( 1 )
+                            //mark for deletion
+                        .flatMap( edgeToDelete -> {
 
-                    //skip the first version since it's the one we want to retain
-                    // validate there is only 1 version of it, delete anything > than the min
-                .skip( 1 ).flatMap( edgeToDelete -> {
+                            logger.debug( "Deleting edge {}", edgeToDelete );
 
-                    logger.debug( "Deleting edge {}", edgeToDelete );
+                            //mark the edge and ignore the cleanup result
+                            return gm.markEdge( edgeToDelete );
+                        } )
+                            //mark all versions, then on the last, delete them from cass
+                        .flatMap( lastMarkedEdge -> gm.deleteEdge( lastMarkedEdge ) );
+
+
+                    // validate there is only 1 version of it, delete anything > than the min
 
-                    //mark the edge and ignore the cleanup result
-                    return gm.markEdge( edgeToDelete )
-                        //delete the edge
-                        .flatMap( edge -> gm.deleteEdge( edgeToDelete ) );
                 } ).map( deletedEdge -> new ConnectionScope( applicationScope, deletedEdge ) );
         } );
     }

http://git-wip-us.apache.org/repos/asf/usergrid/blob/6233bf0b/stack/core/src/test/java/org/apache/usergrid/corepersistence/service/ConnectionServiceImplTest.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/corepersistence/service/ConnectionServiceImplTest.java b/stack/core/src/test/java/org/apache/usergrid/corepersistence/service/ConnectionServiceImplTest.java
index 152721a..a2c18b1 100644
--- a/stack/core/src/test/java/org/apache/usergrid/corepersistence/service/ConnectionServiceImplTest.java
+++ b/stack/core/src/test/java/org/apache/usergrid/corepersistence/service/ConnectionServiceImplTest.java
@@ -49,6 +49,7 @@ import rx.Observable;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
 
 
 @RunWith( ITRunner.class )
@@ -179,19 +180,20 @@ public class ConnectionServiceImplTest {
 
         final Edge written3 = gm.writeEdge( connection3 ).toBlocking().last();
 
+
         logger.info( "Wrote edge 3 with edge {}", written3 );
 
 
+
+        assertTrue( "Expected edge timestamp to be in order", written1.getTimestamp() <= written2.getTimestamp() );
+        assertTrue( "Expected edge timestamp to be in order", written2.getTimestamp() <= written3.getTimestamp() );
+
         //now run the cleanup
 
         final List<ConnectionScope> deletedConnections =
             connectionService.deDupeConnections( Observable.just( applicationScope ) ).toList().toBlocking().last();
 
-//        assertEquals( "2 edges deleted", 2, deletedConnections.size() );
-
         //check our oldest was deleted first
-
-
         assertEdgeData( written2, deletedConnections.get( 0 ).getEdge() );
 
         assertEdgeData( written3, deletedConnections.get( 1 ).getEdge() );
@@ -221,12 +223,13 @@ public class ConnectionServiceImplTest {
      * @param asserted
      */
     private void assertEdgeData(final Edge expected, final Edge asserted){
-        assertEquals("SourceId the same", expected.getSourceNode(), expected.getTargetNode());
-        assertEquals("TargetId the same", expected.getTargetNode(), expected.getTargetNode());
+        assertEquals("SourceId the same", expected.getSourceNode(), asserted.getSourceNode());
+
+        assertEquals("TargetId the same", expected.getTargetNode(), asserted.getTargetNode());
 
-        assertEquals("Type the same", expected.getType(), expected.getType());
+        assertEquals("Type the same", expected.getType(), asserted.getType());
 
-        assertEquals("Timestamp the same", expected.getTimestamp(), expected.getTimestamp());
+        assertEquals("Timestamp the same", expected.getTimestamp(), asserted.getTimestamp());
 
     }
 }

http://git-wip-us.apache.org/repos/asf/usergrid/blob/6233bf0b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/MultiRowColumnIterator.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/MultiRowColumnIterator.java b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/MultiRowColumnIterator.java
index 667992c..16249ae 100644
--- a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/MultiRowColumnIterator.java
+++ b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/MultiRowColumnIterator.java
@@ -201,7 +201,7 @@ public class MultiRowColumnIterator<R, C, T> implements Iterator<T> {
         final List<T> mergedResults;
 
         if ( containsSingleRowOnly( result ) ) {
-            mergedResults = singleRowResult( result );
+               mergedResults = singleRowResult( result );
         }
         else {
             mergedResults = mergeResults( result, selectSize );

http://git-wip-us.apache.org/repos/asf/usergrid/blob/6233bf0b/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/impl/GraphManagerImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/impl/GraphManagerImpl.java b/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/impl/GraphManagerImpl.java
index 8c64fa1..e119c59 100644
--- a/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/impl/GraphManagerImpl.java
+++ b/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/impl/GraphManagerImpl.java
@@ -217,7 +217,7 @@ public class GraphManagerImpl implements GraphManager {
                 protected Iterator<MarkedEdge> getIterator() {
                     return storageEdgeSerialization.getEdgeVersions( scope,
                         new SimpleSearchByEdge( edge.getSourceNode(), edge.getType(), edge.getTargetNode(),
-                            Long.MAX_VALUE, SearchByEdgeType.Order.ASCENDING, Optional.absent() ) );
+                            Long.MAX_VALUE, SearchByEdgeType.Order.DESCENDING, Optional.absent() ) );
                 }
             } ).filter( markedEdge -> markedEdge.isDeleted() ).flatMap( marked ->
                 //fire our delete listener and wait for the results
@@ -458,7 +458,7 @@ public class GraphManagerImpl implements GraphManager {
                     final long edgeTimestamp = edge.getTimestamp();
 
                     //our edge needs to not be deleted and have a version that's > max Version
-                    if ( edge.isDeleted() || Long.compare( edgeTimestamp, maxVersion ) > 0 ) {
+                    if ( edge.isDeleted() ) {
                         return false;
                     }
 

http://git-wip-us.apache.org/repos/asf/usergrid/blob/6233bf0b/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/serialization/impl/shard/impl/EdgeSearcher.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/serialization/impl/shard/impl/EdgeSearcher.java b/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/serialization/impl/shard/impl/EdgeSearcher.java
index 8bcefbb..4d02ba9 100644
--- a/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/serialization/impl/shard/impl/EdgeSearcher.java
+++ b/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/serialization/impl/shard/impl/EdgeSearcher.java
@@ -1,6 +1,7 @@
 package org.apache.usergrid.persistence.graph.serialization.impl.shard.impl;
 
 
+import java.nio.ByteBuffer;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Comparator;
@@ -13,6 +14,7 @@ import org.apache.usergrid.persistence.core.scope.ApplicationScope;
 import org.apache.usergrid.persistence.graph.Edge;
 import org.apache.usergrid.persistence.graph.MarkedEdge;
 import org.apache.usergrid.persistence.graph.SearchByEdgeType;
+import org.apache.usergrid.persistence.graph.serialization.impl.shard.DirectedEdge;
 import org.apache.usergrid.persistence.graph.serialization.impl.shard.Shard;
 
 import com.google.common.base.Optional;
@@ -107,12 +109,12 @@ public abstract class EdgeSearcher<R, C, T> implements ColumnParser<C, T>, Colum
         if ( last.isPresent() ) {
             C sourceEdge = createColumn( last.get() );
 
-
             rangeBuilder.setStart( sourceEdge, getSerializer() );
+        }else {
+            setTimeScan( rangeBuilder );
         }
 
-
-        setRangeOptions(rangeBuilder);
+        setRangeOptions( rangeBuilder );
 
 
     }
@@ -122,6 +124,7 @@ public abstract class EdgeSearcher<R, C, T> implements ColumnParser<C, T>, Colum
         final boolean reversed = order == SearchByEdgeType.Order.ASCENDING;
 
         rangeBuilder.setReversed( reversed );
+
     }
 
 
@@ -153,6 +156,11 @@ public abstract class EdgeSearcher<R, C, T> implements ColumnParser<C, T>, Colum
      */
     protected abstract C createColumn( final T last );
 
+    /**
+     * Set the time scan into the range builder
+     * @param rangeBuilder
+     */
+    protected abstract void setTimeScan(final RangeBuilder rangeBuilder);
 
     /**
      * Create an edge to return to the user based on the directed edge provided

http://git-wip-us.apache.org/repos/asf/usergrid/blob/6233bf0b/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/serialization/impl/shard/impl/ShardedEdgeSerializationImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/serialization/impl/shard/impl/ShardedEdgeSerializationImpl.java b/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/serialization/impl/shard/impl/ShardedEdgeSerializationImpl.java
index 13f7427..2ef50f5 100644
--- a/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/serialization/impl/shard/impl/ShardedEdgeSerializationImpl.java
+++ b/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/serialization/impl/shard/impl/ShardedEdgeSerializationImpl.java
@@ -21,8 +21,8 @@
 package org.apache.usergrid.persistence.graph.serialization.impl.shard.impl;
 
 
+import java.nio.ByteBuffer;
 import java.util.Collection;
-import java.util.Comparator;
 import java.util.Iterator;
 import java.util.UUID;
 
@@ -54,14 +54,14 @@ import org.apache.usergrid.persistence.graph.serialization.impl.shard.ShardedEdg
 import org.apache.usergrid.persistence.graph.serialization.impl.shard.impl.comparators.DescendingTimestampComparator;
 import org.apache.usergrid.persistence.graph.serialization.impl.shard.impl.comparators.OrderedComparator;
 import org.apache.usergrid.persistence.graph.serialization.impl.shard.impl.comparators
-        .SourceDirectedEdgeDescendingComparator;
+    .SourceDirectedEdgeDescendingComparator;
 import org.apache.usergrid.persistence.graph.serialization.impl.shard.impl.comparators
-        .TargetDirectedEdgeDescendingComparator;
+    .TargetDirectedEdgeDescendingComparator;
+import org.apache.usergrid.persistence.graph.serialization.impl.shard.impl.serialize.EdgeSerializer;
 import org.apache.usergrid.persistence.graph.serialization.util.GraphValidation;
 import org.apache.usergrid.persistence.model.entity.Id;
 
 import com.google.common.base.Function;
-import com.google.common.base.Optional;
 import com.google.inject.Singleton;
 import com.netflix.astyanax.Keyspace;
 import com.netflix.astyanax.MutationBatch;
@@ -388,19 +388,6 @@ public class ShardedEdgeSerializationImpl implements ShardedEdgeSerialization {
                     }
 
 
-                    @Override
-                    public void buildRange( final RangeBuilder builder ) {
-
-
-                        if ( last.isPresent() ) {
-                            super.buildRange( builder );
-                            return;
-                        }
-
-                        //start seeking at a value < our max version
-                        builder.setStart( maxTimestamp );
-                    }
-
 
                     @Override
                     protected EdgeRowKey generateRowKey( long shard ) {
@@ -415,6 +402,13 @@ public class ShardedEdgeSerializationImpl implements ShardedEdgeSerialization {
 
 
                     @Override
+                    protected void setTimeScan( final RangeBuilder rangeBuilder ) {
+                          //start seeking at a value < our max version
+                        rangeBuilder.setStart( maxTimestamp );
+                    }
+
+
+                    @Override
                     protected MarkedEdge createEdge( final Long column, final boolean marked ) {
                         return new SimpleMarkedEdge( sourceId, type, targetId, column.longValue(), marked );
                     }
@@ -472,6 +466,14 @@ public class ShardedEdgeSerializationImpl implements ShardedEdgeSerialization {
 
 
                     @Override
+                    protected void setTimeScan( final RangeBuilder rangeBuilder ) {
+                        final ByteBuffer buffer = EdgeSerializer.INSTANCE.fromTimeRange( maxTimestamp );
+
+                        rangeBuilder.setStart( buffer );
+                    }
+
+
+                    @Override
                     protected MarkedEdge createEdge( final DirectedEdge edge, final boolean marked ) {
                         return new SimpleMarkedEdge( sourceId, type, edge.id, edge.timestamp, marked );
                     }
@@ -526,6 +528,14 @@ public class ShardedEdgeSerializationImpl implements ShardedEdgeSerialization {
 
 
                     @Override
+                    protected void setTimeScan( final RangeBuilder rangeBuilder ) {
+                        final ByteBuffer buffer = EdgeSerializer.INSTANCE.fromTimeRange( maxTimestamp );
+
+                        rangeBuilder.setStart( buffer );
+                    }
+
+
+                    @Override
                     protected MarkedEdge createEdge( final DirectedEdge edge, final boolean marked ) {
                         return new SimpleMarkedEdge( targetId, type, edge.id, edge.timestamp, marked );
                     }
@@ -574,6 +584,14 @@ public class ShardedEdgeSerializationImpl implements ShardedEdgeSerialization {
 
 
                     @Override
+                    protected void setTimeScan( final RangeBuilder rangeBuilder ) {
+                        final ByteBuffer buffer = EdgeSerializer.INSTANCE.fromTimeRange( maxTimestamp );
+
+                        rangeBuilder.setStart( buffer );
+                    }
+
+
+                    @Override
                     protected MarkedEdge createEdge( final DirectedEdge edge, final boolean marked ) {
                         return new SimpleMarkedEdge( edge.id, type, targetId, edge.timestamp, marked );
                     }
@@ -627,6 +645,13 @@ public class ShardedEdgeSerializationImpl implements ShardedEdgeSerialization {
 
 
                     @Override
+                    protected void setTimeScan( final RangeBuilder rangeBuilder ) {
+                        final ByteBuffer buffer = EdgeSerializer.INSTANCE.fromTimeRange( maxTimestamp );
+
+                        rangeBuilder.setStart( buffer );
+                    }
+
+                    @Override
                     protected MarkedEdge createEdge( final DirectedEdge edge, final boolean marked ) {
                         return new SimpleMarkedEdge( edge.id, type, targetId, edge.timestamp, marked );
                     }

http://git-wip-us.apache.org/repos/asf/usergrid/blob/6233bf0b/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/serialization/impl/shard/impl/serialize/EdgeSerializer.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/serialization/impl/shard/impl/serialize/EdgeSerializer.java b/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/serialization/impl/shard/impl/serialize/EdgeSerializer.java
index 590cf35..e652c73 100644
--- a/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/serialization/impl/shard/impl/serialize/EdgeSerializer.java
+++ b/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/serialization/impl/shard/impl/serialize/EdgeSerializer.java
@@ -35,14 +35,16 @@ import com.netflix.astyanax.serializers.LongSerializer;
 
 
 /**
- * Serializes to a source->target edge Note that we cannot set the edge type on de-serialization.  Only the target
- * Id and version.
+ * Serializes to a source->target edge Note that we cannot set the edge type on de-serialization.  Only the target Id
+ * and version.
  */
 public class EdgeSerializer extends AbstractSerializer<DirectedEdge> {
 
     private static final IdColDynamicCompositeSerializer ID_COL_SERIALIZER = IdColDynamicCompositeSerializer.get();
     private static final LongSerializer LONG_SERIALIZER = LongSerializer.get();
 
+    public static final EdgeSerializer INSTANCE = new EdgeSerializer();
+
 
     @Override
     public ByteBuffer toByteBuffer( final DirectedEdge edge ) {
@@ -74,4 +76,19 @@ public class EdgeSerializer extends AbstractSerializer<DirectedEdge> {
 
         return new DirectedEdge( id, timestamp );
     }
+
+
+    /**
+     * Create a scan range that represents the timestamp of the edge
+     * @param timestamp
+     * @return
+     */
+    public ByteBuffer fromTimeRange( final long timestamp ) {
+        DynamicComposite composite = new DynamicComposite();
+
+        composite.addComponent( timestamp, LONG_SERIALIZER );
+
+
+        return composite.serialize();
+    }
 }

http://git-wip-us.apache.org/repos/asf/usergrid/blob/6233bf0b/stack/corepersistence/graph/src/test/java/org/apache/usergrid/persistence/graph/GraphManagerIT.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/graph/src/test/java/org/apache/usergrid/persistence/graph/GraphManagerIT.java b/stack/corepersistence/graph/src/test/java/org/apache/usergrid/persistence/graph/GraphManagerIT.java
index 4b2ffc8..eaded15 100644
--- a/stack/corepersistence/graph/src/test/java/org/apache/usergrid/persistence/graph/GraphManagerIT.java
+++ b/stack/corepersistence/graph/src/test/java/org/apache/usergrid/persistence/graph/GraphManagerIT.java
@@ -2353,7 +2353,7 @@ public class GraphManagerIT {
 
 
         final SearchByEdge searchDescending =
-            new SimpleSearchByEdge( edge1.getSourceNode(), edge1.getType(), edge1.getTargetNode(),Long.MAX_VALUE,
+            new SimpleSearchByEdge( edge1.getSourceNode(), edge1.getType(), edge1.getTargetNode(), Long.MAX_VALUE,
                 SearchByEdgeType.Order.DESCENDING, Optional.<Edge>absent()   );
 
         final Observable<Edge> edgesDescending = gm.loadEdgeVersions( searchDescending );
@@ -2373,7 +2373,7 @@ public class GraphManagerIT {
         //now search ascending
 
         final SearchByEdge searchAscending =
-                    new SimpleSearchByEdge( edge1.getSourceNode(), edge1.getType(), edge1.getTargetNode(),Long.MAX_VALUE,
+                    new SimpleSearchByEdge( edge1.getSourceNode(), edge1.getType(), edge1.getTargetNode(), 0,
                         SearchByEdgeType.Order.ASCENDING, Optional.<Edge>absent()   );
 
         Observable<Edge> edgesAscending = gm.loadEdgeVersions( searchAscending );


[43/54] usergrid git commit: Fixes test

Posted by sn...@apache.org.
Fixes test


Project: http://git-wip-us.apache.org/repos/asf/usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/usergrid/commit/acbf3a17
Tree: http://git-wip-us.apache.org/repos/asf/usergrid/tree/acbf3a17
Diff: http://git-wip-us.apache.org/repos/asf/usergrid/diff/acbf3a17

Branch: refs/heads/usergrid-1007-shiro-cache
Commit: acbf3a17216180f67f0f6c9f390e740efd55b223
Parents: d971ec5
Author: Todd Nine <tn...@apigee.com>
Authored: Thu Sep 17 11:46:45 2015 -0600
Committer: Todd Nine <tn...@apigee.com>
Committed: Thu Sep 17 11:46:45 2015 -0600

----------------------------------------------------------------------
 ...ctMvccEntityDataMigrationV1ToV3ImplTest.java | 34 ++++++++++++++------
 1 file changed, 25 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/usergrid/blob/acbf3a17/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/migration/AbstractMvccEntityDataMigrationV1ToV3ImplTest.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/migration/AbstractMvccEntityDataMigrationV1ToV3ImplTest.java b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/migration/AbstractMvccEntityDataMigrationV1ToV3ImplTest.java
index f51b339..9be979b 100644
--- a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/migration/AbstractMvccEntityDataMigrationV1ToV3ImplTest.java
+++ b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/migration/AbstractMvccEntityDataMigrationV1ToV3ImplTest.java
@@ -30,7 +30,10 @@ import org.apache.usergrid.persistence.collection.MvccEntity;
 import org.apache.usergrid.persistence.collection.guice.TestCollectionModule;
 import org.apache.usergrid.persistence.collection.mvcc.entity.impl.MvccEntityImpl;
 import org.apache.usergrid.persistence.collection.serialization.MvccEntitySerializationStrategy;
+import org.apache.usergrid.persistence.collection.serialization.MvccLogEntrySerializationStrategy;
+import org.apache.usergrid.persistence.collection.serialization.UniqueValueSerializationStrategy;
 import org.apache.usergrid.persistence.collection.serialization.impl.CollectionDataVersions;
+import org.apache.usergrid.persistence.collection.serialization.impl.MvccEntitySerializationStrategyV3Impl;
 import org.apache.usergrid.persistence.core.guice.DataMigrationResetRule;
 import org.apache.usergrid.persistence.core.guice.MigrationManagerRule;
 import org.apache.usergrid.persistence.core.migration.data.DataMigrationManager;
@@ -48,6 +51,7 @@ import org.apache.usergrid.persistence.model.entity.SimpleId;
 import org.apache.usergrid.persistence.model.util.UUIDGenerator;
 
 import com.google.inject.Inject;
+import com.netflix.astyanax.Keyspace;
 import com.netflix.astyanax.connectionpool.exceptions.ConnectionException;
 
 import net.jcip.annotations.NotThreadSafe;
@@ -63,7 +67,8 @@ import static org.junit.Assert.assertTrue;
 @NotThreadSafe
 @RunWith( ITRunner.class )
 @UseModules( { TestCollectionModule.class } )
-public abstract class AbstractMvccEntityDataMigrationV1ToV3ImplTest implements DataMigrationResetRule.DataMigrationManagerProvider {
+public abstract class AbstractMvccEntityDataMigrationV1ToV3ImplTest
+    implements DataMigrationResetRule.DataMigrationManagerProvider {
 
 
     @Inject
@@ -76,11 +81,19 @@ public abstract class AbstractMvccEntityDataMigrationV1ToV3ImplTest implements D
 
 
     @Inject
-    public MvccEntityDataMigrationImpl mvccEntityDataMigrationImpl;
+    public VersionedMigrationSet<MvccEntitySerializationStrategy> versions;
 
 
     @Inject
-    public VersionedMigrationSet<MvccEntitySerializationStrategy> versions;
+    public Keyspace keyspace;
+    @Inject
+    public VersionedMigrationSet<MvccEntitySerializationStrategy> allVersions;
+    @Inject
+    public MvccEntitySerializationStrategyV3Impl mvccEntitySerializationStrategyV3;
+    @Inject
+    public UniqueValueSerializationStrategy uniqueValueSerializationStrategy;
+    @Inject
+    public MvccLogEntrySerializationStrategy mvccLogEntrySerializationStrategy;
 
     /**
      * Rule to do the resets we need
@@ -121,20 +134,26 @@ public abstract class AbstractMvccEntityDataMigrationV1ToV3ImplTest implements D
             Observable.just( new EntityIdScope( scope, entity1.getId() ), new EntityIdScope( scope, entity2.getId() ) );
 
 
+        final MigrationDataProvider<EntityIdScope> migrationProvider = () -> entityIdScope;
+
         final TestProgressObserver progressObserver = new TestProgressObserver();
 
         final CollectionDataVersions startVersion = getSourceVersion();
 
         final MigrationRelationship<MvccEntitySerializationStrategy> tuple =
-                  versions.getMigrationRelationship( startVersion.getVersion() );
+            versions.getMigrationRelationship( startVersion.getVersion() );
 
 
         assertEquals( "Same instance for from", v1Impl.getClass(), tuple.from.getClass() );
         assertEquals( "Same instance for to", v3Impl.getClass(), tuple.to.getClass() );
 
+
+        MvccEntityDataMigrationImpl mvccEntityDataMigrationImpl = new MvccEntityDataMigrationImpl(keyspace, allVersions, mvccEntitySerializationStrategyV3, uniqueValueSerializationStrategy,  mvccLogEntrySerializationStrategy, migrationProvider);
+
+
         //now migration
-        final int newVersion = mvccEntityDataMigrationImpl
-            .migrate( startVersion.getVersion(), progressObserver );
+        final int newVersion =
+            mvccEntityDataMigrationImpl.migrate( startVersion.getVersion(), progressObserver );
 
 
         final CollectionDataVersions expectedVersion = expectedTargetVersion();
@@ -183,19 +202,16 @@ public abstract class AbstractMvccEntityDataMigrationV1ToV3ImplTest implements D
 
     /**
      * Get the expected source mvcc implementation for this test
-     * @return
      */
     protected abstract MvccEntitySerializationStrategy getExpectedSourceImpl();
 
     /**
      * Get the expected target mvcc for this test
-     * @return
      */
     protected abstract MvccEntitySerializationStrategy getExpectedTargetImpl();
 
     /**
      * Get the expected start version
-     * @return
      */
     protected abstract CollectionDataVersions getSourceVersion();
 


[08/54] usergrid git commit: Changes to configure our filters correctly, and numerous other test fixes. Only 7 REST tests are not passing.

Posted by sn...@apache.org.
http://git-wip-us.apache.org/repos/asf/usergrid/blob/eb2aa6ff/stack/rest/src/test/resources/logging.properties
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/resources/logging.properties b/stack/rest/src/test/resources/logging.properties
index a0eca06..ecbbf0c 100644
--- a/stack/rest/src/test/resources/logging.properties
+++ b/stack/rest/src/test/resources/logging.properties
@@ -15,14 +15,15 @@
 # limitations under the License.
 
 # Tweak this file to get more logging out Jersey and other depedencies that use
-# Java Logging instead of our preferred SLF4J via Log4j setup. 
+# Java Logging instead of our preferred SLF4J via Log4j setup.
 
-handlers=java.util.logging.ConsoleHandler
-java.util.logging.ConsoleHandler.level=FINEST
-java.util.logging.SimpleFormatter.format=%4$-7s [%3$s] %5$s%6$s%n
+handlers = org.slf4j.bridge.SLF4JBridgeHandler
+#java.util.logging.ConsoleHandler.level=FINEST
+#java.util.logging.SimpleFormatter.format=%4$-7s [%3$s] %5$s%6$s%n
 
 #All log level details
 .level=INFO
-#org.glassfish.jersey.level=FINE
-#org.glassfish.jersey.tracing.level=FINE
+org.glassfish.jersey.level=FINE
+org.glassfish.jersey.tracing.level=FINE
+
 #com.sun.jersey.level=FINE

http://git-wip-us.apache.org/repos/asf/usergrid/blob/eb2aa6ff/stack/services/pom.xml
----------------------------------------------------------------------
diff --git a/stack/services/pom.xml b/stack/services/pom.xml
index 466bd45..a771b34 100644
--- a/stack/services/pom.xml
+++ b/stack/services/pom.xml
@@ -204,6 +204,12 @@
           <version>2.21</version>
       </dependency>
 
+      <dependency>
+          <groupId>org.glassfish.jersey.media</groupId>
+          <artifactId>jersey-media-json-jackson</artifactId>
+          <version>2.21</version>
+      </dependency>
+
     <!--<dependency>-->
       <!--<groupId>com.sun.jersey</groupId>-->
       <!--<artifactId>jersey-core</artifactId>-->

http://git-wip-us.apache.org/repos/asf/usergrid/blob/eb2aa6ff/stack/services/src/main/java/org/apache/usergrid/security/providers/FoursquareProvider.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/security/providers/FoursquareProvider.java b/stack/services/src/main/java/org/apache/usergrid/security/providers/FoursquareProvider.java
index 738a20f..cdba485 100644
--- a/stack/services/src/main/java/org/apache/usergrid/security/providers/FoursquareProvider.java
+++ b/stack/services/src/main/java/org/apache/usergrid/security/providers/FoursquareProvider.java
@@ -17,8 +17,6 @@
 package org.apache.usergrid.security.providers;
 
 
-import com.fasterxml.jackson.core.type.TypeReference;
-import com.sun.jersey.api.client.WebResource;
 import org.apache.usergrid.management.ManagementService;
 import org.apache.usergrid.persistence.EntityManager;
 import org.apache.usergrid.persistence.Query;
@@ -32,8 +30,6 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import javax.ws.rs.client.ClientBuilder;
-import javax.ws.rs.client.WebTarget;
-import javax.ws.rs.core.GenericType;
 import javax.ws.rs.core.MediaType;
 import java.util.ArrayList;
 import java.util.LinkedHashMap;
@@ -94,7 +90,7 @@ public class FoursquareProvider extends AbstractProvider {
             .queryParam( "v", "20120623" )
             .request()
                 .accept( MediaType.APPLICATION_JSON )
-                .get(Map.class);
+                .get( Map.class );
 
         Map<String, Object> fq_user = ( Map<String, Object> ) ( ( Map<?, ?> ) body.get( "response" ) ).get( "user" );
 

http://git-wip-us.apache.org/repos/asf/usergrid/blob/eb2aa6ff/stack/services/src/test/java/org/apache/usergrid/management/OrganizationIT.java
----------------------------------------------------------------------
diff --git a/stack/services/src/test/java/org/apache/usergrid/management/OrganizationIT.java b/stack/services/src/test/java/org/apache/usergrid/management/OrganizationIT.java
index e0561a2..b48fd77 100644
--- a/stack/services/src/test/java/org/apache/usergrid/management/OrganizationIT.java
+++ b/stack/services/src/test/java/org/apache/usergrid/management/OrganizationIT.java
@@ -62,12 +62,13 @@ public class OrganizationIT {
 
     @Test
     public void testCreateOrganization() throws Exception {
-//        UserInfo user =
-//                setup.getMgmtSvc().createAdminUser( uniqueUsername(), "Ed Anuff", uniqueEmail(), "test", false, false );
-//        assertNotNull( user );
+//     UserInfo user =
+//     setup.getMgmtSvc().createAdminUser( uniqueUsername(), "Ed Anuff", uniqueEmail(), "test", false, false );
+//     assertNotNull( user );
 
         final String orgName =  uniqueOrg();
-        OrganizationOwnerInfo organization = newOrgAppAdminRule.createOwnerAndOrganization( orgName, uniqueUsername(), uniqueEmail(),"Ed Anuff", "test" ); //setup.getMgmtSvc().getOrganizationsForAdminUser( organization.getOwner().getUuid() );
+        OrganizationOwnerInfo organization =
+            newOrgAppAdminRule.createOwnerAndOrganization( orgName, uniqueUsername(), uniqueEmail(),"Ed Anuff", "test" );             //setup.getMgmtSvc().getOrganizationsForAdminUser( organization.getOwner().getUuid() );
         //createOrganization( orgName, user, false );
         assertNotNull( organization );
 
@@ -80,13 +81,15 @@ public class OrganizationIT {
             organization.getOrganization().getUuid());
         assertEquals("wrong number of users", 1, users.size());
 
-        ApplicationInfo applicationInfo = setup.getMgmtSvc().createApplication(organization.getOrganization().getUuid(), "ed-application");
+        ApplicationInfo applicationInfo = setup.getMgmtSvc()
+            .createApplication(organization.getOrganization().getUuid(), "ed-application");
         assertNotNull(applicationInfo.getId());
 
 
         setup.getEntityIndex().refresh(applicationInfo.getId());
 
-        Map<UUID, String> applications = setup.getMgmtSvc().getApplicationsForOrganization( organization.getOrganization().getUuid() );
+        Map<UUID, String> applications = setup.getMgmtSvc()
+            .getApplicationsForOrganization( organization.getOrganization().getUuid() );
         assertEquals( "wrong number of applications", 1, applications.size() );
 
         OrganizationInfo organization2 = setup.getMgmtSvc().getOrganizationForApplication( applicationInfo.getId() );
@@ -100,7 +103,8 @@ public class OrganizationIT {
 
         setup.getEntityIndex().refresh(CpNamingUtils.MANAGEMENT_APPLICATION_ID);
 
-        UserInfo u = setup.getMgmtSvc().verifyAdminUserPasswordCredentials( organization.getOwner().getUuid().toString(), "test" );
+        UserInfo u = setup.getMgmtSvc().verifyAdminUserPasswordCredentials(
+            organization.getOwner().getUuid().toString(), "test" );
         assertNotNull( u );
 
         String token = setup.getMgmtSvc().getAccessTokenForAdminUser( organization.getOwner().getUuid(), 0 );


[52/54] usergrid git commit: Merge branch '2.1-release' of https://git-wip-us.apache.org/repos/asf/usergrid into two-dot-o-dev

Posted by sn...@apache.org.
Merge branch '2.1-release' of https://git-wip-us.apache.org/repos/asf/usergrid into two-dot-o-dev


Project: http://git-wip-us.apache.org/repos/asf/usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/usergrid/commit/327ccc64
Tree: http://git-wip-us.apache.org/repos/asf/usergrid/tree/327ccc64
Diff: http://git-wip-us.apache.org/repos/asf/usergrid/diff/327ccc64

Branch: refs/heads/usergrid-1007-shiro-cache
Commit: 327ccc6479b9cb6d85b52536ded7ec7f2dff2780
Parents: a4fa094 0c12abb
Author: Todd Nine <tn...@apigee.com>
Authored: Fri Sep 18 12:50:57 2015 -0600
Committer: Todd Nine <tn...@apigee.com>
Committed: Fri Sep 18 12:50:57 2015 -0600

----------------------------------------------------------------------
 .../usergrid/corepersistence/CoreModule.java    |  51 +++-
 .../corepersistence/CpRelationManager.java      |  23 +-
 .../asyncevents/AsyncEventService.java          |   2 +
 .../migration/CoreMigration.java                |  45 +---
 .../migration/CoreMigrationPlugin.java          |  38 ++-
 .../migration/DeDupConnectionDataMigration.java |  93 ++++++++
 .../migration/EntityTypeMappingMigration.java   | 104 --------
 .../migration/MigrationModuleVersionPlugin.java |   5 -
 .../corepersistence/migration/Versions.java     |  31 ---
 .../builder/PipelineBuilderFactory.java         |   3 +
 .../service/ConnectionScope.java                |  53 +++++
 .../service/ConnectionService.java              |  10 +
 .../service/ConnectionServiceImpl.java          |  89 ++++++-
 .../corepersistence/util/CpNamingUtils.java     |  13 +-
 .../corepersistence/TestCoreModule.java         |  34 +++
 .../DeDupConnectionDataMigrationTest.java       | 145 ++++++++++++
 .../migration/EntityTypeMappingMigrationIT.java | 125 ----------
 .../service/ConnectionServiceImplTest.java      | 235 +++++++++++++++++++
 stack/core/src/test/resources/log4j.properties  |   6 +-
 .../serialization/impl/SerializationModule.java |   4 +-
 .../migration/CollectionMigrationPlugin.java    |   8 +-
 .../migration/MvccEntityDataMigrationImpl.java  |  10 +-
 ...ctMvccEntityDataMigrationV1ToV3ImplTest.java |  39 +--
 .../migration/data/AbstractMigrationPlugin.java |  17 +-
 .../core/migration/data/DataMigration.java      |  11 +-
 .../migration/data/MigrationDataProvider.java   |   2 +-
 .../core/migration/data/MigrationPlugin.java    |   4 +-
 .../migration/schema/MigrationManagerFig.java   |   1 +
 .../migration/data/TestProgressObserver.java    |  10 +-
 .../persistence/graph/guice/GraphModule.java    |   4 +-
 .../graph/impl/GraphManagerImpl.java            |   4 +-
 .../impl/stage/EdgeDeleteListenerImpl.java      |   4 +-
 .../graph/impl/stage/EdgeDeleteRepairImpl.java  |  61 ++---
 .../impl/TargetIdObservableImpl.java            |  13 +-
 .../impl/migration/EdgeDataMigrationImpl.java   |  12 +-
 .../impl/migration/GraphMigrationPlugin.java    |   8 +-
 .../impl/shard/impl/EdgeSearcher.java           |  14 +-
 .../impl/ShardedEdgeSerializationImpl.java      |  59 +++--
 .../shard/impl/serialize/EdgeSerializer.java    |  21 +-
 .../persistence/graph/GraphManagerIT.java       |  73 +++++-
 .../migration/EdgeDataMigrationImplTest.java    |  59 +++--
 .../persistence/index/guice/IndexModule.java    |   4 +-
 .../index/migration/EsIndexMigrationPlugin.java |   8 +-
 43 files changed, 1038 insertions(+), 517 deletions(-)
----------------------------------------------------------------------



[39/54] usergrid git commit: Fix broken APM test.

Posted by sn...@apache.org.
Fix broken APM test.


Project: http://git-wip-us.apache.org/repos/asf/usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/usergrid/commit/54f61dc0
Tree: http://git-wip-us.apache.org/repos/asf/usergrid/tree/54f61dc0
Diff: http://git-wip-us.apache.org/repos/asf/usergrid/diff/54f61dc0

Branch: refs/heads/usergrid-1007-shiro-cache
Commit: 54f61dc0af54d26b86d229c33f2ede4d74fb66ee
Parents: ed053ed
Author: Dave Johnson <sn...@apache.org>
Authored: Wed Sep 16 12:47:19 2015 -0400
Committer: Dave Johnson <sn...@apache.org>
Committed: Wed Sep 16 12:47:19 2015 -0400

----------------------------------------------------------------------
 .../rest/applications/ApplicationResourceIT.java    | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/usergrid/blob/54f61dc0/stack/rest/src/test/java/org/apache/usergrid/rest/applications/ApplicationResourceIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/ApplicationResourceIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/ApplicationResourceIT.java
index 8a94760..453fe54 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/ApplicationResourceIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/ApplicationResourceIT.java
@@ -36,6 +36,7 @@ import org.slf4j.LoggerFactory;
 
 import javax.ws.rs.ClientErrorException;
 import javax.ws.rs.InternalServerErrorException;
+import javax.ws.rs.NotFoundException;
 import javax.ws.rs.client.Invocation;
 import javax.ws.rs.core.Form;
 import javax.ws.rs.core.MediaType;
@@ -91,7 +92,6 @@ public class ApplicationResourceIT extends AbstractRestIT {
             .queryParam("client_id", appCredentials.getClientId())
             .queryParam("client_secret", appCredentials.getClientSecret())
             .request()
-            .accept(MediaType.APPLICATION_JSON)
             .get(ApiResponse.class);
         //assert that a valid response is returned without error
         assertNotNull(apiResponse);
@@ -741,11 +741,11 @@ public class ApplicationResourceIT extends AbstractRestIT {
         Form payload = new Form();
         payload.param( "grant_type", "client_credentials" );
         payload.param( "client_id", clientId );
-        payload.param("client_secret", clientSecret);
+        payload.param( "client_secret", clientSecret );
 
         //POST the form to the application token endpoint
-        Token apiResponse = this.app().token().getTarget( false).request()
-            .accept(MediaType.APPLICATION_JSON)
+        Token apiResponse = this.app().token().getTarget( false ).request()
+            .accept( MediaType.APPLICATION_JSON )
             .post( javax.ws.rs.client.Entity.form(payload), Token.class);
 
         //Assert that a valid token with a valid TTL is returned
@@ -829,7 +829,8 @@ public class ApplicationResourceIT extends AbstractRestIT {
         assertEquals(604800, ttl);
 
         //retrieve the users collection for the application using the new token
-        ApiResponse response = this.app().collection("users").getTarget(true, token ).request().get(ApiResponse.class);
+        ApiResponse response = this.app().collection( "users" ).getTarget( true, token ).request()
+            .get(ApiResponse.class);
         //assert that we did not receive an error
         assertNull(response.getError());
     }
@@ -856,7 +857,8 @@ public class ApplicationResourceIT extends AbstractRestIT {
         assertEquals(604800, ttl);
 
         //retrieve the users collection for the application using the new token
-        ApiResponse response = this.app().collection("users").getTarget( true, token ).request().get( ApiResponse.class);
+        ApiResponse response = this.app().collection( "users" ).getTarget( true, token ).request()
+            .get( ApiResponse.class);
         //assert that we did not receive an error
         assertNull(response.getError());
     }
@@ -866,7 +868,7 @@ public class ApplicationResourceIT extends AbstractRestIT {
         try {
             Collection collection = this.app().collection("apm/apigeeMobileConfig").get();
             fail();
-        }catch (UniformInterfaceException e){
+        } catch (NotFoundException e){
             Assert.assertEquals(404, e.getResponse().getStatus());
         }
     }


[44/54] usergrid git commit: Fixes issue with incorrectly not rolling version when no app-infos are present.

Posted by sn...@apache.org.
Fixes issue with incorrectly not rolling version when no app-infos are present.


Project: http://git-wip-us.apache.org/repos/asf/usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/usergrid/commit/9294af73
Tree: http://git-wip-us.apache.org/repos/asf/usergrid/tree/9294af73
Diff: http://git-wip-us.apache.org/repos/asf/usergrid/diff/9294af73

Branch: refs/heads/usergrid-1007-shiro-cache
Commit: 9294af73ff1af563fd06d9b5dc6a04e37dc76788
Parents: 65d2608
Author: Todd Nine <tn...@apigee.com>
Authored: Thu Sep 17 11:53:09 2015 -0600
Committer: Todd Nine <tn...@apigee.com>
Committed: Thu Sep 17 11:53:09 2015 -0600

----------------------------------------------------------------------
 .../management/AppInfoMigrationPlugin.java      | 234 +++++++++----------
 1 file changed, 116 insertions(+), 118 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/usergrid/blob/9294af73/stack/services/src/main/java/org/apache/usergrid/management/AppInfoMigrationPlugin.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/management/AppInfoMigrationPlugin.java b/stack/services/src/main/java/org/apache/usergrid/management/AppInfoMigrationPlugin.java
index ff73402..54779b9 100644
--- a/stack/services/src/main/java/org/apache/usergrid/management/AppInfoMigrationPlugin.java
+++ b/stack/services/src/main/java/org/apache/usergrid/management/AppInfoMigrationPlugin.java
@@ -20,11 +20,21 @@
 package org.apache.usergrid.management;
 
 
-import com.google.common.base.Optional;
-import com.google.inject.Inject;
+import java.util.Map;
+import java.util.UUID;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.BeanFactory;
+
 import org.apache.usergrid.corepersistence.util.CpEntityMapUtils;
 import org.apache.usergrid.corepersistence.util.CpNamingUtils;
-import org.apache.usergrid.persistence.*;
+import org.apache.usergrid.persistence.EntityFactory;
+import org.apache.usergrid.persistence.EntityManager;
+import org.apache.usergrid.persistence.EntityManagerFactory;
+import org.apache.usergrid.persistence.EntityRef;
+import org.apache.usergrid.persistence.Schema;
 import org.apache.usergrid.persistence.collection.EntityCollectionManager;
 import org.apache.usergrid.persistence.collection.EntityCollectionManagerFactory;
 import org.apache.usergrid.persistence.core.migration.data.MigrationInfoSerialization;
@@ -42,21 +52,17 @@ import org.apache.usergrid.persistence.graph.impl.SimpleSearchByEdge;
 import org.apache.usergrid.persistence.graph.impl.SimpleSearchByEdgeType;
 import org.apache.usergrid.persistence.model.entity.Entity;
 import org.apache.usergrid.persistence.model.entity.Id;
-import org.apache.usergrid.persistence.model.entity.SimpleId;
 import org.apache.usergrid.utils.UUIDUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.BeanFactory;
-import rx.Observable;
 
-import java.util.HashMap;
-import java.util.Map;
-import java.util.UUID;
-import java.util.concurrent.atomic.AtomicInteger;
+import com.google.common.base.Optional;
+import com.google.inject.Inject;
+
+import rx.Observable;
 
 import static org.apache.usergrid.corepersistence.util.CpNamingUtils.getApplicationScope;
 import static org.apache.usergrid.persistence.Schema.PROPERTY_NAME;
 
+
 /**
  * Migration of appinfos collection to application_info collection.
  *
@@ -68,7 +74,7 @@ public class AppInfoMigrationPlugin implements MigrationPlugin {
     /** Old and deprecated SYSTEM_APP */
     public static final UUID SYSTEM_APP_ID = UUID.fromString( "b6768a08-b5d5-11e3-a495-10ddb1de66c3" );
 
-    private static final Logger logger = LoggerFactory.getLogger(AppInfoMigrationPlugin.class);
+    private static final Logger logger = LoggerFactory.getLogger( AppInfoMigrationPlugin.class );
 
     public static String PLUGIN_NAME = "appinfo-migration";
 
@@ -85,27 +91,23 @@ public class AppInfoMigrationPlugin implements MigrationPlugin {
     final private GraphManagerFactory graphManagerFactory;
     private final ManagementService managementService;
 
+
     @Inject
-    public AppInfoMigrationPlugin(
-        EntityManagerFactory emf,
-        MigrationInfoSerialization migrationInfoSerialization,
-        EntityCollectionManagerFactory entityCollectionManagerFactory,
-        GraphManagerFactory graphManagerFactory,
-        BeanFactory beanFactory) {
+    public AppInfoMigrationPlugin( EntityManagerFactory emf, MigrationInfoSerialization migrationInfoSerialization,
+                                   EntityCollectionManagerFactory entityCollectionManagerFactory,
+                                   GraphManagerFactory graphManagerFactory, BeanFactory beanFactory ) {
 
         this.emf = emf;
         this.migrationInfoSerialization = migrationInfoSerialization;
         this.entityCollectionManagerFactory = entityCollectionManagerFactory;
         this.graphManagerFactory = graphManagerFactory;
-        this.managementService = beanFactory.getBean(ManagementService.class);
+        this.managementService = beanFactory.getBean( ManagementService.class );
     }
 
-    public AppInfoMigrationPlugin(
-        EntityManagerFactory emf,
-        MigrationInfoSerialization migrationInfoSerialization,
-        EntityCollectionManagerFactory entityCollectionManagerFactory,
-        GraphManagerFactory graphManagerFactory,
-        ManagementService managementService) {
+
+    public AppInfoMigrationPlugin( EntityManagerFactory emf, MigrationInfoSerialization migrationInfoSerialization,
+                                   EntityCollectionManagerFactory entityCollectionManagerFactory,
+                                   GraphManagerFactory graphManagerFactory, ManagementService managementService ) {
 
         this.emf = emf;
         this.migrationInfoSerialization = migrationInfoSerialization;
@@ -134,12 +136,12 @@ public class AppInfoMigrationPlugin implements MigrationPlugin {
 
 
     @Override
-    public void run(ProgressObserver observer) {
+    public void run( ProgressObserver observer ) {
 
-        final int version = migrationInfoSerialization.getVersion(getName());
+        final int version = migrationInfoSerialization.getVersion( getName() );
 
-        if (version == getMaxVersion()) {
-            logger.debug("Skipping Migration Plugin: " + getName());
+        if ( version == getMaxVersion() ) {
+            logger.debug( "Skipping Migration Plugin: " + getName() );
             return;
         }
 
@@ -147,80 +149,78 @@ public class AppInfoMigrationPlugin implements MigrationPlugin {
         AtomicInteger count = new AtomicInteger();
         //get old app infos to migrate
         final Observable<Entity> oldAppInfos = getOldAppInfos();
-        oldAppInfos
-            .doOnNext(oldAppInfoEntity -> {
-                try {
-                    migrateAppInfo(oldAppInfoEntity, observer);
+        oldAppInfos.doOnNext( oldAppInfoEntity -> {
+            try {
+                migrateAppInfo( oldAppInfoEntity, observer );
+                count.incrementAndGet();
+            }
+            catch ( Exception e ) {
+                if ( e.getCause() instanceof ApplicationAlreadyExistsException ) {
                     count.incrementAndGet();
-                }catch (Exception e){
-                    if(e.getCause() instanceof ApplicationAlreadyExistsException){
-                        count.incrementAndGet();
-                        logger.info("Application already migrated",oldAppInfoEntity.getId().getUuid());
-                    }else {
-                        logger.error("Failed to migrate app info" + oldAppInfoEntity.getId().getUuid(), e);
-                        throw new RuntimeException(e);
-                    }
+                    logger.info( "Application already migrated", oldAppInfoEntity.getId().getUuid() );
                 }
-
-            })
-            .doOnCompleted(() -> {
-                if(count.get()>0) {
-                    migrationInfoSerialization.setVersion(getName(), getMaxVersion());
-                }else{
-                    logger.error("Failed to migrate any app infos");
+                else {
+                    logger.error( "Failed to migrate app info" + oldAppInfoEntity.getId().getUuid(), e );
+                    throw new RuntimeException( e );
                 }
-                observer.complete();
-            }).toBlocking().lastOrDefault(null);
-
+            }
+        } ).doOnCompleted( () -> {
+            migrationInfoSerialization.setVersion( getName(), getMaxVersion() );
+            observer.complete();
+        } ).toBlocking().lastOrDefault( null );
     }
 
 
-    private void migrateAppInfo( org.apache.usergrid.persistence.model.entity.Entity oldAppInfoEntity, ProgressObserver observer) {
+    private void migrateAppInfo( org.apache.usergrid.persistence.model.entity.Entity oldAppInfoEntity,
+                                 ProgressObserver observer ) {
         // Get appinfos from the Graph, we don't expect many so use iterator
         final EntityManager managementEm = emf.getManagementEntityManager();
 
-        Map oldAppInfoMap = CpEntityMapUtils.toMap(oldAppInfoEntity);
+        Map oldAppInfoMap = CpEntityMapUtils.toMap( oldAppInfoEntity );
 
-        final String name = (String) oldAppInfoMap.get(PROPERTY_NAME);
+        final String name = ( String ) oldAppInfoMap.get( PROPERTY_NAME );
 
         try {
-            final String orgName = name.split("/")[0];
-            final String appName = name.split("/")[1];
-            UUID applicationId = getUuid(oldAppInfoMap,"applicationUuid") ;
-            applicationId = applicationId == null ?  getUuid(oldAppInfoMap,"appUuid") : applicationId ;
+            final String orgName = name.split( "/" )[0];
+            final String appName = name.split( "/" )[1];
+            UUID applicationId = getUuid( oldAppInfoMap, "applicationUuid" );
+            applicationId = applicationId == null ? getUuid( oldAppInfoMap, "appUuid" ) : applicationId;
             //get app info from graph to see if it has been migrated already
-            org.apache.usergrid.persistence.Entity appInfo = getApplicationInfo(applicationId);
-            if (appInfo == null) {
+            org.apache.usergrid.persistence.Entity appInfo = getApplicationInfo( applicationId );
+            if ( appInfo == null ) {
 
-                observer.update(getMaxVersion(), "Created application_info for " + appName);
+                observer.update( getMaxVersion(), "Created application_info for " + appName );
                 // create org->app connections, but not for apps in dummy "usergrid" internal organization
-                if(!orgName.equals("usergrid")) { //avoid management org
+                if ( !orgName.equals( "usergrid" ) ) { //avoid management org
 
-                    EntityRef orgRef = managementEm.getAlias(Group.ENTITY_TYPE, orgName);
+                    EntityRef orgRef = managementEm.getAlias( Group.ENTITY_TYPE, orgName );
                     // create and connect new APPLICATION_INFO oldAppInfo to Organization
-                    managementService.createApplication(orgRef.getUuid(), name, applicationId, null);
+                    managementService.createApplication( orgRef.getUuid(), name, applicationId, null );
                 }
-            } else {
+            }
+            else {
                 //already migrated don't do anything
-                observer.update(getMaxVersion(), "Received existing application_info for " + appName + " don't do anything");
+                observer.update( getMaxVersion(),
+                    "Received existing application_info for " + appName + " don't do anything" );
             }
-
-        } catch (Exception e) {
+        }
+        catch ( Exception e ) {
             String msg = "Exception writing application_info for " + name;
-            logger.error(msg, e);
-            observer.failed(getMaxVersion(), msg);
-            throw new RuntimeException(e);
+            logger.error( msg, e );
+            observer.failed( getMaxVersion(), msg );
+            throw new RuntimeException( e );
         }
-
     }
 
-    private UUID getUuid(Map oldAppInfoMap, String key) {
+
+    private UUID getUuid( Map oldAppInfoMap, String key ) {
         UUID applicationId;
-        Object uuidObject = oldAppInfoMap.get(key);
-        if (uuidObject instanceof UUID) {
-            applicationId = (UUID) uuidObject;
-        } else {
-            applicationId = uuidObject == null ? null : UUIDUtils.tryExtractUUID(uuidObject.toString());
+        Object uuidObject = oldAppInfoMap.get( key );
+        if ( uuidObject instanceof UUID ) {
+            applicationId = ( UUID ) uuidObject;
+        }
+        else {
+            applicationId = uuidObject == null ? null : UUIDUtils.tryExtractUUID( uuidObject.toString() );
         }
         return applicationId;
     }
@@ -231,84 +231,82 @@ public class AppInfoMigrationPlugin implements MigrationPlugin {
      */
     private org.apache.usergrid.persistence.Entity getApplicationInfo( final UUID appId ) throws Exception {
 
-        final ApplicationScope managementAppScope = getApplicationScope(CpNamingUtils.MANAGEMENT_APPLICATION_ID);
-        final EntityCollectionManager managementCollectionManager = entityCollectionManagerFactory.createCollectionManager(managementAppScope);
+        final ApplicationScope managementAppScope = getApplicationScope( CpNamingUtils.MANAGEMENT_APPLICATION_ID );
+        final EntityCollectionManager managementCollectionManager =
+            entityCollectionManagerFactory.createCollectionManager( managementAppScope );
 
-        Observable<Edge> edgesObservable = getApplicationInfoEdges(appId);
+        Observable<Edge> edgesObservable = getApplicationInfoEdges( appId );
         //get the graph for all app infos
-        Observable<org.apache.usergrid.persistence.model.entity.Entity> entityObs =
-            edgesObservable.flatMap(edge -> {
-                final Id appInfoId = edge.getTargetNode();
-                return managementCollectionManager
-                    .load(appInfoId)
-                    .filter( entity ->{
-                        //check for app id
-                        return  entity != null ? entity.getId().getUuid().equals(appId) : false;
-                    });
-            });
+        Observable<org.apache.usergrid.persistence.model.entity.Entity> entityObs = edgesObservable.flatMap( edge -> {
+            final Id appInfoId = edge.getTargetNode();
+            return managementCollectionManager.load( appInfoId ).filter( entity -> {
+                //check for app id
+                return entity != null ? entity.getId().getUuid().equals( appId ) : false;
+            } );
+        } );
 
         // don't expect many applications, so we block
         org.apache.usergrid.persistence.model.entity.Entity applicationInfo =
-            entityObs.toBlocking().lastOrDefault(null);
+            entityObs.toBlocking().lastOrDefault( null );
 
         if ( applicationInfo == null ) {
             return null;
         }
 
-        Class clazz = Schema.getDefaultSchema().getEntityClass(applicationInfo.getId().getType());
+        Class clazz = Schema.getDefaultSchema().getEntityClass( applicationInfo.getId().getType() );
 
-        org.apache.usergrid.persistence.Entity entity = EntityFactory.newEntity(
-            applicationInfo.getId().getUuid(), applicationInfo.getId().getType(), clazz);
+        org.apache.usergrid.persistence.Entity entity =
+            EntityFactory.newEntity( applicationInfo.getId().getUuid(), applicationInfo.getId().getType(), clazz );
 
         entity.setProperties( CpEntityMapUtils.toMap( applicationInfo ) );
 
         return entity;
-
     }
 
 
     /**
      * Use Graph to get old appinfos from the old and deprecated System App.
      */
-    public Observable<org.apache.usergrid.persistence.model.entity.Entity> getOldAppInfos( ) {
+    public Observable<org.apache.usergrid.persistence.model.entity.Entity> getOldAppInfos() {
 
-        final ApplicationScope systemAppScope = getApplicationScope(SYSTEM_APP_ID);
+        final ApplicationScope systemAppScope = getApplicationScope( SYSTEM_APP_ID );
 
         final EntityCollectionManager systemCollectionManager =
-            entityCollectionManagerFactory.createCollectionManager(systemAppScope);
+            entityCollectionManagerFactory.createCollectionManager( systemAppScope );
 
-        final GraphManager gm = graphManagerFactory.createEdgeManager(systemAppScope);
+        final GraphManager gm = graphManagerFactory.createEdgeManager( systemAppScope );
 
-        String edgeType = CpNamingUtils.getEdgeTypeFromCollectionName("appinfos");
+        String edgeType = CpNamingUtils.getEdgeTypeFromCollectionName( "appinfos" );
 
         Id rootAppId = systemAppScope.getApplication();
 
-        final SimpleSearchByEdgeType simpleSearchByEdgeType =  new SimpleSearchByEdgeType(
-            rootAppId, edgeType, Long.MAX_VALUE, SearchByEdgeType.Order.DESCENDING, Optional.absent());
+        final SimpleSearchByEdgeType simpleSearchByEdgeType =
+            new SimpleSearchByEdgeType( rootAppId, edgeType, Long.MAX_VALUE, SearchByEdgeType.Order.DESCENDING,
+                Optional.absent() );
 
         Observable<org.apache.usergrid.persistence.model.entity.Entity> entityObs =
-            gm.loadEdgesFromSource( simpleSearchByEdgeType )
-                .flatMap(edge -> {
-                    final Id appInfoId = edge.getTargetNode();
+            gm.loadEdgesFromSource( simpleSearchByEdgeType ).flatMap( edge -> {
+                final Id appInfoId = edge.getTargetNode();
 
-                    return systemCollectionManager.load(appInfoId)
-                        .filter(entity -> (entity != null));
-                });
+                return systemCollectionManager.load( appInfoId ).filter( entity -> ( entity != null ) );
+            } );
 
         return entityObs;
     }
 
-    public Observable<Edge> getApplicationInfoEdges(final UUID applicationId) {
-        final ApplicationScope managementAppScope = getApplicationScope(CpNamingUtils.MANAGEMENT_APPLICATION_ID);
-        final GraphManager gm = graphManagerFactory.createEdgeManager(managementAppScope);
 
-        String edgeType = CpNamingUtils.getEdgeTypeFromCollectionName(CpNamingUtils.APPLICATION_INFOS);
+    public Observable<Edge> getApplicationInfoEdges( final UUID applicationId ) {
+        final ApplicationScope managementAppScope = getApplicationScope( CpNamingUtils.MANAGEMENT_APPLICATION_ID );
+        final GraphManager gm = graphManagerFactory.createEdgeManager( managementAppScope );
+
+        String edgeType = CpNamingUtils.getEdgeTypeFromCollectionName( CpNamingUtils.APPLICATION_INFOS );
 
 
-        final SimpleSearchByEdge simpleSearchByEdgeType =  new SimpleSearchByEdge(
-            CpNamingUtils.generateApplicationId(CpNamingUtils.MANAGEMENT_APPLICATION_ID), edgeType, CpNamingUtils.generateApplicationId( applicationId ), Long.MAX_VALUE, SearchByEdgeType.Order.DESCENDING,
-            Optional.absent());
+        final SimpleSearchByEdge simpleSearchByEdgeType =
+            new SimpleSearchByEdge( CpNamingUtils.generateApplicationId( CpNamingUtils.MANAGEMENT_APPLICATION_ID ),
+                edgeType, CpNamingUtils.generateApplicationId( applicationId ), Long.MAX_VALUE,
+                SearchByEdgeType.Order.DESCENDING, Optional.absent() );
 
-        return gm.loadEdgeVersions(simpleSearchByEdgeType  );
+        return gm.loadEdgeVersions( simpleSearchByEdgeType );
     }
 }


[34/54] usergrid git commit: change parsing logic to parse uuid as string

Posted by sn...@apache.org.
change parsing logic to parse uuid as string


Project: http://git-wip-us.apache.org/repos/asf/usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/usergrid/commit/e2fe9398
Tree: http://git-wip-us.apache.org/repos/asf/usergrid/tree/e2fe9398
Diff: http://git-wip-us.apache.org/repos/asf/usergrid/diff/e2fe9398

Branch: refs/heads/usergrid-1007-shiro-cache
Commit: e2fe93981ea11d78906eafbecd26f912e3dd6703
Parents: 723ee3a
Author: Shawn Feldman <sf...@apache.org>
Authored: Tue Sep 15 18:18:21 2015 -0600
Committer: Shawn Feldman <sf...@apache.org>
Committed: Tue Sep 15 18:18:21 2015 -0600

----------------------------------------------------------------------
 .../index/impl/EntityMappingParser.java         |  2 +-
 .../persistence/index/impl/EsQueryVistor.java   | 52 ++++++++++----------
 .../persistence/index/impl/EntityIndexTest.java | 12 ++++-
 3 files changed, 38 insertions(+), 28 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/usergrid/blob/e2fe9398/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EntityMappingParser.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EntityMappingParser.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EntityMappingParser.java
index bfefaa9..e328d29 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EntityMappingParser.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EntityMappingParser.java
@@ -72,7 +72,7 @@ public class EntityMappingParser implements FieldParser {
      * Visit al the primitive values
      */
     private void visit( final UUID value ) {
-        fields.add( EntityField.create( fieldStack.peek(), value ) );
+       visit(value.toString());
     }
 
 

http://git-wip-us.apache.org/repos/asf/usergrid/blob/e2fe9398/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsQueryVistor.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsQueryVistor.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsQueryVistor.java
index 7b66c0d..af60ed6 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsQueryVistor.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsQueryVistor.java
@@ -107,7 +107,7 @@ public class EsQueryVistor implements QueryVisitor {
          * We use a left and a right, add our boolean query
          */
         if ( useLeftQuery && useRightQuery ) {
-            final BoolQueryBuilder qb = QueryBuilders.boolQuery().must( leftQuery ).must( rightQuery );
+            final BoolQueryBuilder qb = QueryBuilders.boolQuery().must(leftQuery).must(rightQuery);
             queryBuilders.push( qb );
         }
         //only use the left
@@ -131,7 +131,7 @@ public class EsQueryVistor implements QueryVisitor {
 
         //use left and right
         if ( useLeftFilter && useRightFilter ) {
-            final BoolFilterBuilder fb = FilterBuilders.boolFilter().must( leftFilter ).must( rightFilter );
+            final BoolFilterBuilder fb = FilterBuilders.boolFilter().must(leftFilter).must(rightFilter);
             filterBuilders.push( fb );
         }
 
@@ -166,13 +166,13 @@ public class EsQueryVistor implements QueryVisitor {
 
 
         final boolean useLeftQuery = use( leftQuery );
-        final boolean useRightQuery = use( rightQuery );
+        final boolean useRightQuery = use(rightQuery);
 
         //push our boolean filters
         if ( useLeftQuery && useRightQuery ) {
             //when we issue an OR query in usergrid, 1 or more of the terms should match.  When doing bool query in ES, there is no requirement for more than 1 to match, where as in a filter more than 1 must match
-            final BoolQueryBuilder qb = QueryBuilders.boolQuery().should( leftQuery ).should( rightQuery ).minimumNumberShouldMatch(
-                1 );
+            final BoolQueryBuilder qb = QueryBuilders.boolQuery().should( leftQuery ).should(rightQuery).minimumNumberShouldMatch(
+                1);
             queryBuilders.push( qb );
         }
         else if ( useLeftQuery ) {
@@ -189,7 +189,7 @@ public class EsQueryVistor implements QueryVisitor {
 
 
         final boolean useLeftFilter = use( leftFilter );
-        final boolean useRightFilter = use( rightFilter );
+        final boolean useRightFilter = use(rightFilter);
 
         //use left and right
         if ( useLeftFilter && useRightFilter ) {
@@ -225,7 +225,7 @@ public class EsQueryVistor implements QueryVisitor {
         final QueryBuilder notQueryBuilder = queryBuilders.pop();
 
         if ( use( notQueryBuilder ) ) {
-            final QueryBuilder notQuery = QueryBuilders.boolQuery().mustNot( notQueryBuilder );
+            final QueryBuilder notQuery = QueryBuilders.boolQuery().mustNot(notQueryBuilder);
             queryBuilders.push( notQuery  );
         }
         else {
@@ -307,14 +307,14 @@ public class EsQueryVistor implements QueryVisitor {
 
         final GeoDistanceSortBuilder geoSort =
                 SortBuilders.geoDistanceSort( IndexingUtils.FIELD_LOCATION_NESTED ).unit( DistanceUnit.METERS )
-                            .geoDistance( GeoDistance.SLOPPY_ARC ).point( lat, lon );
+                            .geoDistance(GeoDistance.SLOPPY_ARC).point(lat, lon);
 
-        final TermFilterBuilder sortPropertyName = sortPropertyTermFilter( name );
+        final TermFilterBuilder sortPropertyName = sortPropertyTermFilter(name);
 
         geoSort.setNestedFilter( sortPropertyName );
 
 
-        geoSortFields.addField( name, geoSort );
+        geoSortFields.addField(name, geoSort);
         //no op for query, push
 
 
@@ -329,7 +329,7 @@ public class EsQueryVistor implements QueryVisitor {
 
 
         final RangeFilterBuilder termQuery =
-                FilterBuilders.rangeFilter( getFieldNameForType( value ) ).lt( sanitize( value ) );
+                FilterBuilders.rangeFilter( getFieldNameForType( value ) ).lt(sanitize(value));
 
 
         queryBuilders.push( NoOpQueryBuilder.INSTANCE );
@@ -347,7 +347,7 @@ public class EsQueryVistor implements QueryVisitor {
 
 
         final RangeFilterBuilder termQuery =
-                FilterBuilders.rangeFilter( getFieldNameForType( value ) ).lte( sanitize( value ) );
+                FilterBuilders.rangeFilter( getFieldNameForType( value ) ).lte(sanitize(value));
 
 
         queryBuilders.push( NoOpQueryBuilder.INSTANCE );
@@ -362,8 +362,8 @@ public class EsQueryVistor implements QueryVisitor {
         final Object value = op.getLiteral().getValue();
 
         //special case so we support our '*' char with wildcard
-        if ( value instanceof String ) {
-            final String stringValue = (( String ) value).toLowerCase().trim();
+        if ( value instanceof String || value instanceof UUID ) {
+            final String stringValue = (value.toString()).toLowerCase().trim();
 
             // or field is just a string that does need a prefix us a query
             if ( stringValue.contains( "*" ) ) {
@@ -390,7 +390,7 @@ public class EsQueryVistor implements QueryVisitor {
         // assume all other types need prefix
 
         final TermFilterBuilder termQuery =
-                FilterBuilders.termFilter( getFieldNameForType( value ), sanitize( value ) );
+                FilterBuilders.termFilter(getFieldNameForType(value), sanitize(value));
 
         filterBuilders.push( fieldNameTerm( name, termQuery ) );
 
@@ -405,7 +405,7 @@ public class EsQueryVistor implements QueryVisitor {
 
 
         final RangeFilterBuilder rangeQuery =
-                FilterBuilders.rangeFilter( getFieldNameForType( value ) ).gt( sanitize( value ) );
+                FilterBuilders.rangeFilter( getFieldNameForType( value ) ).gt(sanitize(value));
 
         filterBuilders.push( fieldNameTerm( name, rangeQuery ) );
 
@@ -420,9 +420,9 @@ public class EsQueryVistor implements QueryVisitor {
 
 
         final RangeFilterBuilder rangeQuery =
-                FilterBuilders.rangeFilter( getFieldNameForType( value ) ).gte( sanitize( value ) );
+                FilterBuilders.rangeFilter( getFieldNameForType( value ) ).gte(sanitize(value));
 
-        filterBuilders.push( fieldNameTerm( name, rangeQuery ) );
+        filterBuilders.push(fieldNameTerm(name, rangeQuery));
 
         queryBuilders.push( NoOpQueryBuilder.INSTANCE );
     }
@@ -474,12 +474,12 @@ public class EsQueryVistor implements QueryVisitor {
 
         final BoolQueryBuilder booleanQuery = QueryBuilders.boolQuery();
 
-        booleanQuery.must( QueryBuilders.termQuery( IndexingUtils.FIELD_NAME_NESTED, fieldName ) );
+        booleanQuery.must( QueryBuilders.termQuery(IndexingUtils.FIELD_NAME_NESTED, fieldName) );
 
         booleanQuery.must( fieldValueQuery );
 
 
-        return QueryBuilders.nestedQuery( IndexingUtils.ENTITY_FIELDS, booleanQuery );
+        return QueryBuilders.nestedQuery(IndexingUtils.ENTITY_FIELDS, booleanQuery);
     }
 
 
@@ -503,7 +503,11 @@ public class EsQueryVistor implements QueryVisitor {
      * Get the field name for the primitive type
      */
     private String getFieldNameForType( final Object object ) {
-        if ( object instanceof String ) {
+        if ( object instanceof String) {
+            return IndexingUtils.FIELD_STRING_NESTED;
+        }
+
+        if(object instanceof UUID){
             return IndexingUtils.FIELD_STRING_NESTED;
         }
 
@@ -521,10 +525,6 @@ public class EsQueryVistor implements QueryVisitor {
         }
 
 
-        if ( object instanceof UUID ) {
-            return IndexingUtils.FIELD_UUID_NESTED;
-        }
-
 
         throw new UnsupportedOperationException(
                 "Unkown search type of " + object.getClass().getName() + " encountered" );
@@ -540,7 +540,7 @@ public class EsQueryVistor implements QueryVisitor {
         }
 
         if ( input instanceof UUID ) {
-            return input.toString();
+            return  input.toString() ;
         }
 
         return input;

http://git-wip-us.apache.org/repos/asf/usergrid/blob/e2fe9398/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EntityIndexTest.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EntityIndexTest.java b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EntityIndexTest.java
index 34256ca..7aa97b1 100644
--- a/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EntityIndexTest.java
+++ b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EntityIndexTest.java
@@ -127,11 +127,13 @@ public class EntityIndexTest extends BaseIT {
         EntityIndexBatch batch = entityIndex.createBatch();
 
 
+        UUID uuid = UUID.randomUUID();
         Entity entity1 = new Entity( entityType );
         EntityUtils.setVersion(entity1, UUIDGenerator.newTimeUUID());
-        entity1.setField( new UUIDField( IndexingUtils.ENTITY_ID_FIELDNAME, UUID.randomUUID() ) );
+        entity1.setField(new UUIDField(IndexingUtils.ENTITY_ID_FIELDNAME, UUID.randomUUID()));
         entity1.setField( new StringField( "testfield", "test" ) );
         entity1.setField(new IntegerField("ordinal", 0));
+        entity1.setField(new UUIDField("testuuid",uuid));
 
 
         batch.index( indexEdge, entity1 );
@@ -176,6 +178,14 @@ public class EntityIndexTest extends BaseIT {
         //check the id and version
         assertEquals( entity2.getId(), candidate2.getId() );
         assertEquals( entity2.getVersion(), candidate2.getVersion() );
+
+        candidateResults =
+            entityIndex.search( indexEdge, searchTypes, "select * where testuuid = '"+uuid+"'", 100, 0 );
+        assertEquals(entity1.getId(),candidateResults.get(0).getId());
+
+        candidateResults =
+            entityIndex.search( indexEdge, searchTypes, "select * where testuuid = "+uuid, 100, 0 );
+        assertEquals(entity1.getId(),candidateResults.get(0).getId());
     }
 
 


[17/54] usergrid git commit: Merge branch 'two-dot-o-dev' into usergrid-103-upgrade-jersey

Posted by sn...@apache.org.
Merge branch 'two-dot-o-dev' into usergrid-103-upgrade-jersey

Conflicts:
	stack/rest/src/main/java/org/apache/usergrid/rest/SystemResource.java
	stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/applications/ApplicationResource.java
	stack/rest/src/test/java/org/apache/usergrid/rest/SystemResourceIT.java
	stack/rest/src/test/java/org/apache/usergrid/rest/management/ManagementResourceIT.java
	stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/NamedResource.java
	stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/SetupResource.java
	stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/SystemResource.java


Project: http://git-wip-us.apache.org/repos/asf/usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/usergrid/commit/1f77ca16
Tree: http://git-wip-us.apache.org/repos/asf/usergrid/tree/1f77ca16
Diff: http://git-wip-us.apache.org/repos/asf/usergrid/diff/1f77ca16

Branch: refs/heads/usergrid-1007-shiro-cache
Commit: 1f77ca167b29b2ab847b8e1e0dae09332993bdd1
Parents: 3749e74 bc3ce1b
Author: Dave Johnson <sn...@apache.org>
Authored: Tue Sep 8 17:05:47 2015 -0400
Committer: Dave Johnson <sn...@apache.org>
Committed: Tue Sep 8 17:05:47 2015 -0400

----------------------------------------------------------------------
 README.md                                       |   3 +-
 portal/bower.json                               |   2 +-
 portal/js/data/data-controller.js               |   1 -
 portal/js/global/page-controller.js             |   3 +-
 portal/js/global/ug-service.js                  |  19 +-
 portal/js/login/login-controller.js             |   5 +
 portal/package.json                             |   2 +-
 stack/awscluster/gatling-cluster-cf.json        |   2 +-
 .../src/main/groovy/configure_usergrid.groovy   |   5 +-
 .../main/resources/usergrid-default.properties  |  67 +++---
 .../src/test/resources/usergrid-test.properties |   8 +-
 .../usergrid/corepersistence/CoreModule.java    |  18 +-
 .../corepersistence/CpEntityManager.java        |  14 +-
 .../corepersistence/CpEntityManagerFactory.java |  20 +-
 .../usergrid/corepersistence/CpSetup.java       |   3 +-
 .../asyncevents/AmazonAsyncEventService.java    |   4 +-
 .../index/ApplicationIndexLocationStrategy.java |   3 +-
 .../corepersistence/index/CoreIndexFig.java     |  13 +-
 .../index/ManagementIndexLocationStrategy.java  |   9 +-
 .../results/EntityQueryExecutor.java            |   3 +-
 .../service/AggregationService.java             |  64 +++++
 .../service/AggregationServiceFactory.java      |  27 +++
 .../service/AggregationServiceImpl.java         | 114 +++++++++
 .../service/ApplicationService.java             |  32 +++
 .../service/ApplicationServiceImpl.java         | 134 +++++++++++
 .../corepersistence/util/CpNamingUtils.java     |   2 +-
 .../apache/usergrid/count/SimpleBatcher.java    |   2 +-
 .../usergrid/persistence/AbstractEntity.java    |  22 +-
 .../org/apache/usergrid/persistence/Entity.java |   9 +-
 .../persistence/EntityManagerFactory.java       |  10 +
 .../org/apache/usergrid/persistence/Query.java  |   4 +-
 .../usergrid/persistence/cassandra/Setup.java   |  14 +-
 .../main/resources/usergrid-core-context.xml    |   6 +-
 .../java/org/apache/usergrid/Application.java   |   7 +
 .../org/apache/usergrid/CoreApplication.java    |   4 +
 .../java/org/apache/usergrid/CoreITSetup.java   |   3 +
 .../org/apache/usergrid/CoreITSetupImpl.java    |   6 +
 .../corepersistence/AggregationServiceTest.java |  79 +++++++
 .../corepersistence/CpEntityMapUtilsTest.java   |  81 +++++++
 .../corepersistence/StaleIndexCleanupTest.java  |  13 +-
 .../corepersistence/index/IndexNamingTest.java  |  23 +-
 .../persistence/ApplicationServiceIT.java       |  99 ++++++++
 .../usergrid/persistence/CoreSchemaManager.java |   2 +-
 .../usergrid/persistence/EntityManagerIT.java   |   8 +-
 .../apache/usergrid/persistence/IndexIT.java    |   6 +-
 .../cassandra/EntityManagerFactoryImplIT.java   |   2 +-
 .../resources/usergrid-custom-test.properties   |   6 +-
 .../usergrid-scheduler-test.properties          |   2 +
 .../persistence/collection/MvccEntity.java      |   8 +
 .../mvcc/entity/impl/MvccEntityImpl.java        |  30 ++-
 .../collection/mvcc/stage/delete/MarkStart.java |   2 +-
 .../serialization/SerializationFig.java         |   2 +-
 .../MvccEntitySerializationStrategyImpl.java    |   4 +-
 .../MvccEntitySerializationStrategyV3Impl.java  |  31 ++-
 ...ccEntitySerializationStrategyV3ImplTest.java |   1 -
 .../src/test/resources/dynamic-test.properties  |   3 +
 .../src/test/resources/usergrid-CHOP.properties |   3 +
 .../src/test/resources/usergrid-UNIT.properties |   3 +
 .../src/test/resources/usergrid.properties      |   3 +-
 .../persistence/core/astyanax/CassandraFig.java |   2 +-
 .../core/executor/TaskExecutorFactory.java      |  64 ++++-
 .../persistence/core/guice/CommonModule.java    |   2 +
 .../core/guice/SettingsValidationCluster.java   |  26 +++
 .../persistence/core/guicyfig/ClusterFig.java   |  14 +-
 .../guice/SettingsValidationClusterTest.java    |  39 ++++
 .../src/test/resources/usergrid-UNIT.properties |   3 +
 .../src/test/resources/usergrid.properties      |   3 +-
 .../graph/impl/SimpleSearchEdgeType.java        |   4 +-
 .../graph/impl/SimpleSearchIdType.java          |   3 +-
 .../shard/impl/ShardGroupCompactionImpl.java    |   2 +-
 .../persistence/graph/GraphManagerIT.java       |   5 +-
 .../graph/test/util/EdgeTestUtils.java          |   2 +-
 .../src/test/resources/usergrid-AWS.properties  |   2 +
 .../src/test/resources/usergrid-CHOP.properties |   3 +
 .../test/resources/usergrid-SHARD.properties    |   3 +
 .../src/test/resources/usergrid-UNIT.properties |   3 +
 .../src/test/resources/usergrid.properties      |   3 +-
 .../persistence/model/entity/Entity.java        |   3 +
 .../model/entity/EntityToMapConverter.java      |   5 +-
 .../model/entity/MapToEntityConverter.java      |  19 +-
 .../model/field/value/EntityObject.java         |  10 +
 stack/corepersistence/queryindex/pom.xml        |   7 +
 .../usergrid/persistence/index/EntityIndex.java |  56 +++--
 .../usergrid/persistence/index/IndexFig.java    |  13 +-
 .../persistence/index/guice/IndexModule.java    |   6 +-
 .../index/impl/EntityToMapConverter.java        |   5 +-
 .../index/impl/EsEntityIndexImpl.java           |  51 +++-
 .../persistence/index/impl/IndexingUtils.java   |   2 +
 .../EsIndexMappingMigrationPlugin.java          | 148 ++++++++++++
 .../persistence/index/usergrid-mappings.json    |   5 +
 .../persistence/index/impl/EntityIndexTest.java |  87 +++++--
 .../impl/EsIndexMappingMigrationPluginTest.java |  64 +++++
 .../src/test/resources/dynamic-test.properties  |   2 +
 .../src/test/resources/usergrid-CHOP.properties |   3 +
 .../src/test/resources/usergrid-UNIT.properties |   5 +-
 .../src/test/resources/usergrid.properties      |   3 +-
 .../usergrid/persistence/queue/QueueFig.java    |  27 ++-
 .../usergrid/persistence/queue/QueueScope.java  |   8 +-
 .../queue/impl/SNSQueueManagerImpl.java         | 124 +++++-----
 .../persistence/queue/QueueManagerTest.java     |   2 +-
 .../resources/usergrid-standalone.properties    |   5 +-
 stack/loadtests/.gitignore                      |   1 +
 stack/loadtests/README.md                       | 234 +++++++++++++++----
 stack/loadtests/pom.xml                         |  13 +-
 .../runAuditGetAllAppCollectionEntities.sh      |  68 ++++++
 .../loadtests/runAuditGetCollectionEntities.sh  |   1 +
 .../runAuditVerifyCollectionEntities.sh         |   1 +
 stack/loadtests/runCollectionQueryTest.sh       |   3 +-
 .../runCustomInjectRandomEntityByUuidTest.sh    |   1 +
 stack/loadtests/runDeleteEntities.sh            |   1 +
 .../loadtests/runGetEntitiesByNameSequential.sh |   1 +
 stack/loadtests/runGetEntitiesByUuid.sh         |  92 ++++++++
 stack/loadtests/runLoadEntities.sh              |   1 +
 .../loadtests/runLoadLargeMultiFieldEntities.sh | 107 +++++++++
 stack/loadtests/runLoadNoNameEntities.sh        |   1 +
 stack/loadtests/runLoadSortableEntities.sh      |   3 +-
 stack/loadtests/runOrgAppSetup.sh               |  88 +++++++
 .../loadtests/runRandomEntityByNameQueryTest.sh |  91 ++++++++
 stack/loadtests/runRandomEntityByNameTest.sh    |   5 +-
 stack/loadtests/runRandomEntityByUuidTest.sh    |  84 -------
 stack/loadtests/runUpdateEntities.sh            |   1 +
 stack/loadtests/runtests.sh                     | 120 ----------
 stack/loadtests/runtests_deprecated.sh          | 120 ++++++++++
 .../datagenerators/EntityDataGenerator.scala    |  19 +-
 .../datagenerators/FeederGenerator.scala        |   8 +-
 .../usergrid/enums/ConfigProperties.scala       |  27 ++-
 .../usergrid/enums/CsvFeedPatternType.scala     |  30 +++
 .../org/apache/usergrid/enums/EntityType.scala  |   3 +-
 .../apache/usergrid/enums/ScenarioType.scala    |   3 +-
 .../org/apache/usergrid/helpers/Headers.scala   |  63 +++++
 .../org/apache/usergrid/helpers/Setup.scala     |  39 +++-
 .../org/apache/usergrid/helpers/Utils.scala     |   3 +-
 .../scenarios/ApplicationScenarios.scala        |   3 +-
 .../usergrid/scenarios/AuditScenarios.scala     |  23 +-
 .../scenarios/ConnectionScenarios.scala         |   3 +-
 .../usergrid/scenarios/DeviceScenarios.scala    |   3 +-
 .../scenarios/EntityCollectionScenarios.scala   |  21 +-
 .../usergrid/scenarios/EntityScenarios.scala    |   2 +-
 .../usergrid/scenarios/GeoScenarios.scala       |   4 +-
 .../scenarios/NotificationScenarios.scala       |   3 +-
 .../usergrid/scenarios/NotifierScenarios.scala  |   3 +-
 .../scenarios/OrganizationScenarios.scala       |   3 +-
 .../usergrid/scenarios/TokenScenarios.scala     |   2 +-
 .../usergrid/scenarios/UserScenarios.scala      |   4 +-
 .../org/apache/usergrid/settings/Headers.scala  |  62 -----
 .../org/apache/usergrid/settings/Settings.scala |  75 +++++-
 .../usergrid/simulations/AuditSimulation.scala  |   6 +-
 .../simulations/ConfigurableSimulation.scala    |   3 +-
 .../simulations/CustomInjectionSimulation.scala |   2 +-
 .../simulations/deprecated/AppSimulation.scala  |   2 +-
 .../deprecated/ConnectionsSimulation.scala      |   2 +-
 .../deprecated/DeleteUsersSimulation.scala      |   2 +-
 .../deprecated/GetEntitySimulation.scala        |   2 +-
 .../deprecated/GetUserPagesSimulation.scala     |   2 +-
 .../deprecated/GetUsersSimulation.scala         |   2 +-
 .../deprecated/PostCustomEntitySimulation.scala |   2 +-
 .../deprecated/PostUsersSimulation.scala        |   2 +-
 .../PushNotificationTargetUserSimulation.scala  |   2 +-
 .../deprecated/PutCustomEntitySimulation.scala  |   2 +-
 .../deprecated/PutUsersSimulation.scala         |   2 +-
 .../deprecated/SetupSimulation.scala            |   2 +-
 stack/loadtests/src/test/resources/gatling.conf |   6 +-
 .../src/test/resources/logback-test.xml         |   2 +-
 stack/loadtests/src/test/resources/logback.xml  |   2 +-
 stack/loadtests/src/test/scala/Engine.scala     |   5 +-
 .../src/test/scala/IDEPathHelper.scala          |  13 +-
 stack/loadtests/src/test/scala/Recorder.scala   |   8 +-
 stack/loadtests/testConfig.sh                   |   5 +
 stack/pom.xml                                   |   1 +
 .../resources/usergrid-custom-test.properties   |   5 +-
 .../usergrid/rest/ApplicationsResource.java     |  99 ++++++++
 .../apache/usergrid/rest/DatabaseResource.java  |  99 ++++++++
 .../apache/usergrid/rest/SystemResource.java    |  51 ++--
 .../rest/applications/ServiceResource.java      |  24 +-
 .../applications/ApplicationResource.java       |  70 +++++-
 .../resources/usergrid-rest-deploy-context.xml  |   2 +-
 .../usergrid/rest/CollectionMetadataIT.java     | 141 +++++++++++
 .../apache/usergrid/rest/SystemResourceIT.java  |  47 +++-
 .../collection/users/UserResourceIT.java        |   3 +-
 .../rest/management/ManagementResourceIT.java   |  44 +++-
 .../resource/endpoints/BoostrapResource.java    |  49 ++++
 .../resource/endpoints/DatabaseResource.java    |   4 +
 .../test/resource/endpoints/NamedResource.java  |  27 ++-
 .../test/resource/endpoints/SetupResource.java  |   2 +-
 .../test/resource/endpoints/SystemResource.java |  32 ++-
 .../rest/test/resource/model/Entity.java        |   2 +
 .../test/resource/model/QueryParameters.java    |   8 +
 .../resources/corepersistence-UNIT.properties   |   3 +
 .../resources/usergrid-custom-test.properties   |   4 +-
 stack/scripts/migrate_entity_data.py            |  42 +++-
 .../management/AccountCreationProps.java        |   2 -
 .../usergrid/management/ManagementService.java  |  15 ++
 .../cassandra/ManagementServiceImpl.java        | 219 ++++++++++-------
 .../usergrid/services/AbstractService.java      |  28 ++-
 .../usergrid/services/ServiceManager.java       |  14 +-
 .../usergrid/services/ServiceRequest.java       |  50 ++--
 .../notifications/ApplicationQueueManager.java  |   2 +-
 .../notifications/NotificationsService.java     |   5 +-
 .../services/notifications/QueueListener.java   |   6 +-
 .../usergrid/services/queues/QueueListener.java |   2 +-
 .../resources/usergrid-custom-test.properties   |   3 +-
 201 files changed, 3626 insertions(+), 916 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/usergrid/blob/1f77ca16/stack/pom.xml
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/usergrid/blob/1f77ca16/stack/rest/src/main/java/org/apache/usergrid/rest/ApplicationsResource.java
----------------------------------------------------------------------
diff --cc stack/rest/src/main/java/org/apache/usergrid/rest/ApplicationsResource.java
index 0000000,86adbcc..b702276
mode 000000,100644..100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/ApplicationsResource.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/ApplicationsResource.java
@@@ -1,0 -1,100 +1,99 @@@
+ /*
+  *
+  *  * Licensed to the Apache Software Foundation (ASF) under one or more
+  *  *  contributor license agreements.  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.  For additional information regarding
+  *  * copyright in this work, please see the NOTICE file in the top level
+  *  * directory of this distribution.
+  *
+  */
+ package org.apache.usergrid.rest;
+ 
 -import com.sun.jersey.api.json.JSONWithPadding;
 -import org.apache.usergrid.persistence.Entity;
++import com.fasterxml.jackson.jaxrs.json.annotation.JSONP;
+ import org.apache.usergrid.persistence.EntityManager;
+ import org.apache.usergrid.rest.security.annotations.RequireSystemAccess;
+ import org.slf4j.Logger;
+ import org.slf4j.LoggerFactory;
+ import org.springframework.context.annotation.Scope;
+ import org.springframework.stereotype.Component;
+ 
+ import javax.ws.rs.*;
+ import javax.ws.rs.core.Context;
+ import javax.ws.rs.core.MediaType;
+ import javax.ws.rs.core.UriInfo;
+ import java.util.HashMap;
+ import java.util.Map;
+ import java.util.UUID;
+ import java.util.concurrent.atomic.AtomicInteger;
+ 
+ /**
+  * Classy class class.
+  */
+ @Component
+ @Scope( "singleton" )
+ @Produces( {
+     MediaType.APPLICATION_JSON, "application/javascript", "application/x-javascript", "text/ecmascript",
+     "application/ecmascript", "text/jscript"
+ } )
+ public class ApplicationsResource extends AbstractContextResource {
+ 
+     private static final Logger logger = LoggerFactory.getLogger(ApplicationsResource.class);
+ 
+ 
+     public ApplicationsResource() {
 -
+         logger.info( "ApplicationsResource initialized" );
 -    } {
 -
+     }
+ 
+     @RequireSystemAccess
+     @DELETE
++    @JSONP
+     @Path( "{applicationId}" )
 -    public JSONWithPadding clearApplication( @Context UriInfo ui,
 -                                             @PathParam("applicationId") UUID applicationId,
 -                                             @QueryParam( "confirmApplicationName" ) String confirmApplicationName,
 -                                             @QueryParam( "callback" ) @DefaultValue( "callback" ) String callback )
++    public ApiResponse clearApplication( @Context UriInfo ui,
++        @PathParam("applicationId") UUID applicationId,
++        @QueryParam( "confirmApplicationName" ) String confirmApplicationName,
++        @QueryParam( "callback" ) @DefaultValue( "callback" ) String callback )
++
+         throws Exception {
+ 
+         if(confirmApplicationName == null){
+             throw new IllegalArgumentException("please make add a QueryString for confirmApplicationName");
+         }
+ 
+         final EntityManager em =  emf.getEntityManager(applicationId);
+         final String name =  em.getApplication().getApplicationName();
+         if(!name.toLowerCase().equals(confirmApplicationName.toLowerCase())){
 -            throw new IllegalArgumentException("confirmApplicationName: " + confirmApplicationName + " does not equal " + name);
++            throw new IllegalArgumentException(
++                "confirmApplicationName: " + confirmApplicationName + " does not equal " + name);
+         }
+         final ApiResponse response = createApiResponse();
+         response.setAction( "clear application" );
+ 
+         logger.info( "clearing up application" );
+         final AtomicInteger itemsDeleted = new AtomicInteger(0);
+         try {
+             management.deleteAllEntities(applicationId)
+                 .count()
+                 .doOnNext(count -> itemsDeleted.set(count))
+                 .toBlocking().lastOrDefault(0);
+         }
+         catch ( Exception e ) {
+             logger.error( "Unable to delete all items, deleted: " + itemsDeleted.get(), e );
+         }
+         Map<String,Object> data = new HashMap<>();
+         data.put("count",itemsDeleted.get());
+         response.setData(data);
+         response.setSuccess();
 -        return new JSONWithPadding( response, callback );
++        return response;
+     }
+ 
+ }

http://git-wip-us.apache.org/repos/asf/usergrid/blob/1f77ca16/stack/rest/src/main/java/org/apache/usergrid/rest/DatabaseResource.java
----------------------------------------------------------------------
diff --cc stack/rest/src/main/java/org/apache/usergrid/rest/DatabaseResource.java
index 0000000,a8c5fee..2b13e81
mode 000000,100644..100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/DatabaseResource.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/DatabaseResource.java
@@@ -1,0 -1,98 +1,99 @@@
+ /*
+  * 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.usergrid.rest;
+ 
+ 
+ import javax.ws.rs.DefaultValue;
+ import javax.ws.rs.PUT;
+ import javax.ws.rs.Path;
+ import javax.ws.rs.Produces;
+ import javax.ws.rs.QueryParam;
+ import javax.ws.rs.core.Context;
+ import javax.ws.rs.core.MediaType;
+ import javax.ws.rs.core.UriInfo;
+ 
++import com.fasterxml.jackson.jaxrs.json.annotation.JSONP;
+ import org.slf4j.Logger;
+ import org.slf4j.LoggerFactory;
+ import org.springframework.context.annotation.Scope;
+ import org.springframework.stereotype.Component;
+ 
+ import org.apache.usergrid.rest.security.annotations.RequireSystemAccess;
+ 
 -import com.sun.jersey.api.json.JSONWithPadding;
 -
+ 
+ @Component
+ @Scope( "singleton" )
+ @Produces( {
+     MediaType.APPLICATION_JSON, "application/javascript", "application/x-javascript", "text/ecmascript",
+     "application/ecmascript", "text/jscript"
+ } )
+ public class DatabaseResource extends AbstractContextResource {
+ 
+     private static final Logger logger = LoggerFactory.getLogger( DatabaseResource.class );
+ 
+ 
+     public DatabaseResource() {
+         logger.info( "DatabaseResource initialized" );
+     }
+ 
+ 
+     @RequireSystemAccess
+     @PUT
++    @JSONP
+     @Path( "setup" )
 -    public JSONWithPadding runDatabaseSetup( @Context UriInfo ui,
 -                                             @QueryParam( "callback" ) @DefaultValue( "callback" ) String callback )
++    public ApiResponse runDatabaseSetup( @Context UriInfo ui,
++        @QueryParam( "callback" ) @DefaultValue( "callback" ) String callback )
+         throws Exception {
+ 
+         ApiResponse response = createApiResponse();
+         response.setAction( "cassandra setup" );
+ 
+         logger.info( "Setting up Cassandra" );
+ 
+ 
+         emf.setup();
+ 
+ 
+         response.setSuccess();
+ 
 -        return new JSONWithPadding( response, callback );
++        return response;
+     }
+ 
+ 
+     @RequireSystemAccess
+     @PUT
++    @JSONP
+     @Path( "bootstrap" )
 -    public JSONWithPadding runSystemSetup( @Context UriInfo ui,
 -                                           @QueryParam( "callback" ) @DefaultValue( "callback" ) String callback )
++    public ApiResponse runSystemSetup( @Context UriInfo ui,
++        @QueryParam( "callback" ) @DefaultValue( "callback" ) String callback )
+         throws Exception {
+ 
+         ApiResponse response = createApiResponse();
+         response.setAction( "cassandra setup" );
+ 
+         logger.info( "Setting up Cassandra" );
+ 
+ 
+         emf.boostrap();
+         management.setup();
+ 
+         response.setSuccess();
+ 
 -        return new JSONWithPadding( response, callback );
++        return response;
+     }
+ }
+ 

http://git-wip-us.apache.org/repos/asf/usergrid/blob/1f77ca16/stack/rest/src/main/java/org/apache/usergrid/rest/SystemResource.java
----------------------------------------------------------------------
diff --cc stack/rest/src/main/java/org/apache/usergrid/rest/SystemResource.java
index bf2882c,f266441..3497621
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/SystemResource.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/SystemResource.java
@@@ -49,38 -57,10 +49,13 @@@ public class SystemResource extends Abs
  
      @RequireSystemAccess
      @GET
-     @Path( "database/setup" )
-     @JSONP
-     @Produces({MediaType.APPLICATION_JSON, "application/javascript"})
-     public ApiResponse getSetup( @Context UriInfo ui,
-                                      @QueryParam( "callback" ) @DefaultValue( "callback" ) String callback )
-             throws Exception {
- 
-         ApiResponse response = createApiResponse();
-         response.setAction( "cassandra setup" );
- 
-         logger.info( "Setting up Cassandra" );
- 
- 
-         emf.setup();
 +
- 
-         management.setup();
- 
-         response.setSuccess();
- 
-         return response;
-     }
- 
- 
-     @RequireSystemAccess
-     @GET
      @Path( "superuser/setup" )
 -    public JSONWithPadding getSetupSuperuser( @Context UriInfo ui,
 -                                              @QueryParam( "callback" ) @DefaultValue( "callback" ) String callback )
 +    @JSONP
 +    @Produces({MediaType.APPLICATION_JSON, "application/javascript"})
 +    public ApiResponse getSetupSuperuser( @Context UriInfo ui,
-                                               @QueryParam( "callback" ) @DefaultValue( "callback" ) String callback )
-             throws Exception {
++           @QueryParam( "callback" ) @DefaultValue( "callback" ) String callback )
+         throws Exception {
  
          ApiResponse response = createApiResponse();
          response.setAction( "superuser setup" );
@@@ -96,11 -76,13 +71,13 @@@
  
          response.setSuccess();
  
 -        return new JSONWithPadding( response, callback );
 +        return response;
      }
  
+ 
+ 
      @Path( "migrate" )
-     public MigrateResource migrate(){
+     public MigrateResource migrate() {
          return getSubResource( MigrateResource.class );
      }
  

http://git-wip-us.apache.org/repos/asf/usergrid/blob/1f77ca16/stack/rest/src/main/java/org/apache/usergrid/rest/applications/ServiceResource.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/usergrid/blob/1f77ca16/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/applications/ApplicationResource.java
----------------------------------------------------------------------
diff --cc stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/applications/ApplicationResource.java
index 5c83bbc,be8af2d..fa7e16f
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/applications/ApplicationResource.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/applications/ApplicationResource.java
@@@ -50,13 -50,16 +50,10 @@@ import javax.ws.rs.core.Context
  import javax.ws.rs.core.MediaType;
  import javax.ws.rs.core.Response;
  import javax.ws.rs.core.UriInfo;
- import java.util.HashMap;
- import java.util.Map;
- import java.util.Properties;
- import java.util.UUID;
+ import java.util.*;
  
 -import static javax.servlet.http.HttpServletResponse.SC_ACCEPTED;
 -import static javax.servlet.http.HttpServletResponse.SC_BAD_REQUEST;
 -import static javax.servlet.http.HttpServletResponse.SC_INTERNAL_SERVER_ERROR;
 -import static javax.servlet.http.HttpServletResponse.SC_NOT_FOUND;
 -import static javax.servlet.http.HttpServletResponse.SC_OK;
 +import static javax.servlet.http.HttpServletResponse.*;
  import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
 -import org.apache.usergrid.persistence.EntityManager;
 -import org.apache.usergrid.persistence.core.util.Health;
  
  
  @Component("org.apache.usergrid.rest.management.organizations.applications.ApplicationResource")
@@@ -157,12 -154,70 +154,73 @@@ public class ApplicationResource extend
  
          ClientCredentialsInfo credentials =
                  new ClientCredentialsInfo( management.getClientIdForApplication( applicationId ),
-                         management.newClientSecretForApplication( applicationId ) );
+                         management.newClientSecretForApplication(applicationId) );
  
          response.setCredentials( credentials );
 -        return new JSONWithPadding( response, callback );
 +        return response;
      }
  
+     @RequireOrganizationAccess
+     @GET
++    @JSONP
+     @Path("_size")
 -    public JSONWithPadding getApplicationSize(
++    public ApiResponse getApplicationSize(
+         @Context UriInfo ui, @QueryParam("callback") @DefaultValue("callback") String callback )
+         throws Exception {
+ 
+         ApiResponse response = createApiResponse();
+         response.setAction( "get application size for all entities" );
+         long size = management.getApplicationSize(this.applicationId);
+         Map<String,Object> map = new HashMap<>();
+         Map<String,Object> innerMap = new HashMap<>();
+         Map<String,Object> sumMap = new HashMap<>();
+         innerMap.put("application",size);
+         sumMap.put("size",innerMap);
+         map.put("aggregation", sumMap);
+         response.setMetadata(map);
 -        return new JSONWithPadding( response, callback );
++        return response;
+     }
+ 
+     @RequireOrganizationAccess
+     @GET
++    @JSONP
+     @Path("{collection_name}/_size")
 -    public JSONWithPadding getCollectionSize(
++    public ApiResponse getCollectionSize(
+         @Context UriInfo ui,
+         @PathParam( "collection_name" ) String collection_name,
+         @QueryParam("callback") @DefaultValue("callback") String callback )
+         throws Exception {
+         ApiResponse response = createApiResponse();
+         response.setAction("get collection size for all entities");
+         long size = management.getCollectionSize(this.applicationId, collection_name);
+         Map<String,Object> map = new HashMap<>();
+         Map<String,Object> sumMap = new HashMap<>();
+         Map<String,Object> innerMap = new HashMap<>();
+         innerMap.put(collection_name,size);
+         sumMap.put("size",innerMap);
+         map.put("aggregation",sumMap);
+         response.setMetadata(map);
 -        return new JSONWithPadding( response, callback );
++        return response;
+     }
+ 
+     @RequireOrganizationAccess
+     @GET
++    @JSONP
+     @Path("collections/_size")
 -    public JSONWithPadding getEachCollectionSize(
++    public ApiResponse getEachCollectionSize(
+         @Context UriInfo ui,
+         @QueryParam("callback") @DefaultValue("callback") String callback )
+         throws Exception {
+         ApiResponse response = createApiResponse();
+         response.setAction("get collection size for all entities");
+         Map<String,Long> sizes = management.getEachCollectionSize(this.applicationId);
+         Map<String,Object> map = new HashMap<>();
+         Map<String,Object> sumMap = new HashMap<>();
+         sumMap.put("size",sizes);
+         map.put("aggregation",sumMap);
+         response.setMetadata(map);
 -        return new JSONWithPadding( response, callback );
++        return response;
+     }
  
      @POST
      @Path("sia-provider")

http://git-wip-us.apache.org/repos/asf/usergrid/blob/1f77ca16/stack/rest/src/test/java/org/apache/usergrid/rest/CollectionMetadataIT.java
----------------------------------------------------------------------
diff --cc stack/rest/src/test/java/org/apache/usergrid/rest/CollectionMetadataIT.java
index 0000000,4ab5490..4e58935
mode 000000,100644..100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/CollectionMetadataIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/CollectionMetadataIT.java
@@@ -1,0 -1,142 +1,141 @@@
+ /*
+  * 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.usergrid.rest;
+ 
+ 
 -import com.sun.jersey.api.client.UniformInterfaceException;
 -import org.apache.usergrid.persistence.index.utils.UUIDUtils;
+ import org.apache.usergrid.rest.test.resource.AbstractRestIT;
 -import org.apache.usergrid.rest.test.resource.model.ApiResponse;
+ import org.apache.usergrid.rest.test.resource.model.Entity;
+ import org.apache.usergrid.rest.test.resource.model.QueryParameters;
+ import org.junit.Test;
+ import org.slf4j.Logger;
+ import org.slf4j.LoggerFactory;
++
+ import java.util.Map;
+ 
 -import static org.junit.Assert.*;
++import static org.junit.Assert.assertNotNull;
++import static org.junit.Assert.assertNull;
+ 
+ 
+ public class CollectionMetadataIT extends AbstractRestIT {
+ 
+     private static final Logger LOG = LoggerFactory.getLogger( CollectionMetadataIT.class );
+ 
+ 
+     public CollectionMetadataIT() throws Exception {
+         super();
+     }
+ 
+     private final String collectionName = "collectionQueryParameterCollection";
+ 
+     /**
+      * USERGRID-918: control inclusion/exclusion of connection metadata via query parameter
+      */
+     @Test
+     public void testCollectionQueryParameter() throws Exception {
+ 
+         // create entities
+         Entity e1 = new Entity();
+         e1.put("name", "entity1");
+         e1 = this.app().collection(collectionName).post(e1);
+         assertNotNull(e1);
+ 
+         Entity e2 = new Entity();
+         e2.put("name", "entity2");
+         e2 = this.app().collection(collectionName).post(e2);
+         assertNotNull(e2);
+ 
+         Entity e3 = new Entity();
+         e3.put("name", "entity3");
+         e3 = this.app().collection(collectionName).post(e3);
+         assertNotNull(e3);
+ 
+         refreshIndex();
+ 
+         // create connections
+         // e1 hates e3
+         // e2 likes e1
+         // e1 has 1 in (likes) & 1 out (hates) connection
+         // e2 has one out (likes) connection
+         // e3 has one in (hates) connection
+         this.app().collection(collectionName).entity(e1).connection("hates").entity(e3).post();
+         this.app().collection(collectionName).entity(e2).connection("likes").entity(e1).post();
+         refreshIndex();
+ 
+         // no query param, "all", and invalid param all the same
+         checkMetadata(e1, null, "hates", "likes");
+         checkMetadata(e1, "all", "hates", "likes");
+         checkMetadata(e1, "foo", "hates", "likes");
+         checkMetadata(e2, null, "likes", null);
+         checkMetadata(e2, "all", "likes", null);
+         checkMetadata(e2, "foo", "likes", null);
+         checkMetadata(e3, null, null, "hates");
+         checkMetadata(e3, "all", null, "hates");
+         checkMetadata(e3, "foo", null, "hates");
+ 
+         // "none" query param blocks connections and connecting
+         checkMetadata(e1, "none", null, null);
+         checkMetadata(e2, "none", null, null);
+         checkMetadata(e3, "none", null, null);
+ 
+         // "in" query param blocks connections
+         checkMetadata(e1, "in", null, "likes");
+         checkMetadata(e2, "in", null, null);
+         checkMetadata(e3, "in", null, "hates");
+ 
+         // "out" query param blocks connecting
+         checkMetadata(e1, "out", "hates", null);
+         checkMetadata(e2, "out", "likes", null);
+         checkMetadata(e3, "out", null, null);
+ 
+     }
+ 
+     /**
+      * validates that connections and connecting data are as expected
+      *
+      * if paramStr = null, means don't send query parameter
+      * if connectionsType or connectingType = null, means that section shouldn't exist
+      *
+      * unchecked warnings suppressed to avoid warnings casting payload entries to maps
+      */
+     @SuppressWarnings("unchecked")
+     private void checkMetadata(Entity origEntity, String paramStr, String connectionsType, String connectingType) throws Exception {
+         QueryParameters params = new QueryParameters();
+         if (paramStr != null)
+             params.setConnections(paramStr);
+ 
+         Entity e = this.app().collection(collectionName).entity(origEntity).get(params,true);
+ 
+         Map <String,Object> metadata = (Map<String,Object>)e.get("metadata");
+         assertNotNull(metadata);
+ 
+         Map <String,Object> connections = (Map<String,Object>)metadata.get("connections");
+         if (connectionsType != null) {
+             assertNotNull(connections);
+             assertNotNull(connections.get(connectionsType));
+         } else {
+             assertNull(connections);
+         }
+ 
+         Map <String,Object> connecting = (Map<String,Object>)metadata.get("connecting");
+         if (connectingType != null) {
+             assertNotNull(connecting);
+             assertNotNull(connecting.get(connectingType));
+         } else {
+             assertNull(connecting);
+         }
+     }
+ }

http://git-wip-us.apache.org/repos/asf/usergrid/blob/1f77ca16/stack/rest/src/test/java/org/apache/usergrid/rest/SystemResourceIT.java
----------------------------------------------------------------------
diff --cc stack/rest/src/test/java/org/apache/usergrid/rest/SystemResourceIT.java
index 354589c,83e29fa..e70d1b2
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/SystemResourceIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/SystemResourceIT.java
@@@ -20,9 -20,14 +20,12 @@@ package org.apache.usergrid.rest
  import org.apache.usergrid.rest.test.resource.AbstractRestIT;
  import org.apache.usergrid.rest.test.resource.model.Entity;
  import org.apache.usergrid.rest.test.resource.model.QueryParameters;
 +import org.junit.Test;
  
+ import java.util.LinkedHashMap;
+ 
+ import static org.junit.Assert.assertEquals;
  import static org.junit.Assert.assertNotNull;
 -import static org.junit.Assert.assertTrue;
  
  
  /**

http://git-wip-us.apache.org/repos/asf/usergrid/blob/1f77ca16/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/users/UserResourceIT.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/usergrid/blob/1f77ca16/stack/rest/src/test/java/org/apache/usergrid/rest/management/ManagementResourceIT.java
----------------------------------------------------------------------
diff --cc stack/rest/src/test/java/org/apache/usergrid/rest/management/ManagementResourceIT.java
index a26c8c7,7f86ad1..68fc172
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/management/ManagementResourceIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/management/ManagementResourceIT.java
@@@ -134,11 -133,11 +134,11 @@@ public class ManagementResourceIT exten
          try {
              this.management().orgs().org( this.clientSetup.getOrganizationName() ).get( String.class );
          }
 -        catch ( UniformInterfaceException uie ) {
 -            status = uie.getResponse().getClientResponseStatus();
 +        catch ( ClientErrorException uie ) {
 +            status = Response.Status.fromStatusCode( uie.getResponse().getStatus() );
          }
  
-         assertNull( status );
+         assertNull(status);
  
          //test getting the organization by org
  
@@@ -146,11 -145,11 +146,11 @@@
          try {
              this.management().orgs().org( this.clientSetup.getOrganizationName() ).get( String.class );
          }
 -        catch ( UniformInterfaceException uie ) {
 -            status = uie.getResponse().getClientResponseStatus();
 +        catch ( ClientErrorException uie ) {
 +            status = Response.Status.fromStatusCode( uie.getResponse().getStatus() );
          }
  
-         assertNull( status );
+         assertNull(status);
      }
  
  

http://git-wip-us.apache.org/repos/asf/usergrid/blob/1f77ca16/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/BoostrapResource.java
----------------------------------------------------------------------
diff --cc stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/BoostrapResource.java
index 0000000,89450fa..0db31ec
mode 000000,100644..100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/BoostrapResource.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/BoostrapResource.java
@@@ -1,0 -1,52 +1,49 @@@
+ /*
+  * 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.usergrid.rest.test.resource.endpoints;
+ 
+ 
 -import javax.ws.rs.core.MediaType;
 -
+ import org.apache.usergrid.rest.test.resource.model.Entity;
+ import org.apache.usergrid.rest.test.resource.model.QueryParameters;
+ import org.apache.usergrid.rest.test.resource.state.ClientContext;
++import org.glassfish.jersey.client.authentication.HttpAuthenticationFeature;
+ 
 -import com.sun.jersey.api.client.WebResource;
 -import com.sun.jersey.api.client.filter.HTTPBasicAuthFilter;
 -
++import javax.ws.rs.client.WebTarget;
++import javax.ws.rs.core.MediaType;
+ 
+ /**
+  * Functions as the endpoint for all resources that hit /system/ * /setup
+  */
+ public class BoostrapResource extends NamedResource {
+ 
+     public BoostrapResource( final ClientContext context, final UrlResource parent ) {
+         super("bootstrap",context,parent);
+     }
+ 
+     public Entity put(QueryParameters queryParameters){
+ 
 -        WebResource resource = getResource();
++        WebTarget resource = getTarget();
+         resource = addParametersToResource( resource, queryParameters );
+ 
 -        //added httpBasicauth filter to all setup calls because they all do verification this way.
 -        HTTPBasicAuthFilter httpBasicAuthFilter = new HTTPBasicAuthFilter( "superuser","superpassword" );
 -        resource.addFilter( httpBasicAuthFilter );
++        HttpAuthenticationFeature feature = HttpAuthenticationFeature.basicBuilder()
++            .credentials( "superuser", "superpassword" ).build();
+ 
 -        return resource.type( MediaType.APPLICATION_JSON_TYPE ).accept( MediaType.APPLICATION_JSON )
 -                                .put( Entity.class );
++        return resource.register( feature ).request().accept( MediaType.APPLICATION_JSON )
++            .put( javax.ws.rs.client.Entity.json(""), Entity.class );
+     }
+ }

http://git-wip-us.apache.org/repos/asf/usergrid/blob/1f77ca16/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/NamedResource.java
----------------------------------------------------------------------
diff --cc stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/NamedResource.java
index dc6de4b,1a9c776..c8979f0
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/NamedResource.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/NamedResource.java
@@@ -22,17 -27,7 +22,15 @@@ import org.apache.usergrid.rest.test.re
  import org.apache.usergrid.rest.test.resource.model.QueryParameters;
  import org.apache.usergrid.rest.test.resource.model.Token;
  import org.apache.usergrid.rest.test.resource.state.ClientContext;
- import static org.glassfish.jersey.client.authentication.HttpAuthenticationFeature.HTTP_AUTHENTICATION_BASIC_USERNAME;
- import static org.glassfish.jersey.client.authentication.HttpAuthenticationFeature.HTTP_AUTHENTICATION_BASIC_PASSWORD;
  
 +import org.glassfish.jersey.client.authentication.HttpAuthenticationFeature;
 +import org.glassfish.jersey.media.multipart.FormDataMultiPart;
 +import org.glassfish.jersey.media.multipart.MultiPart;
 +
 +import javax.ws.rs.client.Invocation;
 +import javax.ws.rs.client.WebTarget;
 +import javax.ws.rs.core.Form;
 +import javax.ws.rs.core.GenericType;
  import javax.ws.rs.core.MediaType;
  import java.io.InputStream;
  import java.util.Iterator;
@@@ -284,10 -306,10 +286,9 @@@ public class NamedResource implements U
              resource = addParametersToResource(resource, queryParameters);
          }
          GenericType<T> gt = new GenericType<>((Class) type);
 -        return resource.type(MediaType.APPLICATION_JSON_TYPE)
 +        return resource.request()
              .accept( MediaType.APPLICATION_JSON )
 -            .get(gt.getRawClass());
 -
 +            .get( gt );
- 
      }
  
      public String getMatrix() {
@@@ -305,9 -326,8 +306,9 @@@
      }
  
      public ApiResponse put( boolean useToken, byte[] data, MediaType type ) {
-         WebTarget resource = getTarget(useToken );
 -        WebResource resource = getResource(useToken);
 -        return resource.type( type ).put(ApiResponse.class, data);
++        WebTarget resource = getTarget( useToken );
 +        return resource.request().put(
 +            javax.ws.rs.client.Entity.entity(data, type), ApiResponse.class );
      }
  
      public ApiResponse put( byte[] data, MediaType type ) {
@@@ -338,6 -357,14 +339,14 @@@
      }
  
      public ApiResponse delete( boolean useToken ) {
 -        return getResource(useToken).delete(ApiResponse.class);
 +        return getTarget(useToken).request().delete( ApiResponse.class );
      }
+ 
+     public ApiResponse delete( boolean useToken, QueryParameters queryParameters ) {
 -        WebResource resource = getResource(useToken);
++        WebTarget resource = getTarget(useToken);
+         if(queryParameters!=null) {
+             resource = addParametersToResource(resource, queryParameters);
+         }
 -        return resource.delete( ApiResponse.class );
++        return resource.request().delete( ApiResponse.class );
+     }
  }

http://git-wip-us.apache.org/repos/asf/usergrid/blob/1f77ca16/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/SetupResource.java
----------------------------------------------------------------------
diff --cc stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/SetupResource.java
index f11b062,ba2534f..2b2b1b4
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/SetupResource.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/SetupResource.java
@@@ -34,15 -37,16 +34,15 @@@ public class SetupResource extends Name
          super("setup",context,parent);
      }
  
-     public Entity get(QueryParameters queryParameters){
+     public Entity put(QueryParameters queryParameters){
  
 -        WebResource resource = getResource();
 +        WebTarget resource = getTarget();
          resource = addParametersToResource( resource, queryParameters );
  
 -        //added httpBasicauth filter to all setup calls because they all do verification this way.
 -        HTTPBasicAuthFilter httpBasicAuthFilter = new HTTPBasicAuthFilter( "superuser","superpassword" );
 -        resource.addFilter( httpBasicAuthFilter );
 +        HttpAuthenticationFeature feature = HttpAuthenticationFeature.basicBuilder()
 +            .credentials( "superuser", "superpassword" ).build();
  
 -        return resource.type( MediaType.APPLICATION_JSON_TYPE ).accept( MediaType.APPLICATION_JSON )
 -                                .put( Entity.class);
 +        return resource.register( feature ).request()
 +            .accept( MediaType.APPLICATION_JSON ).get( Entity.class );
      }
  }

http://git-wip-us.apache.org/repos/asf/usergrid/blob/1f77ca16/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/SystemResource.java
----------------------------------------------------------------------
diff --cc stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/SystemResource.java
index 35ffc21,c6a0586..4dd6dbc
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/SystemResource.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/SystemResource.java
@@@ -18,10 -18,16 +18,13 @@@
  package org.apache.usergrid.rest.test.resource.endpoints;
  
  
 -import javax.ws.rs.core.MediaType;
 -
 -import com.sun.jersey.api.client.WebResource;
 -import com.sun.jersey.api.client.filter.HTTPBasicAuthFilter;
  import org.apache.usergrid.rest.test.resource.model.ApiResponse;
 -import org.apache.usergrid.rest.test.resource.model.Entity;
+ import org.apache.usergrid.rest.test.resource.model.QueryParameters;
  import org.apache.usergrid.rest.test.resource.state.ClientContext;
++import org.glassfish.jersey.client.authentication.HttpAuthenticationFeature;
  
 -import java.util.UUID;
++import javax.ws.rs.client.WebTarget;
 +import javax.ws.rs.core.MediaType;
  
  
  /**
@@@ -43,16 -44,25 +41,36 @@@ public class SystemResource extends Nam
          return new DatabaseResource(context, this);
      }
  
-     public SystemResource addToPath( String pathPart ) {
-         return new SystemResource( pathPart, context, this );
+ 
+     public ApplicationsResource applications(String appid) {
+         return new ApplicationsResource(appid,context,this);
+     }
++
+     public class ApplicationsResource extends NamedResource {
 -        public ApplicationsResource(final String appid, final ClientContext context, final UrlResource parent ) {
 -            super( "applications/"+appid,context, parent );
++
++        public ApplicationsResource(final String appid, final ClientContext context, final UrlResource parent) {
++            super( "applications/" + appid, context, parent );
+         }
 -        public ApiResponse delete(QueryParameters queryParameters){
+ 
 -            WebResource resource = getResource();
++        public ApiResponse delete(QueryParameters queryParameters) {
++
++            WebTarget resource = getTarget();
+             resource = addParametersToResource( resource, queryParameters );
+ 
 -            //added httpBasicauth filter to all setup calls because they all do verification this way.
 -            HTTPBasicAuthFilter httpBasicAuthFilter = new HTTPBasicAuthFilter( "superuser","superpassword" );
 -            resource.addFilter(httpBasicAuthFilter);
++            HttpAuthenticationFeature feature = HttpAuthenticationFeature.basicBuilder()
++                .credentials( "superuser", "superpassword" ).build();
++
++            return resource.register( feature ).request().delete( ApiResponse.class );
+ 
 -            return resource.type( MediaType.APPLICATION_JSON_TYPE ).accept( MediaType.APPLICATION_JSON )
 -                .delete(ApiResponse.class);
+         }
      }
 +
 +    public ApiResponse put(){
 +        ApiResponse
 +            response = getTarget(true)
 +                .request()
 +                .accept(MediaType.APPLICATION_JSON)
 +                .put( javax.ws.rs.client.Entity.json(null), ApiResponse.class);
 +        return response;
 +    }
  }