usergrid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From snoopd...@apache.org
Subject [06/30] 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.
Date Sun, 20 Sep 2015 20:40:46 GMT
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


Mime
View raw message