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/02/26 17:27:25 UTC

[01/50] [abbrv] incubator-usergrid git commit: Added fix to job scheduler looking for incorrect index name.

Repository: incubator-usergrid
Updated Branches:
  refs/heads/two-dot-o b4727f1db -> 567db37ca


Added fix to job scheduler looking for incorrect index name.


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

Branch: refs/heads/two-dot-o
Commit: 4ecaa4db118caa1231a7dee293e993f73435abbb
Parents: c6a96a8
Author: grey <gr...@apigee.com>
Authored: Thu Feb 19 10:44:13 2015 -0800
Committer: grey <gr...@apigee.com>
Committed: Thu Feb 19 10:44:13 2015 -0800

----------------------------------------------------------------------
 stack/config/src/main/resources/usergrid-default.properties | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/4ecaa4db/stack/config/src/main/resources/usergrid-default.properties
----------------------------------------------------------------------
diff --git a/stack/config/src/main/resources/usergrid-default.properties b/stack/config/src/main/resources/usergrid-default.properties
index 068572d..d42d12c 100644
--- a/stack/config/src/main/resources/usergrid-default.properties
+++ b/stack/config/src/main/resources/usergrid-default.properties
@@ -55,7 +55,7 @@ hystrix.threadpool.graph_user.coreSize=40
 hystrix.threadpool.graph_async.coreSize=40
 
 elasticsearch.cluster_name=elasticsearch
-elasticsearch.index_prefix=usergrid
+elasticsearch.index_prefix=elasticsearch
 elasticsearch.hosts=127.0.0.1
 elasticsearch.port=9300
 #We don't want to overwrite, let the defaults be used


[39/50] [abbrv] incubator-usergrid git commit: Changes to allow us to fix the old tests that are broken because tests now share the same C* keyspace, and some fixes to the old ApplicationResourceIT.

Posted by sn...@apache.org.
Changes to allow us to fix the old tests that are broken because tests now share the same C* keyspace, and some fixes to the old ApplicationResourceIT.


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

Branch: refs/heads/two-dot-o
Commit: 72fcdda38d55356152e594aeae8e212a5a46b091
Parents: d1880e6
Author: Dave Johnson <dm...@apigee.com>
Authored: Wed Feb 25 13:41:49 2015 -0500
Committer: Dave Johnson <dm...@apigee.com>
Committed: Wed Feb 25 13:41:49 2015 -0500

----------------------------------------------------------------------
 .../apache/usergrid/rest/AbstractRestIT.java    | 116 ++++++++-----
 .../applications/ApplicationResourceIT.java     | 174 ++++++++-----------
 2 files changed, 138 insertions(+), 152 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/72fcdda3/stack/rest/src/test/java/org/apache/usergrid/rest/AbstractRestIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/AbstractRestIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/AbstractRestIT.java
index 082e436..5f4a534 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/AbstractRestIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/AbstractRestIT.java
@@ -27,13 +27,14 @@ 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.commons.lang3.RandomStringUtils;
 import org.apache.usergrid.java.client.Client;
-import org.apache.usergrid.management.ManagementService;
-import org.apache.usergrid.setup.ConcurrentProcessSingleton;
+import org.apache.usergrid.management.ApplicationInfo;
+import org.apache.usergrid.management.OrganizationInfo;
+import org.apache.usergrid.management.OrganizationOwnerInfo;
 
 import org.junit.AfterClass;
 import org.junit.Before;
-import org.junit.Rule;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -124,21 +125,43 @@ public abstract class AbstractRestIT extends JerseyTest {
     }
 
 
-    /** Hook to get the token for our base user */
+    public ApplicationInfo appInfo = null;
+    public OrganizationInfo orgInfo = null;
+    public String orgAppPath = null;
+    public String username = null;
+    public String userEmail = null;
+
+    /** Quick fix to get old style test working again. We need them! */
     @Before
-    public void acquireToken() throws Exception {
+    public void setupOrgApp() throws Exception {
+
+        setup.getMgmtSvc().setup();
+
+        String rand = RandomStringUtils.randomAlphanumeric(5);
+
+        orgInfo = setup.getMgmtSvc().getOrganizationByName("test-organization");
+        if ( orgInfo == null  ) {
+            OrganizationOwnerInfo orgOwnerInfo = setup.getMgmtSvc().createOwnerAndOrganization(
+                "test-organization" + rand, "test", "test", "test@usergrid.org", rand, false, false);
+            orgInfo = orgOwnerInfo.getOrganization();
+        }
+
+        appInfo = setup.getMgmtSvc().createApplication(orgInfo.getUuid(), "app-" + rand);
+        refreshIndex( orgInfo.getName(), appInfo.getName() );
+
+        orgAppPath = appInfo.getName() + "/";
+        adminToken();
+
+        setupUsers();
+        refreshIndex( orgInfo.getName(), appInfo.getName() );
+
+        loginClient();
+        refreshIndex( orgInfo.getName(), appInfo.getName() );
+
+        LOG.info( "acquiring token" );
+        access_token = userToken( userEmail, "sesame" );
+        LOG.info( "with token: {}", access_token );
 
-//        setupUsers();
-//
-//        refreshIndex("test-organization", "test-app");
-//
-//        LOG.info( "acquiring token" );
-//        access_token = userToken( "ed@anuff.com", "sesame" );
-//        LOG.info( "with token: {}", access_token );
-//
-//        loginClient();
-//
-//        refreshIndex("test-organization", "test-app");
     }
 
 
@@ -159,39 +182,35 @@ public abstract class AbstractRestIT extends JerseyTest {
     }
 
 
-    protected void setupUsers() {
+    protected void setupUsers() throws Exception {
 
         LOG.info("Entering setupUsers");
 
-        if ( usersSetup ) {
-            LOG.info("Leaving setupUsers: already setup");
-            return;
-        }
+//        if ( usersSetup ) {
+//            LOG.info("Leaving setupUsers: already setup");
+//            return;
+//        }
+
+        String rand = RandomStringUtils.randomAlphanumeric(5);
+        username = "user-" + rand;
+        userEmail = username + "@example.com";
 
-        //
-        createUser( "edanuff", "ed@anuff.com", "sesame", "Ed Anuff" ); // client.setApiUrl(apiUrl);
+        createUser( username, userEmail, "sesame", "User named " + rand);
 
-        usersSetup = true;
-        LOG.info("Leaving setupUsers success");
+        //usersSetup = true;
+        LOG.info("Leaving setupUsers, setup user: " + userEmail );
     }
 
 
     public void loginClient() throws Exception {
-        // now create a client that logs in ed
 
-        // TODO T.N. This is a filthy hack and I should be ashamed of it (which
-        // I am). There's a bug in the grizzly server when it's restarted per
-        // test, and until we can upgrade versions this is the workaround. Backs
-        // off with each attempt to allow the server to catch up
+        String appNameOnly = appInfo.getName().split("/")[1];
 
-
-        setUserPassword( "ed@anuff.com", "sesame" );
-
-        client = new Client( "test-organization", "test-app" ).withApiUrl(
+        client = new Client( "test-organization", appNameOnly ).withApiUrl(
                 UriBuilder.fromUri( "http://localhost/" ).port(tomcatRuntime.getPort() ).build().toString() );
 
         org.apache.usergrid.java.client.response.ApiResponse response =
-                client.authorizeAppUser( "ed@anuff.com", "sesame" );
+            client.authorizeAppUser( userEmail, "sesame" );
 
         assertTrue( response != null && response.getError() == null );
     }
@@ -226,10 +245,8 @@ public abstract class AbstractRestIT extends JerseyTest {
     protected String userToken( String name, String password ) throws Exception {
 
         try {
-            setUserPassword( "ed@anuff.com", "sesame" );
-
-            JsonNode node = mapper.readTree( resource().path( "/test-organization/test-app/token" )
-                    .queryParam( "grant_type", "password" )
+            JsonNode node = mapper.readTree( resource().path( orgAppPath + "token" )
+                    .queryParam("grant_type", "password")
                     .queryParam( "username", name )
                     .queryParam( "password", password ).accept( MediaType.APPLICATION_JSON )
                     .get( String.class ));
@@ -248,7 +265,7 @@ public abstract class AbstractRestIT extends JerseyTest {
     public void createUser( String username, String email, String password, String name ) {
 
         try {
-            JsonNode node = mapper.readTree( resource().path( "/test-organization/test-app/token" )
+            JsonNode node = mapper.readTree( resource().path( orgAppPath + "token" )
                 .queryParam( "grant_type", "password" )
                 .queryParam( "username", username )
                 .queryParam( "password", password )
@@ -271,7 +288,7 @@ public abstract class AbstractRestIT extends JerseyTest {
             .map( "password", password )
             .map( "pin", "1234" );
 
-        resource().path( "/test-organization/test-app/users" )
+        resource().path( orgAppPath + "users" )
             .queryParam( "access_token", adminAccessToken )
             .accept( MediaType.APPLICATION_JSON )
             .type( MediaType.APPLICATION_JSON )
@@ -286,12 +303,12 @@ public abstract class AbstractRestIT extends JerseyTest {
         adminToken();
 
         // change the password as admin. The old password isn't required
-        JsonNode node = mapper.readTree( resource().path(
-                String.format( "/test-organization/test-app/users/%s/password", username ) )
-                .queryParam( "access_token", adminAccessToken ).accept( MediaType.APPLICATION_JSON )
-                .type( MediaType.APPLICATION_JSON_TYPE ).post( String.class, data ));
-
-        assertNull( getError( node ) );
+        JsonNode node = mapper.readTree(
+            resource().path( String.format( orgAppPath + "users/%s/password", username ) )
+                .queryParam("access_token", adminAccessToken)
+                .accept(MediaType.APPLICATION_JSON)
+                .type(MediaType.APPLICATION_JSON_TYPE)
+                .post(String.class, data));
     }
 
 
@@ -385,7 +402,7 @@ public abstract class AbstractRestIT extends JerseyTest {
 
     /** convenience to return a ready WebResource.Builder in a single call */
     protected WebResource.Builder appPath( String path ) {
-        return resource().path( "/test-organization/test-app/" + path )
+        return resource().path( orgAppPath + "" + path )
                 .queryParam( "access_token", access_token )
                 .accept( MediaType.APPLICATION_JSON )
                 .type( MediaType.APPLICATION_JSON_TYPE );
@@ -464,6 +481,9 @@ public abstract class AbstractRestIT extends JerseyTest {
 
         LOG.debug("Refreshing index for app {}/{}", orgName, appName );
 
+        // be nice if somebody accidentally passed in orgName/appName
+        appName = appName.contains("/") ? appInfo.getName().split("/")[1] : appName;
+
         try {
 
             resource().path( "/refreshindex" )

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/72fcdda3/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 ea4ab39..dc84197 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
@@ -54,17 +54,16 @@ import org.slf4j.LoggerFactory;
 public class ApplicationResourceIT extends AbstractRestIT {
     private static final Logger logger = LoggerFactory.getLogger( ApplicationResourceIT.class );
 
+
     @Test
     public void applicationWithOrgCredentials() throws Exception {
 
-        OrganizationInfo orgInfo = setup.getMgmtSvc().getOrganizationByName( "test-organization" );
-
         String clientId = setup.getMgmtSvc().getClientIdForOrganization( orgInfo.getUuid() );
         String clientSecret = setup.getMgmtSvc().getClientSecretForOrganization( orgInfo.getUuid() );
 
-        refreshIndex("test-organization", "test-app");
+        refreshIndex( orgInfo.getName(), appInfo.getName() );
 
-        JsonNode node = mapper.readTree( resource().path( "/test-organization/test-app/users" )
+        JsonNode node = mapper.readTree( resource().path( orgAppPath + "users" )
                 .queryParam( "client_id", clientId )
                 .queryParam( "client_secret", clientSecret ).accept( MediaType.APPLICATION_JSON )
                 .type( MediaType.APPLICATION_JSON_TYPE ).get( String.class ));
@@ -75,18 +74,16 @@ public class ApplicationResourceIT extends AbstractRestIT {
     @Test
     public void applicationWithAppCredentials() throws Exception {
 
-        ApplicationInfo appInfo = setup.getMgmtSvc().getApplicationInfo( "test-organization/test-app" );
-
         String clientId = setup.getMgmtSvc().getClientIdForApplication( appInfo.getId() );
         String clientSecret = setup.getMgmtSvc().getClientSecretForApplication( appInfo.getId() );
 
-        refreshIndex("test-organization", "test-app");
+        refreshIndex( orgInfo.getName(), appInfo.getName() );
 
-        JsonNode node = mapper.readTree( resource().path( "/test-organization/test-app/users" )
+        JsonNode node = mapper.readTree( resource().path( orgAppPath + "users" )
                 .queryParam( "client_id", clientId )
                 .queryParam( "client_secret", clientSecret )
                 .accept( MediaType.APPLICATION_JSON )
-                .type( MediaType.APPLICATION_JSON_TYPE ).get( String.class ));
+                .type( MediaType.APPLICATION_JSON_TYPE).get(String.class));
 
         assertNotNull( node.get( "entities" ) );
     }
@@ -98,14 +95,14 @@ public class ApplicationResourceIT extends AbstractRestIT {
     @Test
     public void jsonForNoAccepts() throws Exception {
 
-        ApplicationInfo app = setup.getMgmtSvc().getApplicationInfo("test-organization/test-app");
+        ApplicationInfo app = appInfo;
         String clientId = setup.getMgmtSvc().getClientIdForApplication( app.getId() );
         String clientSecret = setup.getMgmtSvc().getClientSecretForApplication( app.getId() );
 
-        refreshIndex("test-organization", "test-app");
+        refreshIndex( orgInfo.getName(), appInfo.getName() );
 
         JsonNode node = mapper.readTree( resource()
-                .path( "/test-organization/test-app" )
+                .path( orgAppPath )
                 .queryParam( "client_id", clientId )
                 .queryParam( "client_secret", clientSecret )
                 .get( String.class ));
@@ -120,14 +117,13 @@ public class ApplicationResourceIT extends AbstractRestIT {
     @Test
     public void jsonForAcceptsTextHtml() throws Exception {
 
-        ApplicationInfo app = setup.getMgmtSvc().getApplicationInfo("test-organization/test-app");
-        String clientId = setup.getMgmtSvc().getClientIdForApplication( app.getId() );
-        String clientSecret = setup.getMgmtSvc().getClientSecretForApplication( app.getId() );
+        String clientId = setup.getMgmtSvc().getClientIdForApplication(appInfo.getId());
+        String clientSecret = setup.getMgmtSvc().getClientSecretForApplication( appInfo.getId() );
 
-        refreshIndex("test-organization", "test-app");
+        refreshIndex( orgInfo.getName(), appInfo.getName() );
 
         JsonNode node = mapper.readTree( resource()
-                .path( "/test-organization/test-app" )
+                .path( orgAppPath )
                 .queryParam( "client_id", clientId )
                 .queryParam( "client_secret", clientSecret )
                 .accept( MediaType.TEXT_HTML )
@@ -139,8 +135,6 @@ public class ApplicationResourceIT extends AbstractRestIT {
     @Test
     public void applicationWithJsonCreds() throws Exception {
 
-        ApplicationInfo appInfo = setup.getMgmtSvc().getApplicationInfo( "test-organization/test-app" );
-
         String clientId = setup.getMgmtSvc().getClientIdForApplication( appInfo.getId() );
         String clientSecret = setup.getMgmtSvc().getClientSecretForApplication( appInfo.getId() );
 
@@ -148,19 +142,19 @@ public class ApplicationResourceIT extends AbstractRestIT {
                 .map( "username", "applicationWithJsonCreds" ).map( "name", "applicationWithJsonCreds" )
                 .map( "password", "applicationWithJsonCreds" ).map( "pin", "1234" );
 
-        JsonNode node = mapper.readTree( resource().path( "/test-organization/test-app/users" )
-                .queryParam( "client_id", clientId )
+        JsonNode node = mapper.readTree( resource().path( orgAppPath + "users" )
+                .queryParam("client_id", clientId)
                 .queryParam( "client_secret", clientSecret ).accept( MediaType.APPLICATION_JSON )
                 .type( MediaType.APPLICATION_JSON_TYPE ).post( String.class, payload ));
 
         assertNotNull( getEntity( node, 0 ) );
 
-        refreshIndex("test-organization", "test-app");
+        refreshIndex( orgInfo.getName(), appInfo.getName() );
 
         payload = hashMap( "username", "applicationWithJsonCreds" ).map( "password", "applicationWithJsonCreds" )
                 .map( "grant_type", "password" );
 
-        node = mapper.readTree( resource().path( "/test-organization/test-app/token" ).accept( MediaType.APPLICATION_JSON )
+        node = mapper.readTree( resource().path( orgAppPath + "token" ).accept( MediaType.APPLICATION_JSON )
                 .type( MediaType.APPLICATION_JSON_TYPE ).post( String.class, payload ));
 
         JsonNode token = node.get( "access_token" );
@@ -175,13 +169,10 @@ public class ApplicationResourceIT extends AbstractRestIT {
             + "rootApplicationWithOrgCredentials:139 expected:<3> but was:<4>")
     public void rootApplicationWithOrgCredentials() throws Exception {
 
-        OrganizationInfo orgInfo = setup.getMgmtSvc().getOrganizationByName( "test-organization" );
-        ApplicationInfo appInfo = setup.getMgmtSvc().getApplicationInfo( "test-organization/test-app" );
-
         String clientId = setup.getMgmtSvc().getClientIdForOrganization( orgInfo.getUuid() );
         String clientSecret = setup.getMgmtSvc().getClientSecretForOrganization( orgInfo.getUuid() );
 
-        refreshIndex("test-organization", "test-app");
+        refreshIndex( orgInfo.getName(), appInfo.getName() );
 
         JsonNode node = mapper.readTree( resource().path( "/" + appInfo.getId() )
                 .queryParam( "client_id", clientId )
@@ -189,10 +180,10 @@ public class ApplicationResourceIT extends AbstractRestIT {
                 .type( MediaType.APPLICATION_JSON_TYPE ).get( String.class ));
 
         // ensure the URI uses the properties file as a base
-        assertEquals( node.get( "uri" ).textValue(), "http://sometestvalue/test-organization/test-app" );
+        assertEquals( node.get( "uri" ).textValue(), "http://sometestvalue/" + orgAppPath);
 
         node = getEntity( node, 0 );
-        assertEquals( "test-organization/test-app", node.get( "name" ).asText() );
+        assertEquals( orgAppPath, node.get( "name" ).asText() );
         assertEquals( "Roles", node.get( "metadata" ).get( "collections" ).get( "roles" ).get( "title" ).asText() );
 
         // TODO - when run together with many tests this sees 4 instead of expected 3
@@ -204,12 +195,15 @@ public class ApplicationResourceIT extends AbstractRestIT {
     public void test_GET_credentials_ok() throws IOException {
         String mgmtToken = adminToken();
 
-        refreshIndex("test-organization", "test-app");
+        refreshIndex( orgInfo.getName(), appInfo.getName() );
+
+        JsonNode node = mapper.readTree( resource()
+            .path(orgAppPath + "credentials")
+            .queryParam("access_token", mgmtToken)
+            .accept(MediaType.APPLICATION_JSON)
+            .type(MediaType.APPLICATION_JSON_TYPE)
+            .get(String.class));
 
-        JsonNode node = mapper.readTree( resource().path( "/test-organization/test-app/credentials" )
-                .queryParam( "access_token", mgmtToken )
-                        .accept( MediaType.APPLICATION_JSON ).type( MediaType.APPLICATION_JSON_TYPE )
-                        .get( String.class ));
         assertEquals( "ok", node.get( "status" ).textValue() );
         logNode( node );
     }
@@ -219,9 +213,9 @@ public class ApplicationResourceIT extends AbstractRestIT {
     public void testResetAppCredentials() throws IOException {
         String mgmtToken = adminToken();
 
-        refreshIndex("test-organization", "test-app");
+        refreshIndex( orgInfo.getName(), appInfo.getName() );
 
-        JsonNode node = mapper.readTree( resource().path( "/test-organization/test-app/credentials" )
+        JsonNode node = mapper.readTree( resource().path( orgAppPath + "credentials" )
                 .queryParam( "access_token", mgmtToken )
                         .accept( MediaType.APPLICATION_JSON ).type( MediaType.APPLICATION_JSON_TYPE )
                         .post( String.class ));
@@ -231,39 +225,18 @@ public class ApplicationResourceIT extends AbstractRestIT {
 
 
     @Test
-    public void noAppDelete() throws IOException {
-        String mgmtToken = adminToken();
-
-        Status status = null;
-        JsonNode node = null;
-
-        refreshIndex("test-organization", "test-app");
-
-        try {
-            node = mapper.readTree( resource().path( "/test-organization/test-app" )
-                    .queryParam( "access_token", mgmtToken )
-                    .accept( MediaType.APPLICATION_JSON ).type( MediaType.APPLICATION_JSON_TYPE )
-                    .delete( String.class ));
-        }
-        catch ( UniformInterfaceException uie ) {
-            status = uie.getResponse().getClientResponseStatus();
-        }
-
-        assertEquals( Status.NOT_IMPLEMENTED, status );
-    }
-
-
-    @Test
     public void ttlOverMax() throws Exception {
 
         Map<String, String> payload =
-                hashMap( "grant_type", "password" ).map( "username", "test@usergrid.com" ).map( "password", "test" )
-                        .map( "ttl", Long.MAX_VALUE + "" );
+            hashMap( "grant_type", "password" )
+            .map("username", "test@usergrid.com")
+            .map("password", "test")
+            .map("ttl", Long.MAX_VALUE + "");
 
         Status responseStatus = null;
 
         try {
-            resource().path( "/test-organization/test-app/token" ).accept( MediaType.APPLICATION_JSON )
+            resource().path( orgAppPath + "token" ).accept( MediaType.APPLICATION_JSON )
                     .type( MediaType.APPLICATION_JSON_TYPE ).post( String.class, payload );
         }
         catch ( UniformInterfaceException uie ) {
@@ -279,9 +252,9 @@ public class ApplicationResourceIT extends AbstractRestIT {
 
         long ttl = 2000;
 
-        JsonNode node = mapper.readTree( resource().path( "/test-organization/test-app/token" )
+        JsonNode node = mapper.readTree( resource().path( orgAppPath + "token" )
                 .queryParam( "grant_type", "password" )
-                .queryParam( "username", "ed@anuff.com" )
+                .queryParam( "username", userEmail )
                 .queryParam( "password", "sesame" )
                 .queryParam( "ttl", String.valueOf( ttl ) ).accept( MediaType.APPLICATION_JSON ).get( String.class ));
 
@@ -294,18 +267,18 @@ public class ApplicationResourceIT extends AbstractRestIT {
         long expires_in = node.get( "expires_in" ).longValue();
         assertEquals( ttl, expires_in * 1000 );
 
-        JsonNode userdata = mapper.readTree( resource().path( "/test-organization/test-app/users/ed@anuff.com" )
+        JsonNode userdata = mapper.readTree( resource().path( orgAppPath + "users/" + userEmail )
                 .queryParam( "access_token", token )
                         .accept( MediaType.APPLICATION_JSON ).get( String.class ));
 
-        assertEquals( "ed@anuff.com", getEntity( userdata, 0 ).get( "email" ).asText() );
+        assertEquals( userEmail, getEntity( userdata, 0 ).get( "email" ).asText() );
 
         // wait for the token to expire
-        Thread.sleep( ttl - ( System.currentTimeMillis() - startTime ) + 1000 );
+        Thread.sleep(ttl - (System.currentTimeMillis() - startTime) + 1000);
 
         Status responseStatus = null;
         try {
-            userdata = mapper.readTree( resource().path( "/test-organization/test-app/users/ed@anuff.com" )
+            userdata = mapper.readTree( resource().path( orgAppPath + "users/" + userEmail)
                     .accept( MediaType.APPLICATION_JSON ).type( MediaType.APPLICATION_JSON_TYPE ).get( String.class ));
         }
         catch ( UniformInterfaceException uie ) {
@@ -320,12 +293,14 @@ public class ApplicationResourceIT extends AbstractRestIT {
     public void ttlNan() throws Exception {
 
         Map<String, String> payload =
-                hashMap( "grant_type", "password" ).map( "username", "ed@anuff.com" ).map( "password", "sesame" )
-                        .map( "ttl", "derp" );
+            hashMap( "grant_type", "password" )
+            .map( "username", userEmail)
+                .map( "password", "sesame")
+                .map( "ttl", "derp");
 
         Status responseStatus = null;
         try {
-            resource().path( "/test-organization/test-app/token" ).accept( MediaType.APPLICATION_JSON )
+            resource().path( orgAppPath + "token" ).accept( MediaType.APPLICATION_JSON )
                     .type( MediaType.APPLICATION_JSON_TYPE ).post( String.class, payload );
         }
         catch ( UniformInterfaceException uie ) {
@@ -339,12 +314,12 @@ public class ApplicationResourceIT extends AbstractRestIT {
     @Test
     public void updateAccessTokenTtl() throws Exception {
 
-        JsonNode node = mapper.readTree( resource().path( "/test-organization/test-app/token" )
+        JsonNode node = mapper.readTree( resource().path( orgAppPath + "token" )
                 .queryParam( "grant_type", "password" )
-                .queryParam( "username", "ed@anuff.com" )
-                .queryParam( "password", "sesame" )
-                .accept( MediaType.APPLICATION_JSON )
-                .get( String.class ));
+                .queryParam( "username", userEmail)
+            .queryParam( "password", "sesame")
+            .accept( MediaType.APPLICATION_JSON)
+            .get( String.class));
 
         String token = node.get( "access_token" ).textValue();
         logNode( node );
@@ -355,17 +330,17 @@ public class ApplicationResourceIT extends AbstractRestIT {
 
         Map<String, String> payload = hashMap( "accesstokenttl", "31536000000" );
 
-        node = mapper.readTree( resource().path( "/test-organization/test-app" )
+        node = mapper.readTree( resource().path( orgAppPath )
                 .queryParam( "access_token", adminAccessToken )
                 .type( MediaType.APPLICATION_JSON_TYPE ).put( String.class, payload ));
         logNode( node );
 
-        node = mapper.readTree( resource().path( "/test-organization/test-app/token" )
+        node = mapper.readTree( resource().path( orgAppPath + "token" )
                 .queryParam( "grant_type", "password" )
-                .queryParam( "username", "ed@anuff.com" )
-                .queryParam( "password", "sesame" )
-                .accept( MediaType.APPLICATION_JSON )
-                .get( String.class ));
+                .queryParam( "username", userEmail)
+            .queryParam( "password", "sesame")
+            .accept( MediaType.APPLICATION_JSON)
+            .get( String.class));
 
         assertEquals( 31536000, node.get( "expires_in" ).longValue() );
         logNode( node );
@@ -374,10 +349,9 @@ public class ApplicationResourceIT extends AbstractRestIT {
 
     @Test
     public void authorizationCodeWithWrongCredentials() throws Exception {
-        ApplicationInfo appInfo = setup.getMgmtSvc().getApplicationInfo( "test-organization/test-app" );
         String clientId = setup.getMgmtSvc().getClientIdForApplication( appInfo.getId() );
 
-        refreshIndex("test-organization", "test-app");
+        refreshIndex( orgInfo.getName(), appInfo.getName() );
 
         Form payload = new Form();
         payload.add( "username", "wrong_user" );
@@ -387,7 +361,7 @@ public class ApplicationResourceIT extends AbstractRestIT {
         payload.add( "scope", "none" );
         payload.add( "redirect_uri", "http://www.my_test.com" );
 
-        String result = resource().path( "/test-organization/test-app/authorize" )
+        String result = resource().path( orgAppPath + "authorize" )
                 .type( MediaType.APPLICATION_FORM_URLENCODED_TYPE ).accept( MediaType.TEXT_HTML )
                 .post( String.class, payload );
 
@@ -399,7 +373,7 @@ public class ApplicationResourceIT extends AbstractRestIT {
     @Test
     public void authorizeWithInvalidClientIdRaisesError() throws Exception {
         String result =
-                resource().path( "/test-organization/test-app/authorize" )
+                resource().path( orgAppPath + "authorize" )
                         .queryParam( "response_type", "token" )
                         .queryParam( "client_id", "invalid_client_id" )
                         .queryParam( "redirect_uri", "http://www.my_test.com" ).get( String.class );
@@ -410,11 +384,10 @@ public class ApplicationResourceIT extends AbstractRestIT {
 
     @Test
     public void authorizationCodeWithValidCredentials() throws Exception {
-        ApplicationInfo appInfo = setup.getMgmtSvc().getApplicationInfo( "test-organization/test-app" );
         String clientId = setup.getMgmtSvc().getClientIdForApplication( appInfo.getId() );
 
         Form payload = new Form();
-        payload.add( "username", "ed@anuff.com" );
+        payload.add( "username", userEmail );
         payload.add( "password", "sesame" );
         payload.add( "response_type", "code" );
         payload.add( "client_id", clientId );
@@ -425,7 +398,7 @@ public class ApplicationResourceIT extends AbstractRestIT {
 
         Status status = null;
         try {
-            String result = resource().path( "/test-organization/test-app/authorize" )
+            String result = resource().path( orgAppPath + "authorize" )
                     .type( MediaType.APPLICATION_FORM_URLENCODED_TYPE )
                     .accept( MediaType.TEXT_HTML )
                     .post( String.class, payload );
@@ -440,7 +413,6 @@ public class ApplicationResourceIT extends AbstractRestIT {
 
     @Test
     public void clientCredentialsFlowWithHeaderAuthorization() throws Exception {
-        ApplicationInfo appInfo = setup.getMgmtSvc().getApplicationInfo( "test-organization/test-app" );
         String clientId = setup.getMgmtSvc().getClientIdForApplication( appInfo.getId() );
         String clientSecret = setup.getMgmtSvc().getClientSecretForApplication( appInfo.getId() );
 
@@ -450,7 +422,7 @@ public class ApplicationResourceIT extends AbstractRestIT {
         Form payload = new Form();
         payload.add( "grant_type", "client_credentials" );
 
-        JsonNode node = mapper.readTree( resource().path( "/test-organization/test-app/token" ).header( "Authorization", "Basic " + token )
+        JsonNode node = mapper.readTree( resource().path( orgAppPath + "token" ).header( "Authorization", "Basic " + token )
                         .type( MediaType.APPLICATION_FORM_URLENCODED_TYPE ).accept( MediaType.APPLICATION_JSON )
                         .post( String.class, payload ));
 
@@ -461,7 +433,6 @@ public class ApplicationResourceIT extends AbstractRestIT {
 
     @Test
     public void clientCredentialsFlowWithPayload() throws Exception {
-        ApplicationInfo appInfo = setup.getMgmtSvc().getApplicationInfo( "test-organization/test-app" );
         String clientId = setup.getMgmtSvc().getClientIdForApplication( appInfo.getId() );
         String clientSecret = setup.getMgmtSvc().getClientSecretForApplication( appInfo.getId() );
 
@@ -470,7 +441,7 @@ public class ApplicationResourceIT extends AbstractRestIT {
         payload.add( "client_id", clientId );
         payload.add( "client_secret", clientSecret );
 
-        JsonNode node = mapper.readTree( resource().path( "/test-organization/test-app/token" )
+        JsonNode node = mapper.readTree( resource().path( orgAppPath + "token" )
                 .type( MediaType.APPLICATION_FORM_URLENCODED_TYPE ).accept( MediaType.APPLICATION_JSON )
                 .post( String.class, payload ));
 
@@ -481,7 +452,6 @@ public class ApplicationResourceIT extends AbstractRestIT {
 
     @Test
     public void clientCredentialsFlowWithHeaderAuthorizationAndPayload() throws Exception {
-        ApplicationInfo appInfo = setup.getMgmtSvc().getApplicationInfo( "test-organization/test-app" );
         String clientId = setup.getMgmtSvc().getClientIdForApplication( appInfo.getId() );
         String clientSecret = setup.getMgmtSvc().getClientSecretForApplication( appInfo.getId() );
 
@@ -490,7 +460,7 @@ public class ApplicationResourceIT extends AbstractRestIT {
 
         Map<String, String> payload = hashMap( "grant_type", "client_credentials" );
 
-        JsonNode node = mapper.readTree( resource().path( "/test-organization/test-app/token" ).header( "Authorization", "Basic " + token )
+        JsonNode node = mapper.readTree( resource().path( orgAppPath + "token" ).header( "Authorization", "Basic " + token )
                         .type( MediaType.APPLICATION_JSON_TYPE ).accept( MediaType.APPLICATION_JSON )
                         .post( String.class, payload ));
 
@@ -504,7 +474,7 @@ public class ApplicationResourceIT extends AbstractRestIT {
         JsonNode node = null;
 
         try {
-            node = mapper.readTree( resource().path( "/test-organization/test-app/apm/apigeeMobileConfig" ).get( String.class ));
+            node = mapper.readTree( resource().path( orgAppPath + "apm/apigeeMobileConfig" ).get( String.class ));
             //if things are kosher then JSON should have value for instaOpsApplicationId
             assertTrue( "it's valid json for APM", node.has( "instaOpsApplicationId" ) );
         }
@@ -519,12 +489,10 @@ public class ApplicationResourceIT extends AbstractRestIT {
     @Test
     public void appTokenFromOrgCreds() throws Exception {
 
-        OrganizationInfo orgInfo = setup.getMgmtSvc().getOrganizationByName( "test-organization" );
-
         String clientId = setup.getMgmtSvc().getClientIdForOrganization( orgInfo.getUuid() );
         String clientSecret = setup.getMgmtSvc().getClientSecretForOrganization( orgInfo.getUuid() );
 
-        JsonNode node = mapper.readTree( resource().path( "/test-organization/test-app/token" )
+        JsonNode node = mapper.readTree( resource().path( orgAppPath + "token" )
                 .queryParam( "client_id", clientId )
                 .queryParam( "client_secret", clientSecret )
                 .queryParam( "grant_type", "client_credentials" )
@@ -539,7 +507,7 @@ public class ApplicationResourceIT extends AbstractRestIT {
         //check it's 1 day, should be the same as the default
         assertEquals( 604800, ttl );
 
-        node = mapper.readTree( resource().path( "/test-organization/test-app/users" )
+        node = mapper.readTree( resource().path( orgAppPath + "users" )
                 .queryParam( "access_token", accessToken )
                 .accept( MediaType.APPLICATION_JSON ).type( MediaType.APPLICATION_JSON_TYPE ).get( String.class ));
 
@@ -550,12 +518,10 @@ public class ApplicationResourceIT extends AbstractRestIT {
     @Test
     public void appTokenFromAppCreds() throws Exception {
 
-        ApplicationInfo appInfo = setup.getMgmtSvc().getApplicationInfo( "test-organization/test-app" );
-
         String clientId = setup.getMgmtSvc().getClientIdForApplication( appInfo.getId() );
         String clientSecret = setup.getMgmtSvc().getClientSecretForApplication( appInfo.getId() );
 
-        JsonNode node = mapper.readTree( resource().path( "/test-organization/test-app/token" )
+        JsonNode node = mapper.readTree( resource().path( orgAppPath + "token" )
                 .queryParam( "client_id", clientId )
                 .queryParam( "client_secret", clientSecret )
                 .queryParam( "grant_type", "client_credentials" )
@@ -570,7 +536,7 @@ public class ApplicationResourceIT extends AbstractRestIT {
         //check it's 7 days, should be the same as the default
         assertEquals( 604800, ttl );
 
-        node = mapper.readTree( resource().path( "/test-organization/test-app/users" )
+        node = mapper.readTree( resource().path( orgAppPath + "users" )
                 .queryParam( "access_token", accessToken )
                 .accept( MediaType.APPLICATION_JSON ).type( MediaType.APPLICATION_JSON_TYPE ).get( String.class ));
 


[04/50] [abbrv] incubator-usergrid git commit: Merge branch 'app-rebuild-fix' into USERGRID-273

Posted by sn...@apache.org.
Merge branch 'app-rebuild-fix' into USERGRID-273


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

Branch: refs/heads/two-dot-o
Commit: 011a5e07147b5d59a37e5d20bed9dda712f5bd57
Parents: 5d05f86 d2a0ff2
Author: Todd Nine <tn...@apigee.com>
Authored: Thu Feb 19 22:40:38 2015 -0700
Committer: Todd Nine <tn...@apigee.com>
Committed: Thu Feb 19 22:40:38 2015 -0700

----------------------------------------------------------------------
 .../corepersistence/CpEntityManager.java        |  2 +-
 .../usergrid/corepersistence/CpWalker.java      | 73 ++++++++++----------
 .../org/apache/usergrid/rest/IndexResource.java | 26 ++++---
 3 files changed, 55 insertions(+), 46 deletions(-)
----------------------------------------------------------------------



[38/50] [abbrv] incubator-usergrid git commit: Merge branch 'USERGRID-273' of https://git-wip-us.apache.org/repos/asf/incubator-usergrid into USERGRID-273

Posted by sn...@apache.org.
Merge branch 'USERGRID-273' of https://git-wip-us.apache.org/repos/asf/incubator-usergrid into USERGRID-273


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

Branch: refs/heads/two-dot-o
Commit: 9b846c35a7e31d451a9bdfd64d4083ba17a8f0ec
Parents: d0e3782 f20c353
Author: Todd Nine <tn...@apigee.com>
Authored: Wed Feb 25 09:11:52 2015 -0700
Committer: Todd Nine <tn...@apigee.com>
Committed: Wed Feb 25 09:11:52 2015 -0700

----------------------------------------------------------------------
 .../resources/usergrid-deployment.properties    | 111 -------------------
 1 file changed, 111 deletions(-)
----------------------------------------------------------------------



[07/50] [abbrv] incubator-usergrid git commit: reindexCollection now implemented w/test in the Core module. Still needs a REST level test.

Posted by sn...@apache.org.
reindexCollection now implemented w/test in the Core module. Still needs a REST level test.


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

Branch: refs/heads/two-dot-o
Commit: 2f077f1bada2cb79db5dc9af19f101b668f92b9c
Parents: a704ed7
Author: Dave Johnson <dm...@apigee.com>
Authored: Fri Feb 20 13:52:21 2015 -0500
Committer: Dave Johnson <dm...@apigee.com>
Committed: Fri Feb 20 13:52:21 2015 -0500

----------------------------------------------------------------------
 .../corepersistence/CpEntityManager.java        | 37 ++++----
 .../usergrid/corepersistence/CpWalker.java      | 20 +++-
 .../usergrid/persistence/EntityManager.java     |  2 +-
 .../cassandra/EntityManagerFactoryImpl.java     | 11 +--
 .../cassandra/EntityManagerImpl.java            |  4 +-
 .../PerformanceEntityRebuildIndexTest.java      | 97 ++++++++++++--------
 .../management/importer/ImportCollectionIT.java |  6 +-
 7 files changed, 105 insertions(+), 72 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/2f077f1b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java
index 6af0539..721ac80 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java
@@ -2745,11 +2745,12 @@ public class CpEntityManager implements EntityManager {
      */
     @Override
     public void reindexCollection(
-        final EntityManagerFactory.ProgressObserver po, String collectionName) throws Exception {
+        final EntityManagerFactory.ProgressObserver po, String collectionName, boolean reverse) throws Exception {
 
         CpWalker walker = new CpWalker( );
 
-        walker.walkCollections( this, application, collectionName, new CpVisitor() {
+        walker.walkCollections(
+            this, application, collectionName, reverse, new CpVisitor() {
 
             @Override
             public void visitCollectionEntry( EntityManager em, String collName, Entity entity ) {
@@ -2759,9 +2760,9 @@ public class CpEntityManager implements EntityManager {
                     po.onProgress( entity );
                 }
                 catch ( WriteOptimisticVerifyException wo ) {
-                    //swallow this, it just means this was already updated, which accomplishes our task.  Just ignore.
-                    logger.warn( "Someone beat us to updating entity {} in collection {}.  Ignoring.", entity.getName(),
-                        collName );
+                    // swallow this, it just means this was already updated, which accomplishes our task
+                    logger.warn( "Someone beat us to updating entity {} in collection {}.  Ignoring.",
+                        entity.getName(), collName );
                 }
                 catch ( Exception ex ) {
                     logger.error( "Error repersisting entity", ex );
@@ -2778,23 +2779,23 @@ public class CpEntityManager implements EntityManager {
 
         CpWalker walker = new CpWalker( );
 
-        walker.walkCollections( this, application, null, new CpVisitor() {
+        walker.walkCollections( this, application, null, false, new CpVisitor() {
 
             @Override
             public void visitCollectionEntry( EntityManager em, String collName, Entity entity ) {
 
-                try {
-                    em.update( entity );
-                    po.onProgress( entity );
-                }
-                catch ( WriteOptimisticVerifyException wo ) {
-                    //swallow this, it just means this was already updated, which accomplishes our task.  Just ignore.
-                    logger.warn( "Someone beat us to updating entity {} in collection {}.  Ignoring.", entity.getName(),
-                            collName );
-                }
-                catch ( Exception ex ) {
-                    logger.error( "Error repersisting entity", ex );
-                }
+            try {
+                em.update( entity );
+                po.onProgress( entity );
+            }
+            catch ( WriteOptimisticVerifyException wo ) {
+                //swallow this, it just means this was already updated, which accomplishes our task.
+                logger.warn( "Someone beat us to updating entity {} in collection {}.  Ignoring.",
+                    entity.getName(), collName );
+            }
+            catch ( Exception ex ) {
+                logger.error( "Error repersisting entity", ex );
+            }
             }
         } );
     }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/2f077f1b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpWalker.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpWalker.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpWalker.java
index 6bd90ec..fab7e16 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpWalker.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpWalker.java
@@ -56,15 +56,17 @@ public class CpWalker {
 
 
     public void walkCollections(final CpEntityManager em, final EntityRef start,
-                                String collectionName, final CpVisitor visitor) throws Exception {
+        String collectionName, boolean reverse, final CpVisitor visitor) throws Exception {
 
-        doWalkCollections( em, collectionName, new SimpleId( start.getUuid(), start.getType() ), visitor );
+        doWalkCollections(
+            em, collectionName, reverse, new SimpleId( start.getUuid(), start.getType() ), visitor );
     }
 
 
     private void doWalkCollections(
             final CpEntityManager em,
             final String collectionName,
+            final boolean reverse,
             final Id applicationId,
             final CpVisitor visitor ) {
 
@@ -80,12 +82,20 @@ public class CpWalker {
                 applicationScope.getApplication().getUuid()
             } );
 
-        // only search edge types that start with collections
+        final SearchByEdgeType.Order order;
+        if ( reverse ) {
+            order = SearchByEdgeType.Order.ASCENDING;
+        } else {
+            order = SearchByEdgeType.Order.DESCENDING;
+        }
 
         final String edgeType;
-        if ( collectionName != null ) {
+        if ( collectionName == null ) {
+            // only search edge types that end with collections suffix
             edgeType = CpNamingUtils.EDGE_COLL_SUFFIX;
+
         } else {
+            // only search edges to one collection
             edgeType = CpNamingUtils.getEdgeTypeFromCollectionName( collectionName );
         }
 
@@ -99,7 +109,7 @@ public class CpWalker {
                 logger.debug( "Loading edges of type {} from node {}", edgeType, applicationId );
 
                 return gm.loadEdgesFromSource(  new SimpleSearchByEdgeType(
-                    applicationId, edgeType, Long.MAX_VALUE, SearchByEdgeType.Order.DESCENDING, null ) );
+                    applicationId, edgeType, Long.MAX_VALUE, order , null ) );
 
             }
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/2f077f1b/stack/core/src/main/java/org/apache/usergrid/persistence/EntityManager.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/persistence/EntityManager.java b/stack/core/src/main/java/org/apache/usergrid/persistence/EntityManager.java
index b7ca477..4054d77 100644
--- a/stack/core/src/main/java/org/apache/usergrid/persistence/EntityManager.java
+++ b/stack/core/src/main/java/org/apache/usergrid/persistence/EntityManager.java
@@ -704,7 +704,7 @@ public interface EntityManager {
     public void flushManagerCaches();
 
     void reindexCollection(
-        EntityManagerFactory.ProgressObserver po, String collectionName) throws Exception;
+        EntityManagerFactory.ProgressObserver po, String collectionName, boolean reverse) throws Exception;
 
     public void reindex( final EntityManagerFactory.ProgressObserver po ) throws Exception;
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/2f077f1b/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/EntityManagerFactoryImpl.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/EntityManagerFactoryImpl.java b/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/EntityManagerFactoryImpl.java
index b7808d8..535a14e 100644
--- a/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/EntityManagerFactoryImpl.java
+++ b/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/EntityManagerFactoryImpl.java
@@ -423,6 +423,11 @@ public class EntityManagerFactoryImpl implements EntityManagerFactory, Applicati
     }
 
     @Override
+    public void rebuildCollectionIndex(UUID appId, String collection, boolean reverse, ProgressObserver po) throws Exception {
+        throw new UnsupportedOperationException("Not supported.");
+    }
+
+    @Override
     public void rebuildInternalIndexes(ProgressObserver po) throws Exception {
         throw new UnsupportedOperationException("Not supported.");
     }
@@ -461,12 +466,6 @@ public class EntityManagerFactoryImpl implements EntityManagerFactory, Applicati
         throw new UnsupportedOperationException("Not supported in v1");
     }
 
-
-    @Override
-    public void rebuildCollectionIndex(UUID appId, String collection, ProgressObserver po) {
-        throw new UnsupportedOperationException("Not supported.");
-    }
-
     @Override
     public void addIndex(UUID appId, String suffix,final int shards,final int replicas) {
         throw new UnsupportedOperationException("Not supported in v1");

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/2f077f1b/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/EntityManagerImpl.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/EntityManagerImpl.java b/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/EntityManagerImpl.java
index d0fe985..be43920 100644
--- a/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/EntityManagerImpl.java
+++ b/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/EntityManagerImpl.java
@@ -2932,7 +2932,9 @@ public class EntityManagerImpl implements EntityManager {
     }
 
     @Override
-    public void reindexCollection(EntityManagerFactory.ProgressObserver po, String collectionName) throws Exception {
+    public void reindexCollection(
+        EntityManagerFactory.ProgressObserver po, String collectionName, boolean reverse) throws Exception {
+
         throw new UnsupportedOperationException("Not supported.");
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/2f077f1b/stack/core/src/test/java/org/apache/usergrid/persistence/PerformanceEntityRebuildIndexTest.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/PerformanceEntityRebuildIndexTest.java b/stack/core/src/test/java/org/apache/usergrid/persistence/PerformanceEntityRebuildIndexTest.java
index e853e94..52b6fe4 100644
--- a/stack/core/src/test/java/org/apache/usergrid/persistence/PerformanceEntityRebuildIndexTest.java
+++ b/stack/core/src/test/java/org/apache/usergrid/persistence/PerformanceEntityRebuildIndexTest.java
@@ -24,6 +24,7 @@ import java.util.Map;
 import java.util.UUID;
 import java.util.concurrent.TimeUnit;
 
+import org.apache.commons.lang.RandomStringUtils;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
@@ -60,7 +61,7 @@ public class PerformanceEntityRebuildIndexTest extends AbstractCoreIT {
     private static final MetricRegistry registry = new MetricRegistry();
     private Slf4jReporter reporter;
 
-    private static final long RUNTIME_MS = TimeUnit.SECONDS.toMillis( 3 );
+    private static final long RUNTIME_MS = TimeUnit.SECONDS.toMillis( 10 );
 
     private static final long WRITE_DELAY_MS = 10;
 
@@ -92,7 +93,10 @@ public class PerformanceEntityRebuildIndexTest extends AbstractCoreIT {
 
         logger.info("Started rebuildIndex()");
 
-        final EntityManager em = app.getEntityManager();
+        String rand = RandomStringUtils.randomAlphanumeric(5);
+        final UUID appId = setup.createApplication("org_" + rand, "app_" + rand);
+
+        final EntityManager em = setup.getEmf().getEntityManager( appId );
 
         // ----------------- create a bunch of entities
 
@@ -101,40 +105,50 @@ public class PerformanceEntityRebuildIndexTest extends AbstractCoreIT {
             put("key2", 2000 );
             put("key3", "Some value");
         }};
-        Map<String, Object> cat1map = new HashMap<String, Object>() {{
-            put("name", "enzo");
-            put("color", "orange");
-        }};
-        Map<String, Object> cat2map = new HashMap<String, Object>() {{
-            put("name", "marquee");
-            put("color", "grey");
-        }};
-        Map<String, Object> cat3map = new HashMap<String, Object>() {{
-            put("name", "bertha");
-            put("color", "tabby");
-        }};
 
-        Entity cat1 = em.create("cat", cat1map );
-        Entity cat2 = em.create("cat", cat2map );
-        Entity cat3 = em.create("cat", cat3map );
+//        Map<String, Object> cat1map = new HashMap<String, Object>() {{
+//            put("name", "enzo");
+//            put("color", "orange");
+//        }};
+//        Map<String, Object> cat2map = new HashMap<String, Object>() {{
+//            put("name", "marquee");
+//            put("color", "grey");
+//        }};
+//        Map<String, Object> cat3map = new HashMap<String, Object>() {{
+//            put("name", "bertha");
+//            put("color", "tabby");
+//        }};
+//
+//        Entity cat1 = em.create("cat", cat1map );
+//        Entity cat2 = em.create("cat", cat2map );
+//        Entity cat3 = em.create("cat", cat3map );
 
         final long stopTime = System.currentTimeMillis() + RUNTIME_MS;
 
         List<EntityRef> entityRefs = new ArrayList<EntityRef>();
         int entityCount = 0;
+        int herderCount  = 0;
+        int shepardCount = 0;
         while ( System.currentTimeMillis() < stopTime ) {
 
             final Entity entity;
 
             try {
                 entityMap.put("key", entityCount );
-                entity = em.create("testType", entityMap );
+
+                if ( entityCount % 2 == 0 ) {
+                    entity = em.create("catherder", entityMap);
+                    herderCount++;
+                } else {
+                    entity = em.create("catshepard", entityMap);
+                    shepardCount++;
+                }
 
                 em.refreshIndex();
 
-                em.createConnection(entity, "herds", cat1);
-                em.createConnection(entity, "herds", cat2);
-                em.createConnection(entity, "herds", cat3);
+//                em.createConnection(entity, "herds", cat1);
+//                em.createConnection(entity, "herds", cat2);
+//                em.createConnection(entity, "herds", cat3);
 
             } catch (Exception ex) {
                 throw new RuntimeException("Error creating entity", ex);
@@ -155,24 +169,25 @@ public class PerformanceEntityRebuildIndexTest extends AbstractCoreIT {
         // ----------------- test that we can read them, should work fine
 
         logger.debug("Read the data");
-        readData("testTypes", entityCount );
+        readData( em, "catherders", herderCount, 0);
+        readData( em, "catshepards", shepardCount, 0);
 
         // ----------------- delete the system and application indexes
 
-        logger.debug("Deleting app index and system app index");
-        deleteIndex( CpNamingUtils.SYSTEM_APP_ID );
+        logger.debug("Deleting app index index");
+        //deleteIndex( CpNamingUtils.SYSTEM_APP_ID );
         deleteIndex( em.getApplicationId() );
 
         // ----------------- test that we can read them, should fail
 
         logger.debug("Reading data, should fail this time ");
         try {
-            readData( "testTypes", entityCount );
+            readData( em,  "testTypes", entityCount, 0 );
             fail("should have failed to read data");
 
         } catch (Exception expected) {}
 
-        // ----------------- rebuild index
+        // ----------------- rebuild index for catherders only
 
         logger.debug("Preparing to rebuild all indexes");;
 
@@ -203,7 +218,7 @@ public class PerformanceEntityRebuildIndexTest extends AbstractCoreIT {
 
         try {
 
-            setup.getEmf().rebuildApplicationIndexes( em.getApplicationId(), po );
+            setup.getEmf().rebuildCollectionIndex( em.getApplicationId(), "catherders", false, po );
 
             reporter.report();
             registry.remove( meterName );
@@ -214,9 +229,10 @@ public class PerformanceEntityRebuildIndexTest extends AbstractCoreIT {
             fail();
         }
 
-        // ----------------- test that we can read them
+        // ----------------- test that we can read the catherder collection and not the catshepard
 
-        readData( "testTypes", entityCount );
+        readData( em, "catherders", herderCount, 0 );
+        readData( em, "catshepards", 0, 0 );
     }
 
 
@@ -225,7 +241,10 @@ public class PerformanceEntityRebuildIndexTest extends AbstractCoreIT {
 
         logger.info("Started rebuildIndex()");
 
-        final EntityManager em = app.getEntityManager();
+        String rand = RandomStringUtils.randomAlphanumeric(5);
+        final UUID appId = setup.createApplication("org_" + rand, "app_" + rand);
+
+        final EntityManager em = setup.getEmf().getEntityManager(appId);
 
         // ----------------- create a bunch of entities
 
@@ -288,19 +307,19 @@ public class PerformanceEntityRebuildIndexTest extends AbstractCoreIT {
         // ----------------- test that we can read them, should work fine
 
         logger.debug("Read the data");
-        readData("testTypes", entityCount );
+        readData( em, "testTypes", entityCount, 3 );
 
         // ----------------- delete the system and application indexes
 
         logger.debug("Deleting app index and system app index");
-        deleteIndex( CpNamingUtils.SYSTEM_APP_ID );
+        //deleteIndex( CpNamingUtils.SYSTEM_APP_ID );
         deleteIndex( em.getApplicationId() );
 
         // ----------------- test that we can read them, should fail
 
         logger.debug("Reading data, should fail this time ");
         try {
-            readData( "testTypes", entityCount );
+            readData( em, "testTypes", entityCount, 3 );
             fail("should have failed to read data");
 
         } catch (Exception expected) {}
@@ -349,7 +368,7 @@ public class PerformanceEntityRebuildIndexTest extends AbstractCoreIT {
 
         // ----------------- test that we can read them
 
-        readData( "testTypes", entityCount );
+        readData( em, "testTypes", entityCount, 3 );
     }
 
     /**
@@ -369,9 +388,9 @@ public class PerformanceEntityRebuildIndexTest extends AbstractCoreIT {
     }
 
 
-    private int readData( String collectionName, int expected ) throws Exception {
+    private int readData( EntityManager em,
+        String collectionName, int expectedEntities, int expectedConnections ) throws Exception {
 
-        EntityManager em = app.getEntityManager();
         em.refreshIndex();
 
         Query q = Query.fromQL("select * where key1=1000");
@@ -387,7 +406,7 @@ public class PerformanceEntityRebuildIndexTest extends AbstractCoreIT {
 
                 Results catResults = em.searchConnectedEntities(e,
                     Query.fromQL("select *").setConnectionType( "herds" ));
-                assertEquals( 3, catResults.size() );
+                assertEquals( expectedConnections, catResults.size() );
 
                 if ( count % 100 == 0 ) {
                     logger.info( "read {} entities", count);
@@ -405,9 +424,9 @@ public class PerformanceEntityRebuildIndexTest extends AbstractCoreIT {
             }
         }
 
-        if ( expected != -1 && expected != count ) {
+        if ( expectedEntities != -1 && expectedEntities != count ) {
             throw new RuntimeException("Did not get expected "
-                    + expected + " entities, instead got " + count );
+                    + expectedEntities + " entities, instead got " + count );
         }
         return count;
     }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/2f077f1b/stack/services/src/test/java/org/apache/usergrid/management/importer/ImportCollectionIT.java
----------------------------------------------------------------------
diff --git a/stack/services/src/test/java/org/apache/usergrid/management/importer/ImportCollectionIT.java b/stack/services/src/test/java/org/apache/usergrid/management/importer/ImportCollectionIT.java
index e566512..7fcfc57 100644
--- a/stack/services/src/test/java/org/apache/usergrid/management/importer/ImportCollectionIT.java
+++ b/stack/services/src/test/java/org/apache/usergrid/management/importer/ImportCollectionIT.java
@@ -110,7 +110,8 @@ public class ImportCollectionIT {
         bucketPrefix = System.getProperty( "bucketName" );
 
         // start the scheduler after we're all set up
-        JobSchedulerService jobScheduler = ConcurrentProcessSingleton.getInstance().getSpringResource().getBean( JobSchedulerService.class );
+        JobSchedulerService jobScheduler = ConcurrentProcessSingleton.getInstance()
+            .getSpringResource().getBean( JobSchedulerService.class );
         if ( jobScheduler.state() != Service.State.RUNNING ) {
             jobScheduler.startAsync();
             jobScheduler.awaitRunning();
@@ -481,7 +482,8 @@ public class ImportCollectionIT {
 
         ImportService importService = setup.getImportService();
 
-        Import importEntity = importService.schedule(em.getApplication().getUuid(),  new HashMap<String, Object>() {{
+        Import importEntity = importService.schedule(em.getApplication().getUuid(),
+            new HashMap<String, Object>() {{
             put( "path", organization.getName() + em.getApplication().getName() );
             put( "organizationId", organization.getUuid() );
             put( "applicationId", em.getApplication().getUuid() );


[22/50] [abbrv] incubator-usergrid git commit: Merge branch 'USERGRID-273' of https://git-wip-us.apache.org/repos/asf/incubator-usergrid into USERGRID-409

Posted by sn...@apache.org.
Merge branch 'USERGRID-273' of https://git-wip-us.apache.org/repos/asf/incubator-usergrid into USERGRID-409

# By Dave Johnson (3) and Todd Nine (1)
# Via Todd Nine
* 'USERGRID-273' of https://git-wip-us.apache.org/repos/asf/incubator-usergrid:
  Fixes problem with arquillian configuration and plugin scope
  Not needed in git.
  Don't run two schedulers.
  Move back to Guava 14.0.1 to enable JClouds to work properly, plus changes to Arquillian setup.


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

Branch: refs/heads/two-dot-o
Commit: 07755c15c0d525f10328384aa9f9ffe0fb8393e7
Parents: 08c1f1d b82999e
Author: grey <gr...@apigee.com>
Authored: Mon Feb 23 18:32:43 2015 -0800
Committer: grey <gr...@apigee.com>
Committed: Mon Feb 23 18:32:43 2015 -0800

----------------------------------------------------------------------
 .../batch/job/AbstractSchedulerRuntimeIT.java   |  3 +-
 stack/corepersistence/pom.xml                   |  4 +--
 stack/pom.xml                                   |  6 ++--
 stack/rest/README.md                            | 13 +++-----
 stack/rest/catalina_base/webapps/ROOT           |  1 -
 stack/rest/pom.xml                              | 35 ++++++++------------
 .../usergrid/rest/JobServiceBoostrap.java       |  3 +-
 .../apache/usergrid/rest/AbstractRestIT.java    | 18 +++++-----
 .../rest/management/ImportResourceIT.java       |  3 +-
 .../resources/usergrid-custom-test.properties   |  8 ++---
 .../management/export/ExportServiceIT.java      |  3 +-
 .../management/importer/ImportCollectionIT.java |  3 +-
 .../management/importer/ImportServiceIT.java    |  3 +-
 13 files changed, 43 insertions(+), 60 deletions(-)
----------------------------------------------------------------------



[29/50] [abbrv] incubator-usergrid git commit: Moving back to embedded Tomcat instead of Arquillian.

Posted by sn...@apache.org.
Moving back to embedded Tomcat instead of Arquillian.


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

Branch: refs/heads/two-dot-o
Commit: e05800e450240603dd2b88584242f505b0990296
Parents: 4795355
Author: Dave Johnson <dm...@apigee.com>
Authored: Tue Feb 24 19:10:22 2015 -0500
Committer: Dave Johnson <dm...@apigee.com>
Committed: Tue Feb 24 19:10:22 2015 -0500

----------------------------------------------------------------------
 .../applications/ApplicationsResource.java      |  20 +-
 .../apache/usergrid/rest/AbstractRestIT.java    |  42 ++---
 .../java/org/apache/usergrid/rest/BasicIT.java  |  66 +++----
 .../java/org/apache/usergrid/rest/ITSetup.java  |  15 +-
 .../apache/usergrid/rest/TomcatResource.java    | 182 +++++++++++++++++++
 .../test/resource2point0/AbstractRestIT.java    |  75 ++++----
 6 files changed, 281 insertions(+), 119 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e05800e4/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 0c8ee06..2a5ce9d 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
@@ -140,16 +140,16 @@ public class ApplicationsResource extends AbstractContextResource {
     }
 
 
-    @RequireOrganizationAccess
-    @Path(RootResource.APPLICATION_ID_PATH)
-    @PUT
-    public ApplicationResource restoreApplicationFromOrganizationByApplicationId(
-        @Context UriInfo ui,
-        @PathParam( "applicationId" )
-        String applicationIdStr ) throws Exception {
-
-        return getSubResource( ApplicationResource.class ).init( organization, UUID.fromString( applicationIdStr ) );
-    }
+//    @RequireOrganizationAccess
+//    @Path(RootResource.APPLICATION_ID_PATH)
+//    @PUT
+//    public ApplicationResource restoreApplicationFromOrganizationByApplicationId(
+//        @Context UriInfo ui,
+//        @PathParam( "applicationId" )
+//        String applicationIdStr ) throws Exception {
+//
+//        return getSubResource( ApplicationResource.class ).init( organization, UUID.fromString( applicationIdStr ) );
+//    }
 
 
     @RequireOrganizationAccess

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e05800e4/stack/rest/src/test/java/org/apache/usergrid/rest/AbstractRestIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/AbstractRestIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/AbstractRestIT.java
index eb1f628..15b2882 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/AbstractRestIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/AbstractRestIT.java
@@ -27,35 +27,28 @@ 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.java.client.Client;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.Rule;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.UriBuilder;
 import java.io.IOException;
 import java.net.URI;
+import java.net.URISyntaxException;
 import java.net.URLClassLoader;
 import java.util.Arrays;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.UUID;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.UriBuilder;
-import org.apache.usergrid.java.client.Client;
+
 import static org.apache.usergrid.utils.JsonUtils.mapToFormattedJsonString;
 import static org.apache.usergrid.utils.MapUtils.hashMap;
-
-import org.eu.ingwar.tools.arquillian.extension.suite.annotations.ArquillianSuiteDeployment;
-import org.jboss.arquillian.container.test.api.Deployment;
-import org.jboss.arquillian.junit.Arquillian;
-import org.jboss.shrinkwrap.api.Archive;
-import org.jboss.shrinkwrap.api.ShrinkWrap;
-import org.jboss.shrinkwrap.api.spec.WebArchive;
-import org.jboss.shrinkwrap.resolver.api.maven.Maven;
-import org.jboss.shrinkwrap.resolver.api.maven.archive.importer.MavenImporter;
-import org.junit.AfterClass;
 import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
-import org.junit.Before;
-import org.junit.ClassRule;
-import org.junit.runner.RunWith;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 
 /**
@@ -82,9 +75,10 @@ public abstract class AbstractRestIT extends JerseyTest {
 
     protected static final AppDescriptor descriptor;
 
-    // TODO, this needs to be removed.  Instead we need to hook into the Arquillian event lifecycle
-    // to invoke /system/database/setup from the REST tier.
-    public static ITSetup setup = new ITSetup(  );
+    public static ITSetup setup = new ITSetup();
+
+    @Rule
+    public TomcatResource tomcatResource = new TomcatResource();
 
     //private static final URI baseURI = setup.getBaseURI();
 
@@ -211,7 +205,11 @@ public abstract class AbstractRestIT extends JerseyTest {
 
     @Override
     protected URI getBaseURI() {
-        return setup.getBaseURI();
+        try {
+            return new URI("http://localhost:" + tomcatResource.getPort());
+        } catch (URISyntaxException e) {
+            throw new RuntimeException("Error determining baseURI", e);
+        }
     }
 
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e05800e4/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 53b30a4..20d0a64 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,38 +17,26 @@
 package org.apache.usergrid.rest;
 
 
-import java.util.Map;
-
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.MultivaluedMap;
-
 import com.fasterxml.jackson.databind.JsonNode;
-
-import org.eu.ingwar.tools.arquillian.extension.suite.annotations.ArquillianSuiteDeployment;
+import com.sun.jersey.api.client.UniformInterfaceException;
+import com.sun.jersey.api.client.WebResource;
+import com.sun.jersey.core.util.MultivaluedMapImpl;
+import org.apache.usergrid.persistence.index.utils.UUIDUtils;
+import org.apache.usergrid.rest.test.security.TestAppUser;
+import org.apache.usergrid.rest.test.security.TestUser;
 import org.junit.Rule;
 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 com.sun.jersey.core.util.MultivaluedMapImpl;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.MultivaluedMap;
 import java.io.IOException;
-import java.util.UUID;
+import java.util.Map;
 
 import static org.apache.commons.lang.StringUtils.isNotBlank;
-
-import org.apache.usergrid.persistence.index.utils.UUIDUtils;
-import org.apache.usergrid.persistence.model.util.UUIDGenerator;
-import org.apache.usergrid.rest.management.organizations.OrganizationsResource;
-import org.apache.usergrid.rest.test.resource.app.UsersCollection;
-import org.apache.usergrid.rest.test.security.TestAppUser;
-import org.apache.usergrid.rest.test.security.TestUser;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
 import static org.apache.usergrid.utils.MapUtils.hashMap;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.*;
 
 
 public class BasicIT extends AbstractRestIT {
@@ -80,11 +68,12 @@ public class BasicIT extends AbstractRestIT {
     public void testGenericCollectionEntityNameUuid() throws Exception {
         JsonNode node = null;
         String orgAppPath = "/"+context.getOrgName()+"/"+context.getAppName();
-        TestUser testUser = new TestAppUser( "temp"+ UUIDUtils.newTimeUUID(),"password","temp"+UUIDUtils.newTimeUUID()+"@usergrid.com"  ).create( context );
+        TestUser testUser = new TestAppUser( "temp"+ UUIDUtils.newTimeUUID(),
+            "password","temp"+UUIDUtils.newTimeUUID()+"@usergrid.com"  ).create( context );
 
         //String token = userToken( "ed@anuff.com", "sesame" );
-        WebResource resource =
-                resource().path( orgAppPath+"/suspects" ).queryParam( "access_token", context.getActiveUser().getToken() );
+        WebResource resource = resource().path( orgAppPath+"/suspects" )
+            .queryParam( "access_token", context.getActiveUser().getToken() );
         node = mapper.readTree( resource.accept( MediaType.APPLICATION_JSON ).post( String.class ));
 
 
@@ -95,8 +84,9 @@ public class BasicIT extends AbstractRestIT {
         Map<String, String> payload = hashMap( "hair", "brown" ).map( "sex", "male" ).map( "eyes", "green" )
                 .map( "name", uuid.replace( '-', '0' ) ).map( "build", "thin" ).map( "height", "6 4" );
 
-        node = mapper.readTree( resource.queryParam( "access_token", context.getActiveUser().getToken() ).accept( MediaType.APPLICATION_JSON )
-                       .type( MediaType.APPLICATION_JSON_TYPE ).post( String.class, payload ));
+        node = mapper.readTree( resource.queryParam( "access_token",
+            context.getActiveUser().getToken() ).accept( MediaType.APPLICATION_JSON )
+            .type( MediaType.APPLICATION_JSON_TYPE ).post( String.class, payload ));
 
         logNode( node );
 
@@ -163,8 +153,8 @@ public class BasicIT extends AbstractRestIT {
 
         logNode( node );
 
-        assertEquals( username,
-                node.get( "data" ).get( "organizations" ).get( orgName.toLowerCase() ).get( "users" ).get( username ).get("name").textValue());
+        assertEquals( username, node.get( "data" ).get( "organizations" ).get( orgName.toLowerCase() )
+                    .get( "users" ).get( username ).get("name").textValue());
 
 
         // test login user with incorrect password
@@ -196,11 +186,13 @@ public class BasicIT extends AbstractRestIT {
         assertTrue( "Error should have been thrown", err_thrown );
 
         // test login user with correct password
-        TestUser testUser = new TestAppUser( "temp"+ UUIDUtils.newTimeUUID(),"password","temp"+UUIDUtils.newTimeUUID()+"@usergrid.com"  ).create( context );
+        TestUser testUser = new TestAppUser( "temp"+ UUIDUtils.newTimeUUID(),"password",
+            "temp"+UUIDUtils.newTimeUUID()+"@usergrid.com"  ).create( context );
 
-        node = mapper.readTree( resource().path( "/"+orgName+"/"+appName+"/token" ).queryParam( "grant_type", "password" )
-                .queryParam( "username", testUser.getUser() ).queryParam( "password", testUser.getPassword())
-                .accept( MediaType.APPLICATION_JSON ).get( String.class ));
+        node = mapper.readTree( resource().path( "/"+orgName+"/"+appName+"/token" )
+            .queryParam( "grant_type", "password" )
+            .queryParam( "username", testUser.getUser() ).queryParam( "password", testUser.getPassword())
+            .accept( MediaType.APPLICATION_JSON ).get( String.class ));
 
         logNode( node );
 
@@ -235,8 +227,9 @@ public class BasicIT extends AbstractRestIT {
 
         err_thrown = false;
         try {
-            node = mapper.readTree( resource().path( "/"+orgName+"/"+appName+"/users" ).queryParam( "access_token", "blahblahblah" )
-                    .accept( MediaType.APPLICATION_JSON ).get( String.class ));
+            node = mapper.readTree( resource().path( "/"+orgName+"/"+appName+"/users" )
+                .queryParam( "access_token", "blahblahblah" )
+                .accept( MediaType.APPLICATION_JSON ).get( String.class ));
         }
         catch ( UniformInterfaceException e ) {
             if ( e.getResponse().getStatus() != 401 ) {
@@ -341,7 +334,8 @@ public class BasicIT extends AbstractRestIT {
 
         err_thrown = false;
         try {
-            node = mapper.readTree( resource().path(  "/"+orgName+"/"+appName+"/items" ).accept( MediaType.APPLICATION_JSON )
+            node = mapper.readTree( resource().path(  "/"+orgName+"/"+appName+"/items" )
+                .accept( MediaType.APPLICATION_JSON )
                     .type( MediaType.APPLICATION_JSON_TYPE ).post( String.class, payload ));
         }
         catch ( UniformInterfaceException e ) {

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e05800e4/stack/rest/src/test/java/org/apache/usergrid/rest/ITSetup.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/ITSetup.java b/stack/rest/src/test/java/org/apache/usergrid/rest/ITSetup.java
index 021f937..7888061 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/ITSetup.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/ITSetup.java
@@ -42,6 +42,7 @@ public class ITSetup  {
     private SignInProviderFactory providerFactory;
     private Properties properties;
     private ManagementService managementService;
+    private TomcatResource tomcatResource;
 
     private URI uri;
 
@@ -52,10 +53,6 @@ public class ITSetup  {
 
         this.springResource = ConcurrentProcessSingleton.getInstance().getSpringResource();
 
-        //start tomcat
-
-
-
         emf =                springResource.getBean( EntityManagerFactory.class );
         smf =                springResource.getBean( ServiceManagerFactory.class );
         tokenService =       springResource.getBean( TokenService.class );
@@ -63,16 +60,15 @@ public class ITSetup  {
         applicationCreator = springResource.getBean( ApplicationCreator.class );
         managementService =  springResource.getBean( ManagementService.class );
 
+        tomcatResource = TomcatResource.instance;
+        tomcatResource.setWebAppsPath( "src/main/webapp" );
 
         // Initialize Jersey Client
         //TODO, make this port a resource that's filtered by maven build for the port number
         uri = UriBuilder.fromUri("http://localhost/").port( 8080 ).build();
-
-
     }
 
 
-
     public int getTomcatPort() {
         return 8080;
     }
@@ -111,9 +107,4 @@ public class ITSetup  {
     public SignInProviderFactory getProviderFactory() {
         return providerFactory;
     }
-
-
-    public URI getBaseURI() {
-        return uri;
-    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e05800e4/stack/rest/src/test/java/org/apache/usergrid/rest/TomcatResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/TomcatResource.java b/stack/rest/src/test/java/org/apache/usergrid/rest/TomcatResource.java
new file mode 100644
index 0000000..5f00f7b
--- /dev/null
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/TomcatResource.java
@@ -0,0 +1,182 @@
+/*
+ * 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.google.common.io.Files;
+import com.sun.jersey.api.client.Client;
+import com.sun.jersey.api.client.WebResource;
+import org.apache.catalina.LifecycleException;
+import org.apache.catalina.startup.Tomcat;
+import org.apache.commons.lang.math.RandomUtils;
+import org.apache.usergrid.cassandra.AvailablePortFinder;
+import org.junit.rules.ExternalResource;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.context.ConfigurableApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+import javax.servlet.ServletException;
+import java.io.File;
+import java.util.concurrent.atomic.AtomicInteger;
+
+
+/**
+ * Start and stop embedded Tomcat.
+ */
+public class TomcatResource extends ExternalResource {
+    private static final Logger log = LoggerFactory.getLogger(TomcatResource.class);
+
+    public static final TomcatResource instance = new TomcatResource();
+
+    private static final Object mutex = new Object();
+    private String webAppsPath = "src/main/webapp";
+    private int port;
+    private boolean started = false;
+
+    private static AtomicInteger clientCount = new AtomicInteger(0);
+
+    Tomcat tomcat = null;
+    Process process = null;
+
+
+    public TomcatResource() {
+        try {
+            String[] locations = { "usergrid-properties-context.xml" };
+            ConfigurableApplicationContext appContext =
+                new ClassPathXmlApplicationContext( locations );
+
+        } catch (Exception ex) {
+            throw new RuntimeException("Error getting properties", ex);
+        }
+    }
+
+
+    @Override
+    protected void after() {
+        log.info("Entering after");
+
+        synchronized (mutex) {
+
+            if ( clientCount.decrementAndGet() < 1 ) {
+
+                log.info("----------------------------------------------------------------------");
+                log.info("Destroying Tomcat running on port " + port);
+                log.info("----------------------------------------------------------------------");
+
+                if ( process != null ) {
+                    process.destroy();
+
+                } else if ( tomcat != null ) {
+                    try {
+                        tomcat.stop();
+                        tomcat.destroy();
+                    } catch (LifecycleException ex) {
+                        log.error("Error stopping Tomcat", ex);
+                    }
+                }
+                started = false;
+
+            } else {
+                log.info("NOT stopping Tomcat because it is still in use by {}", clientCount.get());
+            }
+        }
+
+        log.info("Leaving after");
+    }
+
+
+    @Override
+    protected void before() throws Throwable {
+        log.info("Entering before");
+
+        synchronized (mutex) {
+
+            clientCount.incrementAndGet();
+
+            if (started) {
+                log.info("NOT starting Tomcat because it is already started");
+                log.info("Leaving before: {} users of Tomcat", clientCount.get());
+                return;
+            }
+
+            startTomcatEmbedded();
+
+            log.info("Leaving before: Started Tomcat, now {} users", clientCount.get());
+        }
+
+    }
+
+
+    private void waitForTomcat() throws RuntimeException {
+        String url = "http://localhost:" + port + "/status";
+        int count = 0;
+        while (count++ < 30) {
+            try {
+                Thread.sleep(1000);
+                Client c = Client.create();
+                WebResource wr = c.resource( url );
+                wr.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.");
+        }
+    }
+
+
+    private void startTomcatEmbedded() throws ServletException, LifecycleException {
+
+        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", "2000");
+        tomcat.addWebapp( "/", new File( getWebAppsPath() ).getAbsolutePath() );
+
+        log.info("-----------------------------------------------------------------");
+        log.info("Starting Tomcat embedded port {} dir {}", port, dataDir.getAbsolutePath());
+        log.info("-----------------------------------------------------------------");
+        tomcat.start();
+
+        waitForTomcat();
+
+        mutex.notifyAll();
+    }
+
+    public int getPort() {
+        return port;
+    }
+
+    public String getWebAppsPath() {
+        return webAppsPath;
+    }
+
+    public void setWebAppsPath(String webAppsPath) {
+        this.webAppsPath = webAppsPath;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e05800e4/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/AbstractRestIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/AbstractRestIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/AbstractRestIT.java
index cdba34c..43d0ba4 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/AbstractRestIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/AbstractRestIT.java
@@ -17,27 +17,6 @@
 package org.apache.usergrid.rest.test.resource2point0;
 
 
-import java.net.URI;
-import java.net.URLClassLoader;
-import java.util.Arrays;
-
-import org.jboss.arquillian.container.test.api.Deployment;
-import org.jboss.arquillian.junit.Arquillian;
-import org.jboss.shrinkwrap.api.ShrinkWrap;
-import org.jboss.shrinkwrap.api.spec.WebArchive;
-import org.jboss.shrinkwrap.resolver.api.maven.archive.importer.MavenImporter;
-import org.junit.Rule;
-import org.junit.runner.RunWith;
-
-import org.apache.usergrid.rest.ITSetup;
-import org.apache.usergrid.rest.test.resource2point0.endpoints.ApplicationsResource;
-import org.apache.usergrid.rest.test.resource2point0.endpoints.OrganizationResource;
-import org.apache.usergrid.rest.test.resource2point0.endpoints.mgmt.ManagementResource;
-import org.apache.usergrid.rest.test.resource2point0.state.ClientContext;
-import org.apache.usergrid.rest.test.resource2point0.model.Entity;
-import org.apache.usergrid.rest.test.resource2point0.model.Token;
-import org.apache.usergrid.rest.test.resource2point0.state.ClientContext;
-
 import com.fasterxml.jackson.databind.JsonNode;
 import com.fasterxml.jackson.databind.ObjectMapper;
 import com.sun.jersey.api.client.UniformInterfaceException;
@@ -48,26 +27,40 @@ 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.ITSetup;
+import org.apache.usergrid.rest.TomcatResource;
+import org.apache.usergrid.rest.test.resource2point0.endpoints.ApplicationsResource;
+import org.apache.usergrid.rest.test.resource2point0.endpoints.OrganizationResource;
+import org.apache.usergrid.rest.test.resource2point0.endpoints.mgmt.ManagementResource;
+import org.apache.usergrid.rest.test.resource2point0.model.Token;
+import org.apache.usergrid.rest.test.resource2point0.state.ClientContext;
+import org.junit.Rule;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URLClassLoader;
+import java.util.Arrays;
 
 import static org.junit.Assert.assertEquals;
 
 
 
 /**
- * How would we get the client from here
+ * Base class for REST tests.
  */
-@RunWith( Arquillian.class )
+//@RunWith( Arquillian.class )
 public class AbstractRestIT extends JerseyTest {
 
     private static ClientConfig clientConfig = new DefaultClientConfig();
 
-
+    @Rule
+    public TomcatResource tomcatResource = new TomcatResource();
 
     public static ITSetup setup = new ITSetup(  );
 //
 //    TODO: Allow the client to be setup seperately
     @Rule
-    public ClientSetup clientSetup = new ClientSetup(setup.getBaseURI().toString());
+    public ClientSetup clientSetup = new ClientSetup( this.getBaseURI().toString() );
 
     protected static final AppDescriptor descriptor;
 
@@ -86,19 +79,19 @@ public class AbstractRestIT extends JerseyTest {
     }
 
 
-    //We set testable = false so we deploy the archive to the server and test it locally
-    @Deployment( testable = false )
-    public static WebArchive createTestArchive() {
-
-        //we use the MavenImporter from shrinkwrap to just produce whatever maven would build then test with it
-
-        //set maven to be in offline mode
-
-        System.setProperty( "org.apache.maven.offline", "true" );
-
-        return ShrinkWrap.create( MavenImporter.class ).loadPomFromFile( "pom.xml", "arquillian-tomcat" )
-                         .importBuildOutput().as( WebArchive.class );
-    }
+//    //We set testable = false so we deploy the archive to the server and test it locally
+//    @Deployment( testable = false )
+//    public static WebArchive createTestArchive() {
+//
+//        //we use the MavenImporter from shrinkwrap to just produce whatever maven would build then test with it
+//
+//        //set maven to be in offline mode
+//
+//        System.setProperty( "org.apache.maven.offline", "true" );
+//
+//        return ShrinkWrap.create( MavenImporter.class ).loadPomFromFile( "pom.xml", "arquillian-tomcat" )
+//                         .importBuildOutput().as( WebArchive.class );
+//    }
 
     public static void dumpClasspath( ClassLoader loader ) {
         System.out.println( "Classloader " + loader + ":" );
@@ -118,7 +111,11 @@ public class AbstractRestIT extends JerseyTest {
 
     @Override
     protected URI getBaseURI() {
-        return setup.getBaseURI();
+        try {
+            return new URI("http://localhost:" + tomcatResource.getPort());
+        } catch (URISyntaxException e) {
+            throw new RuntimeException("Error determining baseURI", e);
+        }
     }
 
     @Override


[41/50] [abbrv] incubator-usergrid git commit: Merge branch 'USERGRID-273' of https://git-wip-us.apache.org/repos/asf/incubator-usergrid into USERGRID-409

Posted by sn...@apache.org.
Merge branch 'USERGRID-273' of https://git-wip-us.apache.org/repos/asf/incubator-usergrid into USERGRID-409

# By Dave Johnson (6) and Todd Nine (2)
# Via Dave Johnson (2) and Todd Nine (1)
* 'USERGRID-273' of https://git-wip-us.apache.org/repos/asf/incubator-usergrid:
  Changes to allow us to fix the old tests that are broken because tests now share the same C* keyspace, and some fixes to the old ApplicationResourceIT.
  Removes wait from progress observer, since this is no longer used.
  Simple REST tests now working again with Tomcat embedded.
  Add jackson-xc back in.
  Add jackson-xc back in.
  Fixes startup order bug.
  Moving back to embedded Tomcat instead of Arquillian.
  Back off of Arquillian for now.


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

Branch: refs/heads/two-dot-o
Commit: 95ac7af1d964a92d215e225277b8f4d8ecc67c40
Parents: 4be53fb ec6d4e8
Author: grey <gr...@apigee.com>
Authored: Wed Feb 25 15:21:40 2015 -0800
Committer: grey <gr...@apigee.com>
Committed: Wed Feb 25 15:21:40 2015 -0800

----------------------------------------------------------------------
 .../corepersistence/CpEntityManagerFactory.java |   7 +-
 .../persistence/EntityManagerFactory.java       |   5 -
 .../PerformanceEntityRebuildIndexTest.java      |  13 +-
 .../cassandra/EntityManagerFactoryImplIT.java   |   5 -
 stack/pom.xml                                   |   1 +
 stack/rest/pom.xml                              | 134 ++++---------
 .../org/apache/usergrid/rest/IndexResource.java |  27 +--
 .../applications/ApplicationsResource.java      |  20 +-
 .../resources/usergrid-rest-deploy-context.xml  |   2 +-
 .../apache/usergrid/rest/AbstractRestIT.java    | 188 ++++++++++--------
 .../java/org/apache/usergrid/rest/BasicIT.java  |  66 +++----
 .../java/org/apache/usergrid/rest/ITSetup.java  |  57 +-----
 .../org/apache/usergrid/rest/SimplestTest.java  |  35 ++++
 .../org/apache/usergrid/rest/TomcatRuntime.java | 192 +++++++++++++++++++
 .../applications/ApplicationResourceIT.java     | 174 +++++++----------
 .../rest/management/RegistrationIT.java         |   9 +-
 .../test/resource2point0/AbstractRestIT.java    |  77 ++++----
 .../resources/usergrid-deployment.properties    | 111 -----------
 .../resources/usergrid-rest-deploy-context.xml  |  26 +++
 19 files changed, 571 insertions(+), 578 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/95ac7af1/stack/core/src/test/java/org/apache/usergrid/persistence/cassandra/EntityManagerFactoryImplIT.java
----------------------------------------------------------------------


[20/50] [abbrv] incubator-usergrid git commit: Fixes problem with arquillian configuration and plugin scope

Posted by sn...@apache.org.
Fixes problem with arquillian configuration and plugin scope


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

Branch: refs/heads/two-dot-o
Commit: b82999e2a35e0be6e5fff853380ba0b22e3b79c9
Parents: 949c22a
Author: Todd Nine <tn...@apigee.com>
Authored: Mon Feb 23 16:14:26 2015 -0700
Committer: Todd Nine <tn...@apigee.com>
Committed: Mon Feb 23 16:14:26 2015 -0700

----------------------------------------------------------------------
 stack/rest/pom.xml | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/b82999e2/stack/rest/pom.xml
----------------------------------------------------------------------
diff --git a/stack/rest/pom.xml b/stack/rest/pom.xml
index 7746b5d..b3c3663 100644
--- a/stack/rest/pom.xml
+++ b/stack/rest/pom.xml
@@ -45,7 +45,7 @@
             <id>arquillian-tomcat</id>
 
             <activation>
-                <activeByDefault>false</activeByDefault>
+                <activeByDefault>true</activeByDefault>
             </activation>
 
             <dependencies>
@@ -96,6 +96,7 @@
                     <groupId>org.jboss.arquillian.container</groupId>
                     <artifactId>arquillian-tomcat-remote-7</artifactId>
                     <version>1.0.0.CR7</version>
+                    <scope>test</scope>
                 </dependency>
 
             </dependencies>


[17/50] [abbrv] incubator-usergrid git commit: Move back to Guava 14.0.1 to enable JClouds to work properly, plus changes to Arquillian setup.

Posted by sn...@apache.org.
Move back to Guava 14.0.1 to enable JClouds to work properly, plus changes to Arquillian setup.


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

Branch: refs/heads/two-dot-o
Commit: 93b133b51ff2c14a2c62a55b03754068817eb5b9
Parents: 13da256
Author: Dave Johnson <dm...@apigee.com>
Authored: Mon Feb 23 15:45:22 2015 -0500
Committer: Dave Johnson <dm...@apigee.com>
Committed: Mon Feb 23 15:45:22 2015 -0500

----------------------------------------------------------------------
 .../batch/job/AbstractSchedulerRuntimeIT.java   |  3 +-
 stack/corepersistence/pom.xml                   |  4 +--
 stack/pom.xml                                   |  6 ++--
 stack/rest/README.md                            | 13 +++-----
 stack/rest/pom.xml                              | 32 ++++++++------------
 .../usergrid/rest/JobServiceBoostrap.java       |  3 +-
 .../apache/usergrid/rest/AbstractRestIT.java    | 18 +++++------
 .../rest/management/ImportResourceIT.java       |  3 +-
 .../management/export/ExportServiceIT.java      |  3 +-
 .../management/importer/ImportCollectionIT.java |  3 +-
 .../management/importer/ImportServiceIT.java    |  3 +-
 11 files changed, 38 insertions(+), 53 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/93b133b5/stack/core/src/test/java/org/apache/usergrid/batch/job/AbstractSchedulerRuntimeIT.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/batch/job/AbstractSchedulerRuntimeIT.java b/stack/core/src/test/java/org/apache/usergrid/batch/job/AbstractSchedulerRuntimeIT.java
index 534689c..8825497 100644
--- a/stack/core/src/test/java/org/apache/usergrid/batch/job/AbstractSchedulerRuntimeIT.java
+++ b/stack/core/src/test/java/org/apache/usergrid/batch/job/AbstractSchedulerRuntimeIT.java
@@ -96,8 +96,7 @@ public class AbstractSchedulerRuntimeIT {
         JobSchedulerService jobScheduler = springResource.getBean( JobSchedulerService.class );
         jobScheduler.setJobListener( listener );
         if ( jobScheduler.state() != State.RUNNING ) {
-            jobScheduler.startAsync();
-            jobScheduler.awaitRunning();
+            jobScheduler.startAndWait();
         }
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/93b133b5/stack/corepersistence/pom.xml
----------------------------------------------------------------------
diff --git a/stack/corepersistence/pom.xml b/stack/corepersistence/pom.xml
index c89e62f..e7da11f 100644
--- a/stack/corepersistence/pom.xml
+++ b/stack/corepersistence/pom.xml
@@ -61,8 +61,8 @@ limitations under the License.
         <commons.lang.version>3.1</commons.lang.version>
         <elasticsearch.version>1.3.2</elasticsearch.version>
         <fasterxml-uuid.version>3.1.3</fasterxml-uuid.version>
-        <guava.version>18.0</guava.version>
-        <guice.version>4.0-beta5</guice.version>
+        <guava.version>14.0.1</guava.version>
+        <guice.version>3.0</guice.version>
         <guicyfig.version>3.2</guicyfig.version>
         <hystrix.version>1.3.16</hystrix.version>
         <jackson-2-version>2.4.1</jackson-2-version>

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/93b133b5/stack/pom.xml
----------------------------------------------------------------------
diff --git a/stack/pom.xml b/stack/pom.xml
index 2735366..8545e88 100644
--- a/stack/pom.xml
+++ b/stack/pom.xml
@@ -97,6 +97,7 @@
 
       <amber-version>0.22-incubating</amber-version>
       <cassandra-version>1.2.18</cassandra-version>
+      <guava.version>14.0.1</guava.version>
       <hector-om-version>3.0-03</hector-om-version>
       <hector-version>1.1-4</hector-version>
       <hector-test-version>1.1-4</hector-test-version>
@@ -111,7 +112,7 @@
       <shiro-version>1.2.3</shiro-version>
       <slf4j-version>1.6.1</slf4j-version>
       <snakeyaml-version>1.8</snakeyaml-version>
-      <tomcat-version>7.0.52</tomcat-version>
+      <tomcat-version>7.0.59</tomcat-version>
       <antlr.version>3.4</antlr.version>
       <tika.version>1.4</tika.version>
       <mockito.version>1.10.8</mockito.version>
@@ -818,7 +819,7 @@
       <dependency>
         <groupId>com.google.guava</groupId>
         <artifactId>guava</artifactId>
-        <version>18.0</version>
+        <version>${guava.version}</version>
       </dependency>
 
       <dependency>
@@ -1568,6 +1569,7 @@
 		    <exclude>loadtests/gatling/user-files/request-bodies/**</exclude>
 
                     <!-- other -->
+                    <exclude>**/catalina_base/**</exclude>
                     <exclude>**/m2/**</exclude>
                     <exclude>**/*.asc</exclude>
                     <exclude>**/dummy.txt</exclude>

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/93b133b5/stack/rest/README.md
----------------------------------------------------------------------
diff --git a/stack/rest/README.md b/stack/rest/README.md
index bd0034d..94e1f7a 100644
--- a/stack/rest/README.md
+++ b/stack/rest/README.md
@@ -68,14 +68,11 @@ To test, add the following configuration to the TOMCAT_HOME/conf/tomcat-users.xm
 ```xml
 <tomcat-users>
     <role rolename="manager-gui"/>
-    <tomcat-users>
-        <role rolename="manager-gui"/>
-        <role rolename="manager-jmx"/>
-        <role rolename="manager-script"/>
-        <role rolename="manager-status"/>
-       <!-- this username and password is set into src/test/resources/arquillian.xml -->
-        <user username="usergrid" password="testpassword" roles="manager-script, manager-jmx, manager-gui, manager-status"/>
-    </tomcat-users>
+    <role rolename="manager-jmx"/>
+    <role rolename="manager-script"/>
+    <role rolename="manager-status"/>
+    <!-- this username and password is set into src/test/resources/arquillian.xml -->
+    <user username="usergrid" password="testpassword" roles="manager-script, manager-jmx, manager-gui, manager-status"/>
 </tomcat-users>
 ```
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/93b133b5/stack/rest/pom.xml
----------------------------------------------------------------------
diff --git a/stack/rest/pom.xml b/stack/rest/pom.xml
index 0680da2..7746b5d 100644
--- a/stack/rest/pom.xml
+++ b/stack/rest/pom.xml
@@ -32,7 +32,7 @@
     <!-- Override these properties in an active profile within your settings.xml -->
     <properties>
         <usergrid.rest.threads>8</usergrid.rest.threads>
-        <guice.version>4.0-beta5</guice.version>
+        <guice.version>3</guice.version>
         <catalina.host>localhost</catalina.host>
         <catalina.jmx.port>8089</catalina.jmx.port>
     </properties>
@@ -391,7 +391,7 @@
             <scope>test</scope>
         </dependency>
 
-        <!-- arquillian deps -->
+        <!-- Arquillian deps -->
 
         <dependency>
             <groupId>org.codehaus.jackson</groupId>
@@ -400,20 +400,18 @@
             <scope>test</scope>
         </dependency>
 
-
-
         <!--<dependency>-->
-                       <!--<groupId>org.jboss.arquillian.container</groupId>-->
-                       <!--<artifactId>arquillian-tomcat-embedded-7</artifactId>-->
-                       <!--<version>1.1.7.Final</version>-->
-                       <!--<scope>test</scope>-->
-                    <!--</dependency>-->
+            <!--<groupId>org.jboss.arquillian.container</groupId>-->
+            <!--<artifactId>arquillian-tomcat-embedded-7</artifactId>-->
+            <!--<version>1.1.7.Final</version>-->
+            <!--<scope>test</scope>-->
+        <!--</dependency>-->
 
         <dependency>
             <groupId>org.jboss.arquillian</groupId>
             <artifactId>arquillian-bom</artifactId>
             <version>1.1.7.Final</version>
-            <scope>import</scope>
+            <scope>test</scope>
             <type>pom</type>
         </dependency>
 
@@ -424,10 +422,8 @@
             <scope>test</scope>
         </dependency>
 
-
-
-        <!-- Some arquillian dependency runs and old version of guice. We're overridding it here so that we include
-          the right value into the test scope -->
+        <!--Some Arquillian dependency runs and old version of Guice.-->
+        <!--We're overridding it here so that we include the right value into the test scope-->
         <!--<dependency>-->
           <!--<groupId>com.google.inject</groupId>-->
           <!--<artifactId>guice</artifactId>-->
@@ -449,18 +445,14 @@
             <!--<scope>test</scope>-->
         <!--</dependency>-->
 
-
-        <!-- documentation here
-        https://github.com/shrinkwrap/resolver
-        -->
-
+        <!-- documentation here https://github.com/shrinkwrap/resolver -->
         <dependency>
               <groupId>org.jboss.shrinkwrap.resolver</groupId>
               <artifactId>shrinkwrap-resolver-depchain</artifactId>
               <version>2.1.1</version>
               <scope>test</scope>
               <type>pom</type>
-            </dependency>
+        </dependency>
 
         <!--  use the external test client.  Just depend on the maven jetty plugin to launch jetty -->
         <dependency>

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/93b133b5/stack/rest/src/main/java/org/apache/usergrid/rest/JobServiceBoostrap.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/JobServiceBoostrap.java b/stack/rest/src/main/java/org/apache/usergrid/rest/JobServiceBoostrap.java
index f337659..6d31fac 100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/JobServiceBoostrap.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/JobServiceBoostrap.java
@@ -61,8 +61,7 @@ public class JobServiceBoostrap implements
         if ( Boolean.parseBoolean( start ) ) {
             logger.info( "Starting Scheduler Service..." );
             // start the scheduler service
-            schedulerService.startAsync();
-            schedulerService.awaitRunning();
+            schedulerService.startAndWait();
 
         } else {
             logger.info( "Scheduler Service disabled" );

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/93b133b5/stack/rest/src/test/java/org/apache/usergrid/rest/AbstractRestIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/AbstractRestIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/AbstractRestIT.java
index 095c44a..9ce381d 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/AbstractRestIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/AbstractRestIT.java
@@ -64,7 +64,6 @@ import org.slf4j.LoggerFactory;
  * following naming convention: test_[HTTP verb]_[action mapping]_[ok|fail][_[specific
  * failure condition if multiple]
  */
-//
 @RunWith( Arquillian.class )
 public abstract class AbstractRestIT extends JerseyTest {
     private static final Logger LOG = LoggerFactory.getLogger( AbstractRestIT.class );
@@ -81,8 +80,8 @@ public abstract class AbstractRestIT extends JerseyTest {
 
     protected static final AppDescriptor descriptor;
 
-    //TODO, this needs removed.  Instead we need to hook into the arquillian event lifecycle
-    //to invoke /system/database/setup from the REST tier.
+    // TODO, this needs to be removed.  Instead we need to hook into the Arquillian event lifecycle
+    // to invoke /system/database/setup from the REST tier.
     public static ITSetup setup = new ITSetup(  );
 
     //private static final URI baseURI = setup.getBaseURI();
@@ -103,18 +102,19 @@ public abstract class AbstractRestIT extends JerseyTest {
     }
 
 
-    //We set testable = false so we deploy the archive to the server and test it locally
+    // We set testable = false so we deploy the archive to the server and test it locally
     @Deployment( testable = false )
     public static WebArchive createTestArchive() {
 
-        //we use the MavenImporter from shrinkwrap to just produce whatever maven would build then test with it
+        // we use the MavenImporter from shrinkwrap to just produce whatever maven would build then test with it
 
-        //set maven to be in offline mode
+        // set maven to be in offline mode
 
         System.setProperty( "org.apache.maven.offline", "true" );
-
-        return ShrinkWrap.create( MavenImporter.class ).loadPomFromFile( "pom.xml", "arquillian-tomcat" )
-                         .importBuildOutput().as( WebArchive.class );
+        return ShrinkWrap.create( MavenImporter.class )
+            .loadPomFromFile( "pom.xml", "arquillian-tomcat" )
+            .importBuildOutput()
+            .as( WebArchive.class );
     }
 
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/93b133b5/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 0b87548..a095afa 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
@@ -90,8 +90,7 @@ public class ImportResourceIT extends AbstractRestIT {
         // start the scheduler after we're all set up
         JobSchedulerService jobScheduler = ConcurrentProcessSingleton.getInstance().getSpringResource().getBean( JobSchedulerService.class );
         if (jobScheduler.state() != Service.State.RUNNING) {
-            jobScheduler.startAsync();
-            jobScheduler.awaitRunning();
+            jobScheduler.startAndWait();
         }
 
     }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/93b133b5/stack/services/src/test/java/org/apache/usergrid/management/export/ExportServiceIT.java
----------------------------------------------------------------------
diff --git a/stack/services/src/test/java/org/apache/usergrid/management/export/ExportServiceIT.java b/stack/services/src/test/java/org/apache/usergrid/management/export/ExportServiceIT.java
index 3a6d8f9..73ce1b1 100644
--- a/stack/services/src/test/java/org/apache/usergrid/management/export/ExportServiceIT.java
+++ b/stack/services/src/test/java/org/apache/usergrid/management/export/ExportServiceIT.java
@@ -105,8 +105,7 @@ public class ExportServiceIT {
 
             JobSchedulerService jobScheduler = ConcurrentProcessSingleton.getInstance().getSpringResource().getBean(JobSchedulerService.class);
             if (jobScheduler.state() != Service.State.RUNNING) {
-                jobScheduler.startAsync();
-                jobScheduler.awaitRunning();
+                jobScheduler.startAndWait();
             }
         } catch ( Exception e ) {
             logger.warn("Ignoring error starting jobScheduler, already started?", e);

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/93b133b5/stack/services/src/test/java/org/apache/usergrid/management/importer/ImportCollectionIT.java
----------------------------------------------------------------------
diff --git a/stack/services/src/test/java/org/apache/usergrid/management/importer/ImportCollectionIT.java b/stack/services/src/test/java/org/apache/usergrid/management/importer/ImportCollectionIT.java
index d10b611..d0a984d 100644
--- a/stack/services/src/test/java/org/apache/usergrid/management/importer/ImportCollectionIT.java
+++ b/stack/services/src/test/java/org/apache/usergrid/management/importer/ImportCollectionIT.java
@@ -114,8 +114,7 @@ public class ImportCollectionIT {
             .getSpringResource().getBean( JobSchedulerService.class );
 
         if ( jobScheduler.state() != Service.State.RUNNING ) {
-            jobScheduler.startAsync();
-            jobScheduler.awaitRunning();
+            jobScheduler.startAndWait();
         }
 
     }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/93b133b5/stack/services/src/test/java/org/apache/usergrid/management/importer/ImportServiceIT.java
----------------------------------------------------------------------
diff --git a/stack/services/src/test/java/org/apache/usergrid/management/importer/ImportServiceIT.java b/stack/services/src/test/java/org/apache/usergrid/management/importer/ImportServiceIT.java
index 4932ad7..cb64b59 100644
--- a/stack/services/src/test/java/org/apache/usergrid/management/importer/ImportServiceIT.java
+++ b/stack/services/src/test/java/org/apache/usergrid/management/importer/ImportServiceIT.java
@@ -99,8 +99,7 @@ public class ImportServiceIT {
             .getInstance().getSpringResource().getBean( JobSchedulerService.class );
 
         if ( jobScheduler.state() != Service.State.RUNNING ) {
-            jobScheduler.startAsync();
-            jobScheduler.awaitRunning();
+            jobScheduler.startAndWait();
         }
 
         //creates sample test application


[24/50] [abbrv] incubator-usergrid git commit: Adding some JVM options to help with the OOM PermGen problems, and removing all tests from except for one (for now)

Posted by sn...@apache.org.
Adding some JVM options to help with the OOM PermGen problems, and removing all tests from except for one (for now)


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

Branch: refs/heads/two-dot-o
Commit: 35bff549b0df8147bd7b8ee007c9303a08a06502
Parents: c9198a6
Author: Dave Johnson <dm...@apigee.com>
Authored: Tue Feb 24 10:37:37 2015 -0500
Committer: Dave Johnson <dm...@apigee.com>
Committed: Tue Feb 24 10:37:37 2015 -0500

----------------------------------------------------------------------
 stack/rest/catalina_base/bin/setenv.sh |  3 +--
 stack/rest/pom.xml                     | 19 +++++++++++++++++--
 2 files changed, 18 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/35bff549/stack/rest/catalina_base/bin/setenv.sh
----------------------------------------------------------------------
diff --git a/stack/rest/catalina_base/bin/setenv.sh b/stack/rest/catalina_base/bin/setenv.sh
index dbcad13..ab2f736 100644
--- a/stack/rest/catalina_base/bin/setenv.sh
+++ b/stack/rest/catalina_base/bin/setenv.sh
@@ -3,7 +3,6 @@ JAVA_OPTS="$JAVA_OPTS -Dcom.sun.management.jmxremote.port=8089 "
 JAVA_OPTS="$JAVA_OPTS -Dcom.sun.management.jmxremote.ssl=false "
 JAVA_OPTS="$JAVA_OPTS -Dcom.sun.management.jmxremote.authenticate=false"
 JAVA_OPTS="$JAVA_OPTS -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=8000"
-JAVA_OPTS="$JAVA_OPTS -Xmx4000m -Xms4000m"
+JAVA_OPTS="$JAVA_OPTS -Xmx3000m -Xms1000m -XX:MaxPermSize=200m -XX:+CMSClassUnloadingEnabled -XX:+CMSPermGenSweepingEnabled"
 
 CATALINA_PID="$CATALINA_BASE/tomcat.pid"
-

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/35bff549/stack/rest/pom.xml
----------------------------------------------------------------------
diff --git a/stack/rest/pom.xml b/stack/rest/pom.xml
index b3c3663..2959d6c 100644
--- a/stack/rest/pom.xml
+++ b/stack/rest/pom.xml
@@ -151,8 +151,23 @@
                     <argLine>-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>
                     <includes>
-                        <include>**/*IT.java</include>
-                        <include>**/*Test.java</include>
+
+                        <!--<include>**/*IT.java</include>-->
+                        <!--<include>**/*Test.java</include>-->
+
+                        <!-- how many tests can we run before Tomcat JVM throws OOM / PermGen exceptions -->
+
+                        <include>**/org/apache/usergrid/rest/BasicIT.java</include>
+
+                        <!--<include>**/org/apache/usergrid/rest/*IT.java</include>-->
+                        <!--<include>**/org/apache/usergrid/rest/*Test.java</include>-->
+
+                        <!--<include>**/org/apache/usergrid/rest/management/**/*IT.java</include>-->
+                        <!--<include>**/org/apache/usergrid/rest/management/**/*Test.java</include>-->
+
+                        <!--<include>**/org/apache/usergrid/rest/applications/collection/**/*IT.java</include>-->
+                        <!--<include>**/org/apache/usergrid/rest/applications/collection/**/*Test.java</include>-->
+
                     </includes>
 
                 </configuration>


[18/50] [abbrv] incubator-usergrid git commit: Don't run two schedulers.

Posted by sn...@apache.org.
Don't run two schedulers.


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

Branch: refs/heads/two-dot-o
Commit: 2d2bdae3812606ea649a4470ddd9a69863baf22d
Parents: 93b133b
Author: Dave Johnson <dm...@apigee.com>
Authored: Mon Feb 23 16:46:21 2015 -0500
Committer: Dave Johnson <dm...@apigee.com>
Committed: Mon Feb 23 16:46:21 2015 -0500

----------------------------------------------------------------------
 .../rest/src/test/resources/usergrid-custom-test.properties  | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/2d2bdae3/stack/rest/src/test/resources/usergrid-custom-test.properties
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/resources/usergrid-custom-test.properties b/stack/rest/src/test/resources/usergrid-custom-test.properties
index d9688c4..5f7f318 100644
--- a/stack/rest/src/test/resources/usergrid-custom-test.properties
+++ b/stack/rest/src/test/resources/usergrid-custom-test.properties
@@ -12,11 +12,6 @@
 
 # REST module test properties
 
-# these settings allow tests to run and consistently pass on 16GB MacBook Pro 
-# with ug.heapmax=5000m and ug.heapmin=3000m (set in Maven settings.xml) 
-tomcat.startup=embedded
-tomcat.threads=200
-
 cassandra.startup=external
 cassandra.timeout=2000
 cassandra.connections=800
@@ -29,6 +24,9 @@ hystrix.threadpool.graph_async.coreSize=1200
 # needed to enable refresh and properties end-points used in tests
 usergrid.test=true
 
+# the scheduled will be started inside the remote Tomcat VM, not in Maven VM
+usergrid.scheduler.enabled=false
+
 # needed for DuplicateNameIT
 collection.stage.transient.timeout=5
 


[23/50] [abbrv] incubator-usergrid git commit: changes to get REST tests working with Arquillian: - Add setenv.sh to set memory and debug options for Tomcat - Make Arqillian profile active by default - Add shutdown hook to stop job service when Usergrid

Posted by sn...@apache.org.
changes to get REST tests working with Arquillian:
- Add setenv.sh to set memory and debug options for Tomcat
- Make Arqillian profile active by default
- Add shutdown hook to stop job service when Usergrid is underplayed


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

Branch: refs/heads/two-dot-o
Commit: c9198a6c324e9bb159be41ac6cc07efe2a6d4dc2
Parents: 949c22a
Author: Dave Johnson <dm...@apigee.com>
Authored: Tue Feb 24 09:41:45 2015 -0500
Committer: Dave Johnson <dm...@apigee.com>
Committed: Tue Feb 24 09:41:45 2015 -0500

----------------------------------------------------------------------
 stack/rest/catalina_base/bin/setenv.sh          |  9 +++
 stack/rest/pom.xml                              |  3 +-
 .../usergrid/rest/JobServiceBoostrap.java       |  4 +-
 .../apache/usergrid/rest/ShutdownListener.java  | 73 ++++++++++++++++++++
 .../applications/ApplicationsResource.java      |  1 +
 stack/rest/src/main/webapp/WEB-INF/web.xml      | 13 ++--
 6 files changed, 93 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c9198a6c/stack/rest/catalina_base/bin/setenv.sh
----------------------------------------------------------------------
diff --git a/stack/rest/catalina_base/bin/setenv.sh b/stack/rest/catalina_base/bin/setenv.sh
new file mode 100644
index 0000000..dbcad13
--- /dev/null
+++ b/stack/rest/catalina_base/bin/setenv.sh
@@ -0,0 +1,9 @@
+
+JAVA_OPTS="$JAVA_OPTS -Dcom.sun.management.jmxremote.port=8089 "
+JAVA_OPTS="$JAVA_OPTS -Dcom.sun.management.jmxremote.ssl=false "
+JAVA_OPTS="$JAVA_OPTS -Dcom.sun.management.jmxremote.authenticate=false"
+JAVA_OPTS="$JAVA_OPTS -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=8000"
+JAVA_OPTS="$JAVA_OPTS -Xmx4000m -Xms4000m"
+
+CATALINA_PID="$CATALINA_BASE/tomcat.pid"
+

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c9198a6c/stack/rest/pom.xml
----------------------------------------------------------------------
diff --git a/stack/rest/pom.xml b/stack/rest/pom.xml
index 7746b5d..b3c3663 100644
--- a/stack/rest/pom.xml
+++ b/stack/rest/pom.xml
@@ -45,7 +45,7 @@
             <id>arquillian-tomcat</id>
 
             <activation>
-                <activeByDefault>false</activeByDefault>
+                <activeByDefault>true</activeByDefault>
             </activation>
 
             <dependencies>
@@ -96,6 +96,7 @@
                     <groupId>org.jboss.arquillian.container</groupId>
                     <artifactId>arquillian-tomcat-remote-7</artifactId>
                     <version>1.0.0.CR7</version>
+                    <scope>test</scope>
                 </dependency>
 
             </dependencies>

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c9198a6c/stack/rest/src/main/java/org/apache/usergrid/rest/JobServiceBoostrap.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/JobServiceBoostrap.java b/stack/rest/src/main/java/org/apache/usergrid/rest/JobServiceBoostrap.java
index 6d31fac..c6721ea 100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/JobServiceBoostrap.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/JobServiceBoostrap.java
@@ -31,13 +31,12 @@ import java.util.Properties;
  * Simple class that starts the job store after the application context has been fired up. We don't
  * want to start the service until all of spring has been initialized in our webapp context
  */
-//@Component( "jobServiceBoostrap" )
 public class JobServiceBoostrap implements
         ApplicationListener<ContextRefreshedEvent> {
 
     private static final Logger logger = LoggerFactory.getLogger( JobServiceBoostrap.class );
 
-    private static final String START_SCHEDULER_PROP = "usergrid.scheduler.enabled";
+    public static final String START_SCHEDULER_PROP = "usergrid.scheduler.enabled";
 
     @Autowired
     private JobSchedulerService schedulerService;
@@ -60,7 +59,6 @@ public class JobServiceBoostrap implements
         String start = properties.getProperty( START_SCHEDULER_PROP, "true" );
         if ( Boolean.parseBoolean( start ) ) {
             logger.info( "Starting Scheduler Service..." );
-            // start the scheduler service
             schedulerService.startAndWait();
 
         } else {

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c9198a6c/stack/rest/src/main/java/org/apache/usergrid/rest/ShutdownListener.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/ShutdownListener.java b/stack/rest/src/main/java/org/apache/usergrid/rest/ShutdownListener.java
new file mode 100644
index 0000000..7b038c2
--- /dev/null
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/ShutdownListener.java
@@ -0,0 +1,73 @@
+/*
+ * 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 org.apache.usergrid.batch.service.JobSchedulerService;
+import org.apache.usergrid.batch.service.SchedulerService;
+import org.apache.usergrid.persistence.cassandra.CassandraService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.ApplicationContextAware;
+import org.springframework.web.context.support.WebApplicationContextUtils;
+
+import javax.servlet.ServletContextEvent;
+import javax.servlet.ServletContextListener;
+import javax.servlet.http.HttpSessionAttributeListener;
+import javax.servlet.http.HttpSessionEvent;
+import javax.servlet.http.HttpSessionListener;
+import javax.servlet.http.HttpSessionBindingEvent;
+import java.util.Properties;
+
+
+/**
+ * Shutdown job service when context is destroyed (useful when testing).
+ */
+public class ShutdownListener implements ServletContextListener {
+    private static final Logger logger = LoggerFactory.getLogger(ShutdownListener.class);
+    JobSchedulerService schedulerService;
+    Properties properties;
+
+    public ShutdownListener() {
+    }
+
+    public void contextInitialized(ServletContextEvent sce) {
+
+        ApplicationContext ctx = WebApplicationContextUtils
+            .getWebApplicationContext(sce.getServletContext());
+
+        schedulerService = ctx.getBean( JobSchedulerService.class );
+        properties = (Properties)ctx.getBean("properties");
+
+        logger.info("ShutdownListener initialized");
+    }
+
+    public void contextDestroyed(ServletContextEvent sce) {
+
+        logger.info("ShutdownListener invoked");
+
+        boolean started = Boolean.parseBoolean(
+            properties.getProperty(JobServiceBoostrap.START_SCHEDULER_PROP, "true"));
+
+        if ( started ) {
+            schedulerService.stopAndWait();
+            logger.info( "Stopping Scheduler Service..." );
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c9198a6c/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 56d2f98..0c8ee06 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
@@ -142,6 +142,7 @@ public class ApplicationsResource extends AbstractContextResource {
 
     @RequireOrganizationAccess
     @Path(RootResource.APPLICATION_ID_PATH)
+    @PUT
     public ApplicationResource restoreApplicationFromOrganizationByApplicationId(
         @Context UriInfo ui,
         @PathParam( "applicationId" )

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c9198a6c/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 24a82ca..23c0751 100644
--- a/stack/rest/src/main/webapp/WEB-INF/web.xml
+++ b/stack/rest/src/main/webapp/WEB-INF/web.xml
@@ -27,11 +27,15 @@
     <listener>
         <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
     </listener>
-  
+
     <listener>
         <listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
     </listener>
 
+    <listener>
+        <listener-class>org.apache.usergrid.rest.ShutdownListener</listener-class>
+    </listener>
+
     <filter>
         <filter-name>swaggerFilter</filter-name>
         <filter-class>org.apache.usergrid.rest.SwaggerServlet</filter-class>
@@ -59,7 +63,7 @@
         <filter-name>contentTypeFilter</filter-name>
         <url-pattern>/*</url-pattern>
     </filter-mapping>
-    
+
     <filter>
         <filter-name>shiroFilter</filter-name>
         <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
@@ -72,7 +76,7 @@
         <filter-name>shiroFilter</filter-name>
         <url-pattern>/*</url-pattern>
     </filter-mapping>
-	
+
     <filter>
         <filter-name>Usergrid REST API Server</filter-name>
         <filter-class>com.sun.jersey.spi.spring.container.servlet.SpringServlet</filter-class>
@@ -126,7 +130,4 @@
         </taglib>
     </jsp-config>
 
-
-
-
 </web-app>


[25/50] [abbrv] incubator-usergrid git commit: Effort to use arquillian-suite-extension

Posted by sn...@apache.org.
Effort to use arquillian-suite-extension


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

Branch: refs/heads/two-dot-o
Commit: ec8e66642a4b45d17c0c4ddca96823b642d6f462
Parents: 35bff54
Author: Dave Johnson <dm...@apigee.com>
Authored: Tue Feb 24 15:16:23 2015 -0500
Committer: Dave Johnson <dm...@apigee.com>
Committed: Tue Feb 24 15:16:23 2015 -0500

----------------------------------------------------------------------
 stack/rest/pom.xml                              | 58 +++++---------------
 .../apache/usergrid/rest/AbstractRestIT.java    |  7 ++-
 .../java/org/apache/usergrid/rest/BasicIT.java  |  5 +-
 stack/rest/src/test/resources/arquillian.xml    | 14 +----
 4 files changed, 21 insertions(+), 63 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/ec8e6664/stack/rest/pom.xml
----------------------------------------------------------------------
diff --git a/stack/rest/pom.xml b/stack/rest/pom.xml
index 2959d6c..c1c8ea2 100644
--- a/stack/rest/pom.xml
+++ b/stack/rest/pom.xml
@@ -50,48 +50,6 @@
 
             <dependencies>
 
-                <!--embedded mode-->
-                <!--<dependency>-->
-                   <!--<groupId>org.apache.tomcat.embed</groupId>-->
-                   <!--<artifactId>tomcat-embed-core</artifactId>-->
-                   <!--<version>7.0.59</version>-->
-                   <!--<scope>provided</scope>-->
-                <!--</dependency>-->
-                <!--<dependency>-->
-                   <!--<groupId>org.apache.tomcat.embed</groupId>-->
-                   <!--<artifactId>tomcat-embed-jasper</artifactId>-->
-                   <!--<version>7.0.59</version>-->
-                   <!--<scope>provided</scope>-->
-                <!--</dependency>-->
-                <!--<dependency>-->
-                   <!--<groupId>org.apache.tomcat.embed</groupId>-->
-                   <!--<artifactId>tomcat-embed-logging-juli</artifactId>-->
-                   <!--<version>7.0.59</version>-->
-                   <!--<scope>provided</scope>-->
-                <!--</dependency>-->
-                <!--<dependency>-->
-                   <!--<groupId>org.eclipse.jdt.core.compiler</groupId>-->
-                   <!--<artifactId>ecj</artifactId>-->
-                   <!--<version>3.7</version>-->
-                   <!--<scope>test</scope>-->
-                <!--</dependency>-->
-
-                <!--&lt;!&ndash; Weld servlet for testing CDI injections &ndash;&gt;-->
-           <!--<dependency>-->
-               <!--<groupId>org.jboss.weld.servlet</groupId>-->
-               <!--<artifactId>weld-servlet</artifactId>-->
-               <!--<version>2.2.9.Final</version>-->
-           <!--</dependency>-->
-
-                <!-- managed -->
-                <!--<dependency>-->
-                      <!--<groupId>org.jboss.arquillian.container</groupId>-->
-                      <!--<artifactId>arquillian-tomcat-managed-7</artifactId>-->
-                      <!--<version>1.0.0.CR7</version>-->
-                      <!--<scope>test</scope>-->
-                    <!--</dependency>-->
-
-                <!-- remote -->
                 <dependency>
                     <groupId>org.jboss.arquillian.container</groupId>
                     <artifactId>arquillian-tomcat-remote-7</artifactId>
@@ -99,6 +57,14 @@
                     <scope>test</scope>
                 </dependency>
 
+                <!-- only deploy once during tests -->
+                <dependency>
+                    <groupId>org.eu.ingwar.tools</groupId>
+                    <artifactId>arquillian-suite-extension</artifactId>
+                    <version>1.1.2</version>
+                    <scope>test</scope>
+                </dependency>
+
             </dependencies>
 
 
@@ -152,12 +118,14 @@
                     </argLine>
                     <includes>
 
-                        <!--<include>**/*IT.java</include>-->
-                        <!--<include>**/*Test.java</include>-->
+                        <include>**/*IT.java</include>
+                        <include>**/*Test.java</include>
 
                         <!-- how many tests can we run before Tomcat JVM throws OOM / PermGen exceptions -->
 
-                        <include>**/org/apache/usergrid/rest/BasicIT.java</include>
+                        <!--<include>**/org/apache/usergrid/rest/BasicIT.java</include>-->
+                        <!--<include>**/org/apache/usergrid/rest/PartialUpdateTest.java</include>-->
+                        <!--<include>**/org/apache/usergrid/rest/applications/collection/**/CollectionsResourceIT.java</include>-->
 
                         <!--<include>**/org/apache/usergrid/rest/*IT.java</include>-->
                         <!--<include>**/org/apache/usergrid/rest/*Test.java</include>-->

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/ec8e6664/stack/rest/src/test/java/org/apache/usergrid/rest/AbstractRestIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/AbstractRestIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/AbstractRestIT.java
index 9ce381d..fab1e55 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/AbstractRestIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/AbstractRestIT.java
@@ -40,6 +40,7 @@ import org.apache.usergrid.java.client.Client;
 import static org.apache.usergrid.utils.JsonUtils.mapToFormattedJsonString;
 import static org.apache.usergrid.utils.MapUtils.hashMap;
 
+import org.eu.ingwar.tools.arquillian.extension.suite.annotations.ArquillianSuiteDeployment;
 import org.jboss.arquillian.container.test.api.Deployment;
 import org.jboss.arquillian.junit.Arquillian;
 import org.jboss.shrinkwrap.api.Archive;
@@ -64,7 +65,8 @@ import org.slf4j.LoggerFactory;
  * following naming convention: test_[HTTP verb]_[action mapping]_[ok|fail][_[specific
  * failure condition if multiple]
  */
-@RunWith( Arquillian.class )
+@ArquillianSuiteDeployment
+@RunWith(Arquillian.class)
 public abstract class AbstractRestIT extends JerseyTest {
     private static final Logger LOG = LoggerFactory.getLogger( AbstractRestIT.class );
     private static boolean usersSetup = false;
@@ -111,14 +113,13 @@ public abstract class AbstractRestIT extends JerseyTest {
         // set maven to be in offline mode
 
         System.setProperty( "org.apache.maven.offline", "true" );
-        return ShrinkWrap.create( MavenImporter.class )
+        return ShrinkWrap.create(MavenImporter.class)
             .loadPomFromFile( "pom.xml", "arquillian-tomcat" )
             .importBuildOutput()
             .as( WebArchive.class );
     }
 
 
-
     @AfterClass
     public static void teardown() {
         access_token = null;

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/ec8e6664/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 f63df78..53b30a4 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
@@ -24,6 +24,7 @@ import javax.ws.rs.core.MultivaluedMap;
 
 import com.fasterxml.jackson.databind.JsonNode;
 
+import org.eu.ingwar.tools.arquillian.extension.suite.annotations.ArquillianSuiteDeployment;
 import org.junit.Rule;
 import org.junit.Test;
 import org.slf4j.Logger;
@@ -258,7 +259,7 @@ public class BasicIT extends AbstractRestIT {
             err_thrown = true;
         }
         assertTrue( "Error should have been thrown", err_thrown );
-        
+
         // test set app user pin
 
         MultivaluedMap<String, String> formData = new MultivaluedMapImpl();
@@ -270,7 +271,7 @@ public class BasicIT extends AbstractRestIT {
                 .post( String.class, formData ));
 
         refreshIndex(orgName, appName);
-        
+
         node = mapper.readTree( resource()
                 .path( "/"+orgName+"/"+appName+"/token" )
                 .queryParam( "grant_type", "pin" )

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/ec8e6664/stack/rest/src/test/resources/arquillian.xml
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/resources/arquillian.xml b/stack/rest/src/test/resources/arquillian.xml
index 1e6177e..5e5fb6c 100644
--- a/stack/rest/src/test/resources/arquillian.xml
+++ b/stack/rest/src/test/resources/arquillian.xml
@@ -23,19 +23,7 @@
     xmlns="http://jboss.org/schema/arquillian"
     xsi:schemaLocation="http://jboss.org/schema/arquillian http://jboss.org/schema/arquillian/arquillian_1_0.xsd">
 
-    <!--<container qualifier="tomcat" default="true">-->
-        <!--<configuration>-->
-            <!--<property name="bindHttpPort">8080</property>-->
-            <!--<property name="bindAddress">localhost</property>-->
-            <!--<property name="javaVmArguments">-Xmx512m -XX:MaxPermSize=128m</property>-->
-            <!--<property name="catalinaHome">${catalina.home}</property>-->
-            <!--<property name="user">usergrid</property>-->
-            <!--<property name="pass">testpassword</property>-->
-            <!--&lt;!&ndash;This is a workaround for this issue https://issues.jboss.org/browse/ARQ-1814&ndash;&gt;-->
-            <!--<property name="catalinaBase">${catalina.home}</property>-->
-            <!--<property name="allowConnectingToRunningServer">true</property>-->
-        <!--</configuration>-->
-    <!--</container>-->
+    <defaultProtocol type="Servlet 3.0"/>
 
     <container qualifier="tomcat" default="true">
         <configuration>


[03/50] [abbrv] incubator-usergrid git commit: Makes index rebuild parallel.

Posted by sn...@apache.org.
Makes index rebuild parallel.


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

Branch: refs/heads/two-dot-o
Commit: d2a0ff2a5887f71d50a07767fbf4e25f6e474f8a
Parents: 4df281e
Author: Todd Nine <tn...@apigee.com>
Authored: Thu Feb 19 22:40:11 2015 -0700
Committer: Todd Nine <tn...@apigee.com>
Committed: Thu Feb 19 22:40:11 2015 -0700

----------------------------------------------------------------------
 .../corepersistence/CpEntityManager.java        |  2 +-
 .../usergrid/corepersistence/CpWalker.java      | 73 ++++++++++----------
 .../org/apache/usergrid/rest/IndexResource.java | 26 ++++---
 3 files changed, 55 insertions(+), 46 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/d2a0ff2a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java
index e117a73..7eb9f94 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java
@@ -2751,7 +2751,7 @@ public class CpEntityManager implements EntityManager {
      */
     public void reindex( final EntityManagerFactory.ProgressObserver po ) throws Exception {
 
-        CpWalker walker = new CpWalker( po.getWriteDelayTime() );
+        CpWalker walker = new CpWalker( );
 
         walker.walkCollections( this, application, new CpVisitor() {
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/d2a0ff2a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpWalker.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpWalker.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpWalker.java
index ff631ed..8a9eed5 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpWalker.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpWalker.java
@@ -34,7 +34,7 @@ import org.apache.usergrid.persistence.model.entity.SimpleId;
 import rx.Observable;
 import rx.functions.Action1;
 import rx.functions.Func1;
-
+import rx.schedulers.Schedulers;
 
 
 /**
@@ -44,26 +44,25 @@ public class CpWalker {
 
     private static final Logger logger = LoggerFactory.getLogger( CpWalker.class );
 
-    private final long writeDelayMs;
 
 
     /**
      * Wait the set amount of time between successive writes.
-     * @param writeDelayMs
+     * @param
      */
-    public CpWalker(final long writeDelayMs){
-         this.writeDelayMs = writeDelayMs;
+    public CpWalker(){
+
     }
 
 
-    public void walkCollections( final CpEntityManager em, final EntityRef start, 
+    public void walkCollections( final CpEntityManager em, final EntityRef start,
             final CpVisitor visitor ) throws Exception {
 
         doWalkCollections( em, new SimpleId( start.getUuid(), start.getType() ), visitor );
     }
 
 
-    private void doWalkCollections( 
+    private void doWalkCollections(
             final CpEntityManager em, final Id applicationId, final CpVisitor visitor ) {
 
         final ApplicationScope applicationScope = em.getApplicationScope();
@@ -89,45 +88,45 @@ public class CpWalker {
 
                 logger.debug( "Loading edges of type {} from node {}", edgeType, applicationId );
 
-                return gm.loadEdgesFromSource( new SimpleSearchByEdgeType( 
-                    applicationId,
-                    edgeType,
-                    Long.MAX_VALUE,
-                    SearchByEdgeType.Order.DESCENDING,
-                    null ) );
+                return gm.loadEdgesFromSource( new SimpleSearchByEdgeType( applicationId, edgeType, Long.MAX_VALUE,
+                    SearchByEdgeType.Order.DESCENDING, null ) );
             }
-        } ).doOnNext( new Action1<Edge>() {
-
+        } )
+                 //process our edges in parallel for as much efficiency as possible
+                 .parallel( new Func1<Observable<Edge>, Observable<Edge>>() {
             @Override
-            public void call( Edge edge ) {
+            public Observable<Edge> call( final Observable<Edge> edgeObservable ) {
+                //visit and update the entity
+                return edgeObservable.doOnNext( new Action1<Edge>() {
 
-                logger.info( "Re-indexing edge {}", edge );
+                                    @Override
+                                    public void call( Edge edge ) {
 
-                EntityRef targetNodeEntityRef = new SimpleEntityRef( 
-                        edge.getTargetNode().getType(), edge.getTargetNode().getUuid() );
+                                        logger.info( "Re-indexing edge {}", edge );
 
-                Entity entity;
-                try {
-                    entity = em.get( targetNodeEntityRef );
-                }
-                catch ( Exception ex ) {
-                    logger.error( "Error getting sourceEntity {}:{}, continuing", 
-                            targetNodeEntityRef.getType(), targetNodeEntityRef.getUuid() );
-                    return;
-                }
+                                        EntityRef targetNodeEntityRef =
+                                            new SimpleEntityRef( edge.getTargetNode().getType(), edge.getTargetNode().getUuid() );
 
+                                        Entity entity;
+                                        try {
+                                            entity = em.get( targetNodeEntityRef );
+                                        }
+                                        catch ( Exception ex ) {
+                                            logger.error( "Error getting sourceEntity {}:{}, continuing", targetNodeEntityRef.getType(),
+                                                targetNodeEntityRef.getUuid() );
+                                            return;
+                                        }
 
-                String collName = CpNamingUtils.getCollectionName( edge.getType() );
 
-                visitor.visitCollectionEntry( em, collName, entity );
+                                        String collName = CpNamingUtils.getCollectionName( edge.getType() );
 
-                try {
-                    Thread.sleep( writeDelayMs );
-                }
-                catch ( InterruptedException e ) {
-                    throw new RuntimeException( "Unable to wait" );
-                }
+                                        visitor.visitCollectionEntry( em, collName, entity );
+                                    }
+                                } );
             }
-        } ).toBlocking().lastOrDefault( null ); // end foreach on edges
+        }, Schedulers.io() )
+
+        //wait for it to complete
+        .toBlocking().lastOrDefault( null ); // end foreach on edges
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/d2a0ff2a/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 5cbc499..acce2d8 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
@@ -117,22 +117,32 @@ public class IndexResource extends AbstractContextResource {
 
         final UUID appId = UUIDUtils.tryExtractUUID(applicationIdStr);
         ApiResponse response = createApiResponse();
-        response.setAction( "rebuild indexes" );
+        response.setAction( "rebuild indexes started" );
 
+        final EntityManagerFactory.ProgressObserver po = new EntityManagerFactory.ProgressObserver() {
 
-        final EntityManager em = emf.getEntityManager( appId );
+            @Override
+            public void onProgress( final EntityRef entity ) {
+                logger.info( "Indexing entity {}:{}", entity.getType(), entity.getUuid() );
+            }
+
+
+            @Override
+            public long getWriteDelayTime() {
+                return delay;
+            }
+        };
 
-        final Set<String> collectionNames = em.getApplicationCollections();
 
         final Thread rebuild = new Thread() {
 
             @Override
             public void run() {
-                for ( String collectionName : collectionNames )
-
-
-                {
-                    rebuildCollection( appId, collectionName, delay );
+                try {
+                    emf.rebuildApplicationIndexes( appId, po );
+                }
+                catch ( Exception e ) {
+                    logger.error( "Unable to re-index application" );
                 }
             }
         };


[06/50] [abbrv] incubator-usergrid git commit: Partial implementation of re-index collection with option to do it in reverse.

Posted by sn...@apache.org.
Partial implementation of re-index collection with option to do it in reverse.


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

Branch: refs/heads/two-dot-o
Commit: a704ed73b8a2b17334ce87b8581d4fe09e63321f
Parents: 1399849
Author: Dave Johnson <dm...@apigee.com>
Authored: Fri Feb 20 12:10:38 2015 -0500
Committer: Dave Johnson <dm...@apigee.com>
Committed: Fri Feb 20 12:10:38 2015 -0500

----------------------------------------------------------------------
 .../corepersistence/CpEntityManager.java        |  41 ++++--
 .../corepersistence/CpEntityManagerFactory.java |  18 ++-
 .../usergrid/corepersistence/CpWalker.java      |  88 ++++++------
 .../usergrid/persistence/EntityManager.java     |   3 +
 .../persistence/EntityManagerFactory.java       |   7 +-
 .../cassandra/EntityManagerImpl.java            |   5 +
 .../PerformanceEntityRebuildIndexTest.java      | 136 ++++++++++++++++++-
 .../org/apache/usergrid/rest/IndexResource.java |  43 ++++--
 .../apache/usergrid/rest/IndexResourceIT.java   |   2 +-
 9 files changed, 271 insertions(+), 72 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/a704ed73/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java
index 7eb9f94..6af0539 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java
@@ -32,8 +32,6 @@ import java.util.Set;
 import java.util.TreeMap;
 import java.util.TreeSet;
 import java.util.UUID;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.TimeUnit;
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -105,10 +103,6 @@ import org.apache.usergrid.utils.StringUtils;
 import org.apache.usergrid.utils.UUIDUtils;
 
 import com.google.common.base.Preconditions;
-import com.google.common.cache.CacheBuilder;
-import com.google.common.cache.CacheLoader;
-import com.google.common.cache.CacheLoader.InvalidCacheLoadException;
-import com.google.common.cache.LoadingCache;
 import com.netflix.hystrix.exception.HystrixRuntimeException;
 import com.yammer.metrics.annotation.Metered;
 
@@ -150,7 +144,6 @@ import static org.apache.usergrid.persistence.Schema.PROPERTY_TYPE;
 import static org.apache.usergrid.persistence.Schema.PROPERTY_UUID;
 import static org.apache.usergrid.persistence.Schema.TYPE_APPLICATION;
 import static org.apache.usergrid.persistence.Schema.TYPE_ENTITY;
-import static org.apache.usergrid.persistence.SimpleEntityRef.getUuid;
 import static org.apache.usergrid.persistence.cassandra.ApplicationCF.APPLICATION_AGGREGATE_COUNTERS;
 import static org.apache.usergrid.persistence.cassandra.ApplicationCF.ENTITY_COMPOSITE_DICTIONARIES;
 import static org.apache.usergrid.persistence.cassandra.ApplicationCF.ENTITY_COUNTERS;
@@ -2746,6 +2739,38 @@ public class CpEntityManager implements EntityManager {
     }
 
 
+
+    /**
+     * Completely reindex the named collection in the application associated with this EntityManager.
+     */
+    @Override
+    public void reindexCollection(
+        final EntityManagerFactory.ProgressObserver po, String collectionName) throws Exception {
+
+        CpWalker walker = new CpWalker( );
+
+        walker.walkCollections( this, application, collectionName, new CpVisitor() {
+
+            @Override
+            public void visitCollectionEntry( EntityManager em, String collName, Entity entity ) {
+
+                try {
+                    em.update( entity );
+                    po.onProgress( entity );
+                }
+                catch ( WriteOptimisticVerifyException wo ) {
+                    //swallow this, it just means this was already updated, which accomplishes our task.  Just ignore.
+                    logger.warn( "Someone beat us to updating entity {} in collection {}.  Ignoring.", entity.getName(),
+                        collName );
+                }
+                catch ( Exception ex ) {
+                    logger.error( "Error repersisting entity", ex );
+                }
+            }
+        } );
+    }
+
+
     /**
      * Completely reindex the application associated with this EntityManager.
      */
@@ -2753,7 +2778,7 @@ public class CpEntityManager implements EntityManager {
 
         CpWalker walker = new CpWalker( );
 
-        walker.walkCollections( this, application, new CpVisitor() {
+        walker.walkCollections( this, application, null, new CpVisitor() {
 
             @Override
             public void visitCollectionEntry( EntityManager em, String collName, Entity entity ) {

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/a704ed73/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManagerFactory.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManagerFactory.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManagerFactory.java
index bf85b45..01691d4 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManagerFactory.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManagerFactory.java
@@ -597,7 +597,8 @@ public class CpEntityManagerFactory implements EntityManagerFactory, Application
     public long performEntityCount() {
         //TODO, this really needs to be a task that writes this data somewhere since this will get
         //progressively slower as the system expands
-        return AllEntitiesInSystemObservable.getAllEntitiesInSystem( managerCache, 1000 ).longCount().toBlocking().last();
+        return AllEntitiesInSystemObservable
+            .getAllEntitiesInSystem( managerCache, 1000 ).longCount().toBlocking().last();
     }
 
 
@@ -744,8 +745,19 @@ public class CpEntityManagerFactory implements EntityManagerFactory, Application
     }
 
     @Override
-    public void rebuildCollectionIndex(UUID appId, String collection, ProgressObserver po ) {
-        throw new UnsupportedOperationException( "Not supported yet." );
+    public void rebuildCollectionIndex(
+        UUID appId, String collectionName, boolean reverse, ProgressObserver po ) throws Exception  {
+
+        EntityManager em = getEntityManager( appId );
+
+        //explicitly invoke create index, we don't know if it exists or not in ES during a rebuild.
+        em.createIndex();
+        Application app = em.getApplication();
+
+        em.reindexCollection( po, collectionName, reverse );
+
+        logger.info("\n\nRebuilt index for application {} id {} collection {}\n",
+            new Object[] { app.getName(), appId, collectionName } );
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/a704ed73/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpWalker.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpWalker.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpWalker.java
index 8a9eed5..6bd90ec 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpWalker.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpWalker.java
@@ -55,15 +55,18 @@ public class CpWalker {
     }
 
 
-    public void walkCollections( final CpEntityManager em, final EntityRef start,
-            final CpVisitor visitor ) throws Exception {
+    public void walkCollections(final CpEntityManager em, final EntityRef start,
+                                String collectionName, final CpVisitor visitor) throws Exception {
 
-        doWalkCollections( em, new SimpleId( start.getUuid(), start.getType() ), visitor );
+        doWalkCollections( em, collectionName, new SimpleId( start.getUuid(), start.getType() ), visitor );
     }
 
 
     private void doWalkCollections(
-            final CpEntityManager em, final Id applicationId, final CpVisitor visitor ) {
+            final CpEntityManager em,
+            final String collectionName,
+            final Id applicationId,
+            final CpVisitor visitor ) {
 
         final ApplicationScope applicationScope = em.getApplicationScope();
 
@@ -77,10 +80,17 @@ public class CpWalker {
                 applicationScope.getApplication().getUuid()
             } );
 
-        //only search edge types that start with collections
+        // only search edge types that start with collections
+
+        final String edgeType;
+        if ( collectionName != null ) {
+            edgeType = CpNamingUtils.EDGE_COLL_SUFFIX;
+        } else {
+            edgeType = CpNamingUtils.getEdgeTypeFromCollectionName( collectionName );
+        }
 
         Observable<String> edgeTypes = gm.getEdgeTypesFromSource(
-            new SimpleSearchEdgeType( applicationId, CpNamingUtils.EDGE_COLL_SUFFIX, null ) );
+            new SimpleSearchEdgeType( applicationId, edgeType, null ) );
 
         edgeTypes.flatMap( new Func1<String, Observable<Edge>>() {
             @Override
@@ -88,45 +98,45 @@ public class CpWalker {
 
                 logger.debug( "Loading edges of type {} from node {}", edgeType, applicationId );
 
-                return gm.loadEdgesFromSource( new SimpleSearchByEdgeType( applicationId, edgeType, Long.MAX_VALUE,
-                    SearchByEdgeType.Order.DESCENDING, null ) );
-            }
-        } )
-                 //process our edges in parallel for as much efficiency as possible
-                 .parallel( new Func1<Observable<Edge>, Observable<Edge>>() {
-            @Override
-            public Observable<Edge> call( final Observable<Edge> edgeObservable ) {
-                //visit and update the entity
-                return edgeObservable.doOnNext( new Action1<Edge>() {
-
-                                    @Override
-                                    public void call( Edge edge ) {
-
-                                        logger.info( "Re-indexing edge {}", edge );
-
-                                        EntityRef targetNodeEntityRef =
-                                            new SimpleEntityRef( edge.getTargetNode().getType(), edge.getTargetNode().getUuid() );
-
-                                        Entity entity;
-                                        try {
-                                            entity = em.get( targetNodeEntityRef );
-                                        }
-                                        catch ( Exception ex ) {
-                                            logger.error( "Error getting sourceEntity {}:{}, continuing", targetNodeEntityRef.getType(),
-                                                targetNodeEntityRef.getUuid() );
-                                            return;
-                                        }
+                return gm.loadEdgesFromSource(  new SimpleSearchByEdgeType(
+                    applicationId, edgeType, Long.MAX_VALUE, SearchByEdgeType.Order.DESCENDING, null ) );
 
+            }
 
-                                        String collName = CpNamingUtils.getCollectionName( edge.getType() );
+        } ).parallel( new Func1<Observable<Edge>, Observable<Edge>>() {
 
-                                        visitor.visitCollectionEntry( em, collName, entity );
-                                    }
-                                } );
+            @Override
+            public Observable<Edge> call( final Observable<Edge> edgeObservable ) { // process edges in parallel
+                return edgeObservable.doOnNext( new Action1<Edge>() { // visit and update then entity
+
+                    @Override
+                    public void call( Edge edge ) {
+
+                        logger.info( "Re-indexing edge {}", edge );
+
+                        EntityRef targetNodeEntityRef = new SimpleEntityRef(
+                            edge.getTargetNode().getType(),
+                            edge.getTargetNode().getUuid() );
+
+                        Entity entity;
+                        try {
+                            entity = em.get( targetNodeEntityRef );
+                        }
+                        catch ( Exception ex ) {
+                            logger.error( "Error getting sourceEntity {}:{}, continuing",
+                                targetNodeEntityRef.getType(),
+                                targetNodeEntityRef.getUuid() );
+                            return;
+                        }
+
+                        String collName = CpNamingUtils.getCollectionName( edge.getType() );
+                        visitor.visitCollectionEntry( em, collName, entity );
+                    }
+                } );
             }
         }, Schedulers.io() )
 
-        //wait for it to complete
+        // wait for it to complete
         .toBlocking().lastOrDefault( null ); // end foreach on edges
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/a704ed73/stack/core/src/main/java/org/apache/usergrid/persistence/EntityManager.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/persistence/EntityManager.java b/stack/core/src/main/java/org/apache/usergrid/persistence/EntityManager.java
index d425b7a..b7ca477 100644
--- a/stack/core/src/main/java/org/apache/usergrid/persistence/EntityManager.java
+++ b/stack/core/src/main/java/org/apache/usergrid/persistence/EntityManager.java
@@ -703,6 +703,9 @@ public interface EntityManager {
     /** For testing purposes */
     public void flushManagerCaches();
 
+    void reindexCollection(
+        EntityManagerFactory.ProgressObserver po, String collectionName) throws Exception;
+
     public void reindex( final EntityManagerFactory.ProgressObserver po ) throws Exception;
 
     /**

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/a704ed73/stack/core/src/main/java/org/apache/usergrid/persistence/EntityManagerFactory.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/persistence/EntityManagerFactory.java b/stack/core/src/main/java/org/apache/usergrid/persistence/EntityManagerFactory.java
index 7367eca..6a9095d 100644
--- a/stack/core/src/main/java/org/apache/usergrid/persistence/EntityManagerFactory.java
+++ b/stack/core/src/main/java/org/apache/usergrid/persistence/EntityManagerFactory.java
@@ -130,32 +130,29 @@ public interface EntityManagerFactory {
 
     /**
      * Return the migration status message
-     * @return
      */
     public String getMigrateDataStatus();
 
     /**
      * Return the current migration version of the system
-     * @return
      */
     public int getMigrateDataVersion();
 
     /**
      * Force the migration version to the specified version
-     * @param version
      */
     public void setMigrationVersion(int version);
 
     /**
      * Perform a realtime count of every entity in the system.  This can be slow as it traverses the entire system graph
-     * @return
      */
     public long performEntityCount();
 
     /** For testing purposes */
     public void flushEntityManagerCaches();
 
-    public void rebuildCollectionIndex(UUID appId, String collection, ProgressObserver object);
+    void rebuildCollectionIndex(
+        UUID appId, String collection, boolean reverse, ProgressObserver po) throws Exception;
 
     /**
      * Add a new index to the application for scale

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/a704ed73/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/EntityManagerImpl.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/EntityManagerImpl.java b/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/EntityManagerImpl.java
index 6c940a7..d0fe985 100644
--- a/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/EntityManagerImpl.java
+++ b/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/EntityManagerImpl.java
@@ -2932,6 +2932,11 @@ public class EntityManagerImpl implements EntityManager {
     }
 
     @Override
+    public void reindexCollection(EntityManagerFactory.ProgressObserver po, String collectionName) throws Exception {
+        throw new UnsupportedOperationException("Not supported.");
+    }
+
+    @Override
     public void reindex(EntityManagerFactory.ProgressObserver po) throws Exception {
         throw new UnsupportedOperationException("Not supported.");
     }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/a704ed73/stack/core/src/test/java/org/apache/usergrid/persistence/PerformanceEntityRebuildIndexTest.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/PerformanceEntityRebuildIndexTest.java b/stack/core/src/test/java/org/apache/usergrid/persistence/PerformanceEntityRebuildIndexTest.java
index f8eec52..e853e94 100644
--- a/stack/core/src/test/java/org/apache/usergrid/persistence/PerformanceEntityRebuildIndexTest.java
+++ b/stack/core/src/test/java/org/apache/usergrid/persistence/PerformanceEntityRebuildIndexTest.java
@@ -88,6 +88,139 @@ public class PerformanceEntityRebuildIndexTest extends AbstractCoreIT {
 
 
     @Test
+    public void rebuildOneCollectionIndex() throws Exception {
+
+        logger.info("Started rebuildIndex()");
+
+        final EntityManager em = app.getEntityManager();
+
+        // ----------------- create a bunch of entities
+
+        Map<String, Object> entityMap = new HashMap<String, Object>() {{
+            put("key1", 1000 );
+            put("key2", 2000 );
+            put("key3", "Some value");
+        }};
+        Map<String, Object> cat1map = new HashMap<String, Object>() {{
+            put("name", "enzo");
+            put("color", "orange");
+        }};
+        Map<String, Object> cat2map = new HashMap<String, Object>() {{
+            put("name", "marquee");
+            put("color", "grey");
+        }};
+        Map<String, Object> cat3map = new HashMap<String, Object>() {{
+            put("name", "bertha");
+            put("color", "tabby");
+        }};
+
+        Entity cat1 = em.create("cat", cat1map );
+        Entity cat2 = em.create("cat", cat2map );
+        Entity cat3 = em.create("cat", cat3map );
+
+        final long stopTime = System.currentTimeMillis() + RUNTIME_MS;
+
+        List<EntityRef> entityRefs = new ArrayList<EntityRef>();
+        int entityCount = 0;
+        while ( System.currentTimeMillis() < stopTime ) {
+
+            final Entity entity;
+
+            try {
+                entityMap.put("key", entityCount );
+                entity = em.create("testType", entityMap );
+
+                em.refreshIndex();
+
+                em.createConnection(entity, "herds", cat1);
+                em.createConnection(entity, "herds", cat2);
+                em.createConnection(entity, "herds", cat3);
+
+            } catch (Exception ex) {
+                throw new RuntimeException("Error creating entity", ex);
+            }
+
+            entityRefs.add(new SimpleEntityRef( entity.getType(), entity.getUuid() ) );
+            if ( entityCount % 10 == 0 ) {
+                logger.info("Created {} entities", entityCount );
+            }
+
+            entityCount++;
+            try { Thread.sleep( WRITE_DELAY_MS ); } catch (InterruptedException ignored ) {}
+        }
+
+        logger.info("Created {} entities", entityCount);
+        em.refreshIndex();
+
+        // ----------------- test that we can read them, should work fine
+
+        logger.debug("Read the data");
+        readData("testTypes", entityCount );
+
+        // ----------------- delete the system and application indexes
+
+        logger.debug("Deleting app index and system app index");
+        deleteIndex( CpNamingUtils.SYSTEM_APP_ID );
+        deleteIndex( em.getApplicationId() );
+
+        // ----------------- test that we can read them, should fail
+
+        logger.debug("Reading data, should fail this time ");
+        try {
+            readData( "testTypes", entityCount );
+            fail("should have failed to read data");
+
+        } catch (Exception expected) {}
+
+        // ----------------- rebuild index
+
+        logger.debug("Preparing to rebuild all indexes");;
+
+        final String meterName = this.getClass().getSimpleName() + ".rebuildIndex";
+        final Meter meter = registry.meter( meterName );
+
+        EntityManagerFactory.ProgressObserver po = new EntityManagerFactory.ProgressObserver() {
+            int counter = 0;
+
+            @Override
+            public void onProgress( final EntityRef entity ) {
+
+                meter.mark();
+                logger.debug("Indexing {}:{}", entity.getType(), entity.getUuid());
+                if ( !logger.isDebugEnabled() && counter % 100 == 0 ) {
+                    logger.info("Reindexed {} entities", counter );
+                }
+                counter++;
+            }
+
+
+
+            @Override
+            public long getWriteDelayTime() {
+                return 0;
+            }
+        };
+
+        try {
+
+            setup.getEmf().rebuildApplicationIndexes( em.getApplicationId(), po );
+
+            reporter.report();
+            registry.remove( meterName );
+            logger.info("Rebuilt index");
+
+        } catch (Exception ex) {
+            logger.error("Error rebuilding index", ex);
+            fail();
+        }
+
+        // ----------------- test that we can read them
+
+        readData( "testTypes", entityCount );
+    }
+
+
+    @Test
     public void rebuildIndex() throws Exception {
 
         logger.info("Started rebuildIndex()");
@@ -252,7 +385,8 @@ public class PerformanceEntityRebuildIndexTest extends AbstractCoreIT {
 
                 assertEquals( 2000, e.getProperty("key2"));
 
-                Results catResults = em.searchConnectedEntities(e, Query.fromQL("select *").setConnectionType( "herds" ));
+                Results catResults = em.searchConnectedEntities(e,
+                    Query.fromQL("select *").setConnectionType( "herds" ));
                 assertEquals( 3, catResults.size() );
 
                 if ( count % 100 == 0 ) {

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/a704ed73/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 7b391a1..251e25c 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
@@ -160,12 +160,13 @@ public class IndexResource extends AbstractContextResource {
     @RequireSystemAccess
     @PUT
     @Path( "rebuild/" + RootResource.APPLICATION_ID_PATH + "/{collectionName}" )
-    public JSONWithPadding rebuildIndexes( @Context UriInfo ui,
-                                           @PathParam( "applicationId" ) final String applicationIdStr,
-                                           @PathParam( "collectionName" ) final String collectionName,
-                                           @QueryParam( "callback" ) @DefaultValue( "callback" ) String callback,
-                                           @QueryParam( "delay" ) @DefaultValue( "10" ) final long delay )
-            throws Exception {
+    public JSONWithPadding rebuildIndexes(
+        @Context UriInfo ui,
+        @PathParam( "applicationId" ) final String applicationIdStr,
+        @PathParam( "collectionName" ) final String collectionName,
+        @QueryParam( "reverse" ) @DefaultValue( "false" ) final Boolean reverse,
+        @QueryParam( "callback" ) @DefaultValue( "callback" ) String callback,
+        @QueryParam( "delay" ) @DefaultValue( "10" ) final long delay ) throws Exception {
 
         final UUID appId = UUIDUtils.tryExtractUUID( applicationIdStr );
         ApiResponse response = createApiResponse();
@@ -175,7 +176,13 @@ public class IndexResource extends AbstractContextResource {
 
             public void run() {
 
-                rebuildCollection( appId, collectionName, delay );
+                try {
+                    rebuildCollection( appId, collectionName, reverse, delay );
+                } catch (Exception e) {
+
+                    // TODO: handle this in rebuildCollection() instead
+                    throw new RuntimeException("Error rebuilding collection");
+                }
             }
         };
 
@@ -192,13 +199,14 @@ public class IndexResource extends AbstractContextResource {
     @POST
     @Path( RootResource.APPLICATION_ID_PATH )
     public JSONWithPadding addIndex(@Context UriInfo ui,
-                                    @PathParam( "applicationId" ) final String applicationIdStr,
-                                    Map<String, Object> config,
-                                    @QueryParam( "callback" ) @DefaultValue( "callback" ) String callback)  throws Exception{
+            @PathParam( "applicationId" ) final String applicationIdStr,
+            Map<String, Object> config,
+            @QueryParam( "callback" ) @DefaultValue( "callback" ) String callback)  throws Exception{
+
         ApiResponse response = createApiResponse();
         final UUID appId = UUIDUtils.tryExtractUUID(applicationIdStr);
 
-        if(!config.containsKey("replicas") || !config.containsKey("shards") ||
+        if (!config.containsKey("replicas") || !config.containsKey("shards") ||
                 !(config.get("replicas") instanceof Integer) || !(config.get("shards") instanceof Integer)){
             throw new IllegalArgumentException("body must contains 'replicas' of type int and 'shards' of type int");
         }
@@ -207,14 +215,20 @@ public class IndexResource extends AbstractContextResource {
             throw new IllegalArgumentException("Please add an indexSuffix to your post");
         }
 
-        emf.addIndex(appId, config.get("indexSuffix").toString(), (int) config.get("shards"),(int) config.get("replicas"));
+        emf.addIndex(appId, config.get("indexSuffix").toString(),
+            (int) config.get("shards"),(int) config.get("replicas"));
         response.setAction("Add index to alias");
 
         return new JSONWithPadding(response, callback);
 
     }
 
-    private void rebuildCollection( final UUID applicationId, final String collectionName, final long delay ) {
+    private void rebuildCollection(
+        final UUID applicationId,
+        final String collectionName,
+        final boolean reverse,
+        final long delay ) throws Exception {
+
         EntityManagerFactory.ProgressObserver po = new EntityManagerFactory.ProgressObserver() {
 
             @Override
@@ -227,10 +241,9 @@ public class IndexResource extends AbstractContextResource {
             }
         };
 
-
         logger.info( "Reindexing for app id: {} and collection {}", applicationId, collectionName );
 
-        emf.rebuildCollectionIndex( applicationId, collectionName, po );
+        emf.rebuildCollectionIndex(applicationId, collectionName, reverse, po);
         emf.refreshIndex();
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/a704ed73/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 9bf0813..7f8d085 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
@@ -68,7 +68,7 @@ public class IndexResourceIT extends AbstractRestIT {
                     .queryParam("access_token", superToken)
                     .accept(MediaType.APPLICATION_JSON).type(MediaType.APPLICATION_JSON_TYPE)
                     .post(String.class, data));
-        }catch (Exception e){
+        } catch (Exception e) {
             LOG.error("failed", e);
             fail(e.toString());
         }


[45/50] [abbrv] incubator-usergrid git commit: This closes #159

Posted by sn...@apache.org.
This closes #159


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

Branch: refs/heads/two-dot-o
Commit: bedf5afb56b8fb858705901b1fd6ce0d6cc5b25c
Parents: ec6d4e8 102a953
Author: Dave Johnson <sn...@apache.org>
Authored: Thu Feb 26 09:48:42 2015 -0500
Committer: Dave Johnson <sn...@apache.org>
Committed: Thu Feb 26 09:48:42 2015 -0500

----------------------------------------------------------------------
 .../batch/job/AbstractSchedulerRuntimeIT.java   |   3 +-
 stack/corepersistence/pom.xml                   |   4 +-
 stack/pom.xml                                   |   3 +-
 stack/rest/pom.xml                              |  23 +-
 .../usergrid/rest/JobServiceBoostrap.java       |   5 +-
 .../apache/usergrid/rest/ShutdownListener.java  |   8 +-
 .../applications/ApplicationResourceIT.java     | 881 ++++++++++++-------
 .../collection/DuplicateNameIT.java             |  59 +-
 .../users/ConnectionResourceTest.java           | 272 +++---
 .../collection/users/RetrieveUsersTest.java     |   8 +-
 .../rest/management/ImportResourceIT.java       |   3 +-
 .../organizations/AdminEmailEncodingIT.java     | 153 ++--
 .../test/resource2point0/AbstractRestIT.java    |   1 -
 .../endpoints/ApplicationsResource.java         |   5 +
 .../endpoints/TokenResource.java                |  32 +-
 .../endpoints/mgmt/ApplicationResource.java     |   6 +-
 .../endpoints/mgmt/AuthorizeResource.java       |  59 ++
 .../endpoints/mgmt/CredentialsResource.java     |  55 ++
 .../endpoints/mgmt/ManagementResource.java      |  12 +-
 .../endpoints/mgmt/OrgResource.java             |   3 +
 .../endpoints/mgmt/OrganizationResource.java    |  44 +-
 .../endpoints/mgmt/TokenResource.java           |  48 +-
 .../test/resource2point0/model/Credentials.java |  47 +
 .../rest/test/resource2point0/model/Entity.java |   3 +
 .../rest/test/resource2point0/model/Token.java  |  37 +-
 .../management/export/ExportServiceIT.java      |   3 +-
 .../management/importer/ImportCollectionIT.java |   4 +-
 .../management/importer/ImportServiceIT.java    |   3 +-
 28 files changed, 1121 insertions(+), 663 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/bedf5afb/stack/core/src/test/java/org/apache/usergrid/batch/job/AbstractSchedulerRuntimeIT.java
----------------------------------------------------------------------
diff --cc stack/core/src/test/java/org/apache/usergrid/batch/job/AbstractSchedulerRuntimeIT.java
index 8825497,1d87b73..534689c
--- a/stack/core/src/test/java/org/apache/usergrid/batch/job/AbstractSchedulerRuntimeIT.java
+++ b/stack/core/src/test/java/org/apache/usergrid/batch/job/AbstractSchedulerRuntimeIT.java
@@@ -93,10 -90,10 +93,11 @@@ public class AbstractSchedulerRuntimeI
          }
  
          // start the scheduler after we're all set up
 -        JobSchedulerService jobScheduler = cassandraResource.getBean( JobSchedulerService.class );
 +        JobSchedulerService jobScheduler = springResource.getBean( JobSchedulerService.class );
          jobScheduler.setJobListener( listener );
          if ( jobScheduler.state() != State.RUNNING ) {
--            jobScheduler.startAndWait();
++            jobScheduler.startAsync();
++            jobScheduler.awaitRunning();
          }
      }
  

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/bedf5afb/stack/corepersistence/pom.xml
----------------------------------------------------------------------
diff --cc stack/corepersistence/pom.xml
index e7da11f,9bd53fa..c89e62f
--- a/stack/corepersistence/pom.xml
+++ b/stack/corepersistence/pom.xml
@@@ -61,8 -61,8 +61,8 @@@ limitations under the License
          <commons.lang.version>3.1</commons.lang.version>
          <elasticsearch.version>1.3.2</elasticsearch.version>
          <fasterxml-uuid.version>3.1.3</fasterxml-uuid.version>
-         <guava.version>14.0.1</guava.version>
-         <guice.version>3.0</guice.version>
 -        <guava.version>15.0</guava.version>
++        <guava.version>18.0</guava.version>
+         <guice.version>4.0-beta5</guice.version>
          <guicyfig.version>3.2</guicyfig.version>
          <hystrix.version>1.3.16</hystrix.version>
          <jackson-2-version>2.4.1</jackson-2-version>

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/bedf5afb/stack/pom.xml
----------------------------------------------------------------------
diff --cc stack/pom.xml
index 828ea45,217e3fa..167ef14
--- a/stack/pom.xml
+++ b/stack/pom.xml
@@@ -32,106 -32,98 +32,107 @@@
    <description>Parent module for the Apache Usergrid Project</description>
    <packaging>pom</packaging>
  
 -  <properties>
 -    <!-- =================================================================== -->
 -    <!-- Properties: Deployment Setting Defaults                             -->
 -    <!-- =================================================================== -->
 -    <!-- NOTE: override from the CLI or settings.xml                 -->
 -    <!-- NOTE: add server credentials config via settings            -->
 -    <!-- NOTE: <settings>                                            -->
 -    <!-- NOTE:   <servers>                                           -->
 -    <!-- NOTE:     <server>                                          -->
 -    <!-- NOTE:       <id>usergrid.releases</id>                      -->
 -    <!-- NOTE:       <username>akarasulu</username>                  -->
 -    <!-- NOTE:       <password>*********</password>                  -->
 -    <!-- NOTE:     </server>                                         -->
 -    <!-- NOTE:     <server>                                          -->
 -    <!-- NOTE:       <id>usergrid.snapshots</id>                     -->
 -    <!-- NOTE:       <username>akarasulu</username>                  -->
 -    <!-- NOTE:       <password>*********</password>                  -->
 -    <!-- NOTE:     </server>                                         -->
 -    <!-- NOTE:   </servers>                                          -->
 -    <!-- NOTE:                                                       -->
 -    <!-- NOTE:   <profiles>                                          -->
 -    <!-- NOTE:     <profile>                                         -->
 -    <!-- NOTE:       <id>deployment</id>                             -->
 -    <!-- NOTE:       <properties>                                    -->
 -    <!-- NOTE:         <release.repository.url>                      -->
 -    <!-- NOTE:           https://to/your/custom/releases/repository  -->
 -    <!-- NOTE:         </release.repository.url>                     -->
 -    <!-- NOTE:         <snapshot.repository.url>                     -->
 -    <!-- NOTE:           https://to/your/custom/snapshots/repository -->
 -    <!-- NOTE:         </shapshot.repository.url>                    -->
 -    <!-- NOTE:       </properties>                                   -->
 -    <!-- NOTE:     </profile>                                        -->
 -    <!-- NOTE:   </profiles>                                         -->
 -    <!-- NOTE:                                                       -->
 -    <!-- NOTE:   <activeProfiles>                                    -->
 -    <!-- NOTE:     <activeProfile>deployment</activeProfile>         -->
 -    <!-- NOTE:   </activeProfiles>                                   -->
 -    <!-- NOTE: </settings>                                           -->
 -
 -    <snapshot.repository.url>
 -      https://repository.apache.org/content/repositories/snapshots
 -    </snapshot.repository.url>
 -    <release.repository.url>
 -      https://repository.apache.org/service/local/staging/deploy/maven2
 -    </release.repository.url>
 -
 -    <!-- =================================================================== -->
 -    <!-- Properties: General Settings -->
 -    <!-- =================================================================== -->
 -
 -    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
 -
 -    <!-- you can override these via MAVEN_OPTS -->
 -    <ug.heapmax>2048m</ug.heapmax>
 -    <ug.heapmin>2048m</ug.heapmin>
 -	<ug.argline>-Djava.awt.headless=true</ug.argline>
 -
 -    <usergrid-custom-spring-properties>classpath:/usergrid-deployment.properties</usergrid-custom-spring-properties>
 -    <usergrid-custom-spring-test-properties>classpath:/usergrid-custom-test.properties</usergrid-custom-spring-test-properties>
 -
 -    <!-- =================================================================== -->
 -    <!-- Properties: Dependency Settings -->
 -    <!-- =================================================================== -->
 -
 -    <amber-version>0.22-incubating</amber-version>
 -    <cassandra-version>1.2.18</cassandra-version>
 -    <hector-om-version>3.0-03</hector-om-version>
 -    <hector-version>1.1-4</hector-version>
 -    <hector-test-version>1.1-4</hector-test-version>
 -    <jackson-version>1.9.9</jackson-version>
 -    <jackson-2-version>2.3.3</jackson-2-version>
 -    <jclouds.version>1.6.2-incubating</jclouds.version>
 -    <jersey-version>1.18.1</jersey-version>
 -    <junit-version>4.11</junit-version>
 -    <log4j-version>1.2.16</log4j-version>
 -    <metrics-version>2.1.2</metrics-version>
 -    <org.springframework.version>3.1.2.RELEASE</org.springframework.version>
 -    <shiro-version>1.2.0</shiro-version>
 -    <slf4j-version>1.6.1</slf4j-version>
 -    <snakeyaml-version>1.8</snakeyaml-version>
 -    <tomcat-version>7.0.52</tomcat-version>
 -    <antlr.version>3.4</antlr.version>
 -    <tika.version>1.4</tika.version>
 -    <mockito.version>1.10.8</mockito.version>
 -
 -    <usergrid.it.forkCount>3</usergrid.it.forkCount>
 -    <usergrid.it.reuseForks>false</usergrid.it.reuseForks>
 -    <usergrid.it.parallel>suites</usergrid.it.parallel>
 -
 -    <metrics.version>3.0.0</metrics.version>
 -    <rx.version>0.19.6</rx.version>
 -  </properties>
 +    <properties>
 +      <!-- =================================================================== -->
 +      <!-- Properties: Deployment Setting Defaults                             -->
 +      <!-- =================================================================== -->
 +      <!-- NOTE: override from the CLI or settings.xml                 -->
 +      <!-- NOTE: add server credentials config via settings            -->
 +      <!-- NOTE: <settings>                                            -->
 +      <!-- NOTE:   <servers>                                           -->
 +      <!-- NOTE:     <server>                                          -->
 +      <!-- NOTE:       <id>usergrid.releases</id>                      -->
 +      <!-- NOTE:       <username>akarasulu</username>                  -->
 +      <!-- NOTE:       <password>*********</password>                  -->
 +      <!-- NOTE:     </server>                                         -->
 +      <!-- NOTE:     <server>                                          -->
 +      <!-- NOTE:       <id>usergrid.snapshots</id>                     -->
 +      <!-- NOTE:       <username>akarasulu</username>                  -->
 +      <!-- NOTE:       <password>*********</password>                  -->
 +      <!-- NOTE:     </server>                                         -->
 +      <!-- NOTE:   </servers>                                          -->
 +      <!-- NOTE:                                                       -->
 +      <!-- NOTE:   <profiles>                                          -->
 +      <!-- NOTE:     <profile>                                         -->
 +      <!-- NOTE:       <id>deployment</id>                             -->
 +      <!-- NOTE:       <properties>                                    -->
 +      <!-- NOTE:         <release.repository.url>                      -->
 +      <!-- NOTE:           https://to/your/custom/releases/repository  -->
 +      <!-- NOTE:         </release.repository.url>                     -->
 +      <!-- NOTE:         <snapshot.repository.url>                     -->
 +      <!-- NOTE:           https://to/your/custom/snapshots/repository -->
 +      <!-- NOTE:         </shapshot.repository.url>                    -->
 +      <!-- NOTE:       </properties>                                   -->
 +      <!-- NOTE:     </profile>                                        -->
 +      <!-- NOTE:   </profiles>                                         -->
 +      <!-- NOTE:                                                       -->
 +      <!-- NOTE:   <activeProfiles>                                    -->
 +      <!-- NOTE:     <activeProfile>deployment</activeProfile>         -->
 +      <!-- NOTE:   </activeProfiles>                                   -->
 +      <!-- NOTE: </settings>                                           -->
 +
 +      <snapshot.repository.url>
 +        https://repository.apache.org/content/repositories/snapshots
 +      </snapshot.repository.url>
 +      <release.repository.url>
 +        https://repository.apache.org/service/local/staging/deploy/maven2
 +      </release.repository.url>
 +
 +      <!-- =================================================================== -->
 +      <!-- Properties: General Settings -->
 +      <!-- =================================================================== -->
 +
 +      <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
 +
 +      <!-- you can override these via MAVEN_OPTS -->
 +      <ug.heapmax>4096m</ug.heapmax>
 +      <ug.heapmin>2048m</ug.heapmin>
 +  	  <ug.argline>-Djava.awt.headless=true</ug.argline>
 +
 +      <usergrid-custom-spring-properties>classpath:/usergrid-deployment.properties</usergrid-custom-spring-properties>
 +      <usergrid-custom-spring-test-properties>classpath:/usergrid-custom-test.properties</usergrid-custom-spring-test-properties>
 +
 +      <!-- =================================================================== -->
 +      <!-- Properties: Dependency Settings -->
 +      <!-- =================================================================== -->
 +
 +      <amber-version>0.22-incubating</amber-version>
 +      <cassandra-version>1.2.18</cassandra-version>
-       <guava.version>14.0.1</guava.version>
++      <guava.version>18.0</guava.version>
++      <guice.version>4.0-beta5</guice.version>
 +      <hector-om-version>3.0-03</hector-om-version>
 +      <hector-version>1.1-4</hector-version>
 +      <hector-test-version>1.1-4</hector-test-version>
 +      <jackson-version>1.9.9</jackson-version>
 +      <jackson-2-version>2.3.3</jackson-2-version>
 +      <jclouds.version>1.8.0</jclouds.version>
 +      <jersey-version>1.18.1</jersey-version>
 +      <junit-version>4.12</junit-version>
 +      <log4j-version>1.2.16</log4j-version>
 +      <metrics-version>2.1.2</metrics-version>
 +      <org.springframework.version>3.1.2.RELEASE</org.springframework.version>
 +      <shiro-version>1.2.3</shiro-version>
 +      <slf4j-version>1.6.1</slf4j-version>
 +      <snakeyaml-version>1.8</snakeyaml-version>
 +      <tomcat-version>7.0.59</tomcat-version>
 +      <antlr.version>3.4</antlr.version>
 +      <tika.version>1.4</tika.version>
 +      <mockito.version>1.10.8</mockito.version>
 +
 +      <!-- only use half the cores on the machine for testing -->
 +      <usergrid.it.parallel>methods</usergrid.it.parallel>
 +      <usergrid.it.reuseForks>true</usergrid.it.reuseForks>
 +      <usergrid.it.forkCount>1</usergrid.it.forkCount>
 +      <usergrid.it.threads>2</usergrid.it.threads>
 +
 +      <metrics.version>3.0.0</metrics.version>
 +      <rx.version>0.19.6</rx.version>
 +      <surefire.plugin.version>2.18.1</surefire.plugin.version>
 +      <powermock.version>1.6.1</powermock.version>
 +
 +      <maven.build.timestamp.format>yyyy-MM-dd'T'HH-mm-ss'Z'</maven.build.timestamp.format>
 +
 +    </properties>
  
    <licenses>
      <license>

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/bedf5afb/stack/rest/pom.xml
----------------------------------------------------------------------
diff --cc stack/rest/pom.xml
index 927b7f2,4a99443..34a3858
--- a/stack/rest/pom.xml
+++ b/stack/rest/pom.xml
@@@ -31,35 -31,75 +31,34 @@@
  
      <!-- Override these properties in an active profile within your settings.xml -->
      <properties>
 -        <!-- If you got the resources, max parallelism = 6 forks -->
 -        <rest.it.forkCount>2</rest.it.forkCount>
 -        <rest.it.reuseForks>false</rest.it.reuseForks>
 -        <rest.it.parallel>suites</rest.it.parallel>
 -        <rest.it.threadCount>2</rest.it.threadCount>
 +        <usergrid.rest.threads>8</usergrid.rest.threads>
-         <guice.version>3</guice.version>
 +        <catalina.host>localhost</catalina.host>
 +        <catalina.jmx.port>8089</catalina.jmx.port>
      </properties>
  
 +    <!-- profile that arquillian uses when it builds/starts tomcat -->
      <profiles>
  
 -        <profile>
 -            <id>default</id>
 -            <activation>
 -                <activeByDefault>true</activeByDefault>
 -            </activation>
 -            <build>
 -                <plugins>
 -                    <plugin>
 -                        <groupId>org.apache.maven.plugins</groupId>
 -                        <artifactId>maven-surefire-plugin</artifactId>
 -                        <configuration>
 -
 -                            <systemPropertyVariables>
 -                                <storage-config>${basedir}/src/test/conf</storage-config>
 -                                <target.directory>${project.build.directory}</target.directory>
 -                            </systemPropertyVariables>
 -
 -                            <forkCount>${rest.it.forkCount}</forkCount>
 -                            <reuseForks>${rest.it.reuseForks}</reuseForks>
 -
 -                            <parallel>${rest.it.parallel}</parallel>
 -                            <threadCount>${rest.it.threadCount}</threadCount>
 -
 -                            <argLine>-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=src/test/resources/logging.properties ${ug.argline}</argLine>
 -
 -                            <additionalClasspathElements>
 -                                <additionalClasspathElement>./target/classes/jsp/WEB_002dINF/jsp</additionalClasspathElement>
 -                            </additionalClasspathElements>
 -
 -                            <includes>
 -<!--                                <include>**/RestTestSuite.java</include>
 -                                <include>**/RestITSuite.java</include>-->
 -                                <include>**/*IT.java</include>
 -                                <include>**/*Test.java</include>
 -                            </includes>
 -                            <excludes>
 -<!--                                <exclude>**/*Concurrent*Suite.java</exclude>
 -                                <exclude>**/ActivityResourceIT.java</exclude>
 -                                <exclude>**/AdminEmailEncodingIT.java</exclude>
 -                                <exclude>**/ApplicationRequestCounterIT.java</exclude>
 -                                <exclude>**/AssetResourceIT.java</exclude>
 -                                <exclude>**/BasicIT.java</exclude>
 -                                <exclude>**/CollectionsResourceIT.java</exclude>
 -                                <exclude>**/ContentTypeResourceIT.java</exclude>
 -                                <exclude>**/DevicesResourceIT.java</exclude>
 -                                <exclude>**/EventsResourceIT.java</exclude>
 -                                <exclude>**/GroupResourceIT.java</exclude>
 -                                <exclude>**/OrganizationResourceIT.java</exclude>
 -                                <exclude>**/OrganizationsResourceIT.java</exclude>
 -                                <exclude>**/OwnershipResourceIT.java</exclude>
 -                                <exclude>**/PagingResourceIT.java</exclude>
 -                                <exclude>**/PermissionsResourceIT.java</exclude>
 -                                <exclude>**/UserResourceIT.java</exclude>
 -                                <exclude>**/UsersOrganizationsResourceIT.java</exclude>-->
 -                            </excludes>
 -                        </configuration>
 -                    </plugin>
 -                </plugins>
 -            </build>
 -        </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>
  
@@@ -287,6 -311,6 +286,28 @@@
              <artifactId>spring-webmvc</artifactId>
          </dependency>
  
++        <!-- the core, which includes Streaming API, shared low-level abstractions (but NOT data-binding) -->
++        <dependency>
++            <groupId>com.fasterxml.jackson.core</groupId>
++            <artifactId>jackson-core</artifactId>
++            <version>${jackson-2-version}</version>
++        </dependency>
++
++        <!-- Just the annotations; use this dependency if you want to attach annotations
++             to classes without connecting them to the code. -->
++        <dependency>
++            <groupId>com.fasterxml.jackson.core</groupId>
++            <artifactId>jackson-annotations</artifactId>
++            <version>${jackson-2-version}</version>
++        </dependency>
++
++        <!-- databinding; ObjectMapper, JsonNode and related classes are here -->
++        <dependency>
++            <groupId>com.fasterxml.jackson.core</groupId>
++            <artifactId>jackson-databind</artifactId>
++            <version>${jackson-2-version}</version>
++        </dependency>
++
          <dependency>
              <!-- TODO - should not scope be 'test' ? -->
              <groupId>org.slf4j</groupId>

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/bedf5afb/stack/rest/src/main/java/org/apache/usergrid/rest/JobServiceBoostrap.java
----------------------------------------------------------------------
diff --cc stack/rest/src/main/java/org/apache/usergrid/rest/JobServiceBoostrap.java
index c6721ea,0000000..a921f22
mode 100644,000000..100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/JobServiceBoostrap.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/JobServiceBoostrap.java
@@@ -1,69 -1,0 +1,70 @@@
 +/*
 + * Licensed to the Apache Software Foundation (ASF) under one or more
 + * contributor license agreements.  See the NOTICE file distributed with
 + * this work for additional information regarding copyright ownership.
 + * The ASF licenses this file to You under the Apache License, Version 2.0
 + * (the "License"); you may not use this file except in compliance with
 + * the License.  You may obtain a copy of the License at
 + *
 + *      http://www.apache.org/licenses/LICENSE-2.0
 + *
 + * Unless required by applicable law or agreed to in writing, software
 + * distributed under the License is distributed on an "AS IS" BASIS,
 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 + * See the License for the specific language governing permissions and
 + * limitations under the License.
 + */
 +package org.apache.usergrid.rest;
 +
 +import org.apache.usergrid.batch.service.JobSchedulerService;
 +import org.apache.usergrid.persistence.EntityManager;
 +import org.slf4j.Logger;
 +import org.slf4j.LoggerFactory;
 +import org.springframework.beans.factory.annotation.Autowired;
 +import org.springframework.context.ApplicationListener;
 +import org.springframework.context.event.ContextRefreshedEvent;
 +
 +import java.util.Properties;
 +
 +
 +/**
 + * Simple class that starts the job store after the application context has been fired up. We don't
 + * want to start the service until all of spring has been initialized in our webapp context
 + */
 +public class JobServiceBoostrap implements
 +        ApplicationListener<ContextRefreshedEvent> {
 +
 +    private static final Logger logger = LoggerFactory.getLogger( JobServiceBoostrap.class );
 +
 +    public static final String START_SCHEDULER_PROP = "usergrid.scheduler.enabled";
 +
 +    @Autowired
-     private JobSchedulerService schedulerService;
++    private JobSchedulerService jobScheduler;
 +
 +    @Autowired
 +    private Properties properties;
 +
 +    public JobServiceBoostrap() {
 +    }
 +
 +    /*
 +     * (non-Javadoc)
 +     *
 +     * @see
 +     * org.springframework.context.ApplicationListener#onApplicationEvent(org
 +     * .springframework.context.ApplicationEvent)
 +     */
 +    @Override
 +    public void onApplicationEvent( ContextRefreshedEvent event ) {
 +        String start = properties.getProperty( START_SCHEDULER_PROP, "true" );
 +        if ( Boolean.parseBoolean( start ) ) {
 +            logger.info( "Starting Scheduler Service..." );
-             schedulerService.startAndWait();
++            jobScheduler.startAsync();
++            jobScheduler.awaitRunning();
 +
 +        } else {
 +            logger.info( "Scheduler Service disabled" );
 +        }
 +    }
 +
 +}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/bedf5afb/stack/rest/src/main/java/org/apache/usergrid/rest/ShutdownListener.java
----------------------------------------------------------------------
diff --cc stack/rest/src/main/java/org/apache/usergrid/rest/ShutdownListener.java
index 7b038c2,0000000..f9f5421
mode 100644,000000..100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/ShutdownListener.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/ShutdownListener.java
@@@ -1,73 -1,0 +1,75 @@@
 +/*
 + * 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 org.apache.usergrid.batch.service.JobSchedulerService;
 +import org.apache.usergrid.batch.service.SchedulerService;
 +import org.apache.usergrid.persistence.cassandra.CassandraService;
 +import org.slf4j.Logger;
 +import org.slf4j.LoggerFactory;
 +import org.springframework.context.ApplicationContext;
 +import org.springframework.context.ApplicationContextAware;
 +import org.springframework.web.context.support.WebApplicationContextUtils;
 +
 +import javax.servlet.ServletContextEvent;
 +import javax.servlet.ServletContextListener;
 +import javax.servlet.http.HttpSessionAttributeListener;
 +import javax.servlet.http.HttpSessionEvent;
 +import javax.servlet.http.HttpSessionListener;
 +import javax.servlet.http.HttpSessionBindingEvent;
 +import java.util.Properties;
 +
 +
 +/**
-  * Shutdown job service when context is destroyed (useful when testing).
++ * Shutdown job service when context is destroyed.
++ * (Added for Arquillian testing purposes when we have to deploy, re-deploy, etc.)
 + */
 +public class ShutdownListener implements ServletContextListener {
 +    private static final Logger logger = LoggerFactory.getLogger(ShutdownListener.class);
 +    JobSchedulerService schedulerService;
 +    Properties properties;
 +
 +    public ShutdownListener() {
 +    }
 +
 +    public void contextInitialized(ServletContextEvent sce) {
 +
 +        ApplicationContext ctx = WebApplicationContextUtils
 +            .getWebApplicationContext(sce.getServletContext());
 +
 +        schedulerService = ctx.getBean( JobSchedulerService.class );
 +        properties = (Properties)ctx.getBean("properties");
 +
 +        logger.info("ShutdownListener initialized");
 +    }
 +
 +    public void contextDestroyed(ServletContextEvent sce) {
 +
 +        logger.info("ShutdownListener invoked");
 +
 +        boolean started = Boolean.parseBoolean(
 +            properties.getProperty(JobServiceBoostrap.START_SCHEDULER_PROP, "true"));
 +
 +        if ( started ) {
-             schedulerService.stopAndWait();
-             logger.info( "Stopping Scheduler Service..." );
++            schedulerService.stopAsync();
++            schedulerService.awaitTerminated();
++            logger.info( "Stopped Scheduler Service..." );
 +        }
 +    }
 +}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/bedf5afb/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 dc84197,1056df7..3b4a0b6
--- 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
@@@ -16,61 -16,65 +16,63 @@@
   */
  package org.apache.usergrid.rest.applications;
  
- 
- import java.util.Map;
- 
- import javax.ws.rs.core.MediaType;
--
  import com.fasterxml.jackson.databind.JsonNode;
- import org.junit.Ignore;
- import org.junit.Test;
- 
- import org.apache.usergrid.management.ApplicationInfo;
- import org.apache.usergrid.management.OrganizationInfo;
- import org.apache.usergrid.rest.AbstractRestIT;
- 
- import org.apache.shiro.codec.Base64;
- 
- import com.sun.jersey.api.client.ClientResponse;
++import com.fasterxml.jackson.databind.ObjectMapper;
  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.shiro.codec.Base64;
 -import org.apache.usergrid.cassandra.Concurrent;
+ import org.apache.usergrid.rest.test.resource2point0.AbstractRestIT;
+ import org.apache.usergrid.rest.test.resource2point0.endpoints.mgmt.OrganizationResource;
+ import org.apache.usergrid.rest.test.resource2point0.model.*;
+ import org.apache.usergrid.utils.MapUtils;
+ import org.junit.Ignore;
+ import org.junit.Test;
+ import org.slf4j.Logger;
+ import org.slf4j.LoggerFactory;
+ 
+ import javax.ws.rs.core.MediaType;
  import java.io.IOException;
  
- import static org.junit.Assert.assertEquals;
- import static org.junit.Assert.assertNotNull;
- import static org.junit.Assert.assertTrue;
  import static org.apache.usergrid.utils.MapUtils.hashMap;
- import org.slf4j.Logger;
- import org.slf4j.LoggerFactory;
+ import static org.junit.Assert.*;
  
  
  /**
   * Invokes methods on ApplicationResource
-  *
-  * @author zznate
   */
- 
 -@Concurrent()
  public class ApplicationResourceIT extends AbstractRestIT {
-     private static final Logger logger = LoggerFactory.getLogger( ApplicationResourceIT.class );
- 
+     private static final Logger logger = LoggerFactory.getLogger(ApplicationResourceIT.class);
  
+     /**
+      * Retrieve an application using the organization client credentials
+      *
+      * @throws Exception
+      */
      @Test
      public void applicationWithOrgCredentials() throws Exception {
- 
-         String clientId = setup.getMgmtSvc().getClientIdForOrganization( orgInfo.getUuid() );
-         String clientSecret = setup.getMgmtSvc().getClientSecretForOrganization( orgInfo.getUuid() );
- 
-         refreshIndex( orgInfo.getName(), appInfo.getName() );
- 
-         JsonNode node = mapper.readTree( resource().path( orgAppPath + "users" )
-                 .queryParam( "client_id", clientId )
-                 .queryParam( "client_secret", clientSecret ).accept( MediaType.APPLICATION_JSON )
-                 .type( MediaType.APPLICATION_JSON_TYPE ).get( String.class ));
- 
-         assertNotNull( node.get( "entities" ) );
+         //retrieve the credentials
+         Credentials orgCredentials = getOrgCredentials();
+ 
+         //retrieve the app using only the org credentials
+         ApiResponse apiResponse = this.org().app(clientSetup.getAppName()).getResource(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)
+             .get(ApiResponse.class);
+         //assert that a valid response is returned without error
+         assertNotNull(apiResponse);
+         assertNull(apiResponse.getError());
      }
  
+     /**
+      * Retrieve an application using the application client credentials
+      *
+      * @throws Exception
+      */
      @Test
      public void applicationWithAppCredentials() throws Exception {
  

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/bedf5afb/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/DuplicateNameIT.java
----------------------------------------------------------------------
diff --cc stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/DuplicateNameIT.java
index 9c1636a,d01c533..0e57de4
--- 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,25 -16,22 +16,32 @@@
  
  package org.apache.usergrid.rest.applications.collection;
  
 +
 +import org.junit.Rule;
 +import org.junit.Test;
 +import org.slf4j.Logger;
 +import org.slf4j.LoggerFactory;
 +
- import org.apache.usergrid.rest.AbstractRestIT;
 +import org.apache.usergrid.rest.TestContextSetup;
 +
 +import static org.junit.Assert.fail;
 +
+ import com.sun.jersey.api.client.UniformInterfaceException;
+ import org.apache.usergrid.rest.test.resource2point0.AbstractRestIT;
+ import org.apache.usergrid.rest.test.resource2point0.model.Entity;
+ import org.junit.Test;
  
- public class DuplicateNameIT extends AbstractRestIT {
+ import static org.junit.Assert.assertEquals;
+ import static org.junit.Assert.fail;
  
-     private static final Logger logger = LoggerFactory.getLogger( DuplicateNameIT.class );
  
-     @Rule
-     public TestContextSetup context = new TestContextSetup( this );
+ public class DuplicateNameIT extends AbstractRestIT {
  
+     /**
+      * Test to ensure that an error is returned when
+      * attempting to POST multiple entities to the
+      * same collection with the same name
+      */
      @Test
      public void duplicateNamePrevention() {
  

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/bedf5afb/stack/rest/src/test/java/org/apache/usergrid/rest/management/ImportResourceIT.java
----------------------------------------------------------------------
diff --cc stack/rest/src/test/java/org/apache/usergrid/rest/management/ImportResourceIT.java
index a095afa,0000000..0b87548
mode 100644,000000..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
@@@ -1,769 -1,0 +1,770 @@@
 +/*
 + * 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.management;
 +
 +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;
 +import org.apache.usergrid.ServiceITSetupImpl;
 +import org.apache.usergrid.batch.service.JobSchedulerService;
 +import org.apache.usergrid.cassandra.CassandraResource;
 +import org.apache.usergrid.management.importer.S3Upload;
 +import org.apache.usergrid.persistence.index.impl.ElasticSearchResource;
 +import org.apache.usergrid.persistence.index.utils.UUIDUtils;
 +import org.apache.usergrid.rest.test.resource2point0.AbstractRestIT;
 +import org.apache.usergrid.rest.test.resource2point0.model.ApiResponse;
 +import org.apache.usergrid.rest.test.resource2point0.model.Collection;
 +import org.apache.usergrid.rest.test.resource2point0.model.Entity;
 +import org.apache.usergrid.rest.test.resource2point0.model.Organization;
 +import org.apache.usergrid.rest.test.resource2point0.model.Token;
 +import org.apache.usergrid.setup.ConcurrentProcessSingleton;
 +
 +import org.jclouds.ContextBuilder;
 +import org.jclouds.blobstore.BlobStore;
 +import org.jclouds.blobstore.BlobStoreContext;
 +import org.jclouds.blobstore.ContainerNotFoundException;
 +import org.jclouds.blobstore.domain.PageSet;
 +import org.jclouds.blobstore.domain.StorageMetadata;
 +import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule;
 +import org.jclouds.logging.log4j.config.Log4JLoggingModule;
 +import org.jclouds.netty.config.NettyPayloadModule;
 +import org.junit.*;
 +import org.slf4j.Logger;
 +import org.slf4j.LoggerFactory;
 +
 +import java.util.ArrayList;
 +import java.util.HashMap;
 +import java.util.List;
 +import java.util.Properties;
 +
 +import static org.junit.Assert.*;
 +
 +
 +public class ImportResourceIT extends AbstractRestIT {
 +
 +    private static final Logger logger = LoggerFactory.getLogger(ImportResourceIT.class);
 +
 +
 +    private static String bucketPrefix;
 +
 +    private String bucketName;
 +
 +    boolean configured;
 +
 +
 +    public ImportResourceIT() throws Exception {
 +
 +    }
 +
 +
 +    @ClassRule
 +    public static final ServiceITSetup setup =
 +        new ServiceITSetupImpl();
 +
 +    @BeforeClass
 +    public static void setup() throws Exception {
 +
 +        bucketPrefix = System.getProperty("bucketName");
 +
 +        // start the scheduler after we're all set up
 +        JobSchedulerService jobScheduler = ConcurrentProcessSingleton.getInstance().getSpringResource().getBean( JobSchedulerService.class );
 +        if (jobScheduler.state() != Service.State.RUNNING) {
-             jobScheduler.startAndWait();
++            jobScheduler.startAsync();
++            jobScheduler.awaitRunning();
 +        }
 +
 +    }
 +
 +    @Before
 +    public void before() {
 +        configured =
 +            !StringUtils.isEmpty(System.getProperty( SDKGlobalConfiguration.SECRET_KEY_ENV_VAR ))
 +                && !StringUtils.isEmpty(System.getProperty( SDKGlobalConfiguration.ACCESS_KEY_ENV_VAR ))
 +                && !StringUtils.isEmpty(System.getProperty("bucketName"));
 +
 +
 +        if (!configured) {
 +            logger.warn("Skipping test because {}, {} and bucketName not " +
 +                    "specified as system properties, e.g. in your Maven settings.xml file.",
 +                new Object[]{
 +                    "s3_key",
 +                    "s3_access_id"
 +                });
 +        }
 +
 +        if (!StringUtils.isEmpty(bucketPrefix)) {
 +            deleteBucketsWithPrefix();
 +        }
 +
 +        bucketName = bucketPrefix + RandomStringUtils.randomAlphanumeric(10).toLowerCase();
 +    }
 +
 +
 +    /**
 +     * Verify that we can get call the import endpoint and get the job state back.
 +     *
 +     * @throws Exception
 +     */
 +    @Test
 +    public void importGetCollectionJobStatTest() throws Exception {
 +
 +        String org = clientSetup.getOrganizationName();
 +        String app = clientSetup.getAppName();
 +        Entity payload = payloadBuilder();
 +
 +        ///management/orgs/orgname/apps/appname/import
 +        Entity entity = this.management()
 +            .orgs()
 +            .organization(org)
 +            .app()
 +            .addToPath(app)
 +            .addToPath("imports")
 +            .post(payload);
 +
 +        assertNotNull(entity);
 +
 +        entity = this.management()
 +            .orgs()
 +            .organization(org)
 +            .app()
 +            .addToPath(app)
 +            .addToPath("imports")
 +            .addToPath(entity.getUuid().toString())
 +            .get();
 +
 +        assertNotNull(entity.getString("state"));
 +    }
 +
 +    /**
 +     * Verify that import job can only be read with an authorized token and cannot be read
 +     * with an invalid/notAllowed token.
 +     */
 +    @Test
 +    public void importTokenAuthorizationTest() throws Exception {
 +
 +        // this test should post one import job with one token,
 +        // then try to read back the job with another token
 +
 +        // create an import job
 +        String org = clientSetup.getOrganizationName();
 +        String app = clientSetup.getAppName();
 +        Entity payload = payloadBuilder();
 +
 +        // /management/orgs/orgname/apps/appname/import
 +        Entity entity = this.management()
 +            .orgs()
 +            .organization(org)
 +            .app()
 +            .addToPath(app)
 +            .addToPath("imports")
 +            .post(payload);
 +
 +
 +        assertNotNull(entity);
 +
 +        // test that you can access the organization using the currently set token.
 +        this.management().orgs().organization(org).app().addToPath(app)
 +            .addToPath("imports").addToPath(entity.getUuid().toString()).get();
 +
 +        //create a new org/app
 +        String newOrgName = "org" + UUIDUtils.newTimeUUID();
 +        String newOrgUsername = "orgusername" + UUIDUtils.newTimeUUID();
 +        String newOrgEmail = UUIDUtils.newTimeUUID() + "@usergrid.com";
 +        String newOrgPassword = "password1";
 +        Organization orgPayload = new Organization(
 +            newOrgName, newOrgUsername, newOrgEmail, newOrgName, newOrgPassword, null);
 +        Organization orgCreatedResponse = clientSetup.getRestClient().management().orgs().post(orgPayload);
 +        this.refreshIndex();
 +        assertNotNull(orgCreatedResponse);
 +
 +
 +        //log into the new org/app and get a token
 +        Token tokenPayload = new Token("password", newOrgUsername, newOrgPassword);
 +        Token newOrgToken = clientSetup.getRestClient().management().token().post(tokenPayload);
 +
 +        //save the old token and set the newly issued token as current
 +        context().setToken(newOrgToken);
 +
 +
 +        //try to read with the new token, which should fail as unauthorized
 +        try {
 +            this.management().orgs().organization(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) {
 +            errorParse(401, "unauthorized", ex);
 +        }
 +
 +    }
 +
 +
 +    @Test
 +    public void importPostApplicationNullPointerProperties() throws Exception {
 +        String org = clientSetup.getOrganizationName();
 +        String app = clientSetup.getAppName();
 +        ClientResponse.Status responseStatus = ClientResponse.Status.OK;
 +
 +        Entity payload = new Entity();
 +
 +        try {
 +            this.management().orgs().organization(org).app().addToPath(app).addToPath("imports").post(payload);
 +        } catch (UniformInterfaceException uie) {
 +            responseStatus = uie.getResponse().getClientResponseStatus();
 +        }
 +        assertEquals(ClientResponse.Status.BAD_REQUEST, responseStatus);
 +    }
 +
 +    @Test
 +    public void importPostApplicationNullPointerStorageInfo() throws Exception {
 +        String org = clientSetup.getOrganizationName();
 +        String app = clientSetup.getAppName();
 +        ClientResponse.Status responseStatus = ClientResponse.Status.OK;
 +
 +        Entity payload = payloadBuilder();
 +        Entity properties = (Entity) payload.get("properties");
 +        //remove storage_info field
 +        properties.remove("storage_info");
 +
 +        try {
 +            this.management().orgs().organization(org).app().addToPath(app).addToPath("imports").post(payload);
 +        } catch (UniformInterfaceException uie) {
 +            responseStatus = uie.getResponse().getClientResponseStatus();
 +        }
 +        assertEquals(ClientResponse.Status.BAD_REQUEST, responseStatus);
 +    }
 +
 +
 +    @Test
 +    public void importPostApplicationNullPointerStorageProvider() throws Exception {
 +        String org = clientSetup.getOrganizationName();
 +        String app = clientSetup.getAppName();
 +        ClientResponse.Status responseStatus = ClientResponse.Status.OK;
 +
 +        Entity payload = payloadBuilder();
 +        Entity properties = (Entity) payload.get("properties");
 +        //remove storage_info field
 +        properties.remove("storage_provider");
 +
 +
 +        try {
 +            this.management().orgs().organization(org).app().addToPath(app).addToPath("imports").post(payload);
 +        } catch (UniformInterfaceException uie) {
 +            responseStatus = uie.getResponse().getClientResponseStatus();
 +        }
 +        assertEquals(ClientResponse.Status.BAD_REQUEST, responseStatus);
 +    }
 +
 +
 +    @Test
 +    public void importPostApplicationNullPointerStorageVerification() throws Exception {
 +        String org = clientSetup.getOrganizationName();
 +        String app = clientSetup.getAppName();
 +        ClientResponse.Status responseStatus = ClientResponse.Status.OK;
 +
 +        Entity payload = payloadBuilder();
 +
 +        Entity properties = (Entity) payload.get("properties");
 +        Entity storage_info = (Entity) properties.get("storage_info");
 +        //remove storage_key field
 +        storage_info.remove("s3_key");
 +
 +        try {
 +            this.management().orgs().organization(org).app().addToPath(app).addToPath("imports").post(payload);
 +        } catch (UniformInterfaceException uie) {
 +            responseStatus = uie.getResponse().getClientResponseStatus();
 +        }
 +        assertEquals(ClientResponse.Status.BAD_REQUEST, responseStatus);
 +
 +        payload = payloadBuilder();
 +        properties = (Entity) payload.get("properties");
 +        storage_info = (Entity) properties.get("storage_info");
 +        //remove storage_key field
 +        storage_info.remove("s3_access_id");
 +
 +        try {
 +            this.management().orgs().organization(org).app().addToPath(app).addToPath("imports").post(payload);
 +        } catch (UniformInterfaceException uie) {
 +            responseStatus = uie.getResponse().getClientResponseStatus();
 +        }
 +        assertEquals(ClientResponse.Status.BAD_REQUEST, responseStatus);
 +
 +        payload = payloadBuilder();
 +        properties = (Entity) payload.get("properties");
 +        storage_info = (Entity) properties.get("storage_info");
 +        //remove storage_key field
 +        storage_info.remove("bucket_location");
 +
 +        try {
 +            this.management().orgs().organization(org).app().addToPath(app).addToPath("imports").post(payload);
 +        } catch (UniformInterfaceException uie) {
 +            responseStatus = uie.getResponse().getClientResponseStatus();
 +        }
 +        assertEquals(ClientResponse.Status.BAD_REQUEST, responseStatus);
 +    }
 +
 +//    @Test
 +//    public void testExportImportCollection() throws Exception {
 +//        Assume.assumeTrue( configured );
 +//        // create a collection of "thing" entities in the first application, export to S3
 +//        try {
 +//
 +//            Map<UUID, org.apache.usergrid.persistence.Entity> thingsMap = new HashMap<>();
 +//            List<org.apache.usergrid.persistence.Entity> things = new ArrayList<>();
 +//            createTestEntities(emApp1, thingsMap, things, "thing");
 +//
 +//            deleteBucket();
 +//            exportCollection( emApp1, "things" );
 +//
 +//            // create new second application, import the data from S3
 +//
 +//            final UUID appId2 = setup.getMgmtSvc().createApplication(
 +//                organization.getUuid(), "second").getId();
 +//
 +//            final EntityManager emApp2 = setup.getEmf().getEntityManager(appId2);
 +//            importCollection( emApp2, "things" );
 +//
 +//
 +//            // make sure that it worked
 +//
 +//            logger.debug("\n\nCheck connections\n");
 +//
 +//            List<org.apache.usergrid.persistence.Entity> importedThings = emApp2.getCollection(
 +//                appId2, "things", null, Query.Level.ALL_PROPERTIES).getEntities();
 +//            assertTrue( !importedThings.isEmpty() );
 +//
 +//            // two things have connections
 +//
 +//            int conCount = 0;
 +//            for ( org.apache.usergrid.persistence.Entity e : importedThings ) {
 +//                Results r = emApp2.getConnectedEntities( e, "related", null, Query.Level.IDS);
 +//                List<ConnectionRef> connections = r.getConnections();
 +//                conCount += connections.size();
 +//            }
 +//            assertEquals( 2, conCount );
 +//
 +//            logger.debug("\n\nCheck dictionaries\n");
 +//
 +//            // first two items have things in dictionary
 +//
 +//            EntityRef entity0 = importedThings.get(0);
 +//            Map connected0 = emApp2.getDictionaryAsMap(entity0, "connected_types");
 +//            Map connecting0 = emApp2.getDictionaryAsMap(entity0, "connected_types");
 +//            Assert.assertEquals( 1, connected0.size() );
 +//            Assert.assertEquals( 1, connecting0.size() );
 +//
 +//            EntityRef entity1 = importedThings.get(1);
 +//            Map connected1 = emApp2.getDictionaryAsMap(entity1, "connected_types");
 +//            Map connecting1 = emApp2.getDictionaryAsMap(entity1, "connected_types");
 +//            Assert.assertEquals( 1, connected1.size() );
 +//            Assert.assertEquals( 1, connecting1.size() );
 +//
 +//            // the rest rest do not have connections
 +//
 +//            EntityRef entity2 = importedThings.get(2);
 +//            Map connected2 = emApp2.getDictionaryAsMap(entity2, "connected_types");
 +//            Map connecting2 = emApp2.getDictionaryAsMap(entity2, "connected_types");
 +//            Assert.assertEquals( 0, connected2.size() );
 +//            Assert.assertEquals( 0, connecting2.size() );
 +//
 +//            // if entities are deleted from app1, they still exist in app2
 +//
 +//            logger.debug("\n\nCheck dictionary\n");
 +//            for ( org.apache.usergrid.persistence.Entity importedThing : importedThings ) {
 +//                emApp1.delete( importedThing );
 +//            }
 +//            emApp1.refreshIndex();
 +//            emApp2.refreshIndex();
 +//
 +//            importedThings = emApp2.getCollection(
 +//                appId2, "things", null, Query.Level.ALL_PROPERTIES).getEntities();
 +//            assertTrue( !importedThings.isEmpty() );
 +//
 +//        } finally {
 +//            deleteBucket();
 +//        }
 +//    }
 +
 +
 +    /**
 +     * TODO: Test that importing bad JSON will result in an informative error message.
 +     */
 +    @Test
 +    public void testImportGoodJson() throws Exception {
 +        // import from a bad JSON file
 +        Assume.assumeTrue(configured);
 +
 +        String org = clientSetup.getOrganizationName();
 +        String app = clientSetup.getAppName();
 +
 +
 +        //list out all the files in the resource directory you want uploaded
 +        List<String> filenames = new ArrayList<>(1);
 +
 +        filenames.add("testImportCorrect.testCol.1.json");
 +        // create 10 applications each with collection of 10 things, export all to S3
 +        S3Upload s3Upload = new S3Upload();
 +        s3Upload.copyToS3(
 +            System.getProperty( SDKGlobalConfiguration.ACCESS_KEY_ENV_VAR ),
 +            System.getProperty( SDKGlobalConfiguration.SECRET_KEY_ENV_VAR ),
 +            bucketName, filenames);
 +
 +        // import all those exports from S3 into the default test application
 +
 +        Entity importEntity = importCollection();
 +
 +        Entity importGet = this.management().orgs().organization( org ).app().addToPath( app )
 +            .addToPath( "imports" ).addToPath( importEntity.getUuid().toString() ).get();
 +
 +
 +        refreshIndex();
 +
 +        Entity importGetIncludes = this.management().orgs().organization(org).app().addToPath(app)
 +                                       .addToPath("imports" ).addToPath(importEntity.getUuid().toString() )
 +                                       .addToPath("files" ).get();
 +
 +        ApiResponse importGetIncludesResponse = importGetIncludes.getResponse();
 +
 +        assertNotNull(importGet);
 +        assertNotNull( importGetIncludes );
 +        assertEquals( 1,importGetIncludesResponse.getEntityCount());
 +
 +
 +        final Entity includesEntity = importGetIncludesResponse.getEntities().get( 0 );
 +
 +        assertEquals( "testImportCorrect.testCol.1.json", includesEntity.getString( "fileName" ) );
 +        assertEquals(1, includesEntity.get( "importedConnectionCount" ));
 +        assertEquals(1, includesEntity.get( "importedEntityCount" ));
 +
 +        assertEquals("FINISHED", importGet.get("state"));
 +        assertEquals(1, importGet.get("fileCount"));
 +
 +        Collection collection = this.app().collection("things").get();
 +
 +        assertNotNull(collection);
 +        assertEquals(1, collection.getNumOfEntities());
 +        assertEquals("thing0", collection.getResponse().getEntities().get(0).get("name"));
 +
 +
 +        //TODO: make sure it checks the actual imported entities. And the progress they have made.
 +
 +    }
 +
 +    /**
 +     * TODO: Test that importing bad JSON will result in an informative error message.
 +     */
 +    @Test
 +    public void testImportOneGoodOneBad() throws Exception {
 +        // import from a bad JSON file
 +        Assume.assumeTrue(configured);
 +
 +        String org = clientSetup.getOrganizationName();
 +        String app = clientSetup.getAppName();
 +
 +
 +        //list out all the files in the resource directory you want uploaded
 +        List<String> filenames = new ArrayList<>(1);
 +
 +        filenames.add("testImportCorrect.testCol.1.json");
 +        filenames.add("testImport.testApplication.2.json");
 +        // create 10 applications each with collection of 10 things, export all to S3
 +        S3Upload s3Upload = new S3Upload();
 +        s3Upload.copyToS3(
 +            System.getProperty( SDKGlobalConfiguration.ACCESS_KEY_ENV_VAR ),
 +            System.getProperty( SDKGlobalConfiguration.SECRET_KEY_ENV_VAR ),
 +            bucketName, filenames);
 +
 +        // import all those exports from S3 into the default test application
 +
 +        Entity importEntity = importCollection();
 +
 +        Entity importGet = this.management().orgs().organization(org).app().addToPath(app)
 +            .addToPath( "imports" ).addToPath(importEntity.getUuid().toString() ).get();
 +
 +
 +        assertNotNull(importGet);
 +
 +        assertEquals("FAILED", importGet.get("state"));
 +        assertEquals(2, importGet.get("fileCount"));
 +
 +        Collection collection = this.app().collection("things").get();
 +
 +        assertNotNull(collection);
 +        assertEquals(1, collection.getNumOfEntities());
 +        assertEquals("thing0", collection.getResponse().getEntities().get(0).get("name"));
 +
 +
 +    }
 +
 +    /**
 +     * TODO: Test that importing bad JSON will result in an informative error message.
 +     */
 +    @Test
 +    public void testImportOneBadFile() throws Exception {
 +        // import from a bad JSON file
 +        Assume.assumeTrue(configured);
 +
 +        String org = clientSetup.getOrganizationName();
 +        String app = clientSetup.getAppName();
 +
 +
 +        //list out all the files in the resource directory you want uploaded
 +        List<String> filenames = new ArrayList<>(1);
 +
 +        filenames.add("testImport.testApplication.2.json");
 +        // create 10 applications each with collection of 10 things, export all to S3
 +        S3Upload s3Upload = new S3Upload();
 +        s3Upload.copyToS3(
 +            System.getProperty( SDKGlobalConfiguration.ACCESS_KEY_ENV_VAR ),
 +            System.getProperty( SDKGlobalConfiguration.SECRET_KEY_ENV_VAR ),
 +            bucketName, filenames);
 +
 +        // import all those exports from S3 into the default test application
 +
 +        Entity importEntity = importCollection();
 +
 +        Entity importGet = this.management().orgs().organization(org).app().addToPath(app)
 +            .addToPath("imports" ).addToPath(importEntity.getUuid().toString() ).get();
 +
 +
 +        assertNotNull(importGet);
 +
 +        assertEquals("FAILED", importGet.get("state"));
 +        assertEquals(1, importGet.get("fileCount"));
 +
 +
 +        Collection collection = this.app().collection("things").get();
 +
 +        assertNotNull(collection);
 +        assertEquals(0, collection.getNumOfEntities());
 +
 +
 +    }
 +//export with two files and import the two files.
 +    //also test the includes endpoint.
 +
 +    /**
 +     * TODO: Test that importing bad JSON will result in an informative error message.
 +     */
 +    @Test
 +    public void testImportBadJson() throws Exception {
 +        // import from a bad JSON file
 +        Assume.assumeTrue(configured);
 +
 +        String org = clientSetup.getOrganizationName();
 +        String app = clientSetup.getAppName();
 +
 +        //list out all the files in the resource directory you want uploaded
 +        List<String> filenames = new ArrayList<>(1);
 +        filenames.add("testImportInvalidJson.testApplication.3.json");
 +        // create 10 applications each with collection of 10 things, export all to S3
 +        S3Upload s3Upload = new S3Upload();
 +        s3Upload.copyToS3(System.getProperty( SDKGlobalConfiguration.ACCESS_KEY_ENV_VAR ),
 +            System.getProperty( SDKGlobalConfiguration.SECRET_KEY_ENV_VAR ),
 +            bucketName, filenames);
 +
 +        // import all those exports from S3 into the default test application
 +
 +        Entity importEntity = importCollection();
 +
 +        // we should now have 100 Entities in the default app
 +
 +        Entity importGet = this.management().orgs().organization( org ).app().addToPath( app ).addToPath("imports")
 +            .addToPath( importEntity.getUuid().toString() ).get();
 +
 +        Entity importGetIncludes = this.management().orgs().organization(org).app().addToPath(app)
 +            .addToPath("imports" ).addToPath(importEntity.getUuid().toString() )
 +            .addToPath("files" ).get();
 +
 +        assertNotNull(importGet);
 +        //TODO: needs better error checking
 +        assertNotNull(importGetIncludes);
 +
 +        // check that error message indicates JSON parsing error
 +    }
 +
 +    /**
 +     * Call importService to import files from the configured S3 bucket.
 +     */
 +    private Entity importCollection() throws Exception {
 +
 +        String org = clientSetup.getOrganizationName();
 +        String app = clientSetup.getAppName();
 +
 +        logger.debug("\n\nImport into new app {}\n", app);
 +
 +        Entity importPayload = new Entity(new HashMap<String, Object>() {{
 +            put("properties", new HashMap<String, Object>() {{
 +                put("storage_provider", "s3");
 +                put("storage_info", new HashMap<String, Object>() {{
 +                    put("s3_key",
 +                        System.getProperty( SDKGlobalConfiguration.SECRET_KEY_ENV_VAR ));
 +                    put("s3_access_id",
 +                        System.getProperty( SDKGlobalConfiguration.ACCESS_KEY_ENV_VAR ));
 +                    put("bucket_location", bucketName);
 +                }});
 +            }});
 +        }});
 +
 +        Entity importEntity = this.management().orgs().organization(org).app().addToPath(app).addToPath("imports")
 +                                  .post(importPayload);
 +
 +        int maxRetries = 120;
 +        int retries = 0;
 +
 +        while (retries++ < maxRetries) {
 +
 +            Entity importGet = this.management()
 +                .orgs()
 +                .organization(org)
 +                .app()
 +                .addToPath(app)
 +                .addToPath("imports")
 +                .addToPath(importEntity.getUuid().toString())
 +                .get();
 +
 +            if (importGet.get("state").equals("FINISHED") || importGet.get( "state" ).equals( "FAILED" )) {
 +                break;
 +            }
 +
 +            logger.debug("Waiting for import...");
 +            Thread.sleep(1000);
 +        }
 +
 +        refreshIndex();
 +
 +        return importEntity;
 +    }
 +
 +    /**
 +     * Create test entities of a specified type.
 +     * First two entities are connected.
 +     */
 +    private void createTestEntities() throws Exception {
 +
 +        logger.debug("\n\nCreating users in application {}\n",
 +            clientSetup.getAppName());
 +
 +        List<org.apache.usergrid.persistence.Entity> created = new ArrayList<>();
 +        for (int i = 0; i < 10; i++) {
 +            String name = "test" + i;
 +            Entity payload = new Entity();
 +            payload.put("name", name);
 +            payload.put("username", name);
 +            payload.put("email", name + "@test.com");
 +            this.app().collection("users").post(payload);
 +
 +
 +        }
 +
 +        this.refreshIndex();
 +
 +//        // first two things are related to each other
 +//        em.createConnection(new SimpleEntityRef(type, created.get(0).getUuid()),
 +//            "related", new SimpleEntityRef(type, created.get(1).getUuid()));
 +//        em.createConnection(new SimpleEntityRef(type, created.get(1).getUuid()),
 +//            "related", new SimpleEntityRef(type, created.get(0).getUuid()));
 +//
 +//        em.refreshIndex();
 +    }
 +
 +    /**
 +     * Delete the configured s3 bucket.
 +     */
 +    public void deleteBucket() {
 +
 +        logger.debug("\n\nDelete bucket\n");
 +
 +        String accessId = System.getProperty( SDKGlobalConfiguration.ACCESS_KEY_ENV_VAR );
 +        String secretKey = System.getProperty( SDKGlobalConfiguration.SECRET_KEY_ENV_VAR );
 +
 +        Properties overrides = new Properties();
 +        overrides.setProperty("s3" + ".identity", accessId);
 +        overrides.setProperty("s3" + ".credential", secretKey);
 +
 +        final Iterable<? extends Module> MODULES = ImmutableSet.of(new JavaUrlHttpCommandExecutorServiceModule(),
 +            new Log4JLoggingModule(), new NettyPayloadModule());
 +
 +        BlobStoreContext context =
 +            ContextBuilder.newBuilder("s3").credentials(accessId, secretKey).modules(MODULES)
 +                .overrides(overrides ).buildView(BlobStoreContext.class);
 +
 +        BlobStore blobStore = context.getBlobStore();
 +        blobStore.deleteContainer(bucketName);
 +    }
 +
 +    // might be handy if you need to clean up buckets
 +    private static void deleteBucketsWithPrefix() {
 +
 +        logger.debug("\n\nDelete buckets with prefix {}\n", bucketPrefix);
 +
 +        String accessId = System.getProperty( SDKGlobalConfiguration.ACCESS_KEY_ENV_VAR );
 +        String secretKey = System.getProperty( SDKGlobalConfiguration.SECRET_KEY_ENV_VAR );
 +
 +        Properties overrides = new Properties();
 +        overrides.setProperty("s3" + ".identity", accessId);
 +        overrides.setProperty("s3" + ".credential", secretKey);
 +
 +        final Iterable<? extends Module> MODULES = ImmutableSet
 +            .of(new JavaUrlHttpCommandExecutorServiceModule(),
 +                new Log4JLoggingModule(),
 +                new NettyPayloadModule());
 +
 +        BlobStoreContext context =
 +            ContextBuilder.newBuilder("s3").credentials(accessId, secretKey).modules(MODULES)
 +                .overrides(overrides ).buildView(BlobStoreContext.class);
 +
 +        BlobStore blobStore = context.getBlobStore();
 +        final PageSet<? extends StorageMetadata> blobStoreList = blobStore.list();
 +
 +        for (Object o : blobStoreList.toArray()) {
 +            StorageMetadata s = (StorageMetadata) o;
 +
 +            if (s.getName().startsWith(bucketPrefix)) {
 +                try {
 +                    blobStore.deleteContainer(s.getName());
 +                } catch (ContainerNotFoundException cnfe) {
 +                    logger.warn("Attempted to delete bucket {} but it is already deleted", cnfe);
 +                }
 +                logger.debug("Deleted bucket {}", s.getName());
 +            }
 +        }
 +    }
 +
 +
 +    /*Creates fake payload for testing purposes.*/
 +    public Entity payloadBuilder() {
 +        Entity payload = new Entity();
 +        Entity properties = new Entity();
 +        Entity storage_info = new Entity();
 +        //TODO: always put dummy values here and ignore this test.
 +        //TODO: add a ret for when s3 values are invalid.
 +        storage_info.put("s3_key", "insert key here");
 +        storage_info.put("s3_access_id", "insert access id here");
 +        storage_info.put("bucket_location", "insert bucket name here");
 +        properties.put("storage_provider", "s3");
 +        properties.put("storage_info", storage_info);
 +        payload.put("properties", properties);
 +        return payload;
 +    }
 +}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/bedf5afb/stack/rest/src/test/java/org/apache/usergrid/rest/management/organizations/AdminEmailEncodingIT.java
----------------------------------------------------------------------
diff --cc stack/rest/src/test/java/org/apache/usergrid/rest/management/organizations/AdminEmailEncodingIT.java
index e9ebe60,648abd1..4a24c56
--- 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,18 -17,24 +17,21 @@@
  package org.apache.usergrid.rest.management.organizations;
  
  
- import com.fasterxml.jackson.databind.JsonNode;
- import java.io.IOException;
- import org.junit.Rule;
+ import com.sun.jersey.api.client.UniformInterfaceException;
 -import org.apache.usergrid.cassandra.Concurrent;
+ import org.apache.usergrid.rest.test.resource2point0.AbstractRestIT;
+ import org.apache.usergrid.rest.test.resource2point0.model.Application;
+ import org.apache.usergrid.rest.test.resource2point0.model.Entity;
+ import org.apache.usergrid.rest.test.resource2point0.model.Organization;
+ import org.apache.usergrid.rest.test.resource2point0.model.Token;
+ import org.junit.Ignore;
  import org.junit.Test;
+ import org.slf4j.Logger;
+ import org.slf4j.LoggerFactory;
  
- import org.apache.usergrid.rest.AbstractRestIT;
- import org.apache.usergrid.rest.TestContextSetup;
- import org.apache.usergrid.rest.test.security.TestAdminUser;
 -import java.io.IOException;
+ import java.util.UUID;
  
++import static junit.framework.TestCase.assertNotNull;
  import static org.junit.Assert.assertEquals;
--import static org.junit.Assert.assertNotNull;
--
  
  /**
   * Tests for admin emails with + signs create accounts correctly, and can get tokens in both the POST and GET forms of
@@@ -36,84 -42,96 +39,94 @@@
   *
   * @author tnine
   */
 -@Concurrent()
 +
  public class AdminEmailEncodingIT extends AbstractRestIT {
+     private static Logger log = LoggerFactory.getLogger(AdminEmailEncodingIT.class);
  
-     @Rule
-     public TestContextSetup context = new TestContextSetup( this );
- 
- 
+     /**
+      * Ensure that '+' characters in email addresses are handled properly
+      *
+      * @throws Exception
+      */
      @Test
      public void getTokenPlus() throws Exception {
-         String org = "AdminEmailEncodingTestgetTokenPlus";
-         String app = "Plus";
- 
-         doTest( "+", org, app );
+         doTest("+");
      }
  
- 
+     /**
+      * Ensure that '_' characters in email addresses are handled properly
+      *
+      * @throws Exception
+      */
      @Test
      public void getTokenUnderscore() throws Exception {
-         String org = "AdminEmailEncodingTestgetTokenUnderscore";
-         String app = "Underscore";
- 
-         doTest( "_", org, app );
+         doTest("_");
      }
  
- 
+     /**
+      * Ensure that '-' characters in email addresses are handled properly
+      *
+      * @throws Exception
+      */
      @Test
      public void getTokenDash() throws Exception {
-         String org = "AdminEmailEncodingTestgetTokenDash";
-         String app = "Dash";
- 
-         doTest( "-", org, app );
+         doTest("-");
      }
  
+     /**
+      * Ensure that "'" characters in email addresses are handled properly
+      *
+      * @throws Exception
+      */
+     @Test
+     @Ignore //This fails. I'm not sure if it is by design, but a single quote is valid in an email address
+     public void getTokenQuote() throws Exception {
+         doTest("'");
+     }
  
-     private void doTest( String symbol, String org, String app ) throws IOException {
- 
-         org = org.toLowerCase();
-         app = app.toLowerCase();
- 
-         String email = String.format( "admin%sname@adminemailencodingtest.org", symbol );
-         String user = email;
-         String password = "password";
- 
-         TestAdminUser adminUser = new TestAdminUser( user, password, email );
- 
-         context.withApp( app ).withOrg( org ).withUser( adminUser );
- 
-         // create the org and app
-         context.createNewOrgAndUser();
- 
-         // no need for refresh here as Service module does an index refresh when org/app created
- 
-         // now log in via a GET
- 
-         String getToken = context.management().tokenGet( email, password );
- 
-         assertNotNull( getToken );
- 
-         String postToken = context.management().tokenPost( email, password );
- 
-         assertNotNull( postToken );
- 
-         // not log in with our admin
-         context.withUser( adminUser ).loginUser();
- 
-         //now get the "me" and ensure it's correct
- 
-         JsonNode data = context.management().me().get();
- 
-         assertNotNull( data.get( "access_token" ).asText() );
- 
-         data = context.management().users().user( email ).get();
- 
-         JsonNode admin = data.get( "data" ).get( "organizations" ).get( org ).get( "users" ).get( email );
- 
-         assertNotNull( admin );
+     /**
+      * Given an organization name and an arbitrary character or string,
+      * ensure that an organization and admin user can be created when
+      * the given string is a part of the admin email address
 -     *
+      * @param symbol
 -     * @throws IOException
+      */
+     private void doTest(String symbol) throws UniformInterfaceException {
+ 
+         String unique = UUID.randomUUID().toString();
+         String org = "org_getTokenDash" + unique;
+         String app = "app_getTokenDash" + unique;
+ 
+         //Username and password
+         String username = "testuser" + unique;
+         String password = "password" + unique;
+         //create an email address containing 'symbol'
+         String email = String.format("test%suser%s@usergrid.com", symbol, unique);
+ 
+         //create the organization entity
+         Organization orgPayload = new Organization(org, username, email, username, password, null);
+ 
+         //post the organization entity
+         Organization organization = clientSetup.getRestClient().management().orgs().post(orgPayload);
+         assertNotNull(organization);
+ 
+         //Retrieve an authorization token using the credentials created above
+         Token tokenReturned = clientSetup.getRestClient().management().token().post(new Token("password", username, password));
+         assertNotNull(tokenReturned);
+ 
+         //Instruct the test framework to use the new token
+         this.app().token().setToken(tokenReturned);
+         //Create an application within the organization
+         clientSetup.getRestClient().management().orgs().organization(organization.getName()).app().post(new Application(app));
+ 
+         //retrieve the new management user by username and ensure the username and email address matches the input
+         Entity me = clientSetup.getRestClient().management().users().entity(username).get();
+         assertEquals(email, me.get("email"));
+         assertEquals(username, me.get("username"));
+ 
+         //retrieve the new management user by email and ensure the username and email address matches the input
+         me = clientSetup.getRestClient().management().users().entity(email).get();
+         assertEquals(email, me.get("email"));
+         assertEquals(username, me.get("username"));
  
-         assertEquals( email, admin.get( "email" ).asText() );
-         assertEquals( user, admin.get( "username" ).asText() );
      }
  }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/bedf5afb/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/AbstractRestIT.java
----------------------------------------------------------------------
diff --cc stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/AbstractRestIT.java
index 90d3d55,601e751..4e3b480
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/AbstractRestIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/AbstractRestIT.java
@@@ -27,19 -42,6 +27,18 @@@ import com.sun.jersey.test.framework.Ap
  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.ITSetup;
 +import org.apache.usergrid.rest.TomcatRuntime;
 +import org.apache.usergrid.rest.test.resource2point0.endpoints.ApplicationsResource;
 +import org.apache.usergrid.rest.test.resource2point0.endpoints.OrganizationResource;
 +import org.apache.usergrid.rest.test.resource2point0.endpoints.mgmt.ManagementResource;
 +import org.apache.usergrid.rest.test.resource2point0.model.Token;
 +import org.apache.usergrid.rest.test.resource2point0.state.ClientContext;
 +import org.junit.Rule;
 +
 +import java.net.URI;
 +import java.net.URISyntaxException;
 +import java.net.URLClassLoader;
 +import java.util.Arrays;
  
  import static org.junit.Assert.assertEquals;
  

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/bedf5afb/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/mgmt/ApplicationResource.java
----------------------------------------------------------------------
diff --cc stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/mgmt/ApplicationResource.java
index 5975d4e,95fd02b..6b7742f
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/mgmt/ApplicationResource.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/mgmt/ApplicationResource.java
@@@ -20,15 -20,13 +20,15 @@@
  
  package org.apache.usergrid.rest.test.resource2point0.endpoints.mgmt;
  
- 
 +import javax.ws.rs.core.MediaType;
 +
  import org.apache.usergrid.rest.test.resource2point0.endpoints.NamedResource;
  import org.apache.usergrid.rest.test.resource2point0.endpoints.UrlResource;
  import org.apache.usergrid.rest.test.resource2point0.model.Application;
 +import org.apache.usergrid.rest.test.resource2point0.model.*;
  import org.apache.usergrid.rest.test.resource2point0.state.ClientContext;
  
 -import javax.ws.rs.core.MediaType;
+ 
  /**
   * Classy class class.
   */
@@@ -37,31 -35,9 +37,31 @@@ public class ApplicationResource extend
          super("applications", context, parent);
      }
  
 +    public ApplicationResource( final String name, final ClientContext context, final UrlResource parent ) {
 +        super( name, context, parent );
 +    }
 +
 +    public ApplicationResource addToPath( String pathPart ) {
 +        return new ApplicationResource( pathPart, context, this );
 +    }
 +
 +
      public void post(Application application) {
          getResource(true).type(MediaType.APPLICATION_JSON_TYPE)
-                 .accept(MediaType.APPLICATION_JSON).post(application);
+             .accept(MediaType.APPLICATION_JSON).post(application);
      }
  
 +    public Entity post(Entity payload){
 +        ApiResponse response = getResource(true).type( MediaType.APPLICATION_JSON_TYPE ).accept(MediaType.APPLICATION_JSON)
 +            .post(ApiResponse.class, payload);
 +        return new Entity(response);
 +    }
 +
 +
 +    public Entity get() {
 +        ApiResponse response = getResource(true).type(MediaType.APPLICATION_JSON_TYPE ).accept(MediaType.APPLICATION_JSON)
 +            .get(ApiResponse.class);
 +
 +        return new Entity(response);
 +    }
  }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/bedf5afb/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/mgmt/OrganizationResource.java
----------------------------------------------------------------------
diff --cc stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/mgmt/OrganizationResource.java
index 819f8be,24a7883..9281ad2
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/mgmt/OrganizationResource.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/mgmt/OrganizationResource.java
@@@ -75,16 -73,13 +73,20 @@@ public class OrganizationResource exten
  
      }
  
 -    public ApplicationResource app() {
 -        return new ApplicationResource(context, this);
 +    public ApplicationResource app(){
 +        return new ApplicationResource(  context ,this );
      }
  
+     public CredentialsResource credentials() {
+         return new CredentialsResource(context, this);
+     }
+ 
 +    public ApplicationResource apps(String appName){
 +        return new ApplicationResource(  appName, context ,this );
 +    }
 +
 +    public ApplicationResource addToPath( String pathPart ) {
 +        return new ApplicationResource( pathPart, context, this );
 +    }
  
  }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/bedf5afb/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/model/Entity.java
----------------------------------------------------------------------


[16/50] [abbrv] incubator-usergrid git commit: Fixed CoreSchemaManager

Posted by sn...@apache.org.
Fixed CoreSchemaManager


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

Branch: refs/heads/two-dot-o
Commit: aac4a2fc946f957261e7c4cf46838abb4bca4148
Parents: f817f52
Author: grey <gr...@apigee.com>
Authored: Mon Feb 23 12:05:56 2015 -0800
Committer: grey <gr...@apigee.com>
Committed: Mon Feb 23 12:05:56 2015 -0800

----------------------------------------------------------------------
 .../java/org/apache/usergrid/persistence/CoreSchemaManager.java  | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/aac4a2fc/stack/core/src/test/java/org/apache/usergrid/persistence/CoreSchemaManager.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/CoreSchemaManager.java b/stack/core/src/test/java/org/apache/usergrid/persistence/CoreSchemaManager.java
index 5b9adb8..723e971 100644
--- a/stack/core/src/test/java/org/apache/usergrid/persistence/CoreSchemaManager.java
+++ b/stack/core/src/test/java/org/apache/usergrid/persistence/CoreSchemaManager.java
@@ -85,7 +85,7 @@ public class CoreSchemaManager implements SchemaManager {
     public void destroy() {
         LOG.info( "dropping keyspaces" );
         try {
-            cluster.dropKeyspace( CassandraService.SYSTEM_KEYSPACE );
+            cluster.dropKeyspace( CassandraService.getApplicationKeyspace() );
         }
         catch ( RuntimeException ire ) {
             //swallow if it just doesn't exist
@@ -93,7 +93,7 @@ public class CoreSchemaManager implements SchemaManager {
 
 
         try {
-            cluster.dropKeyspace( CassandraService.STATIC_APPLICATION_KEYSPACE );
+            cluster.dropKeyspace( CassandraService.getApplicationKeyspace() );
         }
         catch ( RuntimeException ire ) {
             //swallow if it just doesn't exist


[30/50] [abbrv] incubator-usergrid git commit: Removed extraneous CF. Made the remaining code compile.

Posted by sn...@apache.org.
Removed extraneous CF. Made the remaining code compile.


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

Branch: refs/heads/two-dot-o
Commit: ded674359eccf08509aa4933892018041a1eeda0
Parents: 53e73fb
Author: grey <gr...@apigee.com>
Authored: Tue Feb 24 18:16:18 2015 -0800
Committer: grey <gr...@apigee.com>
Committed: Tue Feb 24 18:16:18 2015 -0800

----------------------------------------------------------------------
 .../usergrid/corepersistence/CpSetup.java       |  45 +++---
 .../persistence/cassandra/CassandraService.java |  31 ++--
 .../cassandra/EntityManagerFactoryImpl.java     | 147 +++----------------
 .../persistence/cassandra/SetupImpl.java        |  32 +---
 .../cassandra/EntityManagerFactoryImplIT.java   |   5 -
 5 files changed, 61 insertions(+), 199 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/ded67435/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpSetup.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpSetup.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpSetup.java
index c71c172..53123bc 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpSetup.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpSetup.java
@@ -39,14 +39,14 @@ import me.prettyprint.hector.api.ddl.ComparatorType;
 
 import static me.prettyprint.hector.api.factory.HFactory.createColumnFamilyDefinition;
 import static org.apache.usergrid.persistence.cassandra.CassandraPersistenceUtils.getCfDefs;
-import static org.apache.usergrid.persistence.cassandra.CassandraService.APPLICATIONS_CF;
+//import static org.apache.usergrid.persistence.cassandra.CassandraService.APPLICATIONS_CF;
 import static org.apache.usergrid.persistence.cassandra.CassandraService.DEFAULT_APPLICATION;
 import static org.apache.usergrid.persistence.cassandra.CassandraService.DEFAULT_ORGANIZATION;
 import static org.apache.usergrid.persistence.cassandra.CassandraService.MANAGEMENT_APPLICATION;
 import static org.apache.usergrid.persistence.cassandra.CassandraService.PRINCIPAL_TOKEN_CF;
-import static org.apache.usergrid.persistence.cassandra.CassandraService.PROPERTIES_CF;
+//import static org.apache.usergrid.persistence.cassandra.CassandraService.PROPERTIES_CF;
 import static org.apache.usergrid.persistence.cassandra.CassandraService.TOKENS_CF;
-import static org.apache.usergrid.persistence.cassandra.CassandraService.USE_VIRTUAL_KEYSPACES;
+//import static org.apache.usergrid.persistence.cassandra.CassandraService.USE_VIRTUAL_KEYSPACES;
 import static org.apache.usergrid.persistence.cassandra.CassandraService.getApplicationKeyspace;
 import static org.apache.usergrid.persistence.cassandra.CassandraService.keyspaceForApplication;
 
@@ -145,11 +145,11 @@ public class CpSetup implements Setup {
 
         migrate();
 
-        cass.createColumnFamily( getApplicationKeyspace(),
-            createColumnFamilyDefinition( getApplicationKeyspace(), APPLICATIONS_CF, ComparatorType.BYTESTYPE ) );
-
-        cass.createColumnFamily( getApplicationKeyspace(),
-            createColumnFamilyDefinition( getApplicationKeyspace(), PROPERTIES_CF, ComparatorType.BYTESTYPE ) );
+//        cass.createColumnFamily( getApplicationKeyspace(),
+//            createColumnFamilyDefinition( getApplicationKeyspace(), APPLICATIONS_CF, ComparatorType.BYTESTYPE ) );
+//
+//        cass.createColumnFamily( getApplicationKeyspace(),
+//            createColumnFamilyDefinition( getApplicationKeyspace(), PROPERTIES_CF, ComparatorType.BYTESTYPE ) );
 
         cass.createColumnFamily( getApplicationKeyspace(),
             createColumnFamilyDefinition( getApplicationKeyspace(), TOKENS_CF, ComparatorType.BYTESTYPE ) );
@@ -176,19 +176,18 @@ public class CpSetup implements Setup {
 
         // Need this legacy stuff for queues
 
-        if ( !USE_VIRTUAL_KEYSPACES ) {
-
-            String app_keyspace = keyspaceForApplication( applicationId );
 
-            logger.info( "Creating application keyspace " + app_keyspace + " for " + applicationName + " application" );
+//            String app_keyspace = keyspaceForApplication( applicationId );
 
-            cass.createColumnFamily( app_keyspace,
-                createColumnFamilyDefinition( getApplicationKeyspace(), APPLICATIONS_CF, ComparatorType.BYTESTYPE ) );
+//            logger.info( "Creating application keyspace " + app_keyspace + " for " + applicationName + " application" );
+//
+//            cass.createColumnFamily( app_keyspace,
+//                createColumnFamilyDefinition( getApplicationKeyspace(), APPLICATIONS_CF, ComparatorType.BYTESTYPE ) );
+//
+//            cass.createColumnFamilies( app_keyspace, getCfDefs( ApplicationCF.class, app_keyspace ) );
+//
+//            cass.createColumnFamilies( app_keyspace, getCfDefs( QueuesCF.class, app_keyspace ) );
 
-            cass.createColumnFamilies( app_keyspace, getCfDefs( ApplicationCF.class, app_keyspace ) );
-
-            cass.createColumnFamilies( app_keyspace, getCfDefs( QueuesCF.class, app_keyspace ) );
-        }
     }
 
 
@@ -199,20 +198,20 @@ public class CpSetup implements Setup {
 
         // Need this legacy stuff for queues
 
-        if ( USE_VIRTUAL_KEYSPACES ) {
+      //  if ( USE_VIRTUAL_KEYSPACES ) {
 
             logger.info( "Creating static application keyspace " + getApplicationKeyspace() );
 
-            cass.createColumnFamily( getApplicationKeyspace(),
-                createColumnFamilyDefinition( getApplicationKeyspace(), APPLICATIONS_CF,
-                    ComparatorType.BYTESTYPE ) );
+//            cass.createColumnFamily( getApplicationKeyspace(),
+//                createColumnFamilyDefinition( getApplicationKeyspace(), APPLICATIONS_CF,
+//                    ComparatorType.BYTESTYPE ) );
 
             cass.createColumnFamilies( getApplicationKeyspace(),
                 getCfDefs( ApplicationCF.class, getApplicationKeyspace() ) );
 
             cass.createColumnFamilies( getApplicationKeyspace(),
                 getCfDefs( QueuesCF.class, getApplicationKeyspace() ) );
-        }
+       // }
     }
 
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/ded67435/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/CassandraService.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/CassandraService.java b/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/CassandraService.java
index 2c74e77..32174ff 100644
--- a/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/CassandraService.java
+++ b/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/CassandraService.java
@@ -97,10 +97,10 @@ public class CassandraService {
    // public static String SYSTEM_KEYSPACE = "Usergrid";
 
     public static String applicationKeyspace;
-    public static final boolean USE_VIRTUAL_KEYSPACES = true;
+    //public static final boolean USE_VIRTUAL_KEYSPACES = true;
 
-    public static final String APPLICATIONS_CF = "Applications";
-    public static final String PROPERTIES_CF = "Properties";
+    //public static final String APPLICATIONS_CF = "Applications";
+    //public static final String PROPERTIES_CF = "Properties";
     public static final String TOKENS_CF = "Tokens";
     public static final String PRINCIPAL_TOKEN_CF = "PrincipalTokens";
 
@@ -238,35 +238,26 @@ public class CassandraService {
 
     /** @return keyspace for application UUID */
     public static String keyspaceForApplication( UUID applicationId ) {
-        if ( USE_VIRTUAL_KEYSPACES ) {
-            return getApplicationKeyspace();
-        }
-        else {
-            return "Application_" + applicationId.toString().replace( '-', '_' );
-        }
+        return getApplicationKeyspace();
+
     }
 
 
     public static UUID prefixForApplication( UUID applicationId ) {
-        if ( USE_VIRTUAL_KEYSPACES ) {
             return applicationId;
-        }
-        else {
-            return null;
-        }
     }
 
 
     public Keyspace getKeyspace( String keyspace, UUID prefix ) {
         Keyspace ko = null;
-        if ( USE_VIRTUAL_KEYSPACES && ( prefix != null ) ) {
+//        if ( USE_VIRTUAL_KEYSPACES && ( prefix != null ) ) {
             ko = createVirtualKeyspace( keyspace, prefix, ue, cluster, consistencyLevelPolicy,
                     ON_FAIL_TRY_ALL_AVAILABLE, accessMap );
-        }
-        else {
-            ko = HFactory.createKeyspace( keyspace, cluster, consistencyLevelPolicy, ON_FAIL_TRY_ALL_AVAILABLE,
-                    accessMap );
-        }
+//        }
+//        else {
+//            ko = HFactory.createKeyspace( keyspace, cluster, consistencyLevelPolicy, ON_FAIL_TRY_ALL_AVAILABLE,
+//                    accessMap );
+//        }
         return ko;
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/ded67435/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/EntityManagerFactoryImpl.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/EntityManagerFactoryImpl.java b/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/EntityManagerFactoryImpl.java
index 9a90e59..f4a151f 100644
--- a/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/EntityManagerFactoryImpl.java
+++ b/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/EntityManagerFactoryImpl.java
@@ -62,8 +62,8 @@ import static org.apache.usergrid.persistence.Schema.TYPE_APPLICATION;
 import static org.apache.usergrid.persistence.cassandra.CassandraPersistenceUtils.addInsertToMutator;
 import static org.apache.usergrid.persistence.cassandra.CassandraPersistenceUtils.asMap;
 import static org.apache.usergrid.persistence.cassandra.CassandraPersistenceUtils.batchExecute;
-import static org.apache.usergrid.persistence.cassandra.CassandraService.APPLICATIONS_CF;
-import static org.apache.usergrid.persistence.cassandra.CassandraService.PROPERTIES_CF;
+//import static org.apache.usergrid.persistence.cassandra.CassandraService.APPLICATIONS_CF;
+//import static org.apache.usergrid.persistence.cassandra.CassandraService.PROPERTIES_CF;
 import static org.apache.usergrid.persistence.cassandra.CassandraService.RETRY_COUNT;
 import static org.apache.usergrid.utils.ConversionUtils.uuid;
 import static org.apache.usergrid.persistence.cassandra.Serializers.*;
@@ -189,22 +189,8 @@ public class EntityManagerFactoryImpl implements EntityManagerFactory, Applicati
     public UUID createApplication( String organizationName, String name, Map<String, Object> properties )
             throws Exception {
 
-        String appName = buildAppName( organizationName, name );
+        throw new UnsupportedOperationException( "We no longer support the 1.0 entity manager anymore" );
 
-        HColumn<String, ByteBuffer> column =
-                cass.getColumn( cass.getUsergridApplicationKeyspace(), APPLICATIONS_CF, appName, PROPERTY_UUID );
-        if ( column != null ) {
-            throw new ApplicationAlreadyExistsException( name );
-            // UUID uuid = uuid(column.getValue());
-            // return uuid;
-        }
-
-        UUID applicationId = UUIDUtils.newTimeUUID();
-        logger.info( "New application id " + applicationId.toString() );
-
-        initializeApplication( organizationName, applicationId, appName, properties );
-
-        return applicationId;
     }
 
 
@@ -220,69 +206,20 @@ public class EntityManagerFactoryImpl implements EntityManagerFactory, Applicati
     }
 
 
-    public UUID initializeApplication( String organizationName, UUID applicationId, String name,
-                                       Map<String, Object> properties ) throws Exception {
-
-        String appName = buildAppName( organizationName, name );
-        // check for pre-existing
-        if ( lookupApplication( appName ) != null ) {
-            throw new ApplicationAlreadyExistsException( appName );
-        }
-        if ( properties == null ) {
-            properties = new TreeMap<String, Object>( CASE_INSENSITIVE_ORDER );
-        }
-
-        properties.put( PROPERTY_NAME, appName );
-
-        getSetup().setupApplicationKeyspace( applicationId, appName );
-
-        Keyspace ko = cass.getUsergridApplicationKeyspace();
-        Mutator<ByteBuffer> m = CountingMutator.createFlushingMutator( ko, be );
-
-        long timestamp = cass.createTimestamp();
-
-        addInsertToMutator( m, APPLICATIONS_CF, appName, PROPERTY_UUID, applicationId, timestamp );
-        addInsertToMutator( m, APPLICATIONS_CF, appName, PROPERTY_NAME, appName, timestamp );
-
-        batchExecute( m, RETRY_COUNT );
-
-        EntityManager em = getEntityManager( applicationId );
-        em.create( TYPE_APPLICATION, APPLICATION_ENTITY_CLASS, properties );
-
-        em.resetRoles();
-
-        return applicationId;
-    }
-
-
     @Override
     public UUID importApplication( String organizationName, UUID applicationId, String name,
                                    Map<String, Object> properties ) throws Exception {
 
-        name = buildAppName( organizationName, name );
+        throw new UnsupportedOperationException( "We no longer support the 1.0 entity manager anymore" );
 
-        HColumn<String, ByteBuffer> column =
-                cass.getColumn( cass.getUsergridApplicationKeyspace(), APPLICATIONS_CF, name, PROPERTY_UUID );
-        if ( column != null ) {
-            throw new ApplicationAlreadyExistsException( name );
-            // UUID uuid = uuid(column.getValue());
-            // return uuid;
-        }
-
-        return initializeApplication( organizationName, applicationId, name, properties );
     }
 
 
     @Override
     @Metered(group = "core", name = "EntityManagerFactory_lookupApplication_byName")
     public UUID lookupApplication( String name ) throws Exception {
-        name = name.toLowerCase();
-        HColumn<String, ByteBuffer> column =
-                cass.getColumn( cass.getUsergridApplicationKeyspace(), APPLICATIONS_CF, name, PROPERTY_UUID );
-        if ( column != null ) {
-            return uuid( column.getValue() );
-        }
-        return null;
+        throw new UnsupportedOperationException( "We no longer support the 1.0 entity manager anymore" );
+
     }
 
 
@@ -297,86 +234,48 @@ public class EntityManagerFactoryImpl implements EntityManagerFactory, Applicati
      */
     @Metered(group = "core", name = "EntityManagerFactory_getApplication")
     public Application getApplication( String name ) throws Exception {
-        name = name.toLowerCase();
-        HColumn<String, ByteBuffer> column =
-                cass.getColumn( cass.getUsergridApplicationKeyspace(), APPLICATIONS_CF, name, PROPERTY_UUID );
-        if ( column == null ) {
-            return null;
-        }
+        throw new UnsupportedOperationException( "We no longer support the 1.0 entity manager anymore" );
 
-        UUID applicationId = uuid( column.getValue() );
-
-        EntityManager em = getEntityManager( applicationId );
-        return ( ( EntityManagerImpl ) em ).getEntity( applicationId, Application.class );
     }
 
 
     @Override
     public Map<String, UUID> getApplications() throws Exception {
-        Map<String, UUID> applications = new TreeMap<String, UUID>( CASE_INSENSITIVE_ORDER );
-        Keyspace ko = cass.getUsergridApplicationKeyspace();
-        RangeSlicesQuery<String, String, UUID> q = createRangeSlicesQuery( ko, se, se, ue );
-        q.setKeys( "", "\uFFFF" );
-        q.setColumnFamily( APPLICATIONS_CF );
-        q.setColumnNames( PROPERTY_UUID );
-        q.setRowCount( 10000 );
-        QueryResult<OrderedRows<String, String, UUID>> r = q.execute();
-        Rows<String, String, UUID> rows = r.get();
-        for ( Row<String, String, UUID> row : rows ) {
-            ColumnSlice<String, UUID> slice = row.getColumnSlice();
-            HColumn<String, UUID> column = slice.getColumnByName( PROPERTY_UUID );
-            applications.put( row.getKey(), column.getValue() );
-        }
-        return applications;
+        throw new UnsupportedOperationException( "We no longer support the 1.0 entity manager anymore" );
+
     }
 
    @Override
     public boolean setServiceProperty( String name, String value ) {
-        try {
-            cass.setColumn( cass.getUsergridApplicationKeyspace(), PROPERTIES_CF, PROPERTIES_CF, name, value );
-            return true;
-        }
-        catch ( Exception e ) {
-            logger.error( "Unable to set property " + name + ": " + e.getMessage() );
-        }
-        return false;
+       throw new UnsupportedOperationException( "We no longer support the 1.0 entity manager anymore" );
+
     }
 
 
     @Override
     public boolean deleteServiceProperty( String name ) {
-        try {
-            cass.deleteColumn( cass.getUsergridApplicationKeyspace(), PROPERTIES_CF, PROPERTIES_CF, name );
-            return true;
-        }
-        catch ( Exception e ) {
-            logger.error( "Unable to delete property " + name + ": " + e.getMessage() );
-        }
-        return false;
+        throw new UnsupportedOperationException( "We no longer support the 1.0 entity manager anymore" );
+
+    }
+
+
+    @Override
+    public UUID initializeApplication( final String orgName, final UUID appId, final String appName,
+                                       final Map<String, Object> props ) throws Exception {
+        return null;
     }
 
 
     @Override
     public boolean updateServiceProperties( Map<String, String> properties ) {
-        try {
-            cass.setColumns( cass.getUsergridApplicationKeyspace(), PROPERTIES_CF, PROPERTIES_CF.getBytes(), properties );
-            return true;
-        }
-        catch ( Exception e ) {
-            logger.error( "Unable to update properties: " + e.getMessage() );
-        }
-        return false;
+        throw new UnsupportedOperationException( "We no longer support the 1.0 entity manager anymore" );
+
     }
 
 
     @Override
     public Map<String, String> getServiceProperties() {
-        try {
-            return asMap( cass.getAllColumns( cass.getUsergridApplicationKeyspace(), PROPERTIES_CF, PROPERTIES_CF, se, se ) );
-        }
-        catch ( Exception e ) {
-            logger.error( "Unable to load properties: " + e.getMessage() );
-        }
+
         return null;
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/ded67435/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/SetupImpl.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/SetupImpl.java b/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/SetupImpl.java
index 775f43b..62b85de 100644
--- a/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/SetupImpl.java
+++ b/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/SetupImpl.java
@@ -23,14 +23,11 @@ import static me.prettyprint.hector.api.factory.HFactory.createColumnFamilyDefin
 import org.apache.usergrid.mq.cassandra.QueuesCF;
 import org.apache.usergrid.persistence.EntityManagerFactory;
 import static org.apache.usergrid.persistence.cassandra.CassandraPersistenceUtils.getCfDefs;
-import static org.apache.usergrid.persistence.cassandra.CassandraService.APPLICATIONS_CF;
 import static org.apache.usergrid.persistence.cassandra.CassandraService.DEFAULT_APPLICATION;
 import static org.apache.usergrid.persistence.cassandra.CassandraService.DEFAULT_ORGANIZATION;
 import static org.apache.usergrid.persistence.cassandra.CassandraService.MANAGEMENT_APPLICATION;
 import static org.apache.usergrid.persistence.cassandra.CassandraService.PRINCIPAL_TOKEN_CF;
-import static org.apache.usergrid.persistence.cassandra.CassandraService.PROPERTIES_CF;
 import static org.apache.usergrid.persistence.cassandra.CassandraService.TOKENS_CF;
-import static org.apache.usergrid.persistence.cassandra.CassandraService.USE_VIRTUAL_KEYSPACES;
 import static org.apache.usergrid.persistence.cassandra.CassandraService.getApplicationKeyspace;
 import static org.apache.usergrid.persistence.cassandra.CassandraService.keyspaceForApplication;
 import org.apache.usergrid.persistence.entities.Application;
@@ -80,12 +77,6 @@ public class SetupImpl implements Setup {
         logger.info( "Initialize system keyspace" );
 
         cass.createColumnFamily( getApplicationKeyspace(), createColumnFamilyDefinition(
-                getApplicationKeyspace(), APPLICATIONS_CF, ComparatorType.BYTESTYPE ) );
-
-        cass.createColumnFamily( getApplicationKeyspace(), createColumnFamilyDefinition(
-                getApplicationKeyspace(), PROPERTIES_CF, ComparatorType.BYTESTYPE ) );
-
-        cass.createColumnFamily( getApplicationKeyspace(), createColumnFamilyDefinition(
                 getApplicationKeyspace(), TOKENS_CF, ComparatorType.BYTESTYPE ) );
 
         cass.createColumnFamily( getApplicationKeyspace(), createColumnFamilyDefinition(
@@ -107,36 +98,30 @@ public class SetupImpl implements Setup {
     public void setupApplicationKeyspace(
             final UUID applicationId, String applicationName ) throws Exception {
 
-        if ( !USE_VIRTUAL_KEYSPACES ) {
             String app_keyspace = keyspaceForApplication( applicationId );
 
             logger.info( "Creating application keyspace " + app_keyspace + " for "
                     + applicationName + " application" );
 
-            cass.createColumnFamily( app_keyspace, createColumnFamilyDefinition(
-                    getApplicationKeyspace(), APPLICATIONS_CF, ComparatorType.BYTESTYPE ) );
+
 
             cass.createColumnFamilies( app_keyspace, getCfDefs( ApplicationCF.class, app_keyspace));
             cass.createColumnFamilies( app_keyspace, getCfDefs( QueuesCF.class, app_keyspace ) );
-        }
+
     }
 
 
     public void setupStaticKeyspace() throws Exception {
 
-        if ( USE_VIRTUAL_KEYSPACES ) {
 
-            logger.info( "Creating static application keyspace " + getApplicationKeyspace() );
 
-            cass.createColumnFamily( getApplicationKeyspace(),
-                    createColumnFamilyDefinition( getApplicationKeyspace(), APPLICATIONS_CF,
-                            ComparatorType.BYTESTYPE ) );
+            logger.info( "Creating static application keyspace " + getApplicationKeyspace() );
 
             cass.createColumnFamilies( getApplicationKeyspace(),
                     getCfDefs( ApplicationCF.class, getApplicationKeyspace() ) );
             cass.createColumnFamilies( getApplicationKeyspace(),
                     getCfDefs( QueuesCF.class, getApplicationKeyspace() ) );
-        }
+
     }
 
 
@@ -146,14 +131,7 @@ public class SetupImpl implements Setup {
 
 
     public static void logCFPermissions() {
-        System.out.println( getApplicationKeyspace() + "." + APPLICATIONS_CF + ".<rw>=usergrid" );
-        System.out.println( getApplicationKeyspace() + "." + PROPERTIES_CF + ".<rw>=usergrid" );
-        for ( CFEnum cf : ApplicationCF.values() ) {
-            System.out.println( getApplicationKeyspace() + "." + cf + ".<rw>=usergrid" );
-        }
-        for ( CFEnum cf : QueuesCF.values() ) {
-            System.out.println( getApplicationKeyspace() + "." + cf + ".<rw>=usergrid" );
-        }
+
     }
 
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/ded67435/stack/core/src/test/java/org/apache/usergrid/persistence/cassandra/EntityManagerFactoryImplIT.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/cassandra/EntityManagerFactoryImplIT.java b/stack/core/src/test/java/org/apache/usergrid/persistence/cassandra/EntityManagerFactoryImplIT.java
index 850ac6b..42f2af1 100644
--- a/stack/core/src/test/java/org/apache/usergrid/persistence/cassandra/EntityManagerFactoryImplIT.java
+++ b/stack/core/src/test/java/org/apache/usergrid/persistence/cassandra/EntityManagerFactoryImplIT.java
@@ -50,8 +50,6 @@ import static org.junit.Assert.assertTrue;
 
 public class EntityManagerFactoryImplIT extends AbstractCoreIT {
 
-    @SuppressWarnings("PointlessBooleanExpression")
-    public static final boolean USE_DEFAULT_DOMAIN = !CassandraService.USE_VIRTUAL_KEYSPACES;
 
     private static final Logger logger = LoggerFactory.getLogger( EntityManagerFactoryImplIT.class );
 
@@ -80,9 +78,6 @@ public class EntityManagerFactoryImplIT extends AbstractCoreIT {
 
 
     public UUID createApplication( String organizationName, String applicationName ) throws Exception {
-        if ( USE_DEFAULT_DOMAIN ) {
-            return emf.getDefaultAppId();
-        }
         return emf.createApplication( organizationName, applicationName );
     }
 


[28/50] [abbrv] incubator-usergrid git commit: Back off of Arquillian for now.

Posted by sn...@apache.org.
Back off of Arquillian for now.


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

Branch: refs/heads/two-dot-o
Commit: 47953555dc5e7f6186e3a0c4bd5d217bdefe66b8
Parents: 99d694b
Author: Dave Johnson <dm...@apigee.com>
Authored: Tue Feb 24 16:34:06 2015 -0500
Committer: Dave Johnson <dm...@apigee.com>
Committed: Tue Feb 24 16:34:06 2015 -0500

----------------------------------------------------------------------
 stack/rest/pom.xml                              | 110 ++++++-------------
 .../apache/usergrid/rest/AbstractRestIT.java    |  32 +++---
 2 files changed, 51 insertions(+), 91 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/47953555/stack/rest/pom.xml
----------------------------------------------------------------------
diff --git a/stack/rest/pom.xml b/stack/rest/pom.xml
index c1c8ea2..70072d9 100644
--- a/stack/rest/pom.xml
+++ b/stack/rest/pom.xml
@@ -41,35 +41,26 @@
     <!-- 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>
-
-                <!-- only deploy once during tests -->
-                <dependency>
-                    <groupId>org.eu.ingwar.tools</groupId>
-                    <artifactId>arquillian-suite-extension</artifactId>
-                    <version>1.1.2</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>
 
@@ -377,67 +368,36 @@
 
         <!-- Arquillian deps -->
 
-        <dependency>
-            <groupId>org.codehaus.jackson</groupId>
-            <artifactId>jackson-xc</artifactId>
-            <version>${jackson-version}</version>
-            <scope>test</scope>
-        </dependency>
-
         <!--<dependency>-->
-            <!--<groupId>org.jboss.arquillian.container</groupId>-->
-            <!--<artifactId>arquillian-tomcat-embedded-7</artifactId>-->
-            <!--<version>1.1.7.Final</version>-->
+            <!--<groupId>org.codehaus.jackson</groupId>-->
+            <!--<artifactId>jackson-xc</artifactId>-->
+            <!--<version>${jackson-version}</version>-->
             <!--<scope>test</scope>-->
         <!--</dependency>-->
 
-        <dependency>
-            <groupId>org.jboss.arquillian</groupId>
-            <artifactId>arquillian-bom</artifactId>
-            <version>1.1.7.Final</version>
-            <scope>test</scope>
-            <type>pom</type>
-        </dependency>
-
-        <dependency>
-            <groupId>org.jboss.arquillian.junit</groupId>
-            <artifactId>arquillian-junit-container</artifactId>
-            <version>1.1.7.Final</version>
-            <scope>test</scope>
-        </dependency>
-
-        <!--Some Arquillian dependency runs and old version of Guice.-->
-        <!--We're overridding it here so that we include the right value into the test scope-->
         <!--<dependency>-->
-          <!--<groupId>com.google.inject</groupId>-->
-          <!--<artifactId>guice</artifactId>-->
-          <!--<version>${guice.version}</version>-->
+            <!--<groupId>org.jboss.arquillian</groupId>-->
+            <!--<artifactId>arquillian-bom</artifactId>-->
+            <!--<version>1.1.7.Final</version>-->
             <!--<scope>test</scope>-->
+            <!--<type>pom</type>-->
         <!--</dependency>-->
 
         <!--<dependency>-->
-          <!--<groupId>com.google.inject.extensions</groupId>-->
-          <!--<artifactId>guice-multibindings</artifactId>-->
-          <!--<version>${guice.version}</version>-->
+            <!--<groupId>org.jboss.arquillian.junit</groupId>-->
+            <!--<artifactId>arquillian-junit-container</artifactId>-->
+            <!--<version>1.1.7.Final</version>-->
             <!--<scope>test</scope>-->
         <!--</dependency>-->
 
         <!--<dependency>-->
-          <!--<groupId>com.google.inject.extensions</groupId>-->
-          <!--<artifactId>guice-assistedinject</artifactId>-->
-          <!--<version>${guice.version}</version>-->
-            <!--<scope>test</scope>-->
+              <!--<groupId>org.jboss.shrinkwrap.resolver</groupId>-->
+              <!--<artifactId>shrinkwrap-resolver-depchain</artifactId>-->
+              <!--<version>2.1.1</version>-->
+              <!--<scope>test</scope>-->
+              <!--<type>pom</type>-->
         <!--</dependency>-->
 
-        <!-- documentation here https://github.com/shrinkwrap/resolver -->
-        <dependency>
-              <groupId>org.jboss.shrinkwrap.resolver</groupId>
-              <artifactId>shrinkwrap-resolver-depchain</artifactId>
-              <version>2.1.1</version>
-              <scope>test</scope>
-              <type>pom</type>
-        </dependency>
-
         <!--  use the external test client.  Just depend on the maven jetty plugin to launch jetty -->
         <dependency>
             <groupId>com.sun.jersey.jersey-test-framework</groupId>

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/47953555/stack/rest/src/test/java/org/apache/usergrid/rest/AbstractRestIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/AbstractRestIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/AbstractRestIT.java
index fab1e55..eb1f628 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/AbstractRestIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/AbstractRestIT.java
@@ -65,8 +65,8 @@ import org.slf4j.LoggerFactory;
  * following naming convention: test_[HTTP verb]_[action mapping]_[ok|fail][_[specific
  * failure condition if multiple]
  */
-@ArquillianSuiteDeployment
-@RunWith(Arquillian.class)
+//@ArquillianSuiteDeployment
+//@RunWith(Arquillian.class)
 public abstract class AbstractRestIT extends JerseyTest {
     private static final Logger LOG = LoggerFactory.getLogger( AbstractRestIT.class );
     private static boolean usersSetup = false;
@@ -104,20 +104,20 @@ public abstract class AbstractRestIT extends JerseyTest {
     }
 
 
-    // We set testable = false so we deploy the archive to the server and test it locally
-    @Deployment( testable = false )
-    public static WebArchive createTestArchive() {
-
-        // we use the MavenImporter from shrinkwrap to just produce whatever maven would build then test with it
-
-        // set maven to be in offline mode
-
-        System.setProperty( "org.apache.maven.offline", "true" );
-        return ShrinkWrap.create(MavenImporter.class)
-            .loadPomFromFile( "pom.xml", "arquillian-tomcat" )
-            .importBuildOutput()
-            .as( WebArchive.class );
-    }
+//    // We set testable = false so we deploy the archive to the server and test it locally
+//    @org.jboss.arquillian.container.test.api.Deployment( testable = false )
+//    public static WebArchive createTestArchive() {
+//
+//        // we use the MavenImporter from shrinkwrap to just produce whatever maven would build then test with it
+//
+//        // set maven to be in offline mode
+//
+//        System.setProperty( "org.apache.maven.offline", "true" );
+//        return ShrinkWrap.create(MavenImporter.class)
+//            .loadPomFromFile( "pom.xml", "arquillian-tomcat" )
+//            .importBuildOutput()
+//            .as( WebArchive.class );
+//    }
 
 
     @AfterClass


[11/50] [abbrv] incubator-usergrid git commit: Adding a CATALINA_BASE to the rest module so we can configure Tomcat as we need it configured for Maven Surefire testing with Arquillian.

Posted by sn...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/13da256f/stack/rest/catalina_base/work/Catalina/localhost/manager/org/apache/jsp/index_jsp.java
----------------------------------------------------------------------
diff --git a/stack/rest/catalina_base/work/Catalina/localhost/manager/org/apache/jsp/index_jsp.java b/stack/rest/catalina_base/work/Catalina/localhost/manager/org/apache/jsp/index_jsp.java
new file mode 100644
index 0000000..4e31533
--- /dev/null
+++ b/stack/rest/catalina_base/work/Catalina/localhost/manager/org/apache/jsp/index_jsp.java
@@ -0,0 +1,83 @@
+/*
+ * Generated by the Jasper component of Apache Tomcat
+ * Version: Apache Tomcat/7.0.59
+ * Generated at: 2015-02-20 15:02:02 UTC
+ * Note: The last modified time of this file was set to
+ *       the last modified time of the source file after
+ *       generation to assist with modification tracking.
+ */
+package org.apache.jsp;
+
+import javax.servlet.*;
+import javax.servlet.http.*;
+import javax.servlet.jsp.*;
+
+public final class index_jsp extends org.apache.jasper.runtime.HttpJspBase
+    implements org.apache.jasper.runtime.JspSourceDependent {
+
+  private static final javax.servlet.jsp.JspFactory _jspxFactory =
+          javax.servlet.jsp.JspFactory.getDefaultFactory();
+
+  private static java.util.Map<java.lang.String,java.lang.Long> _jspx_dependants;
+
+  private javax.el.ExpressionFactory _el_expressionfactory;
+  private org.apache.tomcat.InstanceManager _jsp_instancemanager;
+
+  public java.util.Map<java.lang.String,java.lang.Long> getDependants() {
+    return _jspx_dependants;
+  }
+
+  public void _jspInit() {
+    _el_expressionfactory = _jspxFactory.getJspApplicationContext(getServletConfig().getServletContext()).getExpressionFactory();
+    _jsp_instancemanager = org.apache.jasper.runtime.InstanceManagerFactory.getInstanceManager(getServletConfig());
+  }
+
+  public void _jspDestroy() {
+  }
+
+  public void _jspService(final javax.servlet.http.HttpServletRequest request, final javax.servlet.http.HttpServletResponse response)
+        throws java.io.IOException, javax.servlet.ServletException {
+
+    final javax.servlet.jsp.PageContext pageContext;
+    javax.servlet.http.HttpSession session = null;
+    final javax.servlet.ServletContext application;
+    final javax.servlet.ServletConfig config;
+    javax.servlet.jsp.JspWriter out = null;
+    final java.lang.Object page = this;
+    javax.servlet.jsp.JspWriter _jspx_out = null;
+    javax.servlet.jsp.PageContext _jspx_page_context = null;
+
+
+    try {
+      response.setContentType("text/html");
+      pageContext = _jspxFactory.getPageContext(this, request, response,
+      			null, true, 8192, true);
+      _jspx_page_context = pageContext;
+      application = pageContext.getServletContext();
+      config = pageContext.getServletConfig();
+      session = pageContext.getSession();
+      out = pageContext.getOut();
+      _jspx_out = out;
+
+      out.write('\n');
+ response.sendRedirect(response.encodeRedirectURL(request.getContextPath() +
+        "/html")); 
+    } catch (java.lang.Throwable t) {
+      if (!(t instanceof javax.servlet.jsp.SkipPageException)){
+        out = _jspx_out;
+        if (out != null && out.getBufferSize() != 0)
+          try {
+            if (response.isCommitted()) {
+              out.flush();
+            } else {
+              out.clearBuffer();
+            }
+          } catch (java.io.IOException e) {}
+        if (_jspx_page_context != null) _jspx_page_context.handlePageException(t);
+        else throw new ServletException(t);
+      }
+    } finally {
+      _jspxFactory.releasePageContext(_jspx_page_context);
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/13da256f/stack/rest/src/test/resources/arquillian.xml
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/resources/arquillian.xml b/stack/rest/src/test/resources/arquillian.xml
index f6adcfc..1e6177e 100644
--- a/stack/rest/src/test/resources/arquillian.xml
+++ b/stack/rest/src/test/resources/arquillian.xml
@@ -24,12 +24,6 @@
     xsi:schemaLocation="http://jboss.org/schema/arquillian http://jboss.org/schema/arquillian/arquillian_1_0.xsd">
 
     <!--<container qualifier="tomcat" default="true">-->
-    <!--<configuration>-->
-    <!--<property name="unpackArchive">true</property>-->
-    <!--</configuration>-->
-    <!--</container>-->
-
-    <!--<container qualifier="tomcat" default="true">-->
         <!--<configuration>-->
             <!--<property name="bindHttpPort">8080</property>-->
             <!--<property name="bindAddress">localhost</property>-->
@@ -43,10 +37,10 @@
         <!--</configuration>-->
     <!--</container>-->
 
-
     <container qualifier="tomcat" default="true">
         <configuration>
             <property name="host">${catalina.host}</property>
+            <property name="httpPort">8080</property>
             <property name="user">usergrid</property>
             <property name="pass">testpassword</property>
             <!--This is a workaround for this issue https://issues.jboss.org/browse/ARQ-1814-->
@@ -54,6 +48,4 @@
         </configuration>
     </container>
 
-
 </arquillian>
-


[13/50] [abbrv] incubator-usergrid git commit: Adding a CATALINA_BASE to the rest module so we can configure Tomcat as we need it configured for Maven Surefire testing with Arquillian.

Posted by sn...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/13da256f/stack/rest/catalina_base/conf/web.xml
----------------------------------------------------------------------
diff --git a/stack/rest/catalina_base/conf/web.xml b/stack/rest/catalina_base/conf/web.xml
new file mode 100644
index 0000000..ecaa1a6
--- /dev/null
+++ b/stack/rest/catalina_base/conf/web.xml
@@ -0,0 +1,4614 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+  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 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"
+  version="3.0">
+
+  <!-- ======================== Introduction ============================== -->
+  <!-- This document defines default values for *all* web applications      -->
+  <!-- loaded into this instance of Tomcat.  As each application is         -->
+  <!-- deployed, this file is processed, followed by the                    -->
+  <!-- "/WEB-INF/web.xml" deployment descriptor from your own               -->
+  <!-- applications.                                                        -->
+  <!--                                                                      -->
+  <!-- WARNING:  Do not configure application-specific resources here!      -->
+  <!-- They should go in the "/WEB-INF/web.xml" file in your application.   -->
+
+
+  <!-- ================== Built In Servlet Definitions ==================== -->
+
+
+  <!-- The default servlet for all web applications, that serves static     -->
+  <!-- resources.  It processes all requests that are not mapped to other   -->
+  <!-- servlets with servlet mappings (defined either here or in your own   -->
+  <!-- web.xml file).  This servlet supports the following initialization   -->
+  <!-- parameters (default values are in square brackets):                  -->
+  <!--                                                                      -->
+  <!--   debug               Debugging detail level for messages logged     -->
+  <!--                       by this servlet.  [0]                          -->
+  <!--                                                                      -->
+  <!--   fileEncoding        Encoding to be used to read static resources   -->
+  <!--                       [platform default]                             -->
+  <!--                                                                      -->
+  <!--   input               Input buffer size (in bytes) when reading      -->
+  <!--                       resources to be served.  [2048]                -->
+  <!--                                                                      -->
+  <!--   listings            Should directory listings be produced if there -->
+  <!--                       is no welcome file in this directory?  [false] -->
+  <!--                       WARNING: Listings for directories with many    -->
+  <!--                       entries can be slow and may consume            -->
+  <!--                       significant proportions of server resources.   -->
+  <!--                                                                      -->
+  <!--   output              Output buffer size (in bytes) when writing     -->
+  <!--                       resources to be served.  [2048]                -->
+  <!--                                                                      -->
+  <!--   readonly            Is this context "read only", so HTTP           -->
+  <!--                       commands like PUT and DELETE are               -->
+  <!--                       rejected?  [true]                              -->
+  <!--                                                                      -->
+  <!--   readmeFile          File to display together with the directory    -->
+  <!--                       contents. [null]                               -->
+  <!--                                                                      -->
+  <!--   sendfileSize        If the connector used supports sendfile, this  -->
+  <!--                       represents the minimal file size in KB for     -->
+  <!--                       which sendfile will be used. Use a negative    -->
+  <!--                       value to always disable sendfile.  [48]        -->
+  <!--                                                                      -->
+  <!--   useAcceptRanges     Should the Accept-Ranges header be included    -->
+  <!--                       in responses where appropriate? [true]         -->
+  <!--                                                                      -->
+  <!--  For directory listing customization. Checks localXsltFile, then     -->
+  <!--  globalXsltFile, then defaults to original behavior.                 -->
+  <!--                                                                      -->
+  <!--   localXsltFile       Make directory listings an XML doc and         -->
+  <!--                       pass the result to this style sheet residing   -->
+  <!--                       in that directory. This overrides              -->
+  <!--                       contextXsltFile and globalXsltFile[null]       -->
+  <!--                                                                      -->
+  <!--   contextXsltFile     Make directory listings an XML doc and         -->
+  <!--                       pass the result to this style sheet which is   -->
+  <!--                       relative to the context root. This overrides   -->
+  <!--                       globalXsltFile[null]                           -->
+  <!--                                                                      -->
+  <!--   globalXsltFile      Site wide configuration version of             -->
+  <!--                       localXsltFile. This argument must either be an -->
+  <!--                       absolute or relative (to either                -->
+  <!--                       $CATALINA_BASE/conf or $CATALINA_HOME/conf)    -->
+  <!--                       path that points to a location below either    -->
+  <!--                       $CATALINA_BASE/conf (checked first) or         -->
+  <!--                       $CATALINA_HOME/conf (checked second).[null]    -->
+  <!--                                                                      -->
+  <!--   showServerInfo      Should server information be presented in the  -->
+  <!--                       response sent to clients when directory        -->
+  <!--                       listings is enabled? [true]                    -->
+
+    <servlet>
+        <servlet-name>default</servlet-name>
+        <servlet-class>org.apache.catalina.servlets.DefaultServlet</servlet-class>
+        <init-param>
+            <param-name>debug</param-name>
+            <param-value>0</param-value>
+        </init-param>
+        <init-param>
+            <param-name>listings</param-name>
+            <param-value>false</param-value>
+        </init-param>
+        <load-on-startup>1</load-on-startup>
+    </servlet>
+
+
+  <!-- The JSP page compiler and execution servlet, which is the mechanism  -->
+  <!-- used by Tomcat to support JSP pages.  Traditionally, this servlet    -->
+  <!-- is mapped to the URL pattern "*.jsp".  This servlet supports the     -->
+  <!-- following initialization parameters (default values are in square    -->
+  <!-- brackets):                                                           -->
+  <!--                                                                      -->
+  <!--   checkInterval       If development is false and checkInterval is   -->
+  <!--                       greater than zero, background compilations are -->
+  <!--                       enabled. checkInterval is the time in seconds  -->
+  <!--                       between checks to see if a JSP page (and its   -->
+  <!--                       dependent files) needs to  be recompiled. [0]  -->
+  <!--                                                                      -->
+  <!--   classdebuginfo      Should the class file be compiled with         -->
+  <!--                       debugging information?  [true]                 -->
+  <!--                                                                      -->
+  <!--   classpath           What class path should I use while compiling   -->
+  <!--                       generated servlets?  [Created dynamically      -->
+  <!--                       based on the current web application]          -->
+  <!--                                                                      -->
+  <!--   compiler            Which compiler Ant should use to compile JSP   -->
+  <!--                       pages.  See the jasper documentation for more  -->
+  <!--                       information.                                   -->
+  <!--                                                                      -->
+  <!--   compilerSourceVM    Compiler source VM. [1.6]                      -->
+  <!--                                                                      -->
+  <!--   compilerTargetVM    Compiler target VM. [1.6]                      -->
+  <!--                                                                      -->
+  <!--   development         Is Jasper used in development mode? If true,   -->
+  <!--                       the frequency at which JSPs are checked for    -->
+  <!--                       modification may be specified via the          -->
+  <!--                       modificationTestInterval parameter. [true]     -->
+  <!--                                                                      -->
+  <!--   displaySourceFragment                                              -->
+  <!--                       Should a source fragment be included in        -->
+  <!--                       exception messages? [true]                     -->
+  <!--                                                                      -->
+  <!--   dumpSmap            Should the SMAP info for JSR45 debugging be    -->
+  <!--                       dumped to a file? [false]                      -->
+  <!--                       False if suppressSmap is true                  -->
+  <!--                                                                      -->
+  <!--   enablePooling       Determines whether tag handler pooling is      -->
+  <!--                       enabled. This is a compilation option. It will -->
+  <!--                       not alter the behaviour of JSPs that have      -->
+  <!--                       already been compiled. [true]                  -->
+  <!--                                                                      -->
+  <!--   engineOptionsClass  Allows specifying the Options class used to    -->
+  <!--                       configure Jasper. If not present, the default  -->
+  <!--                       EmbeddedServletOptions will be used.           -->
+  <!--                                                                      -->
+  <!--   errorOnUseBeanInvalidClassAttribute                                -->
+  <!--                       Should Jasper issue an error when the value of -->
+  <!--                       the class attribute in an useBean action is    -->
+  <!--                       not a valid bean class?  [true]                -->
+  <!--                                                                      -->
+  <!--   fork                Tell Ant to fork compiles of JSP pages so that -->
+  <!--                       a separate JVM is used for JSP page compiles   -->
+  <!--                       from the one Tomcat is running in. [true]      -->
+  <!--                                                                      -->
+  <!--   genStringAsCharArray                                               -->
+  <!--                       Should text strings be generated as char       -->
+  <!--                       arrays, to improve performance in some cases?  -->
+  <!--                       [false]                                        -->
+  <!--                                                                      -->
+  <!--   ieClassId           The class-id value to be sent to Internet      -->
+  <!--                       Explorer when using <jsp:plugin> tags.         -->
+  <!--                       [clsid:8AD9C840-044E-11D1-B3E9-00805F499D93]   -->
+  <!--                                                                      -->
+  <!--   javaEncoding        Java file encoding to use for generating java  -->
+  <!--                       source files. [UTF8]                           -->
+  <!--                                                                      -->
+  <!--   keepgenerated       Should we keep the generated Java source code  -->
+  <!--                       for each page instead of deleting it? [true]   -->
+  <!--                                                                      -->
+  <!--   mappedfile          Should we generate static content with one     -->
+  <!--                       print statement per input line, to ease        -->
+  <!--                       debugging?  [true]                             -->
+  <!--                                                                      -->
+  <!--   maxLoadedJsps       The maximum number of JSPs that will be loaded -->
+  <!--                       for a web application. If more than this       -->
+  <!--                       number of JSPs are loaded, the least recently  -->
+  <!--                       used JSPs will be unloaded so that the number  -->
+  <!--                       of JSPs loaded at any one time does not exceed -->
+  <!--                       this limit. A value of zero or less indicates  -->
+  <!--                       no limit. [-1]                                 -->
+  <!--                                                                      -->
+  <!--   jspIdleTimeout      The amount of time in seconds a JSP can be     -->
+  <!--                       idle before it is unloaded. A value of zero    -->
+  <!--                       or less indicates never unload. [-1]           -->
+  <!--                                                                      -->
+  <!--   modificationTestInterval                                           -->
+  <!--                       Causes a JSP (and its dependent files) to not  -->
+  <!--                       be checked for modification during the         -->
+  <!--                       specified time interval (in seconds) from the  -->
+  <!--                       last time the JSP was checked for              -->
+  <!--                       modification. A value of 0 will cause the JSP  -->
+  <!--                       to be checked on every access.                 -->
+  <!--                       Used in development mode only. [4]             -->
+  <!--                                                                      -->
+  <!--   recompileOnFail     If a JSP compilation fails should the          -->
+  <!--                       modificationTestInterval be ignored and the    -->
+  <!--                       next access trigger a re-compilation attempt?  -->
+  <!--                       Used in development mode only and is disabled  -->
+  <!--                       by default as compilation may be expensive and -->
+  <!--                       could lead to excessive resource usage.        -->
+  <!--                       [false]                                        -->
+  <!--                                                                      -->
+  <!--   scratchdir          What scratch directory should we use when      -->
+  <!--                       compiling JSP pages?  [default work directory  -->
+  <!--                       for the current web application]               -->
+  <!--                                                                      -->
+  <!--   suppressSmap        Should the generation of SMAP info for JSR45   -->
+  <!--                       debugging be suppressed?  [false]              -->
+  <!--                                                                      -->
+  <!--   trimSpaces          Should white spaces in template text between   -->
+  <!--                       actions or directives be trimmed?  [false]     -->
+  <!--                                                                      -->
+  <!--   xpoweredBy          Determines whether X-Powered-By response       -->
+  <!--                       header is added by generated servlet.  [false] -->
+
+    <servlet>
+        <servlet-name>jsp</servlet-name>
+        <servlet-class>org.apache.jasper.servlet.JspServlet</servlet-class>
+        <init-param>
+            <param-name>fork</param-name>
+            <param-value>false</param-value>
+        </init-param>
+        <init-param>
+            <param-name>xpoweredBy</param-name>
+            <param-value>false</param-value>
+        </init-param>
+        <load-on-startup>3</load-on-startup>
+    </servlet>
+
+
+  <!-- NOTE: An SSI Filter is also available as an alternative SSI          -->
+  <!-- implementation. Use either the Servlet or the Filter but NOT both.   -->
+  <!--                                                                      -->
+  <!-- Server Side Includes processing servlet, which processes SSI         -->
+  <!-- directives in HTML pages consistent with similar support in web      -->
+  <!-- servers like Apache.  Traditionally, this servlet is mapped to the   -->
+  <!-- URL pattern "*.shtml".  This servlet supports the following          -->
+  <!-- initialization parameters (default values are in square brackets):   -->
+  <!--                                                                      -->
+  <!--   buffered            Should output from this servlet be buffered?   -->
+  <!--                       (0=false, 1=true)  [0]                         -->
+  <!--                                                                      -->
+  <!--   debug               Debugging detail level for messages logged     -->
+  <!--                       by this servlet.  [0]                          -->
+  <!--                                                                      -->
+  <!--   expires             The number of seconds before a page with SSI   -->
+  <!--                       directives will expire.  [No default]          -->
+  <!--                                                                      -->
+  <!--   isVirtualWebappRelative                                            -->
+  <!--                       Should "virtual" paths be interpreted as       -->
+  <!--                       relative to the context root, instead of       -->
+  <!--                       the server root? [false]                       -->
+  <!--                                                                      -->
+  <!--   inputEncoding       The encoding to assume for SSI resources if    -->
+  <!--                       one is not available from the resource.        -->
+  <!--                       [Platform default]                             -->
+  <!--                                                                      -->
+  <!--   outputEncoding      The encoding to use for the page that results  -->
+  <!--                       from the SSI processing. [UTF-8]               -->
+  <!--                                                                      -->
+  <!--   allowExec           Is use of the exec command enabled? [false]    -->
+
+<!--
+    <servlet>
+        <servlet-name>ssi</servlet-name>
+        <servlet-class>
+          org.apache.catalina.ssi.SSIServlet
+        </servlet-class>
+        <init-param>
+          <param-name>buffered</param-name>
+          <param-value>1</param-value>
+        </init-param>
+        <init-param>
+          <param-name>debug</param-name>
+          <param-value>0</param-value>
+        </init-param>
+        <init-param>
+          <param-name>expires</param-name>
+          <param-value>666</param-value>
+        </init-param>
+        <init-param>
+          <param-name>isVirtualWebappRelative</param-name>
+          <param-value>false</param-value>
+        </init-param>
+        <load-on-startup>4</load-on-startup>
+    </servlet>
+-->
+
+
+  <!-- Common Gateway Includes (CGI) processing servlet, which supports     -->
+  <!-- execution of external applications that conform to the CGI spec      -->
+  <!-- requirements.  Typically, this servlet is mapped to the URL pattern  -->
+  <!-- "/cgi-bin/*", which means that any CGI applications that are         -->
+  <!-- executed must be present within the web application.  This servlet   -->
+  <!-- supports the following initialization parameters (default values     -->
+  <!-- are in square brackets):                                             -->
+  <!--                                                                      -->
+  <!--   cgiPathPrefix        The CGI search path will start at             -->
+  <!--                        webAppRootDir + File.separator + this prefix. -->
+  <!--                        If not set, then webAppRootDir is used.       -->
+  <!--                        Recommended value: WEB-INF/cgi                -->
+  <!--                                                                      -->
+  <!--   debug                Debugging detail level for messages logged    -->
+  <!--                        by this servlet.  [0]                         -->
+  <!--                                                                      -->
+  <!--   executable           Name of the executable used to run the        -->
+  <!--                        script. [perl]                                -->
+  <!--                                                                      -->
+  <!--   parameterEncoding    Name of parameter encoding to be used with    -->
+  <!--                        CGI servlet.                                  -->
+  <!--                        [System.getProperty("file.encoding","UTF-8")] -->
+  <!--                                                                      -->
+  <!--   passShellEnvironment Should the shell environment variables (if    -->
+  <!--                        any) be passed to the CGI script? [false]     -->
+  <!--                                                                      -->
+  <!--   stderrTimeout        The time (in milliseconds) to wait for the    -->
+  <!--                        reading of stderr to complete before          -->
+  <!--                        terminating the CGI process. [2000]           -->
+
+<!--
+    <servlet>
+        <servlet-name>cgi</servlet-name>
+        <servlet-class>org.apache.catalina.servlets.CGIServlet</servlet-class>
+        <init-param>
+          <param-name>debug</param-name>
+          <param-value>0</param-value>
+        </init-param>
+        <init-param>
+          <param-name>cgiPathPrefix</param-name>
+          <param-value>WEB-INF/cgi</param-value>
+        </init-param>
+         <load-on-startup>5</load-on-startup>
+    </servlet>
+-->
+
+
+  <!-- ================ Built In Servlet Mappings ========================= -->
+
+
+  <!-- The servlet mappings for the built in servlets defined above.  Note  -->
+  <!-- that, by default, the CGI and SSI servlets are *not* mapped.  You    -->
+  <!-- must uncomment these mappings (or add them to your application's own -->
+  <!-- web.xml deployment descriptor) to enable these services              -->
+
+    <!-- The mapping for the default servlet -->
+    <servlet-mapping>
+        <servlet-name>default</servlet-name>
+        <url-pattern>/</url-pattern>
+    </servlet-mapping>
+
+    <!-- The mappings for the JSP servlet -->
+    <servlet-mapping>
+        <servlet-name>jsp</servlet-name>
+        <url-pattern>*.jsp</url-pattern>
+        <url-pattern>*.jspx</url-pattern>
+    </servlet-mapping>
+
+    <!-- The mapping for the SSI servlet -->
+<!--
+    <servlet-mapping>
+        <servlet-name>ssi</servlet-name>
+        <url-pattern>*.shtml</url-pattern>
+    </servlet-mapping>
+-->
+
+    <!-- The mapping for the CGI Gateway servlet -->
+
+<!--
+    <servlet-mapping>
+        <servlet-name>cgi</servlet-name>
+        <url-pattern>/cgi-bin/*</url-pattern>
+    </servlet-mapping>
+-->
+
+
+  <!-- ================== Built In Filter Definitions ===================== -->
+
+  <!-- A filter that sets character encoding that is used to decode -->
+  <!-- parameters in a POST request -->
+<!--
+    <filter>
+        <filter-name>setCharacterEncodingFilter</filter-name>
+        <filter-class>org.apache.catalina.filters.SetCharacterEncodingFilter</filter-class>
+        <init-param>
+            <param-name>encoding</param-name>
+            <param-value>UTF-8</param-value>
+        </init-param>
+        <async-supported>true</async-supported>
+    </filter>
+-->
+
+  <!-- A filter that triggers request parameters parsing and rejects the    -->
+  <!-- request if some parameters were skipped because of parsing errors or -->
+  <!-- request size limitations.                                            -->
+<!--
+    <filter>
+        <filter-name>failedRequestFilter</filter-name>
+        <filter-class>
+          org.apache.catalina.filters.FailedRequestFilter
+        </filter-class>
+        <async-supported>true</async-supported>
+    </filter>
+-->
+
+
+  <!-- NOTE: An SSI Servlet is also available as an alternative SSI         -->
+  <!-- implementation. Use either the Servlet or the Filter but NOT both.   -->
+  <!--                                                                      -->
+  <!-- Server Side Includes processing filter, which processes SSI          -->
+  <!-- directives in HTML pages consistent with similar support in web      -->
+  <!-- servers like Apache.  Traditionally, this filter is mapped to the    -->
+  <!-- URL pattern "*.shtml", though it can be mapped to "*" as it will     -->
+  <!-- selectively enable/disable SSI processing based on mime types. For   -->
+  <!-- this to work you will need to uncomment the .shtml mime type         -->
+  <!-- definition towards the bottom of this file.                          -->
+  <!-- The contentType init param allows you to apply SSI processing to JSP -->
+  <!-- pages, javascript, or any other content you wish.  This filter       -->
+  <!-- supports the following initialization parameters (default values are -->
+  <!-- in square brackets):                                                 -->
+  <!--                                                                      -->
+  <!--   contentType         A regex pattern that must be matched before    -->
+  <!--                       SSI processing is applied.                     -->
+  <!--                       [text/x-server-parsed-html(;.*)?]              -->
+  <!--                                                                      -->
+  <!--   debug               Debugging detail level for messages logged     -->
+  <!--                       by this servlet.  [0]                          -->
+  <!--                                                                      -->
+  <!--   expires             The number of seconds before a page with SSI   -->
+  <!--                       directives will expire.  [No default]          -->
+  <!--                                                                      -->
+  <!--   isVirtualWebappRelative                                            -->
+  <!--                       Should "virtual" paths be interpreted as       -->
+  <!--                       relative to the context root, instead of       -->
+  <!--                       the server root? [false]                       -->
+  <!--                                                                      -->
+  <!--   allowExec           Is use of the exec command enabled? [false]    -->
+
+<!--
+    <filter>
+        <filter-name>ssi</filter-name>
+        <filter-class>
+          org.apache.catalina.ssi.SSIFilter
+        </filter-class>
+        <init-param>
+          <param-name>contentType</param-name>
+          <param-value>text/x-server-parsed-html(;.*)?</param-value>
+        </init-param>
+        <init-param>
+          <param-name>debug</param-name>
+          <param-value>0</param-value>
+        </init-param>
+        <init-param>
+          <param-name>expires</param-name>
+          <param-value>666</param-value>
+        </init-param>
+        <init-param>
+          <param-name>isVirtualWebappRelative</param-name>
+          <param-value>false</param-value>
+        </init-param>
+    </filter>
+-->
+
+
+  <!-- ==================== Built In Filter Mappings ====================== -->
+
+  <!-- The mapping for the Set Character Encoding Filter -->
+<!--
+    <filter-mapping>
+        <filter-name>setCharacterEncodingFilter</filter-name>
+        <url-pattern>/*</url-pattern>
+    </filter-mapping>
+-->
+
+  <!-- The mapping for the Failed Request Filter -->
+<!--
+    <filter-mapping>
+        <filter-name>failedRequestFilter</filter-name>
+        <url-pattern>/*</url-pattern>
+    </filter-mapping>
+-->
+
+  <!-- The mapping for the SSI Filter -->
+<!--
+    <filter-mapping>
+        <filter-name>ssi</filter-name>
+        <url-pattern>*.shtml</url-pattern>
+    </filter-mapping>
+-->
+
+
+  <!-- ==================== Default Session Configuration ================= -->
+  <!-- You can set the default session timeout (in minutes) for all newly   -->
+  <!-- created sessions by modifying the value below.                       -->
+
+    <session-config>
+        <session-timeout>30</session-timeout>
+    </session-config>
+
+
+  <!-- ===================== Default MIME Type Mappings =================== -->
+  <!-- When serving static resources, Tomcat will automatically generate    -->
+  <!-- a "Content-Type" header based on the resource's filename extension,  -->
+  <!-- based on these mappings.  Additional mappings can be added here (to  -->
+  <!-- apply to all web applications), or in your own application's web.xml -->
+  <!-- deployment descriptor.                                               -->
+
+    <mime-mapping>
+        <extension>123</extension>
+        <mime-type>application/vnd.lotus-1-2-3</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>3dml</extension>
+        <mime-type>text/vnd.in3d.3dml</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>3ds</extension>
+        <mime-type>image/x-3ds</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>3g2</extension>
+        <mime-type>video/3gpp2</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>3gp</extension>
+        <mime-type>video/3gpp</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>7z</extension>
+        <mime-type>application/x-7z-compressed</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>aab</extension>
+        <mime-type>application/x-authorware-bin</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>aac</extension>
+        <mime-type>audio/x-aac</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>aam</extension>
+        <mime-type>application/x-authorware-map</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>aas</extension>
+        <mime-type>application/x-authorware-seg</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>abs</extension>
+        <mime-type>audio/x-mpeg</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>abw</extension>
+        <mime-type>application/x-abiword</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>ac</extension>
+        <mime-type>application/pkix-attr-cert</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>acc</extension>
+        <mime-type>application/vnd.americandynamics.acc</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>ace</extension>
+        <mime-type>application/x-ace-compressed</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>acu</extension>
+        <mime-type>application/vnd.acucobol</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>acutc</extension>
+        <mime-type>application/vnd.acucorp</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>adp</extension>
+        <mime-type>audio/adpcm</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>aep</extension>
+        <mime-type>application/vnd.audiograph</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>afm</extension>
+        <mime-type>application/x-font-type1</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>afp</extension>
+        <mime-type>application/vnd.ibm.modcap</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>ahead</extension>
+        <mime-type>application/vnd.ahead.space</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>ai</extension>
+        <mime-type>application/postscript</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>aif</extension>
+        <mime-type>audio/x-aiff</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>aifc</extension>
+        <mime-type>audio/x-aiff</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>aiff</extension>
+        <mime-type>audio/x-aiff</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>aim</extension>
+        <mime-type>application/x-aim</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>air</extension>
+        <mime-type>application/vnd.adobe.air-application-installer-package+zip</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>ait</extension>
+        <mime-type>application/vnd.dvb.ait</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>ami</extension>
+        <mime-type>application/vnd.amiga.ami</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>anx</extension>
+        <mime-type>application/annodex</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>apk</extension>
+        <mime-type>application/vnd.android.package-archive</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>appcache</extension>
+        <mime-type>text/cache-manifest</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>application</extension>
+        <mime-type>application/x-ms-application</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>apr</extension>
+        <mime-type>application/vnd.lotus-approach</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>arc</extension>
+        <mime-type>application/x-freearc</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>art</extension>
+        <mime-type>image/x-jg</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>asc</extension>
+        <mime-type>application/pgp-signature</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>asf</extension>
+        <mime-type>video/x-ms-asf</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>asm</extension>
+        <mime-type>text/x-asm</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>aso</extension>
+        <mime-type>application/vnd.accpac.simply.aso</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>asx</extension>
+        <mime-type>video/x-ms-asf</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>atc</extension>
+        <mime-type>application/vnd.acucorp</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>atom</extension>
+        <mime-type>application/atom+xml</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>atomcat</extension>
+        <mime-type>application/atomcat+xml</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>atomsvc</extension>
+        <mime-type>application/atomsvc+xml</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>atx</extension>
+        <mime-type>application/vnd.antix.game-component</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>au</extension>
+        <mime-type>audio/basic</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>avi</extension>
+        <mime-type>video/x-msvideo</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>avx</extension>
+        <mime-type>video/x-rad-screenplay</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>aw</extension>
+        <mime-type>application/applixware</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>axa</extension>
+        <mime-type>audio/annodex</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>axv</extension>
+        <mime-type>video/annodex</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>azf</extension>
+        <mime-type>application/vnd.airzip.filesecure.azf</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>azs</extension>
+        <mime-type>application/vnd.airzip.filesecure.azs</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>azw</extension>
+        <mime-type>application/vnd.amazon.ebook</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>bat</extension>
+        <mime-type>application/x-msdownload</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>bcpio</extension>
+        <mime-type>application/x-bcpio</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>bdf</extension>
+        <mime-type>application/x-font-bdf</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>bdm</extension>
+        <mime-type>application/vnd.syncml.dm+wbxml</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>bed</extension>
+        <mime-type>application/vnd.realvnc.bed</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>bh2</extension>
+        <mime-type>application/vnd.fujitsu.oasysprs</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>bin</extension>
+        <mime-type>application/octet-stream</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>blb</extension>
+        <mime-type>application/x-blorb</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>blorb</extension>
+        <mime-type>application/x-blorb</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>bmi</extension>
+        <mime-type>application/vnd.bmi</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>bmp</extension>
+        <mime-type>image/bmp</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>body</extension>
+        <mime-type>text/html</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>book</extension>
+        <mime-type>application/vnd.framemaker</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>box</extension>
+        <mime-type>application/vnd.previewsystems.box</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>boz</extension>
+        <mime-type>application/x-bzip2</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>bpk</extension>
+        <mime-type>application/octet-stream</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>btif</extension>
+        <mime-type>image/prs.btif</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>bz</extension>
+        <mime-type>application/x-bzip</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>bz2</extension>
+        <mime-type>application/x-bzip2</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>c</extension>
+        <mime-type>text/x-c</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>c11amc</extension>
+        <mime-type>application/vnd.cluetrust.cartomobile-config</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>c11amz</extension>
+        <mime-type>application/vnd.cluetrust.cartomobile-config-pkg</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>c4d</extension>
+        <mime-type>application/vnd.clonk.c4group</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>c4f</extension>
+        <mime-type>application/vnd.clonk.c4group</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>c4g</extension>
+        <mime-type>application/vnd.clonk.c4group</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>c4p</extension>
+        <mime-type>application/vnd.clonk.c4group</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>c4u</extension>
+        <mime-type>application/vnd.clonk.c4group</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>cab</extension>
+        <mime-type>application/vnd.ms-cab-compressed</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>caf</extension>
+        <mime-type>audio/x-caf</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>cap</extension>
+        <mime-type>application/vnd.tcpdump.pcap</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>car</extension>
+        <mime-type>application/vnd.curl.car</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>cat</extension>
+        <mime-type>application/vnd.ms-pki.seccat</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>cb7</extension>
+        <mime-type>application/x-cbr</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>cba</extension>
+        <mime-type>application/x-cbr</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>cbr</extension>
+        <mime-type>application/x-cbr</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>cbt</extension>
+        <mime-type>application/x-cbr</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>cbz</extension>
+        <mime-type>application/x-cbr</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>cc</extension>
+        <mime-type>text/x-c</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>cct</extension>
+        <mime-type>application/x-director</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>ccxml</extension>
+        <mime-type>application/ccxml+xml</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>cdbcmsg</extension>
+        <mime-type>application/vnd.contact.cmsg</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>cdf</extension>
+        <mime-type>application/x-cdf</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>cdkey</extension>
+        <mime-type>application/vnd.mediastation.cdkey</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>cdmia</extension>
+        <mime-type>application/cdmi-capability</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>cdmic</extension>
+        <mime-type>application/cdmi-container</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>cdmid</extension>
+        <mime-type>application/cdmi-domain</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>cdmio</extension>
+        <mime-type>application/cdmi-object</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>cdmiq</extension>
+        <mime-type>application/cdmi-queue</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>cdx</extension>
+        <mime-type>chemical/x-cdx</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>cdxml</extension>
+        <mime-type>application/vnd.chemdraw+xml</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>cdy</extension>
+        <mime-type>application/vnd.cinderella</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>cer</extension>
+        <mime-type>application/pkix-cert</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>cfs</extension>
+        <mime-type>application/x-cfs-compressed</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>cgm</extension>
+        <mime-type>image/cgm</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>chat</extension>
+        <mime-type>application/x-chat</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>chm</extension>
+        <mime-type>application/vnd.ms-htmlhelp</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>chrt</extension>
+        <mime-type>application/vnd.kde.kchart</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>cif</extension>
+        <mime-type>chemical/x-cif</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>cii</extension>
+        <mime-type>application/vnd.anser-web-certificate-issue-initiation</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>cil</extension>
+        <mime-type>application/vnd.ms-artgalry</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>cla</extension>
+        <mime-type>application/vnd.claymore</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>class</extension>
+        <mime-type>application/java</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>clkk</extension>
+        <mime-type>application/vnd.crick.clicker.keyboard</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>clkp</extension>
+        <mime-type>application/vnd.crick.clicker.palette</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>clkt</extension>
+        <mime-type>application/vnd.crick.clicker.template</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>clkw</extension>
+        <mime-type>application/vnd.crick.clicker.wordbank</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>clkx</extension>
+        <mime-type>application/vnd.crick.clicker</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>clp</extension>
+        <mime-type>application/x-msclip</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>cmc</extension>
+        <mime-type>application/vnd.cosmocaller</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>cmdf</extension>
+        <mime-type>chemical/x-cmdf</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>cml</extension>
+        <mime-type>chemical/x-cml</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>cmp</extension>
+        <mime-type>application/vnd.yellowriver-custom-menu</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>cmx</extension>
+        <mime-type>image/x-cmx</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>cod</extension>
+        <mime-type>application/vnd.rim.cod</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>com</extension>
+        <mime-type>application/x-msdownload</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>conf</extension>
+        <mime-type>text/plain</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>cpio</extension>
+        <mime-type>application/x-cpio</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>cpp</extension>
+        <mime-type>text/x-c</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>cpt</extension>
+        <mime-type>application/mac-compactpro</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>crd</extension>
+        <mime-type>application/x-mscardfile</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>crl</extension>
+        <mime-type>application/pkix-crl</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>crt</extension>
+        <mime-type>application/x-x509-ca-cert</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>cryptonote</extension>
+        <mime-type>application/vnd.rig.cryptonote</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>csh</extension>
+        <mime-type>application/x-csh</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>csml</extension>
+        <mime-type>chemical/x-csml</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>csp</extension>
+        <mime-type>application/vnd.commonspace</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>css</extension>
+        <mime-type>text/css</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>cst</extension>
+        <mime-type>application/x-director</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>csv</extension>
+        <mime-type>text/csv</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>cu</extension>
+        <mime-type>application/cu-seeme</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>curl</extension>
+        <mime-type>text/vnd.curl</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>cww</extension>
+        <mime-type>application/prs.cww</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>cxt</extension>
+        <mime-type>application/x-director</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>cxx</extension>
+        <mime-type>text/x-c</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>dae</extension>
+        <mime-type>model/vnd.collada+xml</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>daf</extension>
+        <mime-type>application/vnd.mobius.daf</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>dart</extension>
+        <mime-type>application/vnd.dart</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>dataless</extension>
+        <mime-type>application/vnd.fdsn.seed</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>davmount</extension>
+        <mime-type>application/davmount+xml</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>dbk</extension>
+        <mime-type>application/docbook+xml</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>dcr</extension>
+        <mime-type>application/x-director</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>dcurl</extension>
+        <mime-type>text/vnd.curl.dcurl</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>dd2</extension>
+        <mime-type>application/vnd.oma.dd2+xml</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>ddd</extension>
+        <mime-type>application/vnd.fujixerox.ddd</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>deb</extension>
+        <mime-type>application/x-debian-package</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>def</extension>
+        <mime-type>text/plain</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>deploy</extension>
+        <mime-type>application/octet-stream</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>der</extension>
+        <mime-type>application/x-x509-ca-cert</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>dfac</extension>
+        <mime-type>application/vnd.dreamfactory</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>dgc</extension>
+        <mime-type>application/x-dgc-compressed</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>dib</extension>
+        <mime-type>image/bmp</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>dic</extension>
+        <mime-type>text/x-c</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>dir</extension>
+        <mime-type>application/x-director</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>dis</extension>
+        <mime-type>application/vnd.mobius.dis</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>dist</extension>
+        <mime-type>application/octet-stream</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>distz</extension>
+        <mime-type>application/octet-stream</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>djv</extension>
+        <mime-type>image/vnd.djvu</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>djvu</extension>
+        <mime-type>image/vnd.djvu</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>dll</extension>
+        <mime-type>application/x-msdownload</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>dmg</extension>
+        <mime-type>application/x-apple-diskimage</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>dmp</extension>
+        <mime-type>application/vnd.tcpdump.pcap</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>dms</extension>
+        <mime-type>application/octet-stream</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>dna</extension>
+        <mime-type>application/vnd.dna</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>doc</extension>
+        <mime-type>application/msword</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>docm</extension>
+        <mime-type>application/vnd.ms-word.document.macroenabled.12</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>docx</extension>
+        <mime-type>application/vnd.openxmlformats-officedocument.wordprocessingml.document</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>dot</extension>
+        <mime-type>application/msword</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>dotm</extension>
+        <mime-type>application/vnd.ms-word.template.macroenabled.12</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>dotx</extension>
+        <mime-type>application/vnd.openxmlformats-officedocument.wordprocessingml.template</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>dp</extension>
+        <mime-type>application/vnd.osgi.dp</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>dpg</extension>
+        <mime-type>application/vnd.dpgraph</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>dra</extension>
+        <mime-type>audio/vnd.dra</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>dsc</extension>
+        <mime-type>text/prs.lines.tag</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>dssc</extension>
+        <mime-type>application/dssc+der</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>dtb</extension>
+        <mime-type>application/x-dtbook+xml</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>dtd</extension>
+        <mime-type>application/xml-dtd</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>dts</extension>
+        <mime-type>audio/vnd.dts</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>dtshd</extension>
+        <mime-type>audio/vnd.dts.hd</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>dump</extension>
+        <mime-type>application/octet-stream</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>dv</extension>
+        <mime-type>video/x-dv</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>dvb</extension>
+        <mime-type>video/vnd.dvb.file</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>dvi</extension>
+        <mime-type>application/x-dvi</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>dwf</extension>
+        <mime-type>model/vnd.dwf</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>dwg</extension>
+        <mime-type>image/vnd.dwg</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>dxf</extension>
+        <mime-type>image/vnd.dxf</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>dxp</extension>
+        <mime-type>application/vnd.spotfire.dxp</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>dxr</extension>
+        <mime-type>application/x-director</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>ecelp4800</extension>
+        <mime-type>audio/vnd.nuera.ecelp4800</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>ecelp7470</extension>
+        <mime-type>audio/vnd.nuera.ecelp7470</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>ecelp9600</extension>
+        <mime-type>audio/vnd.nuera.ecelp9600</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>ecma</extension>
+        <mime-type>application/ecmascript</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>edm</extension>
+        <mime-type>application/vnd.novadigm.edm</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>edx</extension>
+        <mime-type>application/vnd.novadigm.edx</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>efif</extension>
+        <mime-type>application/vnd.picsel</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>ei6</extension>
+        <mime-type>application/vnd.pg.osasli</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>elc</extension>
+        <mime-type>application/octet-stream</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>emf</extension>
+        <mime-type>application/x-msmetafile</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>eml</extension>
+        <mime-type>message/rfc822</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>emma</extension>
+        <mime-type>application/emma+xml</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>emz</extension>
+        <mime-type>application/x-msmetafile</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>eol</extension>
+        <mime-type>audio/vnd.digital-winds</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>eot</extension>
+        <mime-type>application/vnd.ms-fontobject</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>eps</extension>
+        <mime-type>application/postscript</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>epub</extension>
+        <mime-type>application/epub+zip</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>es3</extension>
+        <mime-type>application/vnd.eszigno3+xml</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>esa</extension>
+        <mime-type>application/vnd.osgi.subsystem</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>esf</extension>
+        <mime-type>application/vnd.epson.esf</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>et3</extension>
+        <mime-type>application/vnd.eszigno3+xml</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>etx</extension>
+        <mime-type>text/x-setext</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>eva</extension>
+        <mime-type>application/x-eva</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>evy</extension>
+        <mime-type>application/x-envoy</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>exe</extension>
+        <mime-type>application/octet-stream</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>exi</extension>
+        <mime-type>application/exi</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>ext</extension>
+        <mime-type>application/vnd.novadigm.ext</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>ez</extension>
+        <mime-type>application/andrew-inset</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>ez2</extension>
+        <mime-type>application/vnd.ezpix-album</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>ez3</extension>
+        <mime-type>application/vnd.ezpix-package</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>f</extension>
+        <mime-type>text/x-fortran</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>f4v</extension>
+        <mime-type>video/x-f4v</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>f77</extension>
+        <mime-type>text/x-fortran</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>f90</extension>
+        <mime-type>text/x-fortran</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>fbs</extension>
+        <mime-type>image/vnd.fastbidsheet</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>fcdt</extension>
+        <mime-type>application/vnd.adobe.formscentral.fcdt</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>fcs</extension>
+        <mime-type>application/vnd.isac.fcs</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>fdf</extension>
+        <mime-type>application/vnd.fdf</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>fe_launch</extension>
+        <mime-type>application/vnd.denovo.fcselayout-link</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>fg5</extension>
+        <mime-type>application/vnd.fujitsu.oasysgp</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>fgd</extension>
+        <mime-type>application/x-director</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>fh</extension>
+        <mime-type>image/x-freehand</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>fh4</extension>
+        <mime-type>image/x-freehand</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>fh5</extension>
+        <mime-type>image/x-freehand</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>fh7</extension>
+        <mime-type>image/x-freehand</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>fhc</extension>
+        <mime-type>image/x-freehand</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>fig</extension>
+        <mime-type>application/x-xfig</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>flac</extension>
+        <mime-type>audio/flac</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>fli</extension>
+        <mime-type>video/x-fli</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>flo</extension>
+        <mime-type>application/vnd.micrografx.flo</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>flv</extension>
+        <mime-type>video/x-flv</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>flw</extension>
+        <mime-type>application/vnd.kde.kivio</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>flx</extension>
+        <mime-type>text/vnd.fmi.flexstor</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>fly</extension>
+        <mime-type>text/vnd.fly</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>fm</extension>
+        <mime-type>application/vnd.framemaker</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>fnc</extension>
+        <mime-type>application/vnd.frogans.fnc</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>for</extension>
+        <mime-type>text/x-fortran</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>fpx</extension>
+        <mime-type>image/vnd.fpx</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>frame</extension>
+        <mime-type>application/vnd.framemaker</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>fsc</extension>
+        <mime-type>application/vnd.fsc.weblaunch</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>fst</extension>
+        <mime-type>image/vnd.fst</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>ftc</extension>
+        <mime-type>application/vnd.fluxtime.clip</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>fti</extension>
+        <mime-type>application/vnd.anser-web-funds-transfer-initiation</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>fvt</extension>
+        <mime-type>video/vnd.fvt</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>fxp</extension>
+        <mime-type>application/vnd.adobe.fxp</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>fxpl</extension>
+        <mime-type>application/vnd.adobe.fxp</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>fzs</extension>
+        <mime-type>application/vnd.fuzzysheet</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>g2w</extension>
+        <mime-type>application/vnd.geoplan</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>g3</extension>
+        <mime-type>image/g3fax</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>g3w</extension>
+        <mime-type>application/vnd.geospace</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>gac</extension>
+        <mime-type>application/vnd.groove-account</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>gam</extension>
+        <mime-type>application/x-tads</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>gbr</extension>
+        <mime-type>application/rpki-ghostbusters</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>gca</extension>
+        <mime-type>application/x-gca-compressed</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>gdl</extension>
+        <mime-type>model/vnd.gdl</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>geo</extension>
+        <mime-type>application/vnd.dynageo</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>gex</extension>
+        <mime-type>application/vnd.geometry-explorer</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>ggb</extension>
+        <mime-type>application/vnd.geogebra.file</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>ggt</extension>
+        <mime-type>application/vnd.geogebra.tool</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>ghf</extension>
+        <mime-type>application/vnd.groove-help</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>gif</extension>
+        <mime-type>image/gif</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>gim</extension>
+        <mime-type>application/vnd.groove-identity-message</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>gml</extension>
+        <mime-type>application/gml+xml</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>gmx</extension>
+        <mime-type>application/vnd.gmx</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>gnumeric</extension>
+        <mime-type>application/x-gnumeric</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>gph</extension>
+        <mime-type>application/vnd.flographit</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>gpx</extension>
+        <mime-type>application/gpx+xml</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>gqf</extension>
+        <mime-type>application/vnd.grafeq</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>gqs</extension>
+        <mime-type>application/vnd.grafeq</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>gram</extension>
+        <mime-type>application/srgs</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>gramps</extension>
+        <mime-type>application/x-gramps-xml</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>gre</extension>
+        <mime-type>application/vnd.geometry-explorer</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>grv</extension>
+        <mime-type>application/vnd.groove-injector</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>grxml</extension>
+        <mime-type>application/srgs+xml</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>gsf</extension>
+        <mime-type>application/x-font-ghostscript</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>gtar</extension>
+        <mime-type>application/x-gtar</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>gtm</extension>
+        <mime-type>application/vnd.groove-tool-message</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>gtw</extension>
+        <mime-type>model/vnd.gtw</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>gv</extension>
+        <mime-type>text/vnd.graphviz</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>gxf</extension>
+        <mime-type>application/gxf</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>gxt</extension>
+        <mime-type>application/vnd.geonext</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>gz</extension>
+        <mime-type>application/x-gzip</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>h</extension>
+        <mime-type>text/x-c</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>h261</extension>
+        <mime-type>video/h261</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>h263</extension>
+        <mime-type>video/h263</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>h264</extension>
+        <mime-type>video/h264</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>hal</extension>
+        <mime-type>application/vnd.hal+xml</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>hbci</extension>
+        <mime-type>application/vnd.hbci</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>hdf</extension>
+        <mime-type>application/x-hdf</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>hh</extension>
+        <mime-type>text/x-c</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>hlp</extension>
+        <mime-type>application/winhlp</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>hpgl</extension>
+        <mime-type>application/vnd.hp-hpgl</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>hpid</extension>
+        <mime-type>application/vnd.hp-hpid</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>hps</extension>
+        <mime-type>application/vnd.hp-hps</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>hqx</extension>
+        <mime-type>application/mac-binhex40</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>htc</extension>
+        <mime-type>text/x-component</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>htke</extension>
+        <mime-type>application/vnd.kenameaapp</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>htm</extension>
+        <mime-type>text/html</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>html</extension>
+        <mime-type>text/html</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>hvd</extension>
+        <mime-type>application/vnd.yamaha.hv-dic</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>hvp</extension>
+        <mime-type>application/vnd.yamaha.hv-voice</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>hvs</extension>
+        <mime-type>application/vnd.yamaha.hv-script</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>i2g</extension>
+        <mime-type>application/vnd.intergeo</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>icc</extension>
+        <mime-type>application/vnd.iccprofile</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>ice</extension>
+        <mime-type>x-conference/x-cooltalk</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>icm</extension>
+        <mime-type>application/vnd.iccprofile</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>ico</extension>
+        <mime-type>image/x-icon</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>ics</extension>
+        <mime-type>text/calendar</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>ief</extension>
+        <mime-type>image/ief</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>ifb</extension>
+        <mime-type>text/calendar</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>ifm</extension>
+        <mime-type>application/vnd.shana.informed.formdata</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>iges</extension>
+        <mime-type>model/iges</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>igl</extension>
+        <mime-type>application/vnd.igloader</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>igm</extension>
+        <mime-type>application/vnd.insors.igm</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>igs</extension>
+        <mime-type>model/iges</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>igx</extension>
+        <mime-type>application/vnd.micrografx.igx</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>iif</extension>
+        <mime-type>application/vnd.shana.informed.interchange</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>imp</extension>
+        <mime-type>application/vnd.accpac.simply.imp</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>ims</extension>
+        <mime-type>application/vnd.ms-ims</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>in</extension>
+        <mime-type>text/plain</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>ink</extension>
+        <mime-type>application/inkml+xml</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>inkml</extension>
+        <mime-type>application/inkml+xml</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>install</extension>
+        <mime-type>application/x-install-instructions</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>iota</extension>
+        <mime-type>application/vnd.astraea-software.iota</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>ipfix</extension>
+        <mime-type>application/ipfix</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>ipk</extension>
+        <mime-type>application/vnd.shana.informed.package</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>irm</extension>
+        <mime-type>application/vnd.ibm.rights-management</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>irp</extension>
+        <mime-type>application/vnd.irepository.package+xml</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>iso</extension>
+        <mime-type>application/x-iso9660-image</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>itp</extension>
+        <mime-type>application/vnd.shana.informed.formtemplate</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>ivp</extension>
+        <mime-type>application/vnd.immervision-ivp</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>ivu</extension>
+        <mime-type>application/vnd.immervision-ivu</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>jad</extension>
+        <mime-type>text/vnd.sun.j2me.app-descriptor</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>jam</extension>
+        <mime-type>application/vnd.jam</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>jar</extension>
+        <mime-type>application/java-archive</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>java</extension>
+        <mime-type>text/x-java-source</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>jisp</extension>
+        <mime-type>application/vnd.jisp</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>jlt</extension>
+        <mime-type>application/vnd.hp-jlyt</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>jnlp</extension>
+        <mime-type>application/x-java-jnlp-file</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>joda</extension>
+        <mime-type>application/vnd.joost.joda-archive</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>jpe</extension>
+        <mime-type>image/jpeg</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>jpeg</extension>
+        <mime-type>image/jpeg</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>jpg</extension>
+        <mime-type>image/jpeg</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>jpgm</extension>
+        <mime-type>video/jpm</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>jpgv</extension>
+        <mime-type>video/jpeg</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>jpm</extension>
+        <mime-type>video/jpm</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>js</extension>
+        <mime-type>application/javascript</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>jsf</extension>
+        <mime-type>text/plain</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>json</extension>
+        <mime-type>application/json</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>jsonml</extension>
+        <mime-type>application/jsonml+json</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>jspf</extension>
+        <mime-type>text/plain</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>kar</extension>
+        <mime-type>audio/midi</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>karbon</extension>
+        <mime-type>application/vnd.kde.karbon</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>kfo</extension>
+        <mime-type>application/vnd.kde.kformula</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>kia</extension>
+        <mime-type>application/vnd.kidspiration</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>kml</extension>
+        <mime-type>application/vnd.google-earth.kml+xml</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>kmz</extension>
+        <mime-type>application/vnd.google-earth.kmz</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>kne</extension>
+        <mime-type>application/vnd.kinar</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>knp</extension>
+        <mime-type>application/vnd.kinar</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>kon</extension>
+        <mime-type>application/vnd.kde.kontour</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>kpr</extension>
+        <mime-type>application/vnd.kde.kpresenter</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>kpt</extension>
+        <mime-type>application/vnd.kde.kpresenter</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>kpxx</extension>
+        <mime-type>application/vnd.ds-keypoint</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>ksp</extension>
+        <mime-type>application/vnd.kde.kspread</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>ktr</extension>
+        <mime-type>application/vnd.kahootz</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>ktx</extension>
+        <mime-type>image/ktx</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>ktz</extension>
+        <mime-type>application/vnd.kahootz</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>kwd</extension>
+        <mime-type>application/vnd.kde.kword</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>kwt</extension>
+        <mime-type>application/vnd.kde.kword</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>lasxml</extension>
+        <mime-type>application/vnd.las.las+xml</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>latex</extension>
+        <mime-type>application/x-latex</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>lbd</extension>
+        <mime-type>application/vnd.llamagraphics.life-balance.desktop</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>lbe</extension>
+        <mime-type>application/vnd.llamagraphics.life-balance.exchange+xml</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>les</extension>
+        <mime-type>application/vnd.hhe.lesson-player</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>lha</extension>
+        <mime-type>application/x-lzh-compressed</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>link66</extension>
+        <mime-type>application/vnd.route66.link66+xml</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>list</extension>
+        <mime-type>text/plain</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>list3820</extension>
+        <mime-type>application/vnd.ibm.modcap</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>listafp</extension>
+        <mime-type>application/vnd.ibm.modcap</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>lnk</extension>
+        <mime-type>application/x-ms-shortcut</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>log</extension>
+        <mime-type>text/plain</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>lostxml</extension>
+        <mime-type>application/lost+xml</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>lrf</extension>
+        <mime-type>application/octet-stream</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>lrm</extension>
+        <mime-type>application/vnd.ms-lrm</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>ltf</extension>
+        <mime-type>application/vnd.frogans.ltf</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>lvp</extension>
+        <mime-type>audio/vnd.lucent.voice</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>lwp</extension>
+        <mime-type>application/vnd.lotus-wordpro</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>lzh</extension>
+        <mime-type>application/x-lzh-compressed</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>m13</extension>
+        <mime-type>application/x-msmediaview</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>m14</extension>
+        <mime-type>application/x-msmediaview</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>m1v</extension>
+        <mime-type>video/mpeg</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>m21</extension>
+        <mime-type>application/mp21</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>m2a</extension>
+        <mime-type>audio/mpeg</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>m2v</extension>
+        <mime-type>video/mpeg</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>m3a</extension>
+        <mime-type>audio/mpeg</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>m3u</extension>
+        <mime-type>audio/x-mpegurl</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>m3u8</extension>
+        <mime-type>application/vnd.apple.mpegurl</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>m4a</extension>
+        <mime-type>audio/mp4</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>m4b</extension>
+        <mime-type>audio/mp4</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>m4r</extension>
+        <mime-type>audio/mp4</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>m4u</extension>
+        <mime-type>video/vnd.mpegurl</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>m4v</extension>
+        <mime-type>video/mp4</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>ma</extension>
+        <mime-type>application/mathematica</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>mac</extension>
+        <mime-type>image/x-macpaint</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>mads</extension>
+        <mime-type>application/mads+xml</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>mag</extension>
+        <mime-type>application/vnd.ecowin.chart</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>maker</extension>
+        <mime-type>application/vnd.framemaker</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>man</extension>
+        <mime-type>text/troff</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>mar</extension>
+        <mime-type>application/octet-stream</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>mathml</extension>
+        <mime-type>application/mathml+xml</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>mb</extension>
+        <mime-type>application/mathematica</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>mbk</extension>
+        <mime-type>application/vnd.mobius.mbk</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>mbox</extension>
+        <mime-type>application/mbox</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>mc1</extension>
+        <mime-type>application/vnd.medcalcdata</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>mcd</extension>
+        <mime-type>application/vnd.mcd</mime-type>
+    </mime-mapping>
+    <mime-mapping>
+        <extension>mcurl</extension>
+        <mime-type>text/vnd.curl.mcurl</mime-type>
+    </

<TRUNCATED>

[33/50] [abbrv] incubator-usergrid git commit: Add jackson-xc back in.

Posted by sn...@apache.org.
Add jackson-xc back in.


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

Branch: refs/heads/two-dot-o
Commit: fe5ea330fdeb563b8ddc06bb22eafa1a46617498
Parents: f20c353
Author: Dave Johnson <dm...@apigee.com>
Authored: Wed Feb 25 10:07:14 2015 -0500
Committer: Dave Johnson <dm...@apigee.com>
Committed: Wed Feb 25 10:07:14 2015 -0500

----------------------------------------------------------------------
 stack/rest/pom.xml                              | 41 +++++++-------------
 .../resources/usergrid-rest-deploy-context.xml  |  2 +-
 .../org/apache/usergrid/rest/SimplestTest.java  | 35 +++++++++++++++++
 .../org/apache/usergrid/rest/TomcatRuntime.java |  4 +-
 4 files changed, 53 insertions(+), 29 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/fe5ea330/stack/rest/pom.xml
----------------------------------------------------------------------
diff --git a/stack/rest/pom.xml b/stack/rest/pom.xml
index 70072d9..3a6c0de 100644
--- a/stack/rest/pom.xml
+++ b/stack/rest/pom.xml
@@ -105,29 +105,12 @@
                     <forkCount>1</forkCount>
                     <threadCount>${usergrid.rest.threads}</threadCount>
                     <reuseForks>true</reuseForks>
-                    <argLine>-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 ${ug.argline}
                     </argLine>
                     <includes>
-
                         <include>**/*IT.java</include>
                         <include>**/*Test.java</include>
-
-                        <!-- how many tests can we run before Tomcat JVM throws OOM / PermGen exceptions -->
-
-                        <!--<include>**/org/apache/usergrid/rest/BasicIT.java</include>-->
-                        <!--<include>**/org/apache/usergrid/rest/PartialUpdateTest.java</include>-->
-                        <!--<include>**/org/apache/usergrid/rest/applications/collection/**/CollectionsResourceIT.java</include>-->
-
-                        <!--<include>**/org/apache/usergrid/rest/*IT.java</include>-->
-                        <!--<include>**/org/apache/usergrid/rest/*Test.java</include>-->
-
-                        <!--<include>**/org/apache/usergrid/rest/management/**/*IT.java</include>-->
-                        <!--<include>**/org/apache/usergrid/rest/management/**/*Test.java</include>-->
-
-                        <!--<include>**/org/apache/usergrid/rest/applications/collection/**/*IT.java</include>-->
-                        <!--<include>**/org/apache/usergrid/rest/applications/collection/**/*Test.java</include>-->
-
-                    </includes>
+                   </includes>
 
                 </configuration>
 
@@ -358,6 +341,12 @@
             <groupId>org.jvnet.mock-javamail</groupId>
             <artifactId>mock-javamail</artifactId>
             <scope>test</scope>
+            <exclusions>
+                <exclusion>
+                    <artifactId>mail</artifactId>
+                    <groupId>javax.mail</groupId>
+                </exclusion>
+            </exclusions>
         </dependency>
 
         <dependency>
@@ -366,14 +355,14 @@
             <scope>test</scope>
         </dependency>
 
-        <!-- Arquillian deps -->
+        <dependency>
+            <groupId>org.codehaus.jackson</groupId>
+            <artifactId>jackson-xc</artifactId>
+            <version>${jackson-version}</version>
+            <scope>test</scope>
+        </dependency>
 
-        <!--<dependency>-->
-            <!--<groupId>org.codehaus.jackson</groupId>-->
-            <!--<artifactId>jackson-xc</artifactId>-->
-            <!--<version>${jackson-version}</version>-->
-            <!--<scope>test</scope>-->
-        <!--</dependency>-->
+        <!-- Arquillian deps -->
 
         <!--<dependency>-->
             <!--<groupId>org.jboss.arquillian</groupId>-->

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/fe5ea330/stack/rest/src/main/resources/usergrid-rest-deploy-context.xml
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/resources/usergrid-rest-deploy-context.xml b/stack/rest/src/main/resources/usergrid-rest-deploy-context.xml
index d240231..9965dbc 100644
--- a/stack/rest/src/main/resources/usergrid-rest-deploy-context.xml
+++ b/stack/rest/src/main/resources/usergrid-rest-deploy-context.xml
@@ -33,7 +33,7 @@
 		<property name="locations">
 			<list>
 				<value>classpath:/usergrid-default.properties</value>
-                <value>classpath:/usergrid-deployment.properties</value>
+                <value>${usergrid-custom-spring-properties}</value>
 			</list>
 		</property>
 	</bean>

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/fe5ea330/stack/rest/src/test/java/org/apache/usergrid/rest/SimplestTest.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/SimplestTest.java b/stack/rest/src/test/java/org/apache/usergrid/rest/SimplestTest.java
new file mode 100644
index 0000000..6703c1b
--- /dev/null
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/SimplestTest.java
@@ -0,0 +1,35 @@
+/*
+ * 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 org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import static org.junit.Assert.assertNotNull;
+
+/**
+ * Simplest test verifies if REST test infrastructure is functioning.
+ */
+public class SimplestTest extends org.apache.usergrid.rest.test.resource2point0.AbstractRestIT {
+    private static final Logger log = LoggerFactory.getLogger(SimplestTest.class);
+
+    @Test
+    public void getGetToken() {
+        assertNotNull( getAdminToken() );
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/fe5ea330/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 ab22450..498068a 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
@@ -42,7 +42,7 @@ public class TomcatRuntime extends ExternalResource {
     private static final Logger log = LoggerFactory.getLogger( TomcatRuntime.class );
 
 
-    private static final String WEBAPPS_PATH = "src/main/webapp";
+    private static final String WEBAPP_PATH = System.getProperty("webapp.directory");
 
     private static TomcatRuntime instance;
 
@@ -54,7 +54,7 @@ public class TomcatRuntime extends ExternalResource {
         //before we run tomcat, we need to cleanup our data
         ConcurrentProcessSingleton.getInstance();
 
-        tomcat = new TomcatInstance( WEBAPPS_PATH );
+        tomcat = new TomcatInstance( WEBAPP_PATH );
         tomcat.startTomcat();
 
         //stop on JVM shutdown


[36/50] [abbrv] incubator-usergrid git commit: Removed all instances of virtual keyspaces

Posted by sn...@apache.org.
Removed all instances of virtual keyspaces


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

Branch: refs/heads/two-dot-o
Commit: 4be53fb105150222cfdb2cb9b6e18186a3fb2058
Parents: 35bae26
Author: grey <gr...@apigee.com>
Authored: Wed Feb 25 08:03:17 2015 -0800
Committer: grey <gr...@apigee.com>
Committed: Wed Feb 25 08:03:17 2015 -0800

----------------------------------------------------------------------
 .../usergrid/corepersistence/CpSetup.java       | 34 ++++++++----------
 .../persistence/cassandra/CassandraService.java | 20 +----------
 .../persistence/cassandra/SetupImpl.java        | 38 +++++++++-----------
 .../cassandra/EntityManagerFactoryImplIT.java   |  6 ----
 4 files changed, 31 insertions(+), 67 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/4be53fb1/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpSetup.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpSetup.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpSetup.java
index c71c172..345473a 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpSetup.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpSetup.java
@@ -46,7 +46,6 @@ import static org.apache.usergrid.persistence.cassandra.CassandraService.MANAGEM
 import static org.apache.usergrid.persistence.cassandra.CassandraService.PRINCIPAL_TOKEN_CF;
 import static org.apache.usergrid.persistence.cassandra.CassandraService.PROPERTIES_CF;
 import static org.apache.usergrid.persistence.cassandra.CassandraService.TOKENS_CF;
-import static org.apache.usergrid.persistence.cassandra.CassandraService.USE_VIRTUAL_KEYSPACES;
 import static org.apache.usergrid.persistence.cassandra.CassandraService.getApplicationKeyspace;
 import static org.apache.usergrid.persistence.cassandra.CassandraService.keyspaceForApplication;
 
@@ -176,19 +175,16 @@ public class CpSetup implements Setup {
 
         // Need this legacy stuff for queues
 
-        if ( !USE_VIRTUAL_KEYSPACES ) {
+        String app_keyspace = keyspaceForApplication( applicationId );
 
-            String app_keyspace = keyspaceForApplication( applicationId );
+        logger.info( "Creating application keyspace " + app_keyspace + " for " + applicationName + " application" );
 
-            logger.info( "Creating application keyspace " + app_keyspace + " for " + applicationName + " application" );
-
-            cass.createColumnFamily( app_keyspace,
-                createColumnFamilyDefinition( getApplicationKeyspace(), APPLICATIONS_CF, ComparatorType.BYTESTYPE ) );
+        cass.createColumnFamily( app_keyspace,
+            createColumnFamilyDefinition( getApplicationKeyspace(), APPLICATIONS_CF, ComparatorType.BYTESTYPE ) );
 
-            cass.createColumnFamilies( app_keyspace, getCfDefs( ApplicationCF.class, app_keyspace ) );
+        cass.createColumnFamilies( app_keyspace, getCfDefs( ApplicationCF.class, app_keyspace ) );
 
-            cass.createColumnFamilies( app_keyspace, getCfDefs( QueuesCF.class, app_keyspace ) );
-        }
+        cass.createColumnFamilies( app_keyspace, getCfDefs( QueuesCF.class, app_keyspace ) );
     }
 
 
@@ -199,20 +195,18 @@ public class CpSetup implements Setup {
 
         // Need this legacy stuff for queues
 
-        if ( USE_VIRTUAL_KEYSPACES ) {
+        logger.info( "Creating static application keyspace " + getApplicationKeyspace() );
 
-            logger.info( "Creating static application keyspace " + getApplicationKeyspace() );
+        cass.createColumnFamily( getApplicationKeyspace(),
+            createColumnFamilyDefinition( getApplicationKeyspace(), APPLICATIONS_CF,
+                ComparatorType.BYTESTYPE ) );
 
-            cass.createColumnFamily( getApplicationKeyspace(),
-                createColumnFamilyDefinition( getApplicationKeyspace(), APPLICATIONS_CF,
-                    ComparatorType.BYTESTYPE ) );
+        cass.createColumnFamilies( getApplicationKeyspace(),
+            getCfDefs( ApplicationCF.class, getApplicationKeyspace() ) );
 
-            cass.createColumnFamilies( getApplicationKeyspace(),
-                getCfDefs( ApplicationCF.class, getApplicationKeyspace() ) );
+        cass.createColumnFamilies( getApplicationKeyspace(),
+            getCfDefs( QueuesCF.class, getApplicationKeyspace() ) );
 
-            cass.createColumnFamilies( getApplicationKeyspace(),
-                getCfDefs( QueuesCF.class, getApplicationKeyspace() ) );
-        }
     }
 
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/4be53fb1/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/CassandraService.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/CassandraService.java b/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/CassandraService.java
index 2c74e77..38d9555 100644
--- a/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/CassandraService.java
+++ b/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/CassandraService.java
@@ -97,7 +97,6 @@ public class CassandraService {
    // public static String SYSTEM_KEYSPACE = "Usergrid";
 
     public static String applicationKeyspace;
-    public static final boolean USE_VIRTUAL_KEYSPACES = true;
 
     public static final String APPLICATIONS_CF = "Applications";
     public static final String PROPERTIES_CF = "Properties";
@@ -238,35 +237,18 @@ public class CassandraService {
 
     /** @return keyspace for application UUID */
     public static String keyspaceForApplication( UUID applicationId ) {
-        if ( USE_VIRTUAL_KEYSPACES ) {
             return getApplicationKeyspace();
-        }
-        else {
-            return "Application_" + applicationId.toString().replace( '-', '_' );
-        }
     }
 
 
     public static UUID prefixForApplication( UUID applicationId ) {
-        if ( USE_VIRTUAL_KEYSPACES ) {
             return applicationId;
-        }
-        else {
-            return null;
-        }
     }
 
 
     public Keyspace getKeyspace( String keyspace, UUID prefix ) {
-        Keyspace ko = null;
-        if ( USE_VIRTUAL_KEYSPACES && ( prefix != null ) ) {
-            ko = createVirtualKeyspace( keyspace, prefix, ue, cluster, consistencyLevelPolicy,
+        Keyspace ko = createVirtualKeyspace( keyspace, prefix, ue, cluster, consistencyLevelPolicy,
                     ON_FAIL_TRY_ALL_AVAILABLE, accessMap );
-        }
-        else {
-            ko = HFactory.createKeyspace( keyspace, cluster, consistencyLevelPolicy, ON_FAIL_TRY_ALL_AVAILABLE,
-                    accessMap );
-        }
         return ko;
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/4be53fb1/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/SetupImpl.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/SetupImpl.java b/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/SetupImpl.java
index 775f43b..e6c52bd 100644
--- a/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/SetupImpl.java
+++ b/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/SetupImpl.java
@@ -30,7 +30,6 @@ import static org.apache.usergrid.persistence.cassandra.CassandraService.MANAGEM
 import static org.apache.usergrid.persistence.cassandra.CassandraService.PRINCIPAL_TOKEN_CF;
 import static org.apache.usergrid.persistence.cassandra.CassandraService.PROPERTIES_CF;
 import static org.apache.usergrid.persistence.cassandra.CassandraService.TOKENS_CF;
-import static org.apache.usergrid.persistence.cassandra.CassandraService.USE_VIRTUAL_KEYSPACES;
 import static org.apache.usergrid.persistence.cassandra.CassandraService.getApplicationKeyspace;
 import static org.apache.usergrid.persistence.cassandra.CassandraService.keyspaceForApplication;
 import org.apache.usergrid.persistence.entities.Application;
@@ -104,39 +103,34 @@ public class SetupImpl implements Setup {
      * @throws Exception the exception
      */
     @Override
-    public void setupApplicationKeyspace(
-            final UUID applicationId, String applicationName ) throws Exception {
+    public void setupApplicationKeyspace(final UUID applicationId, String applicationName ) throws Exception {
 
-        if ( !USE_VIRTUAL_KEYSPACES ) {
-            String app_keyspace = keyspaceForApplication( applicationId );
+        String app_keyspace = keyspaceForApplication( applicationId );
 
-            logger.info( "Creating application keyspace " + app_keyspace + " for "
-                    + applicationName + " application" );
+        logger.info( "Creating application keyspace " + app_keyspace + " for "
+                + applicationName + " application" );
 
-            cass.createColumnFamily( app_keyspace, createColumnFamilyDefinition(
-                    getApplicationKeyspace(), APPLICATIONS_CF, ComparatorType.BYTESTYPE ) );
+        cass.createColumnFamily( app_keyspace, createColumnFamilyDefinition(
+                getApplicationKeyspace(), APPLICATIONS_CF, ComparatorType.BYTESTYPE ) );
 
-            cass.createColumnFamilies( app_keyspace, getCfDefs( ApplicationCF.class, app_keyspace));
-            cass.createColumnFamilies( app_keyspace, getCfDefs( QueuesCF.class, app_keyspace ) );
-        }
+        cass.createColumnFamilies( app_keyspace, getCfDefs( ApplicationCF.class, app_keyspace));
+        cass.createColumnFamilies( app_keyspace, getCfDefs( QueuesCF.class, app_keyspace ) );
     }
 
 
     public void setupStaticKeyspace() throws Exception {
 
-        if ( USE_VIRTUAL_KEYSPACES ) {
 
-            logger.info( "Creating static application keyspace " + getApplicationKeyspace() );
+        logger.info( "Creating static application keyspace " + getApplicationKeyspace() );
 
-            cass.createColumnFamily( getApplicationKeyspace(),
-                    createColumnFamilyDefinition( getApplicationKeyspace(), APPLICATIONS_CF,
-                            ComparatorType.BYTESTYPE ) );
+        cass.createColumnFamily( getApplicationKeyspace(),
+                createColumnFamilyDefinition( getApplicationKeyspace(), APPLICATIONS_CF,
+                        ComparatorType.BYTESTYPE ) );
 
-            cass.createColumnFamilies( getApplicationKeyspace(),
-                    getCfDefs( ApplicationCF.class, getApplicationKeyspace() ) );
-            cass.createColumnFamilies( getApplicationKeyspace(),
-                    getCfDefs( QueuesCF.class, getApplicationKeyspace() ) );
-        }
+        cass.createColumnFamilies( getApplicationKeyspace(),
+                getCfDefs( ApplicationCF.class, getApplicationKeyspace() ) );
+        cass.createColumnFamilies( getApplicationKeyspace(),
+                getCfDefs( QueuesCF.class, getApplicationKeyspace() ) );
     }
 
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/4be53fb1/stack/core/src/test/java/org/apache/usergrid/persistence/cassandra/EntityManagerFactoryImplIT.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/cassandra/EntityManagerFactoryImplIT.java b/stack/core/src/test/java/org/apache/usergrid/persistence/cassandra/EntityManagerFactoryImplIT.java
index 850ac6b..3c22d03 100644
--- a/stack/core/src/test/java/org/apache/usergrid/persistence/cassandra/EntityManagerFactoryImplIT.java
+++ b/stack/core/src/test/java/org/apache/usergrid/persistence/cassandra/EntityManagerFactoryImplIT.java
@@ -50,9 +50,6 @@ import static org.junit.Assert.assertTrue;
 
 public class EntityManagerFactoryImplIT extends AbstractCoreIT {
 
-    @SuppressWarnings("PointlessBooleanExpression")
-    public static final boolean USE_DEFAULT_DOMAIN = !CassandraService.USE_VIRTUAL_KEYSPACES;
-
     private static final Logger logger = LoggerFactory.getLogger( EntityManagerFactoryImplIT.class );
 
 
@@ -80,9 +77,6 @@ public class EntityManagerFactoryImplIT extends AbstractCoreIT {
 
 
     public UUID createApplication( String organizationName, String applicationName ) throws Exception {
-        if ( USE_DEFAULT_DOMAIN ) {
-            return emf.getDefaultAppId();
-        }
         return emf.createApplication( organizationName, applicationName );
     }
 


[34/50] [abbrv] incubator-usergrid git commit: Simple REST tests now working again with Tomcat embedded.

Posted by sn...@apache.org.
Simple REST tests now working again with Tomcat embedded.


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

Branch: refs/heads/two-dot-o
Commit: d1880e6ecfe7e2a3198dec5834e815df810fb7b1
Parents: fe5ea33
Author: Dave Johnson <dm...@apigee.com>
Authored: Wed Feb 25 10:38:57 2015 -0500
Committer: Dave Johnson <dm...@apigee.com>
Committed: Wed Feb 25 10:38:57 2015 -0500

----------------------------------------------------------------------
 stack/pom.xml                                   |  1 +
 stack/rest/pom.xml                              |  1 -
 .../resources/usergrid-rest-deploy-context.xml  | 26 ++++++++++++++++++++
 3 files changed, 27 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/d1880e6e/stack/pom.xml
----------------------------------------------------------------------
diff --git a/stack/pom.xml b/stack/pom.xml
index 8545e88..828ea45 100644
--- a/stack/pom.xml
+++ b/stack/pom.xml
@@ -89,6 +89,7 @@
       <ug.heapmin>2048m</ug.heapmin>
   	  <ug.argline>-Djava.awt.headless=true</ug.argline>
 
+      <usergrid-custom-spring-properties>classpath:/usergrid-deployment.properties</usergrid-custom-spring-properties>
       <usergrid-custom-spring-test-properties>classpath:/usergrid-custom-test.properties</usergrid-custom-spring-test-properties>
 
       <!-- =================================================================== -->

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/d1880e6e/stack/rest/pom.xml
----------------------------------------------------------------------
diff --git a/stack/rest/pom.xml b/stack/rest/pom.xml
index 3a6c0de..927b7f2 100644
--- a/stack/rest/pom.xml
+++ b/stack/rest/pom.xml
@@ -37,7 +37,6 @@
         <catalina.jmx.port>8089</catalina.jmx.port>
     </properties>
 
-
     <!-- profile that arquillian uses when it builds/starts tomcat -->
     <profiles>
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/d1880e6e/stack/rest/src/test/resources/usergrid-rest-deploy-context.xml
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/resources/usergrid-rest-deploy-context.xml b/stack/rest/src/test/resources/usergrid-rest-deploy-context.xml
new file mode 100644
index 0000000..06d5de4
--- /dev/null
+++ b/stack/rest/src/test/resources/usergrid-rest-deploy-context.xml
@@ -0,0 +1,26 @@
+<?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">
+
+    <import resource="classpath:/usergrid-test-context.xml" />
+
+</beans>


[26/50] [abbrv] incubator-usergrid git commit: Merge branch 'USERGRID-273' of https://git-wip-us.apache.org/repos/asf/incubator-usergrid into USERGRID-273

Posted by sn...@apache.org.
Merge branch 'USERGRID-273' of https://git-wip-us.apache.org/repos/asf/incubator-usergrid into USERGRID-273

Conflicts:
	stack/rest/pom.xml


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

Branch: refs/heads/two-dot-o
Commit: 99d694b87ed85b515ac77f929eee034e92ac4560
Parents: ec8e666 b82999e
Author: Dave Johnson <dm...@apigee.com>
Authored: Tue Feb 24 15:17:18 2015 -0500
Committer: Dave Johnson <dm...@apigee.com>
Committed: Tue Feb 24 15:17:18 2015 -0500

----------------------------------------------------------------------

----------------------------------------------------------------------



[32/50] [abbrv] incubator-usergrid git commit: Add jackson-xc back in.

Posted by sn...@apache.org.
Add jackson-xc back in.


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

Branch: refs/heads/two-dot-o
Commit: f20c3532e9ebad5d613da30b338168d1e25fac43
Parents: ba7a11a
Author: Dave Johnson <dm...@apigee.com>
Authored: Wed Feb 25 10:00:30 2015 -0500
Committer: Dave Johnson <dm...@apigee.com>
Committed: Wed Feb 25 10:00:30 2015 -0500

----------------------------------------------------------------------
 .../resources/usergrid-deployment.properties    | 111 -------------------
 1 file changed, 111 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/f20c3532/stack/rest/src/test/resources/usergrid-deployment.properties
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/resources/usergrid-deployment.properties b/stack/rest/src/test/resources/usergrid-deployment.properties
deleted file mode 100644
index 34b0aa7..0000000
--- a/stack/rest/src/test/resources/usergrid-deployment.properties
+++ /dev/null
@@ -1,111 +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.
-#
-
-######################################################
-# Minimal Usergrid configuration properties for local Tomcat and Cassandra
-
-usergrid.test=true
-
-cassandra.url=localhost:9160
-cassandra.cluster=usergrid
-cassandra.keyspace.strategy=org.apache.cassandra.locator.SimpleStrategy
-cassandra.keyspace.replication=replication_factor:1
-#cassandra.keyspace.strategy=org.apache.cassandra.locator.NetworkTopologyStrategy
-#cassandra.keyspace.replication=us-east:3
-
-cassandra.timeout=5000
-cassandra.connections=10
-cassandra.discovery=NONE
-#usergrid.read.cl=ONE
-#usergrid.write.cl=ONE
-
-usergrid.notifications.listener.queueName=notifications/queuelistenerv1_31;notifications/queuelistenerv1_32;notifications/queuelistenerv1_33;notifications/queuelistenerv1_34;notifications/queuelistenerv1_35;notifications/queuelistenerv1_36
-usergrid.notifications.listener.maxThreads=0
-
-
-hystrix.threadpool.graph_user.coreSize=10
-hystrix.threadpool.graph_async.coreSize=10
-
-elasticsearch.cluster_name=usergrid
-elasticsearch.index_prefix=usergrid
-elasticsearch.hosts=127.0.0.1
-elasticsearch.port=9300
-elasticsearch.number_shards=1
-elasticsearch.number_replicas=0
-
-
-######################################################
-# Admin and test user setup
-
-usergrid.sysadmin.login.allowed=true
-usergrid.sysadmin.login.name=superuser
-usergrid.sysadmin.login.password=superuser
-usergrid.sysadmin.login.email=junk@nowhere.org
-
-usergrid.sysadmin.email=junk@nowhere.org
-usergrid.sysadmin.approve.users=false
-usergrid.sysadmin.approve.organizations=false
-
-# Base mailer account - default for all outgoing messages
-usergrid.management.mailer=Admin <ju...@nowhere.org>
-
-usergrid.setup-test-account=true
-
-usergrid.test-account.app=test-app
-usergrid.test-account.organization=test-organization
-usergrid.test-account.admin-user.username=test
-usergrid.test-account.admin-user.name=Test User
-usergrid.test-account.admin-user.email=junk@nowhere.org
-usergrid.test-account.admin-user.password=test
-
-######################################################
-# Auto-confirm and sign-up notifications settings
-
-usergrid.management.admin_users_require_confirmation=false
-usergrid.management.admin_users_require_activation=false
-
-usergrid.management.organizations_require_activation=false
-usergrid.management.notify_sysadmin_of_new_organizations=true
-usergrid.management.notify_sysadmin_of_new_admin_users=true
-
-######################################################
-# URLs
-
-# Redirect path when request come in for TLD
-usergrid.redirect_root=http://localhost:8080/status
-
-usergrid.view.management.organizations.organization.activate=http://localhost:8080/accounts/welcome
-usergrid.view.management.organizations.organization.confirm=http://localhost:8080/accounts/welcome
-
-usergrid.view.management.users.user.activate=http://localhost:8080/accounts/welcome
-usergrid.view.management.users.user.confirm=http://localhost:8080/accounts/welcome
-
-usergrid.admin.confirmation.url=http://localhost:8080/management/users/%s/confirm
-usergrid.user.confirmation.url=http://localhost:8080/%s/%s/users/%s/confirm
-
-usergrid.organization.activation.url=http://localhost:8080/management/organizations/%s/activate
-
-usergrid.admin.activation.url=http://localhost:8080/management/users/%s/activate
-usergrid.user.activation.url=http://localhost:8080%s/%s/users/%s/activate
-
-usergrid.admin.resetpw.url=http://localhost:8080/management/users/%s/resetpw
-usergrid.user.resetpw.url=http://localhost:8080/%s/%s/users/%s/resetpw
-
-
-#usergrid.metrics.graphite.host=


[40/50] [abbrv] incubator-usergrid git commit: Merge branch 'USERGRID-273' of https://git-wip-us.apache.org/repos/asf/incubator-usergrid into USERGRID-273

Posted by sn...@apache.org.
Merge branch 'USERGRID-273' of https://git-wip-us.apache.org/repos/asf/incubator-usergrid into USERGRID-273


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

Branch: refs/heads/two-dot-o
Commit: ec6d4e8ab33e0fb68c1439d5ba950f4ffd28d7d5
Parents: 72fcdda 9b846c3
Author: Dave Johnson <dm...@apigee.com>
Authored: Wed Feb 25 13:42:18 2015 -0500
Committer: Dave Johnson <dm...@apigee.com>
Committed: Wed Feb 25 13:42:18 2015 -0500

----------------------------------------------------------------------
 .../corepersistence/CpEntityManagerFactory.java |  7 ++---
 .../persistence/EntityManagerFactory.java       |  5 ----
 .../PerformanceEntityRebuildIndexTest.java      | 13 +++-------
 .../cassandra/EntityManagerFactoryImplIT.java   |  5 ----
 .../org/apache/usergrid/rest/IndexResource.java | 27 +++-----------------
 5 files changed, 9 insertions(+), 48 deletions(-)
----------------------------------------------------------------------



[12/50] [abbrv] incubator-usergrid git commit: Adding a CATALINA_BASE to the rest module so we can configure Tomcat as we need it configured for Maven Surefire testing with Arquillian.

Posted by sn...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/13da256f/stack/rest/catalina_base/lib/usergrid-deployment.properties
----------------------------------------------------------------------
diff --git a/stack/rest/catalina_base/lib/usergrid-deployment.properties b/stack/rest/catalina_base/lib/usergrid-deployment.properties
new file mode 100644
index 0000000..daf7324
--- /dev/null
+++ b/stack/rest/catalina_base/lib/usergrid-deployment.properties
@@ -0,0 +1,113 @@
+#
+# 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.
+#
+
+######################################################
+# Minimal Usergrid configuration properties for local Tomcat and Cassandra
+
+usergrid.test=true
+
+cassandra.url=localhost:9160
+cassandra.cluster=usergrid
+cassandra.keyspace.strategy=org.apache.cassandra.locator.SimpleStrategy
+cassandra.keyspace.replication=replication_factor:1
+#cassandra.keyspace.strategy=org.apache.cassandra.locator.NetworkTopologyStrategy
+#cassandra.keyspace.replication=us-east:3
+
+cassandra.timeout=5000
+cassandra.connections=10
+cassandra.discovery=NONE
+#usergrid.read.cl=ONE
+#usergrid.write.cl=ONE
+
+usergrid.notifications.listener.queueName=notifications/queuelistenerv1_31;notifications/queuelistenerv1_32;notifications/queuelistenerv1_33;notifications/queuelistenerv1_34;notifications/queuelistenerv1_35;notifications/queuelistenerv1_36
+usergrid.notifications.listener.maxThreads=0
+
+
+hystrix.threadpool.graph_user.coreSize=10
+hystrix.threadpool.graph_async.coreSize=10
+
+elasticsearch.cluster_name=elasticsearch
+#elasticsearch.cluster_name=grindrgw-prod
+#elasticsearch.cluster_name=rea1dug001-prod
+elasticsearch.index_prefix=usergrid
+elasticsearch.hosts=127.0.0.1
+elasticsearch.port=9300
+elasticsearch.number_shards=1
+elasticsearch.number_replicas=0
+
+
+######################################################
+# Admin and test user setup
+
+usergrid.sysadmin.login.allowed=true
+usergrid.sysadmin.login.name=superuser
+usergrid.sysadmin.login.password=superuser
+usergrid.sysadmin.login.email=superuser@usergrid.example.com
+
+usergrid.sysadmin.email=superuser@usergrid.example.com
+usergrid.sysadmin.approve.users=false
+usergrid.sysadmin.approve.organizations=false
+
+# Base mailer account - default for all outgoing messages
+usergrid.management.mailer=Admin <ad...@usergrid.example.com>
+
+usergrid.setup-test-account=true
+
+usergrid.test-account.app=test-app
+usergrid.test-account.organization=test-organization
+usergrid.test-account.admin-user.username=test
+usergrid.test-account.admin-user.name=Test User
+usergrid.test-account.admin-user.email=testuser@usergrid.example.com
+usergrid.test-account.admin-user.password=test
+
+######################################################
+# Auto-confirm and sign-up notifications settings
+
+usergrid.management.admin_users_require_confirmation=false
+usergrid.management.admin_users_require_activation=false
+
+usergrid.management.organizations_require_activation=false
+usergrid.management.notify_sysadmin_of_new_organizations=true
+usergrid.management.notify_sysadmin_of_new_admin_users=true
+
+######################################################
+# URLs
+
+# Redirect path when request come in for TLD
+usergrid.redirect_root=http://localhost:8080/status
+
+usergrid.view.management.organizations.organization.activate=http://localhost:8080/accounts/welcome
+usergrid.view.management.organizations.organization.confirm=http://localhost:8080/accounts/welcome
+
+usergrid.view.management.users.user.activate=http://localhost:8080/accounts/welcome
+usergrid.view.management.users.user.confirm=http://localhost:8080/accounts/welcome
+
+usergrid.admin.confirmation.url=http://localhost:8080/management/users/%s/confirm
+usergrid.user.confirmation.url=http://localhost:8080/%s/%s/users/%s/confirm
+
+usergrid.organization.activation.url=http://localhost:8080/management/organizations/%s/activate
+
+usergrid.admin.activation.url=http://localhost:8080/management/users/%s/activate
+usergrid.user.activation.url=http://localhost:8080%s/%s/users/%s/activate
+
+usergrid.admin.resetpw.url=http://localhost:8080/management/users/%s/resetpw
+usergrid.user.resetpw.url=http://localhost:8080/%s/%s/users/%s/resetpw
+
+
+#usergrid.metrics.graphite.host=

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/13da256f/stack/rest/catalina_base/webapps/ROOT
----------------------------------------------------------------------
diff --git a/stack/rest/catalina_base/webapps/ROOT b/stack/rest/catalina_base/webapps/ROOT
new file mode 120000
index 0000000..e92f674
--- /dev/null
+++ b/stack/rest/catalina_base/webapps/ROOT
@@ -0,0 +1 @@
+../../target/ROOT
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/13da256f/stack/rest/catalina_base/webapps/host-manager/META-INF/context.xml
----------------------------------------------------------------------
diff --git a/stack/rest/catalina_base/webapps/host-manager/META-INF/context.xml b/stack/rest/catalina_base/webapps/host-manager/META-INF/context.xml
new file mode 100644
index 0000000..3390e96
--- /dev/null
+++ b/stack/rest/catalina_base/webapps/host-manager/META-INF/context.xml
@@ -0,0 +1,27 @@
+<?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.
+-->
+<Context antiResourceLocking="false" privileged="true" >
+  <!--
+    Remove the comment markers from around the Valve below to limit access to
+    the host-manager application to clients connecting from localhost
+  -->
+  <!--
+  <Valve className="org.apache.catalina.valves.RemoteAddrValve"
+         allow="127\.\d+\.\d+\.\d+|::1|0:0:0:0:0:0:0:1" />
+  -->
+</Context>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/13da256f/stack/rest/catalina_base/webapps/host-manager/WEB-INF/jsp/401.jsp
----------------------------------------------------------------------
diff --git a/stack/rest/catalina_base/webapps/host-manager/WEB-INF/jsp/401.jsp b/stack/rest/catalina_base/webapps/host-manager/WEB-INF/jsp/401.jsp
new file mode 100644
index 0000000..83c8c6f
--- /dev/null
+++ b/stack/rest/catalina_base/webapps/host-manager/WEB-INF/jsp/401.jsp
@@ -0,0 +1,70 @@
+<%--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+--%>
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
+<html>
+ <head>
+  <title>401 Unauthorized</title>
+  <style type="text/css">
+    <!--
+    BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;font-size:12px;}
+    H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;}
+    PRE, TT {border: 1px dotted #525D76}
+    A {color : black;}A.name {color : black;}
+    -->
+  </style>
+ </head>
+ <body>
+   <h1>401 Unauthorized</h1>
+   <p>
+    You are not authorized to view this page. If you have not changed
+    any configuration files, please examine the file
+    <tt>conf/tomcat-users.xml</tt> in your installation. That
+    file must contain the credentials to let you use this webapp.
+   </p>
+   <p>
+    For example, to add the <tt>admin-gui</tt> role to a user named
+    <tt>tomcat</tt> with a password of <tt>s3cret</tt>, add the following to the
+    config file listed above.
+   </p>
+<pre>
+&lt;role rolename="admin-gui"/&gt;
+&lt;user username="tomcat" password="s3cret" roles="admin-gui"/&gt;
+</pre>
+   <p>
+    Note that for Tomcat 7 onwards, the roles required to use the host manager
+    application were changed from the single <tt>admin</tt> role to the
+    following two roles. You will need to assign the role(s) required for
+    the functionality you wish to access.
+   </p>
+    <ul>
+      <li><tt>admin-gui</tt> - allows access to the HTML GUI</li>
+      <li><tt>admin-script</tt> - allows access to the text interface</li>
+    </ul>
+   <p>
+    The HTML interface is protected against CSRF but the text interface is not.
+    To maintain the CSRF protection:
+   </p>
+   <ul>
+    <li>Users with the <tt>admin-gui</tt> role should not be granted the
+       <tt>admin-script</tt> role.</li>
+    <li>If the text interface is accessed through a browser (e.g. for testing
+        since this interface is intended for tools not humans) then the browser
+        must be closed afterwards to terminate the session.</li>
+   </ul>
+ </body>
+
+</html>

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/13da256f/stack/rest/catalina_base/webapps/host-manager/WEB-INF/jsp/403.jsp
----------------------------------------------------------------------
diff --git a/stack/rest/catalina_base/webapps/host-manager/WEB-INF/jsp/403.jsp b/stack/rest/catalina_base/webapps/host-manager/WEB-INF/jsp/403.jsp
new file mode 100644
index 0000000..2dbb448
--- /dev/null
+++ b/stack/rest/catalina_base/webapps/host-manager/WEB-INF/jsp/403.jsp
@@ -0,0 +1,84 @@
+<%--
+  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.
+--%>
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
+<html>
+ <head>
+  <title>403 Access Denied</title>
+  <style type="text/css">
+    <!--
+    BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;font-size:12px;}
+    H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;}
+    PRE, TT {border: 1px dotted #525D76}
+    A {color : black;}A.name {color : black;}
+    -->
+  </style>
+ </head>
+ <body>
+   <h1>403 Access Denied</h1>
+   <p>
+    You are not authorized to view this page.
+   </p>
+   <p>
+    If you have already configured the Host Manager application to allow access
+    and you have used your browsers back button, used a saved book-mark or
+    similar then you may have triggered the cross-site request forgery (CSRF)
+    protection that has been enabled for the HTML interface of the Host Manager
+    application. You will need to reset this protection by returning to the
+    <a href="<%=request.getContextPath()%>/html">main Host Manager page</a>.
+    Once you return to this page, you will be able to continue using the Host
+    Manager appliction's HTML interface normally. If you continue to see this
+    access denied message, check that you have the necessary permissions to
+    access this application.
+   </p>
+   <p> If you have not changed
+    any configuration files, please examine the file
+    <tt>conf/tomcat-users.xml</tt> in your installation. That
+    file must contain the credentials to let you use this webapp.
+   </p>
+   <p>
+    For example, to add the <tt>admin-gui</tt> role to a user named
+    <tt>tomcat</tt> with a password of <tt>s3cret</tt>, add the following to the
+    config file listed above.
+   </p>
+<pre>
+&lt;role rolename="admin-gui"/&gt;
+&lt;user username="tomcat" password="s3cret" roles="admin-gui"/&gt;
+</pre>
+   <p>
+    Note that for Tomcat 7 onwards, the roles required to use the host manager
+    application were changed from the single <tt>admin</tt> role to the
+    following two roles. You will need to assign the role(s) required for
+    the functionality you wish to access.
+   </p>
+    <ul>
+      <li><tt>admin-gui</tt> - allows access to the HTML GUI</li>
+      <li><tt>admin-script</tt> - allows access to the text interface</li>
+    </ul>
+   <p>
+    The HTML interface is protected against CSRF but the text interface is not.
+    To maintain the CSRF protection:
+   </p>
+   <ul>
+    <li>Users with the <tt>admin-gui</tt> role should not be granted the
+       <tt>admin-script</tt> role.</li>
+    <li>If the text interface is accessed through a browser (e.g. for testing
+        since this interface is intended for tools not humans) then the browser
+        must be closed afterwards to terminate the session.</li>
+   </ul>
+ </body>
+
+</html>

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/13da256f/stack/rest/catalina_base/webapps/host-manager/WEB-INF/jsp/404.jsp
----------------------------------------------------------------------
diff --git a/stack/rest/catalina_base/webapps/host-manager/WEB-INF/jsp/404.jsp b/stack/rest/catalina_base/webapps/host-manager/WEB-INF/jsp/404.jsp
new file mode 100644
index 0000000..d1b5b0b
--- /dev/null
+++ b/stack/rest/catalina_base/webapps/host-manager/WEB-INF/jsp/404.jsp
@@ -0,0 +1,61 @@
+<%--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+--%>
+<%@ page import="org.apache.catalina.util.RequestUtil" %>
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
+<html>
+ <head>
+  <title>404 Not found</title>
+  <style type="text/css">
+    <!--
+    BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;font-size:12px;}
+    H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;}
+    PRE, TT {border: 1px dotted #525D76}
+    A {color : black;}A.name {color : black;}
+    -->
+  </style>
+ </head>
+ <body>
+   <h1>404 Not found</h1>
+   <p>
+    The page you tried to access
+    (<%=RequestUtil.filter((String) request.getAttribute(
+            "javax.servlet.error.request_uri"))%>)
+    does not exist.
+   </p>
+   <p>
+    The Host Manager application has been re-structured for Tomcat 7 onwards and
+    some URLs have changed. All URLs used to access the Manager application
+    should now start with one of the following options:
+   </p>
+    <ul>
+      <li><%=request.getContextPath()%>/html for the HTML GUI</li>
+      <li><%=request.getContextPath()%>/text for the text interface</li>
+    </ul>
+   <p>
+    Note that the URL for the text interface has changed from
+    &quot;<%=request.getContextPath()%>&quot; to
+    &quot;<%=request.getContextPath()%>/text&quot;.
+   </p>
+   <p>
+    You probably need to adjust the URL you are using to access the Host Manager
+    application. However, there is always a chance you have found a bug in the
+    Host Manager application. If you are sure you have found a bug, and that the
+    bug has not already been reported, please report it to the Apache Tomcat
+    team.
+   </p>
+ </body>
+</html>

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/13da256f/stack/rest/catalina_base/webapps/host-manager/WEB-INF/web.xml
----------------------------------------------------------------------
diff --git a/stack/rest/catalina_base/webapps/host-manager/WEB-INF/web.xml b/stack/rest/catalina_base/webapps/host-manager/WEB-INF/web.xml
new file mode 100644
index 0000000..30f319b
--- /dev/null
+++ b/stack/rest/catalina_base/webapps/host-manager/WEB-INF/web.xml
@@ -0,0 +1,144 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+  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 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"
+  version="3.0"
+  metadata-complete="true">
+
+  <display-name>Tomcat Host Manager Application</display-name>
+  <description>
+    A scriptable host management web application for the Tomcat Web Server;
+    Manager lets you view, create and remove virtual hosts.
+  </description>
+
+  <servlet>
+    <servlet-name>HostManager</servlet-name>
+    <servlet-class>org.apache.catalina.manager.host.HostManagerServlet</servlet-class>
+    <init-param>
+      <param-name>debug</param-name>
+      <param-value>2</param-value>
+    </init-param>
+  </servlet>
+  <servlet>
+    <servlet-name>HTMLHostManager</servlet-name>
+    <servlet-class>org.apache.catalina.manager.host.HTMLHostManagerServlet</servlet-class>
+    <init-param>
+      <param-name>debug</param-name>
+      <param-value>2</param-value>
+    </init-param>
+  </servlet>
+
+  <filter>
+    <filter-name>SetCharacterEncoding</filter-name>
+    <filter-class>org.apache.catalina.filters.SetCharacterEncodingFilter</filter-class>
+    <init-param>
+      <param-name>encoding</param-name>
+      <param-value>UTF-8</param-value>
+    </init-param>
+  </filter>
+
+  <filter-mapping>
+    <filter-name>SetCharacterEncoding</filter-name>
+    <url-pattern>/*</url-pattern>
+  </filter-mapping>
+
+  <filter>
+    <filter-name>CSRF</filter-name>
+    <filter-class>org.apache.catalina.filters.CsrfPreventionFilter</filter-class>
+    <init-param>
+      <param-name>entryPoints</param-name>
+      <param-value>/html,/html/,/html/list,/index.jsp</param-value>
+    </init-param>
+  </filter>
+
+  <filter-mapping>
+    <filter-name>CSRF</filter-name>
+    <servlet-name>HTMLHostManager</servlet-name>
+  </filter-mapping>
+
+  <!-- Define the Manager Servlet Mapping -->
+  <servlet-mapping>
+    <servlet-name>HostManager</servlet-name>
+    <url-pattern>/text/*</url-pattern>
+  </servlet-mapping>
+  <servlet-mapping>
+    <servlet-name>HTMLHostManager</servlet-name>
+    <url-pattern>/html/*</url-pattern>
+  </servlet-mapping>
+
+  <!-- Define a Security Constraint on this Application -->
+  <security-constraint>
+    <web-resource-collection>
+      <web-resource-name>HostManager commands</web-resource-name>
+      <url-pattern>/text/*</url-pattern>
+    </web-resource-collection>
+    <auth-constraint>
+       <!-- NOTE:  This role is not present in the default users file -->
+       <role-name>admin-script</role-name>
+    </auth-constraint>
+  </security-constraint>
+  <security-constraint>
+    <web-resource-collection>
+      <web-resource-name>HTMLHostManager commands</web-resource-name>
+      <url-pattern>/html/*</url-pattern>
+    </web-resource-collection>
+    <auth-constraint>
+       <!-- NOTE:  This role is not present in the default users file -->
+       <role-name>admin-gui</role-name>
+    </auth-constraint>
+  </security-constraint>
+
+  <!-- Define the Login Configuration for this Application -->
+  <login-config>
+    <auth-method>BASIC</auth-method>
+    <realm-name>Tomcat Host Manager Application</realm-name>
+  </login-config>
+
+  <!-- Security roles referenced by this web application -->
+  <security-role>
+    <description>
+      The role that is required to log in to the Host Manager Application HTML
+      interface
+    </description>
+    <role-name>admin-gui</role-name>
+  </security-role>
+  <security-role>
+    <description>
+      The role that is required to log in to the Host Manager Application text
+      interface
+    </description>
+    <role-name>admin-script</role-name>
+  </security-role>
+
+  <error-page>
+    <error-code>401</error-code>
+    <location>/WEB-INF/jsp/401.jsp</location>
+  </error-page>
+  <error-page>
+    <error-code>403</error-code>
+    <location>/WEB-INF/jsp/403.jsp</location>
+  </error-page>
+  <error-page>
+    <error-code>404</error-code>
+    <location>/WEB-INF/jsp/404.jsp</location>
+  </error-page>
+
+</web-app>

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/13da256f/stack/rest/catalina_base/webapps/host-manager/images/add.gif
----------------------------------------------------------------------
diff --git a/stack/rest/catalina_base/webapps/host-manager/images/add.gif b/stack/rest/catalina_base/webapps/host-manager/images/add.gif
new file mode 100644
index 0000000..0774d07
Binary files /dev/null and b/stack/rest/catalina_base/webapps/host-manager/images/add.gif differ

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/13da256f/stack/rest/catalina_base/webapps/host-manager/images/asf-logo.gif
----------------------------------------------------------------------
diff --git a/stack/rest/catalina_base/webapps/host-manager/images/asf-logo.gif b/stack/rest/catalina_base/webapps/host-manager/images/asf-logo.gif
new file mode 100644
index 0000000..22eb9d7
Binary files /dev/null and b/stack/rest/catalina_base/webapps/host-manager/images/asf-logo.gif differ

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/13da256f/stack/rest/catalina_base/webapps/host-manager/images/code.gif
----------------------------------------------------------------------
diff --git a/stack/rest/catalina_base/webapps/host-manager/images/code.gif b/stack/rest/catalina_base/webapps/host-manager/images/code.gif
new file mode 100644
index 0000000..d27307b
Binary files /dev/null and b/stack/rest/catalina_base/webapps/host-manager/images/code.gif differ

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/13da256f/stack/rest/catalina_base/webapps/host-manager/images/design.gif
----------------------------------------------------------------------
diff --git a/stack/rest/catalina_base/webapps/host-manager/images/design.gif b/stack/rest/catalina_base/webapps/host-manager/images/design.gif
new file mode 100644
index 0000000..f5db0a9
Binary files /dev/null and b/stack/rest/catalina_base/webapps/host-manager/images/design.gif differ

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/13da256f/stack/rest/catalina_base/webapps/host-manager/images/docs.gif
----------------------------------------------------------------------
diff --git a/stack/rest/catalina_base/webapps/host-manager/images/docs.gif b/stack/rest/catalina_base/webapps/host-manager/images/docs.gif
new file mode 100644
index 0000000..d64a4a1
Binary files /dev/null and b/stack/rest/catalina_base/webapps/host-manager/images/docs.gif differ

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/13da256f/stack/rest/catalina_base/webapps/host-manager/images/fix.gif
----------------------------------------------------------------------
diff --git a/stack/rest/catalina_base/webapps/host-manager/images/fix.gif b/stack/rest/catalina_base/webapps/host-manager/images/fix.gif
new file mode 100644
index 0000000..d59ad64
Binary files /dev/null and b/stack/rest/catalina_base/webapps/host-manager/images/fix.gif differ

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/13da256f/stack/rest/catalina_base/webapps/host-manager/images/tomcat.gif
----------------------------------------------------------------------
diff --git a/stack/rest/catalina_base/webapps/host-manager/images/tomcat.gif b/stack/rest/catalina_base/webapps/host-manager/images/tomcat.gif
new file mode 100644
index 0000000..6175673
Binary files /dev/null and b/stack/rest/catalina_base/webapps/host-manager/images/tomcat.gif differ

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/13da256f/stack/rest/catalina_base/webapps/host-manager/images/update.gif
----------------------------------------------------------------------
diff --git a/stack/rest/catalina_base/webapps/host-manager/images/update.gif b/stack/rest/catalina_base/webapps/host-manager/images/update.gif
new file mode 100644
index 0000000..31e22ab
Binary files /dev/null and b/stack/rest/catalina_base/webapps/host-manager/images/update.gif differ

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/13da256f/stack/rest/catalina_base/webapps/host-manager/images/void.gif
----------------------------------------------------------------------
diff --git a/stack/rest/catalina_base/webapps/host-manager/images/void.gif b/stack/rest/catalina_base/webapps/host-manager/images/void.gif
new file mode 100644
index 0000000..e565824
Binary files /dev/null and b/stack/rest/catalina_base/webapps/host-manager/images/void.gif differ

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/13da256f/stack/rest/catalina_base/webapps/host-manager/index.jsp
----------------------------------------------------------------------
diff --git a/stack/rest/catalina_base/webapps/host-manager/index.jsp b/stack/rest/catalina_base/webapps/host-manager/index.jsp
new file mode 100644
index 0000000..d4816e5
--- /dev/null
+++ b/stack/rest/catalina_base/webapps/host-manager/index.jsp
@@ -0,0 +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
+
+      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.
+--%>
+<% response.sendRedirect(response.encodeRedirectURL(request.getContextPath() +
+        "/html")); %>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/13da256f/stack/rest/catalina_base/webapps/host-manager/manager.xml
----------------------------------------------------------------------
diff --git a/stack/rest/catalina_base/webapps/host-manager/manager.xml b/stack/rest/catalina_base/webapps/host-manager/manager.xml
new file mode 100644
index 0000000..250065a
--- /dev/null
+++ b/stack/rest/catalina_base/webapps/host-manager/manager.xml
@@ -0,0 +1,26 @@
+<?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.
+-->
+<!--
+
+    Context configuration file for the Tomcat Manager Web App
+
+-->
+<Context docBase="${catalina.home}/webapps/manager"
+         privileged="true" antiResourceLocking="false" antiJARLocking="false">
+
+</Context>

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/13da256f/stack/rest/catalina_base/webapps/manager/META-INF/context.xml
----------------------------------------------------------------------
diff --git a/stack/rest/catalina_base/webapps/manager/META-INF/context.xml b/stack/rest/catalina_base/webapps/manager/META-INF/context.xml
new file mode 100644
index 0000000..21d9bac
--- /dev/null
+++ b/stack/rest/catalina_base/webapps/manager/META-INF/context.xml
@@ -0,0 +1,27 @@
+<?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.
+-->
+<Context antiResourceLocking="false" privileged="true" >
+  <!--
+    Remove the comment markers from around the Valve below to limit access to
+    the manager application to clients connecting from localhost
+  -->
+  <!--
+  <Valve className="org.apache.catalina.valves.RemoteAddrValve"
+         allow="127\.\d+\.\d+\.\d+|::1|0:0:0:0:0:0:0:1" />
+  -->
+</Context>

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/13da256f/stack/rest/catalina_base/webapps/manager/WEB-INF/jsp/401.jsp
----------------------------------------------------------------------
diff --git a/stack/rest/catalina_base/webapps/manager/WEB-INF/jsp/401.jsp b/stack/rest/catalina_base/webapps/manager/WEB-INF/jsp/401.jsp
new file mode 100644
index 0000000..01f8aa9
--- /dev/null
+++ b/stack/rest/catalina_base/webapps/manager/WEB-INF/jsp/401.jsp
@@ -0,0 +1,79 @@
+<%--
+  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.
+--%>
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
+<html>
+ <head>
+  <title>401 Unauthorized</title>
+  <style type="text/css">
+    <!--
+    BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;font-size:12px;}
+    H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;}
+    PRE, TT {border: 1px dotted #525D76}
+    A {color : black;}A.name {color : black;}
+    -->
+  </style>
+ </head>
+ <body>
+   <h1>401 Unauthorized</h1>
+   <p>
+    You are not authorized to view this page. If you have not changed
+    any configuration files, please examine the file
+    <tt>conf/tomcat-users.xml</tt> in your installation. That
+    file must contain the credentials to let you use this webapp.
+   </p>
+   <p>
+    For example, to add the <tt>manager-gui</tt> role to a user named
+    <tt>tomcat</tt> with a password of <tt>s3cret</tt>, add the following to the
+    config file listed above.
+   </p>
+<pre>
+&lt;role rolename="manager-gui"/&gt;
+&lt;user username="tomcat" password="s3cret" roles="manager-gui"/&gt;
+</pre>
+   <p>
+    Note that for Tomcat 7 onwards, the roles required to use the manager
+    application were changed from the single <tt>manager</tt> role to the
+    following four roles. You will need to assign the role(s) required for
+    the functionality you wish to access.
+   </p>
+    <ul>
+      <li><tt>manager-gui</tt> - allows access to the HTML GUI and the status
+          pages</li>
+      <li><tt>manager-script</tt> - allows access to the text interface and the
+          status pages</li>
+      <li><tt>manager-jmx</tt> - allows access to the JMX proxy and the status
+          pages</li>
+      <li><tt>manager-status</tt> - allows access to the status pages only</li>
+    </ul>
+   <p>
+    The HTML interface is protected against CSRF but the text and JMX interfaces
+    are not. To maintain the CSRF protection:
+   </p>
+   <ul>
+    <li>Users with the <tt>manager-gui</tt> role should not be granted either
+        the <tt>manager-script</tt> or <tt>manager-jmx</tt> roles.</li>
+    <li>If the text or jmx interfaces are accessed through a browser (e.g. for
+        testing since these interfaces are intended for tools not humans) then
+        the browser must be closed afterwards to terminate the session.</li>
+   </ul>
+   <p>
+    For more information - please see the
+    <a href="/docs/manager-howto.html">Manager App HOW-TO</a>.
+   </p>
+ </body>
+
+</html>

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/13da256f/stack/rest/catalina_base/webapps/manager/WEB-INF/jsp/403.jsp
----------------------------------------------------------------------
diff --git a/stack/rest/catalina_base/webapps/manager/WEB-INF/jsp/403.jsp b/stack/rest/catalina_base/webapps/manager/WEB-INF/jsp/403.jsp
new file mode 100644
index 0000000..43d960f
--- /dev/null
+++ b/stack/rest/catalina_base/webapps/manager/WEB-INF/jsp/403.jsp
@@ -0,0 +1,94 @@
+<%--
+  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.
+--%>
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
+<html>
+ <head>
+  <title>403 Access Denied</title>
+  <style type="text/css">
+    <!--
+    BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;font-size:12px;}
+    H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;}
+    PRE, TT {border: 1px dotted #525D76}
+    A {color : black;}A.name {color : black;}
+    -->
+  </style>
+ </head>
+ <body>
+   <h1>403 Access Denied</h1>
+   <p>
+    You are not authorized to view this page.
+   </p>
+   <p>
+    If you have already configured the Manager application to allow access and
+    you have used your browsers back button, used a saved book-mark or similar
+    then you may have triggered the cross-site request forgery (CSRF) protection
+    that has been enabled for the HTML interface of the Manager application. You
+    will need to reset this protection by returning to the
+    <a href="<%=request.getContextPath()%>/html">main Manager page</a>. Once you
+    return to this page, you will be able to continue using the Manager
+    appliction's HTML interface normally. If you continue to see this access
+    denied message, check that you have the necessary permissions to access this
+    application.
+   </p>
+   <p>
+    If you have not changed
+    any configuration files, please examine the file
+    <tt>conf/tomcat-users.xml</tt> in your installation. That
+    file must contain the credentials to let you use this webapp.
+   </p>
+   <p>
+    For example, to add the <tt>manager-gui</tt> role to a user named
+    <tt>tomcat</tt> with a password of <tt>s3cret</tt>, add the following to the
+    config file listed above.
+   </p>
+<pre>
+&lt;role rolename="manager-gui"/&gt;
+&lt;user username="tomcat" password="s3cret" roles="manager-gui"/&gt;
+</pre>
+   <p>
+    Note that for Tomcat 7 onwards, the roles required to use the manager
+    application were changed from the single <tt>manager</tt> role to the
+    following four roles. You will need to assign the role(s) required for
+    the functionality you wish to access.
+   </p>
+    <ul>
+      <li><tt>manager-gui</tt> - allows access to the HTML GUI and the status
+          pages</li>
+      <li><tt>manager-script</tt> - allows access to the text interface and the
+          status pages</li>
+      <li><tt>manager-jmx</tt> - allows access to the JMX proxy and the status
+          pages</li>
+      <li><tt>manager-status</tt> - allows access to the status pages only</li>
+    </ul>
+   <p>
+    The HTML interface is protected against CSRF but the text and JMX interfaces
+    are not. To maintain the CSRF protection:
+   </p>
+   <ul>
+    <li>Users with the <tt>manager-gui</tt> role should not be granted either
+        the <tt>manager-script</tt> or <tt>manager-jmx</tt> roles.</li>
+    <li>If the text or jmx interfaces are accessed through a browser (e.g. for
+        testing since these interfaces are intended for tools not humans) then
+        the browser must be closed afterwards to terminate the session.</li>
+   </ul>
+   <p>
+    For more information - please see the
+    <a href="/docs/manager-howto.html">Manager App HOW-TO</a>.
+   </p>
+ </body>
+
+</html>

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/13da256f/stack/rest/catalina_base/webapps/manager/WEB-INF/jsp/404.jsp
----------------------------------------------------------------------
diff --git a/stack/rest/catalina_base/webapps/manager/WEB-INF/jsp/404.jsp b/stack/rest/catalina_base/webapps/manager/WEB-INF/jsp/404.jsp
new file mode 100644
index 0000000..86d4f35
--- /dev/null
+++ b/stack/rest/catalina_base/webapps/manager/WEB-INF/jsp/404.jsp
@@ -0,0 +1,62 @@
+<%--
+  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.
+--%>
+<%@ page import="org.apache.catalina.util.RequestUtil" %>
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
+<html>
+ <head>
+  <title>404 Not found</title>
+  <style type="text/css">
+    <!--
+    BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;font-size:12px;}
+    H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;}
+    PRE, TT {border: 1px dotted #525D76}
+    A {color : black;}A.name {color : black;}
+    -->
+  </style>
+ </head>
+ <body>
+   <h1>404 Not found</h1>
+   <p>
+    The page you tried to access
+    (<%=RequestUtil.filter((String) request.getAttribute(
+            "javax.servlet.error.request_uri"))%>)
+    does not exist.
+   </p>
+   <p>
+    The Manager application has been re-structured for Tomcat 7 onwards and some
+    of URLs have changed. All URLs used to access the Manager application should
+    now start with one of the following options:
+   </p>
+    <ul>
+      <li><%=request.getContextPath()%>/html for the HTML GUI</li>
+      <li><%=request.getContextPath()%>/text for the text interface</li>
+      <li><%=request.getContextPath()%>/jmxproxy for the JMX proxy</li>
+      <li><%=request.getContextPath()%>/status for the status pages</li>
+    </ul>
+   <p>
+    Note that the URL for the text interface has changed from
+    &quot;<%=request.getContextPath()%>&quot; to
+    &quot;<%=request.getContextPath()%>/text&quot;.
+   </p>
+   <p>
+    You probably need to adjust the URL you are using to access the Manager
+    application. However, there is always a chance you have found a bug in the
+    Manager application. If you are sure you have found a bug, and that the bug
+    has not already been reported, please report it to the Apache Tomcat team.
+   </p>
+ </body>
+</html>

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/13da256f/stack/rest/catalina_base/webapps/manager/WEB-INF/jsp/sessionDetail.jsp
----------------------------------------------------------------------
diff --git a/stack/rest/catalina_base/webapps/manager/WEB-INF/jsp/sessionDetail.jsp b/stack/rest/catalina_base/webapps/manager/WEB-INF/jsp/sessionDetail.jsp
new file mode 100644
index 0000000..9362dab
--- /dev/null
+++ b/stack/rest/catalina_base/webapps/manager/WEB-INF/jsp/sessionDetail.jsp
@@ -0,0 +1,197 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<%--
+ 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.
+--%>
+<%@page session="false" contentType="text/html; charset=ISO-8859-1" %>
+<%@page import="java.util.Enumeration" %>
+<%@page import="javax.servlet.http.HttpSession" %>
+<%@page import="org.apache.catalina.Session" %>
+<%@page import="org.apache.catalina.manager.JspHelper" %>
+<%@page import="org.apache.catalina.util.ContextName" %>
+<!DOCTYPE html
+     PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<%--!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
+ "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"--%>
+
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
+<% String path = (String) request.getAttribute("path");
+   String version = (String) request.getAttribute("version");
+   ContextName cn = new ContextName(path, version);
+   Session currentSession = (Session)request.getAttribute("currentSession");
+   String currentSessionId = null;
+   HttpSession currentHttpSession = null;
+   if (currentSession != null) {
+       currentHttpSession = currentSession.getSession();
+       currentSessionId = JspHelper.escapeXml(currentSession.getId());
+   } else {
+       currentSessionId = "Session invalidated";
+   }
+   String submitUrl = JspHelper.escapeXml(response.encodeURL(
+           ((HttpServletRequest) pageContext.getRequest()).getRequestURI() +
+           "?path=" + path + "&version=" + version));
+%>
+<head>
+    <meta http-equiv="content-type" content="text/html; charset=iso-8859-1"/>
+    <meta http-equiv="pragma" content="no-cache"/><!-- HTTP 1.0 -->
+    <meta http-equiv="cache-control" content="no-cache,must-revalidate"/><!-- HTTP 1.1 -->
+    <meta http-equiv="expires" content="0"/><!-- 0 is an invalid value and should be treated as 'now' -->
+    <meta http-equiv="content-language" content="en"/>
+    <meta name="author" content="Cedrik LIME"/>
+    <meta name="copyright" content="copyright 2005-2015 the Apache Software Foundation"/>
+    <meta name="robots" content="noindex,nofollow,noarchive"/>
+    <title>Sessions Administration: details for <%= currentSessionId %></title>
+</head>
+<body>
+<% if (currentHttpSession == null) { %>
+   <h1><%=currentSessionId%></h1>
+<% } else { %>
+   <h1>Details for Session <%= currentSessionId %></h1>
+
+   <table style="text-align: left;" border="0">
+     <tr>
+       <th>Session Id</th>
+       <td><%= currentSessionId %></td>
+     </tr>
+     <tr>
+       <th>Guessed Locale</th>
+       <td><%= JspHelper.guessDisplayLocaleFromSession(currentSession) %></td>
+     </tr>
+     <tr>
+       <th>Guessed User</th>
+       <td><%= JspHelper.guessDisplayUserFromSession(currentSession) %></td>
+     </tr>
+     <tr>
+       <th>Creation Time</th>
+       <td><%= JspHelper.getDisplayCreationTimeForSession(currentSession) %></td>
+     </tr>
+     <tr>
+       <th>Last Accessed Time</th>
+       <td><%= JspHelper.getDisplayLastAccessedTimeForSession(currentSession) %></td>
+     </tr>
+     <tr>
+       <th>Session Max Inactive Interval</th>
+       <td><%= JspHelper.secondsToTimeString(currentSession.getMaxInactiveInterval()) %></td>
+     </tr>
+     <tr>
+       <th>Used Time</th>
+       <td><%= JspHelper.getDisplayUsedTimeForSession(currentSession) %></td>
+     </tr>
+     <tr>
+       <th>Inactive Time</th>
+       <td><%= JspHelper.getDisplayInactiveTimeForSession(currentSession) %></td>
+     </tr>
+     <tr>
+       <th>TTL</th>
+       <td><%= JspHelper.getDisplayTTLForSession(currentSession) %></td>
+     </tr>
+   </table>
+
+   <form method="post" action="<%= submitUrl %>">
+     <div>
+       <input type="hidden" name="sessionId" value="<%= currentSessionId %>" />
+       <input type="hidden" name="action" value="sessionDetail" />
+       <%
+       if ("Primary".equals(request.getParameter("sessionType"))) {
+       %>
+         <input type="hidden" name="sessionType" value="Primary" />
+       <%
+       }
+       %>    <input type="submit" value="Refresh" />
+     </div>
+   </form>
+
+   <div class="error"><%= JspHelper.escapeXml(request.getAttribute("error")) %></div>
+   <div class="message"><%= JspHelper.escapeXml(request.getAttribute("message")) %></div>
+
+   <table style="text-align: left;" border="1" cellpadding="2" cellspacing="2">
+   <% int nAttributes = 0;
+      Enumeration attributeNamesEnumeration = currentHttpSession.getAttributeNames();
+      while (attributeNamesEnumeration.hasMoreElements()) {
+          attributeNamesEnumeration.nextElement();
+          ++nAttributes;
+      }
+   %>
+       <caption style="font-variant: small-caps;"><%= JspHelper.formatNumber(nAttributes) %> attributes</caption>
+       <thead>
+           <tr>
+               <th>Remove Attribute</th>
+               <th>Attribute name</th>
+               <th>Attribute value</th>
+           </tr>
+       </thead>
+       <%--tfoot>
+           <tr>
+               <td colspan="3" style="text-align: center;">
+                   TODO: set Max Inactive Interval on sessions
+               </td>
+           </tr>
+       </tfoot--%>
+       <tbody>
+   <% attributeNamesEnumeration = currentHttpSession.getAttributeNames();
+      while (attributeNamesEnumeration.hasMoreElements()) {
+          String attributeName = (String) attributeNamesEnumeration.nextElement();
+   %>
+           <tr>
+               <td align="center">
+                   <form method="post" action="<%= submitUrl %>">
+                       <div>
+                           <input type="hidden" name="action" value="removeSessionAttribute" />
+                           <input type="hidden" name="sessionId" value="<%= currentSessionId %>" />
+                           <input type="hidden" name="attributeName" value="<%= JspHelper.escapeXml(attributeName) %>" />
+                           <%
+                             if ("Primary".equals(request.getParameter("sessionType"))) {
+                           %>
+                             <input type="submit" value="Remove" />
+                             <input type="hidden" name="sessionType" value="Primary" />
+                           <%
+                             } else {
+                               out.print("Primary sessions only");
+                             }
+                           %>
+                       </div>
+                   </form>
+               </td>
+               <td><%= JspHelper.escapeXml(attributeName) %></td>
+               <td><% Object attributeValue = currentHttpSession.getAttribute(attributeName); %><span title="<%= attributeValue == null ? "" : attributeValue.getClass().toString() %>"><%= JspHelper.escapeXml(attributeValue) %></span></td>
+           </tr>
+   <% } // end while %>
+       </tbody>
+   </table>
+<% } // endif%>
+
+<form method="post" action="<%=submitUrl%>">
+  <p style="text-align: center;">
+    <input type="submit" value="Return to session list" />
+  </p>
+</form>
+
+<%--div style="display: none;">
+<p>
+    <a href="http://validator.w3.org/check?uri=referer"><img
+        src="http://www.w3.org/Icons/valid-html401"
+        alt="Valid HTML 4.01!" height="31" width="88"></a>
+    <a href="http://validator.w3.org/check?uri=referer"><img
+        src="http://www.w3.org/Icons/valid-xhtml10"
+        alt="Valid XHTML 1.0!" height="31" width="88" /></a>
+    <a href="http://validator.w3.org/check?uri=referer"><img
+        src="http://www.w3.org/Icons/valid-xhtml11"
+        alt="Valid XHTML 1.1!" height="31" width="88" /></a>
+</p>
+</div--%>
+
+</body>
+</html>

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/13da256f/stack/rest/catalina_base/webapps/manager/WEB-INF/jsp/sessionsList.jsp
----------------------------------------------------------------------
diff --git a/stack/rest/catalina_base/webapps/manager/WEB-INF/jsp/sessionsList.jsp b/stack/rest/catalina_base/webapps/manager/WEB-INF/jsp/sessionsList.jsp
new file mode 100644
index 0000000..1cbf75e
--- /dev/null
+++ b/stack/rest/catalina_base/webapps/manager/WEB-INF/jsp/sessionsList.jsp
@@ -0,0 +1,172 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<%--
+ 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.
+--%>
+<%@page session="false" contentType="text/html; charset=ISO-8859-1" %>
+<%@page import="java.util.Collection" %>
+<%@page import="java.util.Iterator" %>
+<%@page import="org.apache.catalina.manager.JspHelper" %>
+<%@page import="org.apache.catalina.Session" %>
+<%@page import="org.apache.catalina.ha.session.DeltaSession" %>
+<%@page import="org.apache.catalina.util.ContextName" %>
+<!DOCTYPE html
+     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+
+<%@page import="org.apache.catalina.manager.DummyProxySession"%><html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
+<% String path = (String) request.getAttribute("path");
+   String version = (String) request.getAttribute("version");
+   ContextName cn = new ContextName(path, version);
+   String submitUrl = JspHelper.escapeXml(response.encodeURL(
+           ((HttpServletRequest) pageContext.getRequest()).getRequestURI() +
+           "?path=" + path + "&version=" + version));
+   Collection activeSessions = (Collection) request.getAttribute("activeSessions");
+%>
+<head>
+    <meta http-equiv="content-type" content="text/html; charset=iso-8859-1"/>
+    <meta http-equiv="pragma" content="no-cache"/><!-- HTTP 1.0 -->
+    <meta http-equiv="cache-control" content="no-cache,must-revalidate"/><!-- HTTP 1.1 -->
+    <meta http-equiv="expires" content="0"/><!-- 0 is an invalid value and should be treated as 'now' -->
+    <meta http-equiv="content-language" content="en"/>
+    <meta name="author" content="Cedrik LIME"/>
+    <meta name="copyright" content="copyright 2005-2015 the Apache Software Foundation"/>
+    <meta name="robots" content="noindex,nofollow,noarchive"/>
+    <title>Sessions Administration for <%= JspHelper.escapeXml(cn.getDisplayName()) %></title>
+</head>
+<body>
+<h1>Sessions Administration for <%= JspHelper.escapeXml(cn.getDisplayName()) %></h1>
+
+<p>Tips:</p>
+<ul>
+    <li>Click on a column to sort.</li>
+    <li>To view a session details and/or remove a session attributes, click on its id.</li>
+</ul>
+
+<div class="error"><%= JspHelper.escapeXml(request.getAttribute("error")) %></div>
+<div class="message"><%= JspHelper.escapeXml(request.getAttribute("message")) %></div>
+
+<form action="<%= submitUrl %>" method="post" id="sessionsForm">
+    <fieldset><legend>Active HttpSessions informations</legend>
+        <input type="hidden" name="action" id="sessionsFormAction" value="injectSessions"/>
+        <input type="hidden" name="sort" id="sessionsFormSort" value="<%= JspHelper.escapeXml(request.getAttribute("sort")) %>"/>
+        <% String order = (String) request.getAttribute("order");
+           if (order == null || "".equals(order)) {
+               order = "ASC";
+           }
+        %>
+        <input type="hidden" name="order" id="sessionsFormSortOrder" value="<%= JspHelper.escapeXml(order) %>"/>
+        <input type="submit" name="refresh" id="refreshButton" value="Refresh Sessions list" onclick="document.getElementById('sessionsFormAction').value='refreshSessions'; return true;"/>
+        <%= JspHelper.formatNumber(activeSessions.size()) %> active Sessions<br/>
+        <table border="1" cellpadding="2" cellspacing="2" width="100%">
+            <thead>
+                <tr>
+                    <th><a onclick="document.getElementById('sessionsFormSort').value='id'; document.getElementById('refreshButton').click(); return true;">Session Id</a></th>
+                    <th><a onclick="document.getElementById('sessionsFormSort').value='id'; document.getElementById('refreshButton').click(); return true;">Type</a></th>
+                    <th><a onclick="document.getElementById('sessionsFormSort').value='locale'; document.getElementById('refreshButton').click(); return true;">Guessed Locale</a></th>
+                    <th><a onclick="document.getElementById('sessionsFormSort').value='user'; document.getElementById('refreshButton').click(); return true;">Guessed User name</a></th>
+                    <th><a onclick="document.getElementById('sessionsFormSort').value='CreationTime'; document.getElementById('refreshButton').click(); return true;">Creation Time</a></th>
+                    <th><a onclick="document.getElementById('sessionsFormSort').value='LastAccessedTime'; document.getElementById('refreshButton').click(); return true;">Last Accessed Time</a></th>
+                    <th><a onclick="document.getElementById('sessionsFormSort').value='UsedTime'; document.getElementById('refreshButton').click(); return true;">Used Time</a></th>
+                    <th><a onclick="document.getElementById('sessionsFormSort').value='InactiveTime'; document.getElementById('refreshButton').click(); return true;">Inactive Time</a></th>
+                    <th><a onclick="document.getElementById('sessionsFormSort').value='TTL'; document.getElementById('refreshButton').click(); return true;"><span title="Time To Live">TTL</span></a></th>
+                </tr>
+            </thead>
+            <% if (activeSessions.size() > 10) { %>
+            <tfoot><%-- <tfoot> is the same as <thead> --%>
+                <tr>
+                    <th><a onclick="document.getElementById('sessionsFormSort').value='id'; document.getElementById('refreshButton').click(); return true;">Session Id</a></th>
+                    <th><a onclick="document.getElementById('sessionsFormSort').value='id'; document.getElementById('refreshButton').click(); return true;">Type</a></th>
+                    <th><a onclick="document.getElementById('sessionsFormSort').value='locale'; document.getElementById('refreshButton').click(); return true;">Guessed Locale</a></th>
+                    <th><a onclick="document.getElementById('sessionsFormSort').value='user'; document.getElementById('refreshButton').click(); return true;">Guessed User name</a></th>
+                    <th><a onclick="document.getElementById('sessionsFormSort').value='CreationTime'; document.getElementById('refreshButton').click(); return true;">Creation Time</a></th>
+                    <th><a onclick="document.getElementById('sessionsFormSort').value='LastAccessedTime'; document.getElementById('refreshButton').click(); return true;">Last Accessed Time</a></th>
+                    <th><a onclick="document.getElementById('sessionsFormSort').value='UsedTime'; document.getElementById('refreshButton').click(); return true;">Used Time</a></th>
+                    <th><a onclick="document.getElementById('sessionsFormSort').value='InactiveTime'; document.getElementById('refreshButton').click(); return true;">Inactive Time</a></th>
+                    <th><a onclick="document.getElementById('sessionsFormSort').value='TTL'; document.getElementById('refreshButton').click(); return true;"><span title="Time To Live">TTL</span></a></th>
+                </tr>
+            </tfoot>
+            <% } // end if %>
+            <tbody>
+<% Iterator iter = activeSessions.iterator();
+   while (iter.hasNext()) {
+       Session currentSession = (Session) iter.next();
+       String currentSessionId = JspHelper.escapeXml(currentSession.getId());
+       String type;
+       if (currentSession instanceof DeltaSession) {
+           if (((DeltaSession) currentSession).isPrimarySession()) {
+               type = "Primary";
+           } else {
+               type = "Backup";
+           }
+       } else if (currentSession instanceof DummyProxySession) {
+           type = "Proxy";
+       } else {
+           type = "Primary";
+       }
+%>
+                <tr>
+                    <td><input type="checkbox" name="sessionIds" value="<%= currentSessionId %>" />
+                      <%
+                        if ("Proxy".equals(type)) {
+                            out.print(currentSessionId);
+                        } else {
+                      %>
+                      <a href="<%= submitUrl %>&amp;action=sessionDetail&amp;sessionId=<%= currentSessionId %>&amp;sessionType=<%= type %>"><%= currentSessionId %></a>
+                      <%
+                        }
+                      %>
+                    </td>
+                    <td style="text-align: center;"><%= type %></td>
+                    <td style="text-align: center;"><%= JspHelper.guessDisplayLocaleFromSession(currentSession) %></td>
+                    <td style="text-align: center;"><%= JspHelper.guessDisplayUserFromSession(currentSession) %></td>
+                    <td style="text-align: center;"><%= JspHelper.getDisplayCreationTimeForSession(currentSession) %></td>
+                    <td style="text-align: center;"><%= JspHelper.getDisplayLastAccessedTimeForSession(currentSession) %></td>
+                    <td style="text-align: center;"><%= JspHelper.getDisplayUsedTimeForSession(currentSession) %></td>
+                    <td style="text-align: center;"><%= JspHelper.getDisplayInactiveTimeForSession(currentSession) %></td>
+                    <td style="text-align: center;"><%= JspHelper.getDisplayTTLForSession(currentSession) %></td>
+                </tr>
+<% } // end while %>
+            </tbody>
+        </table>
+        <p style="text-align: center;">
+            <input type="submit" name="invalidate" value="Invalidate selected Sessions" onclick="document.getElementById('sessionsFormAction').value='invalidateSessions'; return true;"/>
+        </p>
+    </fieldset>
+</form>
+
+<form method="get" action="<%=request.getContextPath()%>/html">
+  <p style="text-align: center;">
+    <input type="submit" value="Return to main page" />
+  </p>
+</form>
+
+<%--div style="display: none;">
+<p>
+    <a href="http://validator.w3.org/check?uri=referer"><img
+        src="http://www.w3.org/Icons/valid-html401"
+        alt="Valid HTML 4.01!" height="31" width="88"></a>
+    <a href="http://validator.w3.org/check?uri=referer"><img
+        src="http://www.w3.org/Icons/valid-xhtml10"
+        alt="Valid XHTML 1.0!" height="31" width="88" /></a>
+    <a href="http://validator.w3.org/check?uri=referer"><img
+        src="http://www.w3.org/Icons/valid-xhtml11"
+        alt="Valid XHTML 1.1!" height="31" width="88" /></a>
+</p>
+</div--%>
+
+</body>
+</html>

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/13da256f/stack/rest/catalina_base/webapps/manager/WEB-INF/web.xml
----------------------------------------------------------------------
diff --git a/stack/rest/catalina_base/webapps/manager/WEB-INF/web.xml b/stack/rest/catalina_base/webapps/manager/WEB-INF/web.xml
new file mode 100644
index 0000000..8fb7728
--- /dev/null
+++ b/stack/rest/catalina_base/webapps/manager/WEB-INF/web.xml
@@ -0,0 +1,209 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+ 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 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"
+  version="3.0"
+  metadata-complete="true">
+
+  <display-name>Tomcat Manager Application</display-name>
+  <description>
+    A scriptable management web application for the Tomcat Web Server;
+    Manager lets you view, load/unload/etc particular web applications.
+  </description>
+
+  <servlet>
+    <servlet-name>Manager</servlet-name>
+    <servlet-class>org.apache.catalina.manager.ManagerServlet</servlet-class>
+    <init-param>
+      <param-name>debug</param-name>
+      <param-value>2</param-value>
+    </init-param>
+  </servlet>
+  <servlet>
+    <servlet-name>HTMLManager</servlet-name>
+    <servlet-class>org.apache.catalina.manager.HTMLManagerServlet</servlet-class>
+    <init-param>
+      <param-name>debug</param-name>
+      <param-value>2</param-value>
+    </init-param>
+    <!-- Uncomment this to show proxy sessions from the Backup manager or a
+         StoreManager in the sessions list for an application
+    <init-param>
+      <param-name>showProxySessions</param-name>
+      <param-value>true</param-value>
+    </init-param>
+    -->
+    <multipart-config>
+      <!-- 50MB max -->
+      <max-file-size>52428800</max-file-size>
+      <max-request-size>52428800</max-request-size>
+      <file-size-threshold>0</file-size-threshold>
+    </multipart-config>
+  </servlet>
+  <servlet>
+    <servlet-name>Status</servlet-name>
+    <servlet-class>org.apache.catalina.manager.StatusManagerServlet</servlet-class>
+    <init-param>
+      <param-name>debug</param-name>
+      <param-value>0</param-value>
+    </init-param>
+  </servlet>
+
+  <servlet>
+    <servlet-name>JMXProxy</servlet-name>
+    <servlet-class>org.apache.catalina.manager.JMXProxyServlet</servlet-class>
+  </servlet>
+
+  <!-- Define the Manager Servlet Mapping -->
+  <servlet-mapping>
+    <servlet-name>Manager</servlet-name>
+      <url-pattern>/text/*</url-pattern>
+  </servlet-mapping>
+  <servlet-mapping>
+    <servlet-name>Status</servlet-name>
+    <url-pattern>/status/*</url-pattern>
+  </servlet-mapping>
+  <servlet-mapping>
+    <servlet-name>JMXProxy</servlet-name>
+      <url-pattern>/jmxproxy/*</url-pattern>
+  </servlet-mapping>
+  <servlet-mapping>
+    <servlet-name>HTMLManager</servlet-name>
+    <url-pattern>/html/*</url-pattern>
+  </servlet-mapping>
+
+  <filter>
+    <filter-name>SetCharacterEncoding</filter-name>
+    <filter-class>org.apache.catalina.filters.SetCharacterEncodingFilter</filter-class>
+    <init-param>
+      <param-name>encoding</param-name>
+      <param-value>UTF-8</param-value>
+    </init-param>
+  </filter>
+
+  <filter-mapping>
+    <filter-name>SetCharacterEncoding</filter-name>
+    <url-pattern>/*</url-pattern>
+  </filter-mapping>
+
+  <filter>
+    <filter-name>CSRF</filter-name>
+    <filter-class>org.apache.catalina.filters.CsrfPreventionFilter</filter-class>
+    <init-param>
+      <param-name>entryPoints</param-name>
+      <param-value>/html,/html/,/html/list,/index.jsp</param-value>
+    </init-param>
+  </filter>
+
+  <filter-mapping>
+    <filter-name>CSRF</filter-name>
+    <servlet-name>HTMLManager</servlet-name>
+    <servlet-name>jsp</servlet-name>
+  </filter-mapping>
+
+  <!-- Define a Security Constraint on this Application -->
+  <!-- NOTE:  None of these roles are present in the default users file -->
+  <security-constraint>
+    <web-resource-collection>
+      <web-resource-name>HTML Manager interface (for humans)</web-resource-name>
+      <url-pattern>/html/*</url-pattern>
+    </web-resource-collection>
+    <auth-constraint>
+       <role-name>manager-gui</role-name>
+    </auth-constraint>
+  </security-constraint>
+  <security-constraint>
+    <web-resource-collection>
+      <web-resource-name>Text Manager interface (for scripts)</web-resource-name>
+      <url-pattern>/text/*</url-pattern>
+    </web-resource-collection>
+    <auth-constraint>
+       <role-name>manager-script</role-name>
+    </auth-constraint>
+  </security-constraint>
+  <security-constraint>
+    <web-resource-collection>
+      <web-resource-name>JMX Proxy interface</web-resource-name>
+      <url-pattern>/jmxproxy/*</url-pattern>
+    </web-resource-collection>
+    <auth-constraint>
+       <role-name>manager-jmx</role-name>
+    </auth-constraint>
+  </security-constraint>
+  <security-constraint>
+    <web-resource-collection>
+      <web-resource-name>Status interface</web-resource-name>
+      <url-pattern>/status/*</url-pattern>
+    </web-resource-collection>
+    <auth-constraint>
+       <role-name>manager-gui</role-name>
+       <role-name>manager-script</role-name>
+       <role-name>manager-jmx</role-name>
+       <role-name>manager-status</role-name>
+    </auth-constraint>
+  </security-constraint>
+
+  <!-- Define the Login Configuration for this Application -->
+  <login-config>
+    <auth-method>BASIC</auth-method>
+    <realm-name>Tomcat Manager Application</realm-name>
+  </login-config>
+
+  <!-- Security roles referenced by this web application -->
+  <security-role>
+    <description>
+      The role that is required to access the HTML Manager pages
+    </description>
+    <role-name>manager-gui</role-name>
+  </security-role>
+  <security-role>
+    <description>
+      The role that is required to access the text Manager pages
+    </description>
+    <role-name>manager-script</role-name>
+  </security-role>
+  <security-role>
+    <description>
+      The role that is required to access the HTML JMX Proxy
+    </description>
+    <role-name>manager-jmx</role-name>
+  </security-role>
+  <security-role>
+    <description>
+      The role that is required to access to the Manager Status pages
+    </description>
+    <role-name>manager-status</role-name>
+  </security-role>
+
+  <error-page>
+    <error-code>401</error-code>
+    <location>/WEB-INF/jsp/401.jsp</location>
+  </error-page>
+  <error-page>
+    <error-code>403</error-code>
+    <location>/WEB-INF/jsp/403.jsp</location>
+  </error-page>
+  <error-page>
+    <error-code>404</error-code>
+    <location>/WEB-INF/jsp/404.jsp</location>
+  </error-page>
+
+</web-app>

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/13da256f/stack/rest/catalina_base/webapps/manager/images/add.gif
----------------------------------------------------------------------
diff --git a/stack/rest/catalina_base/webapps/manager/images/add.gif b/stack/rest/catalina_base/webapps/manager/images/add.gif
new file mode 100644
index 0000000..0774d07
Binary files /dev/null and b/stack/rest/catalina_base/webapps/manager/images/add.gif differ

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/13da256f/stack/rest/catalina_base/webapps/manager/images/asf-logo.gif
----------------------------------------------------------------------
diff --git a/stack/rest/catalina_base/webapps/manager/images/asf-logo.gif b/stack/rest/catalina_base/webapps/manager/images/asf-logo.gif
new file mode 100644
index 0000000..22eb9d7
Binary files /dev/null and b/stack/rest/catalina_base/webapps/manager/images/asf-logo.gif differ

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/13da256f/stack/rest/catalina_base/webapps/manager/images/code.gif
----------------------------------------------------------------------
diff --git a/stack/rest/catalina_base/webapps/manager/images/code.gif b/stack/rest/catalina_base/webapps/manager/images/code.gif
new file mode 100644
index 0000000..d27307b
Binary files /dev/null and b/stack/rest/catalina_base/webapps/manager/images/code.gif differ

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/13da256f/stack/rest/catalina_base/webapps/manager/images/design.gif
----------------------------------------------------------------------
diff --git a/stack/rest/catalina_base/webapps/manager/images/design.gif b/stack/rest/catalina_base/webapps/manager/images/design.gif
new file mode 100644
index 0000000..f5db0a9
Binary files /dev/null and b/stack/rest/catalina_base/webapps/manager/images/design.gif differ

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/13da256f/stack/rest/catalina_base/webapps/manager/images/docs.gif
----------------------------------------------------------------------
diff --git a/stack/rest/catalina_base/webapps/manager/images/docs.gif b/stack/rest/catalina_base/webapps/manager/images/docs.gif
new file mode 100644
index 0000000..d64a4a1
Binary files /dev/null and b/stack/rest/catalina_base/webapps/manager/images/docs.gif differ

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/13da256f/stack/rest/catalina_base/webapps/manager/images/fix.gif
----------------------------------------------------------------------
diff --git a/stack/rest/catalina_base/webapps/manager/images/fix.gif b/stack/rest/catalina_base/webapps/manager/images/fix.gif
new file mode 100644
index 0000000..d59ad64
Binary files /dev/null and b/stack/rest/catalina_base/webapps/manager/images/fix.gif differ

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/13da256f/stack/rest/catalina_base/webapps/manager/images/tomcat.gif
----------------------------------------------------------------------
diff --git a/stack/rest/catalina_base/webapps/manager/images/tomcat.gif b/stack/rest/catalina_base/webapps/manager/images/tomcat.gif
new file mode 100644
index 0000000..f2aa6f8
Binary files /dev/null and b/stack/rest/catalina_base/webapps/manager/images/tomcat.gif differ

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/13da256f/stack/rest/catalina_base/webapps/manager/images/update.gif
----------------------------------------------------------------------
diff --git a/stack/rest/catalina_base/webapps/manager/images/update.gif b/stack/rest/catalina_base/webapps/manager/images/update.gif
new file mode 100644
index 0000000..31e22ab
Binary files /dev/null and b/stack/rest/catalina_base/webapps/manager/images/update.gif differ

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/13da256f/stack/rest/catalina_base/webapps/manager/images/void.gif
----------------------------------------------------------------------
diff --git a/stack/rest/catalina_base/webapps/manager/images/void.gif b/stack/rest/catalina_base/webapps/manager/images/void.gif
new file mode 100644
index 0000000..e565824
Binary files /dev/null and b/stack/rest/catalina_base/webapps/manager/images/void.gif differ

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/13da256f/stack/rest/catalina_base/webapps/manager/index.jsp
----------------------------------------------------------------------
diff --git a/stack/rest/catalina_base/webapps/manager/index.jsp b/stack/rest/catalina_base/webapps/manager/index.jsp
new file mode 100644
index 0000000..d4816e5
--- /dev/null
+++ b/stack/rest/catalina_base/webapps/manager/index.jsp
@@ -0,0 +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
+
+      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.
+--%>
+<% response.sendRedirect(response.encodeRedirectURL(request.getContextPath() +
+        "/html")); %>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/13da256f/stack/rest/catalina_base/webapps/manager/status.xsd
----------------------------------------------------------------------
diff --git a/stack/rest/catalina_base/webapps/manager/status.xsd b/stack/rest/catalina_base/webapps/manager/status.xsd
new file mode 100644
index 0000000..5af979d
--- /dev/null
+++ b/stack/rest/catalina_base/webapps/manager/status.xsd
@@ -0,0 +1,84 @@
+<?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.
+-->
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
+    <xs:element name="status">
+        <xs:complexType>
+            <xs:sequence>
+                <xs:element name="jvm" type="jvm"/>
+                <xs:element name="connector" type="connector" minOccurs="1" maxOccurs="unbounded"/>
+            </xs:sequence>
+        </xs:complexType>
+    </xs:element>
+    <xs:complexType name="connector">
+        <xs:sequence>
+            <xs:element name="threadInfo" type="threadInfo"/>
+            <xs:element name="requestInfo" type="requestInfo"/>
+            <xs:element name="workers" type="workers"/>
+        </xs:sequence>
+        <xs:attribute name="name" type="xs:string" use="required"/>
+    </xs:complexType>
+    <xs:complexType name="jvm">
+        <xs:sequence>
+            <xs:element name="memory" type="memory"/>
+            <xs:element name="memorypool" type="memorypool" minOccurs="0" maxOccurs="unbounded"/>
+        </xs:sequence>
+    </xs:complexType>
+    <xs:complexType name="memory">
+        <xs:attribute name="free" type="xs:long" use="required"/>
+        <xs:attribute name="total" type="xs:long" use="required"/>
+        <xs:attribute name="max" type="xs:long" use="required"/>
+    </xs:complexType>
+    <xs:complexType name="memorypool">
+        <xs:attribute name="name" type="xs:string" use="required"/>
+        <xs:attribute name="type" type="xs:string" use="required"/>
+        <xs:attribute name="usageInit" type="xs:long" use="required"/>
+        <xs:attribute name="usageCommitted" type="xs:long" use="required"/>
+        <xs:attribute name="usageMax" type="xs:long" use="required"/>
+        <xs:attribute name="usageUsed" type="xs:long" use="required"/>
+    </xs:complexType>
+    <xs:complexType name="requestInfo">
+        <xs:attribute name="maxTime" type="xs:long" use="required"/>
+        <xs:attribute name="processingTime" type="xs:int" use="required"/>
+        <xs:attribute name="requestCount" type="xs:long" use="required"/>
+        <xs:attribute name="errorCount" type="xs:long" use="required"/>
+        <xs:attribute name="bytesReceived" type="xs:long" use="required"/>
+        <xs:attribute name="bytesSent" type="xs:long" use="required"/>
+    </xs:complexType>
+    <xs:complexType name="threadInfo">
+        <xs:attribute name="maxThreads" type="xs:int" use="required"/>
+        <xs:attribute name="currentThreadCount" type="xs:int" use="required"/>
+        <xs:attribute name="currentThreadsBusy" type="xs:int" use="required"/>
+    </xs:complexType>
+    <xs:complexType name="worker">
+        <xs:attribute name="stage" type="xs:string" use="required"/>
+        <xs:attribute name="requestProcessingTime" type="xs:int" use="required"/>
+        <xs:attribute name="requestBytesSent" type="xs:long" use="required"/>
+        <xs:attribute name="requestBytesReceived" type="xs:long" use="required"/>
+        <xs:attribute name="remoteAddr" type="xs:string" use="required"/>
+        <xs:attribute name="virtualHost" type="xs:string" use="required"/>
+        <xs:attribute name="method" type="xs:string" use="required"/>
+        <xs:attribute name="currentUri" type="xs:string" use="required"/>
+        <xs:attribute name="currentQueryString" type="xs:string" use="required"/>
+        <xs:attribute name="protocol" type="xs:string" use="required"/>
+    </xs:complexType>
+    <xs:complexType name="workers">
+        <xs:sequence>
+            <xs:element name="worker" type="worker" minOccurs="0" maxOccurs="unbounded"/>
+        </xs:sequence>
+    </xs:complexType>
+</xs:schema>

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/13da256f/stack/rest/catalina_base/webapps/manager/xform.xsl
----------------------------------------------------------------------
diff --git a/stack/rest/catalina_base/webapps/manager/xform.xsl b/stack/rest/catalina_base/webapps/manager/xform.xsl
new file mode 100644
index 0000000..b07fcb9
--- /dev/null
+++ b/stack/rest/catalina_base/webapps/manager/xform.xsl
@@ -0,0 +1,125 @@
+<?xml version="1.0"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+  version="1.0">
+
+  <!-- Output method -->
+  <xsl:output encoding="iso-8859-1"
+              indent="no"/>
+
+  <xsl:template match="status">
+    <html>
+    <head>
+        <TITLE>Tomcat Status</TITLE>
+        <STYLE type="text/css">
+            body, table, tr, td, a, div, span {
+                vertical-align : top;
+            }
+        </STYLE>
+    </head>
+    <body>
+      <div style='font-size:20px;'>Tomcat Status</div>
+
+      <xsl:apply-templates select="jvm"/>
+      <xsl:apply-templates select="connector"/>
+     </body>
+    </html>
+  </xsl:template>
+
+  <xsl:template match="jvm">
+   <xsl:apply-templates select="memory"/>
+   <b>Memory Pools</b><br />
+   <xsl:apply-templates select="memorypool"/>
+   <hr />
+  </xsl:template>
+
+  <xsl:template match="memory">
+    <table><tr>
+             <td><b>JVM:</b></td>
+             <td><b>free:</b> <xsl:value-of select="@free"/></td>
+             <td><b>total:</b> <xsl:value-of select="@total"/></td>
+             <td><b>max:</b> <xsl:value-of select="@max"/></td>
+           </tr>
+    </table><hr />
+  </xsl:template>
+
+  <xsl:template match="memorypool">
+    <table><tr>
+             <td><b>Name:</b> <xsl:value-of select="@name"/></td>
+             <td><b>Type:</b> <xsl:value-of select="@type"/></td>
+             <td><b>Initial:</b> <xsl:value-of select="@usageInit"/></td>
+             <td><b>Committed:</b> <xsl:value-of select="@usageCommitted"/></td>
+             <td><b>Maximum:</b> <xsl:value-of select="@usageMax"/></td>
+             <td><b>Used:</b> <xsl:value-of select="@usageUsed"/></td>
+           </tr>
+    </table>
+  </xsl:template>
+
+  <xsl:template match="connector">
+     <b>Connector -- </b> <xsl:value-of select="@name"/><br />
+
+      <xsl:apply-templates select="threadInfo"/>
+      <xsl:apply-templates select="requestInfo"/>
+      <xsl:apply-templates select="workers"/>
+  </xsl:template>
+
+  <xsl:template match="threadInfo">
+    <table><tr>
+             <td><b>threadInfo</b></td>
+             <td><b>maxThreads:</b> <xsl:value-of select="@maxThreads"/></td>
+             <td><b>currentThreadCount:</b> <xsl:value-of select="@currentThreadCount"/></td>
+             <td><b>currentThreadsBusy:</b> <xsl:value-of select="@currentThreadsBusy"/></td>
+           </tr>
+    </table><hr />
+  </xsl:template>
+
+  <xsl:template match="requestInfo">
+    <table><tr>
+             <td><b>requestInfo </b></td>
+             <td><b>maxTime:</b> <xsl:value-of select="@maxTime"/></td>
+             <td><b>processingTime:</b> <xsl:value-of select="@processingTime"/></td>
+             <td><b>requestCount:</b> <xsl:value-of select="@requestCount"/></td>
+             <td><b>errorCount:</b> <xsl:value-of select="@errorCount"/></td>
+             <td><b>bytesReceived:</b> <xsl:value-of select="@bytesReceived"/></td>
+             <td><b>bytesSent:</b> <xsl:value-of select="@bytesSent"/></td>
+           </tr>
+    </table><hr />
+  </xsl:template>
+
+  <xsl:template match="workers">
+   <table>
+    <tr><th>Stage</th><th>Time</th><th>B Sent</th><th>B Recv</th><th>Client</th><th>VHost</th><th>Request</th></tr>
+      <xsl:apply-templates select="worker"/>
+
+   </table><hr />
+  </xsl:template>
+
+  <xsl:template match="worker">
+   <tr>
+    <td><xsl:value-of select="@stage"/></td>
+    <td><xsl:value-of select="@requestProcessingTime"/></td>
+    <td><xsl:value-of select="@requestBytesSent"/></td>
+    <td><xsl:value-of select="@requestBytesReceived"/></td>
+    <td><xsl:value-of select="@remoteAddr"/></td>
+    <td><xsl:value-of select="@virtualHost"/></td>
+    <td><xsl:value-of select="@method"/> <xsl:value-of select="@currentUri"/>?<xsl:value-of select="@currentQueryString"/> <xsl:value-of select="@protocol"/></td>
+   </tr>
+  </xsl:template>
+
+</xsl:stylesheet>

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/13da256f/stack/rest/catalina_base/webapps/portal
----------------------------------------------------------------------
diff --git a/stack/rest/catalina_base/webapps/portal b/stack/rest/catalina_base/webapps/portal
new file mode 120000
index 0000000..b88a900
--- /dev/null
+++ b/stack/rest/catalina_base/webapps/portal
@@ -0,0 +1 @@
+../../../../portal/
\ No newline at end of file


[15/50] [abbrv] incubator-usergrid git commit: [USERGRID-409} Fixed all commit errors and merged the STATIC_APPLICATION_KEYSPACE and the SYSTEM_KEYSPACE into a single static ApplicationKeyspace. This allows us to separate a keyspace for each individual a

Posted by sn...@apache.org.
[USERGRID-409} Fixed all commit errors and merged the STATIC_APPLICATION_KEYSPACE and the SYSTEM_KEYSPACE into a single static ApplicationKeyspace. This allows us to separate a keyspace for each individual application on the system.


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

Branch: refs/heads/two-dot-o
Commit: f817f52437cfe3202db12c56b9f94b616ac8431c
Parents: 13da256
Author: grey <gr...@apigee.com>
Authored: Mon Feb 23 12:02:26 2015 -0800
Committer: grey <gr...@apigee.com>
Committed: Mon Feb 23 12:02:26 2015 -0800

----------------------------------------------------------------------
 .../usergrid/corepersistence/CpSetup.java       | 35 ++++++------
 .../persistence/cassandra/CassandraService.java | 58 +++++++++++---------
 .../cassandra/EntityManagerFactoryImpl.java     | 20 +++----
 .../persistence/cassandra/SetupImpl.java        | 43 +++++++--------
 .../main/resources/usergrid-core-context.xml    |  1 +
 .../core/astyanax/AstyanaxKeyspaceProvider.java |  2 +-
 .../persistence/core/astyanax/CassandraFig.java | 10 ++--
 .../tokens/cassandra/TokenServiceImpl.java      | 14 ++---
 8 files changed, 93 insertions(+), 90 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/f817f524/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpSetup.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpSetup.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpSetup.java
index a09ca49..c71c172 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpSetup.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpSetup.java
@@ -45,10 +45,9 @@ import static org.apache.usergrid.persistence.cassandra.CassandraService.DEFAULT
 import static org.apache.usergrid.persistence.cassandra.CassandraService.MANAGEMENT_APPLICATION;
 import static org.apache.usergrid.persistence.cassandra.CassandraService.PRINCIPAL_TOKEN_CF;
 import static org.apache.usergrid.persistence.cassandra.CassandraService.PROPERTIES_CF;
-import static org.apache.usergrid.persistence.cassandra.CassandraService.STATIC_APPLICATION_KEYSPACE;
-import static org.apache.usergrid.persistence.cassandra.CassandraService.SYSTEM_KEYSPACE;
 import static org.apache.usergrid.persistence.cassandra.CassandraService.TOKENS_CF;
 import static org.apache.usergrid.persistence.cassandra.CassandraService.USE_VIRTUAL_KEYSPACES;
+import static org.apache.usergrid.persistence.cassandra.CassandraService.getApplicationKeyspace;
 import static org.apache.usergrid.persistence.cassandra.CassandraService.keyspaceForApplication;
 
 
@@ -146,17 +145,17 @@ public class CpSetup implements Setup {
 
         migrate();
 
-        cass.createColumnFamily( SYSTEM_KEYSPACE,
-            createColumnFamilyDefinition( SYSTEM_KEYSPACE, APPLICATIONS_CF, ComparatorType.BYTESTYPE ) );
+        cass.createColumnFamily( getApplicationKeyspace(),
+            createColumnFamilyDefinition( getApplicationKeyspace(), APPLICATIONS_CF, ComparatorType.BYTESTYPE ) );
 
-        cass.createColumnFamily( SYSTEM_KEYSPACE,
-            createColumnFamilyDefinition( SYSTEM_KEYSPACE, PROPERTIES_CF, ComparatorType.BYTESTYPE ) );
+        cass.createColumnFamily( getApplicationKeyspace(),
+            createColumnFamilyDefinition( getApplicationKeyspace(), PROPERTIES_CF, ComparatorType.BYTESTYPE ) );
 
-        cass.createColumnFamily( SYSTEM_KEYSPACE,
-            createColumnFamilyDefinition( SYSTEM_KEYSPACE, TOKENS_CF, ComparatorType.BYTESTYPE ) );
+        cass.createColumnFamily( getApplicationKeyspace(),
+            createColumnFamilyDefinition( getApplicationKeyspace(), TOKENS_CF, ComparatorType.BYTESTYPE ) );
 
-        cass.createColumnFamily( SYSTEM_KEYSPACE,
-            createColumnFamilyDefinition( SYSTEM_KEYSPACE, PRINCIPAL_TOKEN_CF, ComparatorType.UUIDTYPE ) );
+        cass.createColumnFamily( getApplicationKeyspace(),
+            createColumnFamilyDefinition( getApplicationKeyspace(), PRINCIPAL_TOKEN_CF, ComparatorType.UUIDTYPE ) );
 
         logger.info( "System keyspace initialized" );
     }
@@ -184,7 +183,7 @@ public class CpSetup implements Setup {
             logger.info( "Creating application keyspace " + app_keyspace + " for " + applicationName + " application" );
 
             cass.createColumnFamily( app_keyspace,
-                createColumnFamilyDefinition( SYSTEM_KEYSPACE, APPLICATIONS_CF, ComparatorType.BYTESTYPE ) );
+                createColumnFamilyDefinition( getApplicationKeyspace(), APPLICATIONS_CF, ComparatorType.BYTESTYPE ) );
 
             cass.createColumnFamilies( app_keyspace, getCfDefs( ApplicationCF.class, app_keyspace ) );
 
@@ -202,17 +201,17 @@ public class CpSetup implements Setup {
 
         if ( USE_VIRTUAL_KEYSPACES ) {
 
-            logger.info( "Creating static application keyspace " + STATIC_APPLICATION_KEYSPACE );
+            logger.info( "Creating static application keyspace " + getApplicationKeyspace() );
 
-            cass.createColumnFamily( STATIC_APPLICATION_KEYSPACE,
-                createColumnFamilyDefinition( STATIC_APPLICATION_KEYSPACE, APPLICATIONS_CF,
+            cass.createColumnFamily( getApplicationKeyspace(),
+                createColumnFamilyDefinition( getApplicationKeyspace(), APPLICATIONS_CF,
                     ComparatorType.BYTESTYPE ) );
 
-            cass.createColumnFamilies( STATIC_APPLICATION_KEYSPACE,
-                getCfDefs( ApplicationCF.class, STATIC_APPLICATION_KEYSPACE ) );
+            cass.createColumnFamilies( getApplicationKeyspace(),
+                getCfDefs( ApplicationCF.class, getApplicationKeyspace() ) );
 
-            cass.createColumnFamilies( STATIC_APPLICATION_KEYSPACE,
-                getCfDefs( QueuesCF.class, STATIC_APPLICATION_KEYSPACE ) );
+            cass.createColumnFamilies( getApplicationKeyspace(),
+                getCfDefs( QueuesCF.class, getApplicationKeyspace() ) );
         }
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/f817f524/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/CassandraService.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/CassandraService.java b/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/CassandraService.java
index 2322b95..2c74e77 100644
--- a/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/CassandraService.java
+++ b/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/CassandraService.java
@@ -36,9 +36,12 @@ import org.apache.usergrid.persistence.IndexBucketLocator;
 import org.apache.usergrid.persistence.IndexBucketLocator.IndexType;
 import org.apache.usergrid.persistence.cassandra.index.IndexBucketScanner;
 import org.apache.usergrid.persistence.cassandra.index.IndexScanner;
+import org.apache.usergrid.persistence.core.astyanax.CassandraFig;
 import org.apache.usergrid.persistence.hector.CountingMutator;
 import org.apache.usergrid.utils.MapUtils;
 
+import com.google.inject.Injector;
+
 import me.prettyprint.cassandra.connection.HConnectionManager;
 import me.prettyprint.cassandra.model.ConfigurableConsistencyLevel;
 import me.prettyprint.cassandra.serializers.ByteBufferSerializer;
@@ -90,10 +93,10 @@ import static org.apache.usergrid.utils.MapUtils.filter;
 
 public class CassandraService {
 
-    public static String SYSTEM_KEYSPACE = "Usergrid";
-
-    public static String STATIC_APPLICATION_KEYSPACE = "Usergrid_Applications";
+    //make the below two not static
+   // public static String SYSTEM_KEYSPACE = "Usergrid";
 
+    public static String applicationKeyspace;
     public static final boolean USE_VIRTUAL_KEYSPACES = true;
 
     public static final String APPLICATIONS_CF = "Applications";
@@ -137,14 +140,17 @@ public class CassandraService {
 
     public static final UUID NULL_ID = new UUID( 0, 0 );
 
-
+//Wire guice injector via spring here, just pass the injector in the spring
     public CassandraService( Properties properties, Cluster cluster,
-                             CassandraHostConfigurator cassandraHostConfigurator, LockManager lockManager ) {
+                             CassandraHostConfigurator cassandraHostConfigurator, LockManager lockManager,
+                           final Injector injector) {
         this.properties = properties;
         this.cluster = cluster;
         chc = cassandraHostConfigurator;
         this.lockManager = lockManager;
         db_logger.info( "" + cluster.getKnownPoolHosts( false ) );
+        //getInjector
+        applicationKeyspace  = injector.getInstance( CassandraFig.class ).getApplicationKeyspace();
     }
 
 
@@ -158,7 +164,7 @@ public class CassandraService {
         accessMap.put( "username", properties.getProperty( "cassandra.username" ) );
         accessMap.put( "password", properties.getProperty( "cassandra.password" ) );
         systemKeyspace =
-                HFactory.createKeyspace( SYSTEM_KEYSPACE, cluster, consistencyLevelPolicy, ON_FAIL_TRY_ALL_AVAILABLE,
+                HFactory.createKeyspace( getApplicationKeyspace() , cluster, consistencyLevelPolicy, ON_FAIL_TRY_ALL_AVAILABLE,
                         accessMap );
 
 
@@ -168,6 +174,9 @@ public class CassandraService {
 
     }
 
+    public static String getApplicationKeyspace() {
+        return applicationKeyspace;
+    }
 
     public Cluster getCluster() {
         return cluster;
@@ -230,7 +239,7 @@ public class CassandraService {
     /** @return keyspace for application UUID */
     public static String keyspaceForApplication( UUID applicationId ) {
         if ( USE_VIRTUAL_KEYSPACES ) {
-            return STATIC_APPLICATION_KEYSPACE;
+            return getApplicationKeyspace();
         }
         else {
             return "Application_" + applicationId.toString().replace( '-', '_' );
@@ -271,20 +280,15 @@ public class CassandraService {
 
     /** The Usergrid_Applications keyspace directly */
     public Keyspace getUsergridApplicationKeyspace() {
-        return getKeyspace( STATIC_APPLICATION_KEYSPACE, null );
-    }
-
-
-    public Keyspace getSystemKeyspace() {
-        return systemKeyspace;
+        return getKeyspace( getApplicationKeyspace(), null );
     }
 
 
     public boolean checkKeyspacesExist() {
         boolean exists = false;
         try {
-            exists = cluster.describeKeyspace( SYSTEM_KEYSPACE ) != null
-                    && cluster.describeKeyspace( STATIC_APPLICATION_KEYSPACE ) != null;
+            exists = cluster.describeKeyspace( getApplicationKeyspace() ) != null;
+
         }
         catch ( Exception ex ) {
             logger.error( "could not describe keyspaces", ex );
@@ -406,7 +410,7 @@ public class CassandraService {
     /**
      * Gets the columns.
      *
-     * @param keyspace the keyspace
+     * @param ko the keyspace
      * @param columnFamily the column family
      * @param key the key
      *
@@ -462,7 +466,7 @@ public class CassandraService {
     /**
      * Gets the columns.
      *
-     * @param keyspace the keyspace
+     * @param ko the keyspace
      * @param columnFamily the column family
      * @param key the key
      * @param start the start
@@ -584,7 +588,7 @@ public class CassandraService {
     /**
      * Gets the columns.
      *
-     * @param keyspace the keyspace
+     * @param ko the keyspace
      * @param columnFamily the column family
      * @param keys the keys
      *
@@ -623,7 +627,7 @@ public class CassandraService {
     /**
      * Gets the columns.
      *
-     * @param keyspace the keyspace
+     * @param ko the keyspace
      * @param columnFamily the column family
      * @param key the key
      * @param columnNames the column names
@@ -668,7 +672,7 @@ public class CassandraService {
     /**
      * Gets the columns.
      *
-     * @param keyspace the keyspace
+     * @param ko the keyspace
      * @param columnFamily the column family
      * @param keys the keys
      * @param columnNames the column names
@@ -711,7 +715,7 @@ public class CassandraService {
     /**
      * Gets the column.
      *
-     * @param keyspace the keyspace
+     * @param ko the keyspace
      * @param columnFamily the column family
      * @param key the key
      * @param column the column
@@ -827,7 +831,7 @@ public class CassandraService {
     /**
      * Sets the columns.
      *
-     * @param keyspace the keyspace
+     * @param ko the keyspace
      * @param columnFamily the column family
      * @param key the key
      * @param map the map
@@ -894,7 +898,7 @@ public class CassandraService {
     /**
      * Delete column.
      *
-     * @param keyspace the keyspace
+     * @param ko the keyspace
      * @param columnFamily the column family
      * @param key the key
      * @param column the column
@@ -915,7 +919,7 @@ public class CassandraService {
     /**
      * Gets the row keys.
      *
-     * @param keyspace the keyspace
+     * @param ko the keyspace
      * @param columnFamily the column family
      *
      * @return set of keys
@@ -953,7 +957,7 @@ public class CassandraService {
     /**
      * Gets the row keys as uui ds.
      *
-     * @param keyspace the keyspace
+     * @param ko the keyspace
      * @param columnFamily the column family
      *
      * @return list of row key UUIDs
@@ -985,7 +989,7 @@ public class CassandraService {
     /**
      * Delete row.
      *
-     * @param keyspace the keyspace
+     * @param ko the keyspace
      * @param columnFamily the column family
      * @param key the key
      *
@@ -1043,7 +1047,7 @@ public class CassandraService {
 
 
 
-    
+
     public void destroy() throws Exception {
     	if (cluster != null) {
     		HConnectionManager connectionManager = cluster.getConnectionManager();

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/f817f524/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/EntityManagerFactoryImpl.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/EntityManagerFactoryImpl.java b/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/EntityManagerFactoryImpl.java
index 8b5906c..9a90e59 100644
--- a/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/EntityManagerFactoryImpl.java
+++ b/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/EntityManagerFactoryImpl.java
@@ -192,7 +192,7 @@ public class EntityManagerFactoryImpl implements EntityManagerFactory, Applicati
         String appName = buildAppName( organizationName, name );
 
         HColumn<String, ByteBuffer> column =
-                cass.getColumn( cass.getSystemKeyspace(), APPLICATIONS_CF, appName, PROPERTY_UUID );
+                cass.getColumn( cass.getUsergridApplicationKeyspace(), APPLICATIONS_CF, appName, PROPERTY_UUID );
         if ( column != null ) {
             throw new ApplicationAlreadyExistsException( name );
             // UUID uuid = uuid(column.getValue());
@@ -236,7 +236,7 @@ public class EntityManagerFactoryImpl implements EntityManagerFactory, Applicati
 
         getSetup().setupApplicationKeyspace( applicationId, appName );
 
-        Keyspace ko = cass.getSystemKeyspace();
+        Keyspace ko = cass.getUsergridApplicationKeyspace();
         Mutator<ByteBuffer> m = CountingMutator.createFlushingMutator( ko, be );
 
         long timestamp = cass.createTimestamp();
@@ -262,7 +262,7 @@ public class EntityManagerFactoryImpl implements EntityManagerFactory, Applicati
         name = buildAppName( organizationName, name );
 
         HColumn<String, ByteBuffer> column =
-                cass.getColumn( cass.getSystemKeyspace(), APPLICATIONS_CF, name, PROPERTY_UUID );
+                cass.getColumn( cass.getUsergridApplicationKeyspace(), APPLICATIONS_CF, name, PROPERTY_UUID );
         if ( column != null ) {
             throw new ApplicationAlreadyExistsException( name );
             // UUID uuid = uuid(column.getValue());
@@ -278,7 +278,7 @@ public class EntityManagerFactoryImpl implements EntityManagerFactory, Applicati
     public UUID lookupApplication( String name ) throws Exception {
         name = name.toLowerCase();
         HColumn<String, ByteBuffer> column =
-                cass.getColumn( cass.getSystemKeyspace(), APPLICATIONS_CF, name, PROPERTY_UUID );
+                cass.getColumn( cass.getUsergridApplicationKeyspace(), APPLICATIONS_CF, name, PROPERTY_UUID );
         if ( column != null ) {
             return uuid( column.getValue() );
         }
@@ -299,7 +299,7 @@ public class EntityManagerFactoryImpl implements EntityManagerFactory, Applicati
     public Application getApplication( String name ) throws Exception {
         name = name.toLowerCase();
         HColumn<String, ByteBuffer> column =
-                cass.getColumn( cass.getSystemKeyspace(), APPLICATIONS_CF, name, PROPERTY_UUID );
+                cass.getColumn( cass.getUsergridApplicationKeyspace(), APPLICATIONS_CF, name, PROPERTY_UUID );
         if ( column == null ) {
             return null;
         }
@@ -314,7 +314,7 @@ public class EntityManagerFactoryImpl implements EntityManagerFactory, Applicati
     @Override
     public Map<String, UUID> getApplications() throws Exception {
         Map<String, UUID> applications = new TreeMap<String, UUID>( CASE_INSENSITIVE_ORDER );
-        Keyspace ko = cass.getSystemKeyspace();
+        Keyspace ko = cass.getUsergridApplicationKeyspace();
         RangeSlicesQuery<String, String, UUID> q = createRangeSlicesQuery( ko, se, se, ue );
         q.setKeys( "", "\uFFFF" );
         q.setColumnFamily( APPLICATIONS_CF );
@@ -333,7 +333,7 @@ public class EntityManagerFactoryImpl implements EntityManagerFactory, Applicati
    @Override
     public boolean setServiceProperty( String name, String value ) {
         try {
-            cass.setColumn( cass.getSystemKeyspace(), PROPERTIES_CF, PROPERTIES_CF, name, value );
+            cass.setColumn( cass.getUsergridApplicationKeyspace(), PROPERTIES_CF, PROPERTIES_CF, name, value );
             return true;
         }
         catch ( Exception e ) {
@@ -346,7 +346,7 @@ public class EntityManagerFactoryImpl implements EntityManagerFactory, Applicati
     @Override
     public boolean deleteServiceProperty( String name ) {
         try {
-            cass.deleteColumn( cass.getSystemKeyspace(), PROPERTIES_CF, PROPERTIES_CF, name );
+            cass.deleteColumn( cass.getUsergridApplicationKeyspace(), PROPERTIES_CF, PROPERTIES_CF, name );
             return true;
         }
         catch ( Exception e ) {
@@ -359,7 +359,7 @@ public class EntityManagerFactoryImpl implements EntityManagerFactory, Applicati
     @Override
     public boolean updateServiceProperties( Map<String, String> properties ) {
         try {
-            cass.setColumns( cass.getSystemKeyspace(), PROPERTIES_CF, PROPERTIES_CF.getBytes(), properties );
+            cass.setColumns( cass.getUsergridApplicationKeyspace(), PROPERTIES_CF, PROPERTIES_CF.getBytes(), properties );
             return true;
         }
         catch ( Exception e ) {
@@ -372,7 +372,7 @@ public class EntityManagerFactoryImpl implements EntityManagerFactory, Applicati
     @Override
     public Map<String, String> getServiceProperties() {
         try {
-            return asMap( cass.getAllColumns( cass.getSystemKeyspace(), PROPERTIES_CF, PROPERTIES_CF, se, se ) );
+            return asMap( cass.getAllColumns( cass.getUsergridApplicationKeyspace(), PROPERTIES_CF, PROPERTIES_CF, se, se ) );
         }
         catch ( Exception e ) {
             logger.error( "Unable to load properties: " + e.getMessage() );

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/f817f524/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/SetupImpl.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/SetupImpl.java b/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/SetupImpl.java
index 97a7654..775f43b 100644
--- a/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/SetupImpl.java
+++ b/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/SetupImpl.java
@@ -29,10 +29,9 @@ import static org.apache.usergrid.persistence.cassandra.CassandraService.DEFAULT
 import static org.apache.usergrid.persistence.cassandra.CassandraService.MANAGEMENT_APPLICATION;
 import static org.apache.usergrid.persistence.cassandra.CassandraService.PRINCIPAL_TOKEN_CF;
 import static org.apache.usergrid.persistence.cassandra.CassandraService.PROPERTIES_CF;
-import static org.apache.usergrid.persistence.cassandra.CassandraService.STATIC_APPLICATION_KEYSPACE;
-import static org.apache.usergrid.persistence.cassandra.CassandraService.SYSTEM_KEYSPACE;
 import static org.apache.usergrid.persistence.cassandra.CassandraService.TOKENS_CF;
 import static org.apache.usergrid.persistence.cassandra.CassandraService.USE_VIRTUAL_KEYSPACES;
+import static org.apache.usergrid.persistence.cassandra.CassandraService.getApplicationKeyspace;
 import static org.apache.usergrid.persistence.cassandra.CassandraService.keyspaceForApplication;
 import org.apache.usergrid.persistence.entities.Application;
 import org.slf4j.Logger;
@@ -80,17 +79,17 @@ public class SetupImpl implements Setup {
 
         logger.info( "Initialize system keyspace" );
 
-        cass.createColumnFamily( SYSTEM_KEYSPACE, createColumnFamilyDefinition(
-                SYSTEM_KEYSPACE, APPLICATIONS_CF, ComparatorType.BYTESTYPE ) );
+        cass.createColumnFamily( getApplicationKeyspace(), createColumnFamilyDefinition(
+                getApplicationKeyspace(), APPLICATIONS_CF, ComparatorType.BYTESTYPE ) );
 
-        cass.createColumnFamily( SYSTEM_KEYSPACE, createColumnFamilyDefinition(
-                SYSTEM_KEYSPACE, PROPERTIES_CF, ComparatorType.BYTESTYPE ) );
+        cass.createColumnFamily( getApplicationKeyspace(), createColumnFamilyDefinition(
+                getApplicationKeyspace(), PROPERTIES_CF, ComparatorType.BYTESTYPE ) );
 
-        cass.createColumnFamily( SYSTEM_KEYSPACE, createColumnFamilyDefinition(
-                SYSTEM_KEYSPACE, TOKENS_CF, ComparatorType.BYTESTYPE ) );
+        cass.createColumnFamily( getApplicationKeyspace(), createColumnFamilyDefinition(
+                getApplicationKeyspace(), TOKENS_CF, ComparatorType.BYTESTYPE ) );
 
-        cass.createColumnFamily( SYSTEM_KEYSPACE, createColumnFamilyDefinition(
-                SYSTEM_KEYSPACE, PRINCIPAL_TOKEN_CF, ComparatorType.UUIDTYPE ) );
+        cass.createColumnFamily( getApplicationKeyspace(), createColumnFamilyDefinition(
+                getApplicationKeyspace(), PRINCIPAL_TOKEN_CF, ComparatorType.UUIDTYPE ) );
 
         logger.info( "System keyspace initialized" );
     }
@@ -115,7 +114,7 @@ public class SetupImpl implements Setup {
                     + applicationName + " application" );
 
             cass.createColumnFamily( app_keyspace, createColumnFamilyDefinition(
-                    SYSTEM_KEYSPACE, APPLICATIONS_CF, ComparatorType.BYTESTYPE ) );
+                    getApplicationKeyspace(), APPLICATIONS_CF, ComparatorType.BYTESTYPE ) );
 
             cass.createColumnFamilies( app_keyspace, getCfDefs( ApplicationCF.class, app_keyspace));
             cass.createColumnFamilies( app_keyspace, getCfDefs( QueuesCF.class, app_keyspace ) );
@@ -127,16 +126,16 @@ public class SetupImpl implements Setup {
 
         if ( USE_VIRTUAL_KEYSPACES ) {
 
-            logger.info( "Creating static application keyspace " + STATIC_APPLICATION_KEYSPACE );
+            logger.info( "Creating static application keyspace " + getApplicationKeyspace() );
 
-            cass.createColumnFamily( STATIC_APPLICATION_KEYSPACE,
-                    createColumnFamilyDefinition( STATIC_APPLICATION_KEYSPACE, APPLICATIONS_CF,
+            cass.createColumnFamily( getApplicationKeyspace(),
+                    createColumnFamilyDefinition( getApplicationKeyspace(), APPLICATIONS_CF,
                             ComparatorType.BYTESTYPE ) );
 
-            cass.createColumnFamilies( STATIC_APPLICATION_KEYSPACE,
-                    getCfDefs( ApplicationCF.class, STATIC_APPLICATION_KEYSPACE ) );
-            cass.createColumnFamilies( STATIC_APPLICATION_KEYSPACE,
-                    getCfDefs( QueuesCF.class, STATIC_APPLICATION_KEYSPACE ) );
+            cass.createColumnFamilies( getApplicationKeyspace(),
+                    getCfDefs( ApplicationCF.class, getApplicationKeyspace() ) );
+            cass.createColumnFamilies( getApplicationKeyspace(),
+                    getCfDefs( QueuesCF.class, getApplicationKeyspace() ) );
         }
     }
 
@@ -147,13 +146,13 @@ public class SetupImpl implements Setup {
 
 
     public static void logCFPermissions() {
-        System.out.println( SYSTEM_KEYSPACE + "." + APPLICATIONS_CF + ".<rw>=usergrid" );
-        System.out.println( SYSTEM_KEYSPACE + "." + PROPERTIES_CF + ".<rw>=usergrid" );
+        System.out.println( getApplicationKeyspace() + "." + APPLICATIONS_CF + ".<rw>=usergrid" );
+        System.out.println( getApplicationKeyspace() + "." + PROPERTIES_CF + ".<rw>=usergrid" );
         for ( CFEnum cf : ApplicationCF.values() ) {
-            System.out.println( STATIC_APPLICATION_KEYSPACE + "." + cf + ".<rw>=usergrid" );
+            System.out.println( getApplicationKeyspace() + "." + cf + ".<rw>=usergrid" );
         }
         for ( CFEnum cf : QueuesCF.values() ) {
-            System.out.println( STATIC_APPLICATION_KEYSPACE + "." + cf + ".<rw>=usergrid" );
+            System.out.println( getApplicationKeyspace() + "." + cf + ".<rw>=usergrid" );
         }
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/f817f524/stack/core/src/main/resources/usergrid-core-context.xml
----------------------------------------------------------------------
diff --git a/stack/core/src/main/resources/usergrid-core-context.xml b/stack/core/src/main/resources/usergrid-core-context.xml
index 60f69af..f0e5bd4 100644
--- a/stack/core/src/main/resources/usergrid-core-context.xml
+++ b/stack/core/src/main/resources/usergrid-core-context.xml
@@ -105,6 +105,7 @@
 		<constructor-arg ref="cassandraCluster" />
 		<constructor-arg ref="cassandraHostConfigurator" />
 		<constructor-arg ref="lockManager" />
+        <constructor-arg ref="injector"/>
 		<property name="consistencyLevelPolicy" ref="consistencyLevelPolicy"/>
 	</bean>
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/f817f524/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/AstyanaxKeyspaceProvider.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/AstyanaxKeyspaceProvider.java b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/AstyanaxKeyspaceProvider.java
index 8bd5a9f..5172331 100644
--- a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/AstyanaxKeyspaceProvider.java
+++ b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/AstyanaxKeyspaceProvider.java
@@ -73,7 +73,7 @@ public class AstyanaxKeyspaceProvider implements Provider<Keyspace> {
 
         AstyanaxContext<Keyspace> context =
                 new AstyanaxContext.Builder().forCluster( cassandraFig.getClusterName() )
-                        .forKeyspace( cassandraFig.getKeyspaceName() )
+                        .forKeyspace( cassandraFig.getApplicationKeyspace())
 
                         /*
                          * TODO tnine Filter this by adding a host supplier.  We will get token discovery from cassandra

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/f817f524/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/CassandraFig.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/CassandraFig.java b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/CassandraFig.java
index df94adc..1208a1a 100644
--- a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/CassandraFig.java
+++ b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/CassandraFig.java
@@ -53,9 +53,9 @@ public interface CassandraFig extends GuicyFig {
     @Default( "Usergrid" )
     String getClusterName();
 
-    @Key( "collections.keyspace" )
-    @Default( "Usergrid_Collections" )
-    String getKeyspaceName();
+    @Key( "cassandra.keyspace.application" )
+    @Default( "Usergrid_Applications" )
+    String getApplicationKeyspace();
 
     @Key( "cassandra.port" )
     @Default( "9160" )
@@ -71,8 +71,8 @@ public interface CassandraFig extends GuicyFig {
 
     @Key("cassandra.discovery")
     @Default( "RING_DESCRIBE" )
-    String getDiscoveryType();    
-    
+    String getDiscoveryType();
+
     @Key("cassandra.embedded")
     @Default( "false" )
     boolean isEmbedded();

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/f817f524/stack/services/src/main/java/org/apache/usergrid/security/tokens/cassandra/TokenServiceImpl.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/security/tokens/cassandra/TokenServiceImpl.java b/stack/services/src/main/java/org/apache/usergrid/security/tokens/cassandra/TokenServiceImpl.java
index 50156b5..4d8b987 100644
--- a/stack/services/src/main/java/org/apache/usergrid/security/tokens/cassandra/TokenServiceImpl.java
+++ b/stack/services/src/main/java/org/apache/usergrid/security/tokens/cassandra/TokenServiceImpl.java
@@ -261,7 +261,7 @@ public class TokenServiceImpl implements TokenService {
 
         long maxTokenTtl = getMaxTtl( TokenCategory.getFromBase64String( token ), tokenInfo.getPrincipal() );
 
-        Mutator<UUID> batch = createMutator( cassandra.getSystemKeyspace(), ue );
+        Mutator<UUID> batch = createMutator( cassandra.getUsergridApplicationKeyspace(), ue );
 
         HColumn<String, Long> col =
                 createColumn( TOKEN_ACCESSED, now, calcTokenTime( tokenInfo.getExpiration( maxTokenTtl ) ),
@@ -326,7 +326,7 @@ public class TokenServiceImpl implements TokenService {
     public void removeTokens( AuthPrincipalInfo principal ) throws Exception {
         List<UUID> tokenIds = getTokenUUIDS( principal );
 
-        Mutator<ByteBuffer> batch = createMutator( cassandra.getSystemKeyspace(), be );
+        Mutator<ByteBuffer> batch = createMutator( cassandra.getUsergridApplicationKeyspace(), be );
 
         for ( UUID tokenId : tokenIds ) {
             batch.addDeletion( bytebuffer( tokenId ), TOKENS_CF );
@@ -359,7 +359,7 @@ public class TokenServiceImpl implements TokenService {
 
         UUID tokenId = info.getUuid();
 
-        Mutator<ByteBuffer> batch = createMutator( cassandra.getSystemKeyspace(), be );
+        Mutator<ByteBuffer> batch = createMutator( cassandra.getUsergridApplicationKeyspace(), be );
 
         // clean up the link in the principal -> token index if the principal is
         // on the token
@@ -380,7 +380,7 @@ public class TokenServiceImpl implements TokenService {
             throw new InvalidTokenException( "No token specified" );
         }
         Map<String, ByteBuffer> columns = getColumnMap( cassandra
-                .getColumns( cassandra.getSystemKeyspace(), TOKENS_CF, uuid, TOKEN_PROPERTIES, se,
+                .getColumns( cassandra.getUsergridApplicationKeyspace(), TOKENS_CF, uuid, TOKEN_PROPERTIES, se,
                         be ) );
         if ( !hasKeys( columns, REQUIRED_TOKEN_PROPERTIES ) ) {
             throw new InvalidTokenException( "Token not found in database" );
@@ -415,7 +415,7 @@ public class TokenServiceImpl implements TokenService {
 
         ByteBuffer tokenUUID = bytebuffer( tokenInfo.getUuid() );
 
-        Keyspace ko = cassandra.getSystemKeyspace();
+        Keyspace ko = cassandra.getUsergridApplicationKeyspace();
 
         Mutator<ByteBuffer> m = createMutator( ko, be );
 
@@ -449,7 +449,7 @@ public class TokenServiceImpl implements TokenService {
 
       /*
        * write to the PRINCIPAL+TOKEN The format is as follow
-       * 
+       *
        * appid+principalId+principalType :{ tokenuuid: 0x00}
        */
 
@@ -473,7 +473,7 @@ public class TokenServiceImpl implements TokenService {
         ByteBuffer rowKey = principalKey( principal );
 
         List<HColumn<ByteBuffer, ByteBuffer>> cols = cassandra
-                .getColumns( cassandra.getSystemKeyspace(), PRINCIPAL_TOKEN_CF, rowKey, null, null, Integer.MAX_VALUE,
+                .getColumns( cassandra.getUsergridApplicationKeyspace(), PRINCIPAL_TOKEN_CF, rowKey, null, null, Integer.MAX_VALUE,
                         false );
 
         List<UUID> results = new ArrayList<UUID>( cols.size() );


[44/50] [abbrv] incubator-usergrid git commit: This closes #159

Posted by sn...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/bedf5afb/stack/services/src/test/java/org/apache/usergrid/management/export/ExportServiceIT.java
----------------------------------------------------------------------
diff --cc stack/services/src/test/java/org/apache/usergrid/management/export/ExportServiceIT.java
index 73ce1b1,0000000..3a6d8f9
mode 100644,000000..100644
--- a/stack/services/src/test/java/org/apache/usergrid/management/export/ExportServiceIT.java
+++ b/stack/services/src/test/java/org/apache/usergrid/management/export/ExportServiceIT.java
@@@ -1,1115 -1,0 +1,1116 @@@
 +/*
 + * 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.management.export;
 +
 +
 +import java.io.File;
 +import java.io.FileReader;
 +import java.util.*;
 +
 +import com.fasterxml.jackson.core.type.TypeReference;
 +import com.fasterxml.jackson.databind.ObjectMapper;
 +import com.google.common.util.concurrent.Service;
 +import org.apache.commons.lang.RandomStringUtils;
 +import org.apache.commons.lang3.StringUtils;
 +import org.apache.usergrid.batch.service.JobSchedulerService;
 +import org.jclouds.ContextBuilder;
 +import org.jclouds.blobstore.BlobStore;
 +import org.jclouds.blobstore.BlobStoreContext;
 +import org.jclouds.blobstore.domain.Blob;
 +import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule;
 +import org.jclouds.logging.log4j.config.Log4JLoggingModule;
 +import org.jclouds.netty.config.NettyPayloadModule;
 +import org.junit.*;
 +import org.slf4j.Logger;
 +import org.slf4j.LoggerFactory;
 +
 +import org.apache.usergrid.NewOrgAppAdminRule;
 +import org.apache.usergrid.ServiceITSetup;
 +import org.apache.usergrid.ServiceITSetupImpl;
 +import org.apache.usergrid.batch.JobExecution;
 +import org.apache.usergrid.cassandra.ClearShiroSubject;
 +
 +import org.apache.usergrid.management.ApplicationInfo;
 +import org.apache.usergrid.management.OrganizationInfo;
 +import org.apache.usergrid.management.UserInfo;
 +import org.apache.usergrid.persistence.Entity;
 +import org.apache.usergrid.persistence.EntityManager;
 +import org.apache.usergrid.persistence.SimpleEntityRef;
 +import org.apache.usergrid.persistence.entities.JobData;
 +import org.apache.usergrid.setup.ConcurrentProcessSingleton;
 +
 +import com.amazonaws.SDKGlobalConfiguration;
 +import com.google.common.collect.ImmutableSet;
 +import com.google.inject.Module;
 +
 +import static org.apache.usergrid.TestHelper.newUUIDString;
 +import static org.apache.usergrid.TestHelper.uniqueApp;
 +import static org.apache.usergrid.TestHelper.uniqueOrg;
 +import static org.junit.Assert.assertEquals;
 +import static org.junit.Assert.assertFalse;
 +import static org.junit.Assert.assertNotNull;
 +import static org.junit.Assert.assertTrue;
 +import static org.mockito.Mockito.mock;
 +import static org.mockito.Mockito.when;
 +
 +
 +/**
 + *
 + *
 + */
 +public class ExportServiceIT {
 +
 +    private static final Logger logger = LoggerFactory.getLogger( ExportServiceIT.class );
 +
 +
 +    @ClassRule
 +    public static final ServiceITSetup setup = new ServiceITSetupImpl(  );
 +
 +    @Rule
 +    public ClearShiroSubject clearShiroSubject = new ClearShiroSubject();
 +
 +    @Rule
 +    public NewOrgAppAdminRule newOrgAppAdminRule = new NewOrgAppAdminRule( setup );
 +
 +    // app-level data generated only once
 +    private UserInfo adminUser;
 +    private OrganizationInfo organization;
 +    private UUID applicationId;
 +
 +    private static String bucketPrefix;
 +
 +    private String bucketName;
 +
 +    @Before
 +    public void setup() throws Exception {
 +        logger.info("in setup");
 +
 +        // start the scheduler after we're all set up
 +        try {
 +
 +            JobSchedulerService jobScheduler = ConcurrentProcessSingleton.getInstance().getSpringResource().getBean(JobSchedulerService.class);
 +            if (jobScheduler.state() != Service.State.RUNNING) {
-                 jobScheduler.startAndWait();
++                jobScheduler.startAsync();
++                jobScheduler.awaitRunning();
 +            }
 +        } catch ( Exception e ) {
 +            logger.warn("Ignoring error starting jobScheduler, already started?", e);
 +        }
 +
 +        adminUser = newOrgAppAdminRule.getAdminInfo();
 +        organization = newOrgAppAdminRule.getOrganizationInfo();
 +        applicationId = newOrgAppAdminRule.getApplicationInfo().getId();
 +
 +        setup.getEmf().refreshIndex();
 +    }
 +
 +
 +    @Before
 +    public void before() {
 +
 +        boolean configured =
 +            !StringUtils.isEmpty(System.getProperty( SDKGlobalConfiguration.SECRET_KEY_ENV_VAR))
 +                && !StringUtils.isEmpty(System.getProperty( SDKGlobalConfiguration.ACCESS_KEY_ENV_VAR))
 +                && !StringUtils.isEmpty(System.getProperty("bucketName"));
 +
 +        if ( !configured ) {
 +            logger.warn("Skipping test because {}, {} and bucketName not " +
 +                    "specified as system properties, e.g. in your Maven settings.xml file.",
 +                new Object[] {
 +                    SDKGlobalConfiguration.SECRET_KEY_ENV_VAR,
 +                    SDKGlobalConfiguration.ACCESS_KEY_ENV_VAR
 +                });
 +        }
 +
 +        Assume.assumeTrue( configured );
 +
 +        adminUser = newOrgAppAdminRule.getAdminInfo();
 +        organization = newOrgAppAdminRule.getOrganizationInfo();
 +        applicationId = newOrgAppAdminRule.getApplicationInfo().getId();
 +
 +        bucketPrefix = System.getProperty( "bucketName" );
 +        bucketName = bucketPrefix + RandomStringUtils.randomAlphanumeric(10).toLowerCase();
 +    }
 +
 +
 +    //Tests to make sure we can call the job with mock data and it runs.
 +    @Ignore("Connections won't save when run with maven, but on local builds it will.")
 +    public void testConnectionsOnCollectionExport() throws Exception {
 +
 +        File f = null;
 +        int indexCon = 0;
 +
 +        try {
 +            f = new File( "testFileConnections.json" );
 +        }
 +        catch ( Exception e ) {
 +            // consumed because this checks to see if the file exists.
 +            // If it doesn't then don't do anything and carry on.
 +        }
 +        f.deleteOnExit();
 +
 +        S3Export s3Export = new MockS3ExportImpl("testFileConnections.json" );
 +
 +        ExportService exportService = setup.getExportService();
 +
 +        String appName = newOrgAppAdminRule.getApplicationInfo().getName();
 +        HashMap<String, Object> payload = payloadBuilder(appName);
 +
 +        payload.put( "organizationId", organization.getUuid() );
 +        payload.put( "applicationId", applicationId );
 +        payload.put( "collectionName", "users" );
 +
 +        EntityManager em = setup.getEmf().getEntityManager( applicationId );
 +        //intialize user object to be posted
 +        Map<String, Object> userProperties = null;
 +        Entity[] entity;
 +        entity = new Entity[2];
 +        //creates entities
 +        for ( int i = 0; i < 2; i++ ) {
 +            userProperties = new LinkedHashMap<String, Object>();
 +            userProperties.put( "username", "meatIsGreat" + i );
 +            userProperties.put( "email", "grey" + i + "@anuff.com" );//String.format( "test%i@anuff.com", i ) );
 +
 +            entity[i] = em.create( "users", userProperties );
 +        }
 +        //creates connections
 +        em.createConnection( em.get( new SimpleEntityRef( "user", entity[0].getUuid() ) ), "Vibrations",
 +            em.get( new SimpleEntityRef( "user", entity[1].getUuid() ) ) );
 +        em.createConnection(
 +                em.get( new SimpleEntityRef( "user", entity[1].getUuid()) ), "Vibrations",
 +                em.get( new SimpleEntityRef( "user", entity[0].getUuid()) ) );
 +
 +        UUID exportUUID = exportService.schedule( payload );
 +
 +        TypeReference<HashMap<String,Object>> typeRef
 +            = new TypeReference<HashMap<String,Object>>() {};
 +
 +        ObjectMapper mapper = new ObjectMapper();
 +        HashMap<String,Object> jsonMap = mapper.readValue(new FileReader( f ), typeRef);
 +
 +        Map collectionsMap = (Map)jsonMap.get("collections");
 +        List usersList = (List)collectionsMap.get("users");
 +
 +        int indexApp = 0;
 +        for ( indexApp = 0; indexApp < usersList.size(); indexApp++ ) {
 +            Map user = (Map)usersList.get( indexApp );
 +            Map userProps = (Map)user.get("Metadata");
 +            String uuid = ( String ) userProps.get( "uuid" );
 +            if ( entity[0].getUuid().toString().equals( uuid ) ) {
 +                break;
 +            }
 +        }
 +
 +        assertTrue("Uuid was not found in exported files. ", indexApp < usersList.size());
 +
 +        Map userMap = (Map)usersList.get( indexApp );
 +        Map connectionsMap = (Map)userMap.get("connections");
 +        assertNotNull( connectionsMap );
 +
 +        List vibrationsList = (List)connectionsMap.get( "Vibrations" );
 +
 +        assertNotNull( vibrationsList );
 +
 +        f.deleteOnExit();
 +    }
 +
 +
 +    @Test //Connections won't save when run with maven, but on local builds it will.
 +    public void testConnectionsOnApplicationEndpoint() throws Exception {
 +
 +        File f = null;
 +
 +        try {
 +            f = new File( "testConnectionsOnApplicationEndpoint.json" );
 +        }
 +        catch ( Exception e ) {
 +            // consumed because this checks to see if the file exists.
 +            // If it doesn't then don't do anything and carry on.
 +        }
 +
 +        String fileName = "testConnectionsOnApplicationEndpoint.json";
 +
 +        S3Export s3Export = new MockS3ExportImpl( "testConnectionsOnApplicationEndpoint.json" );
 +
 +        ExportService exportService = setup.getExportService();
 +
 +        String appName = newOrgAppAdminRule.getApplicationInfo().getName();
 +        HashMap<String, Object> payload = payloadBuilder( appName );
 +
 +        payload.put( "organizationId", organization.getUuid() );
 +        payload.put( "applicationId", applicationId );
 +
 +        EntityManager em = setup.getEmf().getEntityManager( applicationId );
 +
 +        // intialize user object to be posted
 +        Map<String, Object> userProperties = null;
 +        Entity[] entity;
 +        entity = new Entity[2];
 +
 +        // creates entities
 +        for ( int i = 0; i < 2; i++ ) {
 +            userProperties = new LinkedHashMap<String, Object>();
 +            userProperties.put( "username", "billybob" + i );
 +            userProperties.put( "email", "test" + i + "@anuff.com" );//String.format( "test%i@anuff.com", i ) );
 +
 +            entity[i] = em.create( "users", userProperties );
 +        }
 +        em.refreshIndex();
 +        //creates connections
 +        em.createConnection( em.get( new SimpleEntityRef( "user", entity[0].getUuid() ) ), "Vibrations",
 +            em.get( new SimpleEntityRef( "user", entity[1].getUuid() ) ) );
 +        em.createConnection(
 +                em.get( new SimpleEntityRef( "user", entity[1].getUuid())), "Vibrations",
 +                em.get( new SimpleEntityRef( "user", entity[0].getUuid())) );
 +
 +        UUID exportUUID = exportService.schedule( payload );
 +
 +        //create and initialize jobData returned in JobExecution.
 +        JobData jobData = jobDataCreator(payload,exportUUID,s3Export);
 +
 +        JobExecution jobExecution = mock( JobExecution.class );
 +        when( jobExecution.getJobData() ).thenReturn( jobData );
 +
 +        exportService.doExport( jobExecution );
 +
 +        TypeReference<HashMap<String,Object>> typeRef
 +            = new TypeReference<HashMap<String,Object>>() {};
 +
 +        ObjectMapper mapper = new ObjectMapper();
 +        HashMap<String,Object> jsonMap = mapper.readValue(new FileReader( f ), typeRef);
 +
 +        Map collectionsMap = (Map)jsonMap.get("collections");
 +        List usersList = (List)collectionsMap.get("users");
 +
 +        int indexApp = 0;
 +        for ( indexApp = 0; indexApp < usersList.size(); indexApp++ ) {
 +            Map user = (Map)usersList.get( indexApp );
 +            Map userProps = (Map)user.get("Metadata");
 +            String uuid = ( String ) userProps.get( "uuid" );
 +            if ( entity[0].getUuid().toString().equals( uuid ) ) {
 +                break;
 +            }
 +        }
 +
 +        assertTrue("Uuid was not found in exported files. ", indexApp < usersList.size());
 +
 +        Map userMap = (Map)usersList.get( indexApp );
 +        Map connectionsMap = (Map)userMap.get("connections");
 +        assertNotNull( connectionsMap );
 +
 +        List vibrationsList = (List)connectionsMap.get( "Vibrations" );
 +
 +        assertNotNull( vibrationsList );
 +
 +        f.deleteOnExit();
 +    }
 +
 +    @Test
 +    public void testExportOneOrgCollectionEndpoint() throws Exception {
 +
 +        File f = null;
 +
 +
 +        try {
 +            f = new File( "exportOneOrg.json" );
 +        }
 +        catch ( Exception e ) {
 +            //consumed because this checks to see if the file exists.
 +            // If it doesn't then don't do anything and carry on.
 +        }
 +
 +        //create another org to ensure we don't export it
 +        newOrgAppAdminRule.createOwnerAndOrganization(
 +            "noExport"+newUUIDString(),
 +            "junkUserName"+newUUIDString(),
 +            "junkRealName"+newUUIDString(),
 +            newUUIDString()+"ugExport@usergrid.com",
 +            "123456789" );
 +
 +        S3Export s3Export = new MockS3ExportImpl("exportOneOrg.json");
 +      //  s3Export.setFilename( "exportOneOrg.json" );
 +        ExportService exportService = setup.getExportService();
 +
 +        String appName = newOrgAppAdminRule.getApplicationInfo().getName();
 +        HashMap<String, Object> payload = payloadBuilder(appName);
 +
 +        payload.put( "organizationId", organization.getUuid() );
 +        payload.put( "applicationId", applicationId );
 +        payload.put( "collectionName", "roles" );
 +
 +        UUID exportUUID = exportService.schedule( payload );
 +
 +        JobData jobData = jobDataCreator(payload,exportUUID,s3Export);
 +
 +
 +        JobExecution jobExecution = mock( JobExecution.class );
 +        when( jobExecution.getJobData() ).thenReturn( jobData );
 +
 +        exportService.doExport( jobExecution );
 +
 +        TypeReference<HashMap<String,Object>> typeRef
 +            = new TypeReference<HashMap<String,Object>>() {};
 +
 +        ObjectMapper mapper = new ObjectMapper();
 +        Map<String,Object> jsonMap = mapper.readValue(new FileReader( f ), typeRef);
 +
 +        Map collectionsMap = (Map)jsonMap.get("collections");
 +        String collectionName = (String)collectionsMap.keySet().iterator().next();
 +        List collection = (List)collectionsMap.get(collectionName);
 +
 +        for ( Object o : collection ) {
 +            Map entityMap = (Map)o;
 +            Map metadataMap = (Map)entityMap.get("Metadata");
 +            String entityName = (String)metadataMap.get("name");
 +            assertFalse( "junkRealName".equals( entityName ) );
 +        }
 +        f.deleteOnExit();
 +    }
 +
 +
 +    //
 +    //creation of files doesn't always delete itself
 +    @Test
 +    public void testExportOneAppOnCollectionEndpoint() throws Exception {
 +
 +        final String orgName = uniqueOrg();
 +        final String appName = uniqueApp();
 +
 +
 +        File f = null;
 +
 +        try {
 +            f = new File( "exportOneApp.json" );
 +        }
 +        catch ( Exception e ) {
 +            // consumed because this checks to see if the file exists.
 +            // If it doesn't, don't do anything and carry on.
 +        }
 +        f.deleteOnExit();
 +
 +
 +        UUID appId = setup.getEmf().createApplication( orgName, appName );
 +
 +
 +        EntityManager em = setup.getEmf().getEntityManager( appId );
 +        //intialize user object to be posted
 +        Map<String, Object> userProperties = null;
 +        Entity[] entity;
 +        entity = new Entity[1];
 +        //creates entities
 +        for ( int i = 0; i < 1; i++ ) {
 +            userProperties = new LinkedHashMap<String, Object>();
 +            userProperties.put( "username", "junkRealName" );
 +            userProperties.put( "email", "test" + i + "@anuff.com" );
 +            entity[i] = em.create( "user", userProperties );
 +        }
 +
 +        S3Export s3Export = new MockS3ExportImpl("exportOneApp.json");
 +        //s3Export.setFilename( "exportOneApp.json" );
 +        ExportService exportService = setup.getExportService();
 +
 +        HashMap<String, Object> payload = payloadBuilder(appName);
 +
 +        payload.put( "organizationId", organization.getUuid() );
 +        payload.put( "applicationId", applicationId );
 +
 +        UUID exportUUID = exportService.schedule( payload );
 +
 +        JobData jobData = jobDataCreator(payload,exportUUID,s3Export);
 +
 +        JobExecution jobExecution = mock( JobExecution.class );
 +        when( jobExecution.getJobData() ).thenReturn( jobData );
 +
 +        exportService.doExport( jobExecution );
 +
 +        TypeReference<HashMap<String,Object>> typeRef
 +            = new TypeReference<HashMap<String,Object>>() {};
 +
 +        ObjectMapper mapper = new ObjectMapper();
 +        Map<String,Object> jsonMap = mapper.readValue(new FileReader( f ), typeRef);
 +
 +        Map collectionsMap = (Map)jsonMap.get("collections");
 +        String collectionName = (String)collectionsMap.keySet().iterator().next();
 +        List collection = (List)collectionsMap.get(collectionName);
 +
 +        for ( Object o : collection ) {
 +            Map entityMap = (Map)o;
 +            Map metadataMap = (Map)entityMap.get("Metadata");
 +            String entityName = (String)metadataMap.get("name");
 +            assertFalse( "junkRealName".equals( entityName ) );
 +        }
 +    }
 +
 +
 +    @Test
 +    public void testExportOneAppOnApplicationEndpointWQuery() throws Exception {
 +
 +        File f = null;
 +        try {
 +            f = new File( "exportOneAppWQuery.json" );
 +        }
 +        catch ( Exception e ) {
 +            // consumed because this checks to see if the file exists.
 +            // If it doesn't, don't do anything and carry on.
 +        }
 +        f.deleteOnExit();
 +
 +
 +        EntityManager em = setup.getEmf().getEntityManager( applicationId );
 +        //intialize user object to be posted
 +        Map<String, Object> userProperties = null;
 +        Entity[] entity;
 +        entity = new Entity[1];
 +        //creates entities
 +        for ( int i = 0; i < 1; i++ ) {
 +            userProperties = new LinkedHashMap<String, Object>();
 +            userProperties.put( "name", "me" );
 +            userProperties.put( "username", "junkRealName" );
 +            userProperties.put( "email", "burp" + i + "@anuff.com" );
 +            entity[i] = em.create( "users", userProperties );
 +        }
 +
 +        S3Export s3Export = new MockS3ExportImpl("exportOneAppWQuery.json" );
 +        ExportService exportService = setup.getExportService();
 +
 +        String appName = newOrgAppAdminRule.getApplicationInfo().getName();
 +        HashMap<String, Object> payload = payloadBuilder(appName);
 +
 +        payload.put( "query", "select * where username = 'junkRealName'" );
 +        payload.put( "organizationId", organization.getUuid() );
 +        payload.put( "applicationId", applicationId );
 +
 +        UUID exportUUID = exportService.schedule( payload );
 +
 +        JobData jobData = jobDataCreator(payload,exportUUID,s3Export);
 +
 +        JobExecution jobExecution = mock( JobExecution.class );
 +        when( jobExecution.getJobData() ).thenReturn( jobData );
 +
 +       em.refreshIndex();
 +
 +        exportService.doExport( jobExecution );
 +
 +        TypeReference<HashMap<String,Object>> typeRef
 +            = new TypeReference<HashMap<String,Object>>() {};
 +
 +        ObjectMapper mapper = new ObjectMapper();
 +        Map<String,Object> jsonMap = mapper.readValue(new FileReader( f ), typeRef);
 +
 +        Map collectionsMap = (Map)jsonMap.get("collections");
 +        String collectionName = (String)collectionsMap.keySet().iterator().next();
 +        List collection = (List)collectionsMap.get( collectionName );
 +
 +        for ( Object o : collection ) {
 +            Map entityMap = (Map)o;
 +            Map metadataMap = (Map)entityMap.get("Metadata");
 +            String entityName = (String)metadataMap.get("name");
 +            assertFalse( "junkRealName".equals( entityName ) );
 +        }
 +    }
 +
 +
 +    @Test
 +    public void testExportOneCollection() throws Exception {
 +
 +        File f = null;
 +        int entitiesToCreate = 5;
 +
 +        try {
 +            f = new File( "exportOneCollection.json" );
 +        }
 +        catch ( Exception e ) {
 +            // consumed because this checks to see if the file exists.
 +            // If it doesn't, don't do anything and carry on.
 +        }
 +
 +        f.deleteOnExit();
 +
 +        EntityManager em = setup.getEmf().getEntityManager( applicationId );
 +
 +        // em.createApplicationCollection( "qtsMagics" );
 +        // intialize user object to be posted
 +        Map<String, Object> userProperties = null;
 +        Entity[] entity;
 +        entity = new Entity[entitiesToCreate];
 +        //creates entities
 +        for ( int i = 0; i < entitiesToCreate; i++ ) {
 +            userProperties = new LinkedHashMap<String, Object>();
 +            userProperties.put( "username", "billybob" + i );
 +            userProperties.put( "email", "test" + i + "@anuff.com" );
 +            entity[i] = em.create( "qtsMagics", userProperties );
 +        }
 +
 +        S3Export s3Export = new MockS3ExportImpl("exportOneCollection.json" );
 +        ExportService exportService = setup.getExportService();
 +
 +        String appName = newOrgAppAdminRule.getApplicationInfo().getName();
 +        HashMap<String, Object> payload = payloadBuilder(appName);
 +
 +        payload.put( "organizationId", organization.getUuid() );
 +        payload.put( "applicationId", applicationId );
 +        payload.put( "collectionName", "qtsMagics" );
 +
 +        UUID exportUUID = exportService.schedule( payload );
 +
 +        JobData jobData = jobDataCreator(payload,exportUUID,s3Export);
 +
 +        JobExecution jobExecution = mock( JobExecution.class );
 +        when( jobExecution.getJobData() ).thenReturn( jobData );
 +
 +        em.refreshIndex();
 +
 +        exportService.doExport( jobExecution );
 +
 +        TypeReference<HashMap<String,Object>> typeRef
 +            = new TypeReference<HashMap<String,Object>>() {};
 +
 +        ObjectMapper mapper = new ObjectMapper();
 +        HashMap<String,Object> jsonMap = mapper.readValue(new FileReader( f ), typeRef);
 +
 +        Map collectionsMap = (Map)jsonMap.get("collections");
 +        String collectionName = (String)collectionsMap.keySet().iterator().next();
 +        List collection = (List)collectionsMap.get( collectionName );
 +
 +        assertEquals(entitiesToCreate, collection.size());
 +    }
 +
 +
 +    @Test
 +    public void testExportOneCollectionWQuery() throws Exception {
 +
 +        File f = null;
 +        int entitiesToCreate = 5;
 +
 +        try {
 +            f = new File( "exportOneCollectionWQuery.json" );
 +        }
 +        catch ( Exception e ) {
 +            // consumed because this checks to see if the file exists.
 +            // If it doesn't, don't do anything and carry on.
 +        }
 +        f.deleteOnExit();
 +
 +        EntityManager em = setup.getEmf().getEntityManager( applicationId );
 +        em.createApplicationCollection( "baconators" );
 +        em.refreshIndex();
 +
 +        //initialize user object to be posted
 +        Map<String, Object> userProperties = null;
 +        Entity[] entity;
 +        entity = new Entity[entitiesToCreate];
 +
 +        // creates entities
 +        for ( int i = 0; i < entitiesToCreate; i++ ) {
 +            userProperties = new LinkedHashMap<String, Object>();
 +            userProperties.put( "username", "billybob" + i );
 +            userProperties.put( "email", "test" + i + "@anuff.com" );
 +            entity[i] = em.create( "baconators", userProperties );
 +        }
 +
 +        S3Export s3Export = new MockS3ExportImpl("exportOneCollectionWQuery.json");
 +        ExportService exportService = setup.getExportService();
 +
 +        String appName = newOrgAppAdminRule.getApplicationInfo().getName();
 +        HashMap<String, Object> payload = payloadBuilder(appName);
 +
 +        payload.put( "query", "select * where username contains 'billybob0'" );
 +        payload.put( "organizationId", organization.getUuid() );
 +        payload.put( "applicationId", applicationId );
 +        payload.put( "collectionName", "baconators" );
 +
 +        UUID exportUUID = exportService.schedule( payload );
 +
 +        JobData jobData = jobDataCreator( payload, exportUUID, s3Export );
 +
 +        JobExecution jobExecution = mock( JobExecution.class );
 +        when( jobExecution.getJobData() ).thenReturn( jobData );
 +
 +        em.refreshIndex();
 +
 +        exportService.doExport( jobExecution );
 +
 +        TypeReference<HashMap<String,Object>> typeRef
 +            = new TypeReference<HashMap<String,Object>>() {};
 +
 +        ObjectMapper mapper = new ObjectMapper();
 +        Map<String,Object> jsonMap = mapper.readValue(new FileReader( f ), typeRef);
 +
 +        Map collectionsMap = (Map)jsonMap.get("collections");
 +        String collectionName = (String)collectionsMap.keySet().iterator().next();
 +        List collectionList = (List)collectionsMap.get( collectionName );
 +
 +        assertEquals(1, collectionList.size());
 +    }
 +
 +
 +    @Test
 +    @Ignore("this is a meaningless test because our export format does not support export of organizations")
 +    public void testExportOneOrganization() throws Exception {
 +
 +        // create a bunch of organizations, each with applications and collections of entities
 +
 +        int maxOrgs = 3;
 +        int maxApps = 3;
 +        int maxEntities = 20;
 +
 +        List<ApplicationInfo> appsMade = new ArrayList<>();
 +        List<OrganizationInfo> orgsMade = new ArrayList<>();
 +
 +        for ( int orgIndex = 0; orgIndex < maxOrgs; orgIndex++ ) {
 +
 +
 +            String orgName = "org_" + RandomStringUtils.randomAlphanumeric(10);
 +            OrganizationInfo orgMade = setup.getMgmtSvc().createOrganization( orgName, adminUser, true );
 +            orgsMade.add( orgMade );
 +            logger.debug("Created org {}", orgName);
 +
 +            for ( int appIndex = 0; appIndex < maxApps; appIndex++ ) {
 +
 +                String appName =  "app_" + RandomStringUtils.randomAlphanumeric(10);
 +                ApplicationInfo appMade = setup.getMgmtSvc().createApplication( orgMade.getUuid(), appName );
 +                appsMade.add( appMade );
 +                logger.debug("Created app {}", appName);
 +
 +                for (int entityIndex = 0; entityIndex < maxEntities; entityIndex++) {
 +
 +                    EntityManager appEm = setup.getEmf().getEntityManager( appMade.getId() );
 +                    appEm.create( appName + "_type", new HashMap<String, Object>() {{
 +                        put("property1", "value1");
 +                        put("property2", "value2");
 +                    }});
 +                }
 +            }
 +        }
 +
 +        // export one of the organizations only, using mock S3 export that writes to local disk
 +
 +        String exportFileName = "exportOneOrganization.json";
 +        S3Export s3Export = new MockS3ExportImpl( exportFileName );
 +
 +        HashMap<String, Object> payload = payloadBuilder(appsMade.get(0).getName());
 +        payload.put("organizationId", orgsMade.get(0).getUuid() );
 +        payload.put( "applicationId", appsMade.get(0).getId() );
 +
 +        ExportService exportService = setup.getExportService();
 +        UUID exportUUID = exportService.schedule( payload );
 +
 +        JobData jobData = jobDataCreator( payload, exportUUID, s3Export );
 +        JobExecution jobExecution = mock( JobExecution.class );
 +        when( jobExecution.getJobData() ).thenReturn(jobData);
 +
 +        exportService.doExport( jobExecution );
 +
 +        // finally, we check that file was created and contains the right number of entities in the array
 +
 +        File exportedFile = new File( exportFileName );
 +        exportedFile.deleteOnExit();
 +
 +        TypeReference<HashMap<String,Object>> typeRef
 +            = new TypeReference<HashMap<String,Object>>() {};
 +
 +        ObjectMapper mapper = new ObjectMapper();
 +        Map<String,Object> jsonMap = mapper.readValue(new FileReader( exportedFile ), typeRef);
 +        Map collectionsMap = (Map)jsonMap.get("collections");
 +
 +        List collectionList = (List)collectionsMap.get("users");
 +
 +        assertEquals( 3, collectionList.size() );
 +    }
 +
 +
 +    @Test
 +    public void testExportDoJob() throws Exception {
 +
 +        String appName = newOrgAppAdminRule.getApplicationInfo().getName();
 +        HashMap<String, Object> payload = payloadBuilder(appName);
 +
 +        payload.put( "organizationId", organization.getUuid() );
 +        payload.put( "applicationId", applicationId );
 +
 +
 +        JobData jobData = new JobData();
 +        jobData.setProperty( "jobName", "exportJob" );
 +
 +        // this needs to be populated with properties of export info
 +        jobData.setProperty( "exportInfo", payload );
 +
 +        JobExecution jobExecution = mock( JobExecution.class );
 +
 +        when( jobExecution.getJobData() ).thenReturn( jobData );
 +        when( jobExecution.getJobId() ).thenReturn( UUID.randomUUID() );
 +
 +        ExportJob job = new ExportJob();
 +        ExportService eS = mock( ExportService.class );
 +        job.setExportService( eS );
 +        try {
 +            job.doJob( jobExecution );
 +        }
 +        catch ( Exception e ) {
 +            logger.error("Error doing job", e);
 +            assert ( false );
 +        }
 +        assert ( true );
 +    }
 +
 +    //tests that with empty job data, the export still runs.
 +    @Test
 +    public void testExportEmptyJobData() throws Exception {
 +
 +        JobData jobData = new JobData();
 +
 +        JobExecution jobExecution = mock( JobExecution.class );
 +
 +        when( jobExecution.getJobData() ).thenReturn( jobData );
 +        when( jobExecution.getJobId() ).thenReturn( UUID.randomUUID() );
 +
 +        ExportJob job = new ExportJob();
 +        S3Export s3Export = mock( S3Export.class );
 +        //setup.getExportService().setS3Export( s3Export );
 +        job.setExportService( setup.getExportService() );
 +        try {
 +            job.doJob( jobExecution );
 +        }
 +        catch ( Exception e ) {
 +            assert ( false );
 +        }
 +        assert ( true );
 +    }
 +
 +
 +    @Test
 +    public void testNullJobExecution() {
 +
 +        JobData jobData = new JobData();
 +
 +        JobExecution jobExecution = mock( JobExecution.class );
 +
 +        when( jobExecution.getJobData() ).thenReturn( jobData );
 +        when( jobExecution.getJobId() ).thenReturn( UUID.randomUUID() );
 +
 +        ExportJob job = new ExportJob();
 +        S3Export s3Export = mock( S3Export.class );
 +       // setup.getExportService().setS3Export( s3Export );
 +        job.setExportService( setup.getExportService() );
 +        try {
 +            job.doJob( jobExecution );
 +        }
 +        catch ( Exception e ) {
 +            assert ( false );
 +        }
 +        assert ( true );
 +    }
 +
 +
 +    @Test
 +    @Ignore // TODO: fix this test...
 +    public void testIntegration100EntitiesOn() throws Exception {
 +
 +        logger.debug("testIntegration100EntitiesOn(): starting...");
 +
 +        ExportService exportService = setup.getExportService();
 +
 +        String appName = newOrgAppAdminRule.getApplicationInfo().getName();
 +        HashMap<String, Object> payload = payloadBuilder(appName);
 +
 +        payload.put( "organizationId", organization.getUuid() );
 +        payload.put( "applicationId", applicationId );
 +
 +        // create five applications each with collection of five entities
 +
 +        for ( int i = 0; i < 5; i++ ) {
 +
 +            ApplicationInfo appMade = setup.getMgmtSvc().createApplication( organization.getUuid(), "superapp" + i );
 +            EntityManager appEm = setup.getEmf().getEntityManager( appMade.getId() );
 +
 +            String collName = "superappCol" + i;
 +            appEm.createApplicationCollection(collName);
 +
 +            Map<String, Object> entityLevelProperties = null;
 +            Entity[] entNotCopied;
 +            entNotCopied = new Entity[5];
 +
 +            for ( int index = 0; index < 5; index++ ) {
 +                entityLevelProperties = new LinkedHashMap<String, Object>();
 +                entityLevelProperties.put( "username", "bobso" + index );
 +                entityLevelProperties.put( "email", "derp" + index + "@anuff.com" );
 +                entNotCopied[index] = appEm.create( collName, entityLevelProperties );
 +            }
 +        }
 +
 +        // export the organization containing those apps and collections
 +
 +        UUID exportUUID = exportService.schedule( payload );
 +
 +        int maxRetries = 100;
 +        int retries = 0;
 +        while ( !exportService.getState( exportUUID ).equals( "FINISHED" ) && retries++ < maxRetries ) {
 +            Thread.sleep(100);
 +        }
 +
 +        String accessId = System.getProperty( SDKGlobalConfiguration.ACCESS_KEY_ENV_VAR );
 +        String secretKey = System.getProperty( SDKGlobalConfiguration.SECRET_KEY_ENV_VAR );
 +        Properties overrides = new Properties();
 +        overrides.setProperty( "s3" + ".identity", accessId );
 +        overrides.setProperty( "s3" + ".credential", secretKey );
 +
 +        // test that we can find the file that were exported to S3
 +
 +        BlobStore blobStore = null;
 +        try {
 +
 +            final Iterable<? extends Module> MODULES = ImmutableSet.of(
 +                new JavaUrlHttpCommandExecutorServiceModule(),
 +                new Log4JLoggingModule(),
 +                new NettyPayloadModule());
 +
 +            BlobStoreContext context = ContextBuilder.newBuilder("s3")
 +                .credentials(accessId, secretKey)
 +                .modules(MODULES)
 +                .overrides(overrides)
 +                .buildView(BlobStoreContext.class);
 +
 +            String expectedFileName = ((ExportServiceImpl) exportService)
 +                .prepareOutputFileName(organization.getName(), "applications");
 +
 +            blobStore = context.getBlobStore();
 +            if (!blobStore.blobExists(bucketName, expectedFileName)) {
 +                blobStore.deleteContainer(bucketName);
 +                Assert.fail("Blob does not exist: " + expectedFileName);
 +            }
 +            Blob bo = blobStore.getBlob(bucketName, expectedFileName);
 +
 +            Long numOfFiles = blobStore.countBlobs(bucketName);
 +            Long numWeWant = 1L;
 +            blobStore.deleteContainer(bucketName);
 +            assertEquals(numOfFiles, numWeWant);
 +            assertNotNull(bo);
 +
 +        } finally {
 +            blobStore.deleteContainer(bucketName);
 +        }
 +    }
 +
 +    @Ignore("Why is this ignored?")
 +    @Test
 +    public void testIntegration100EntitiesForAllApps() throws Exception {
 +
 +        S3Export s3Export = new S3ExportImpl();
 +        ExportService exportService = setup.getExportService();
 +
 +        String appName = newOrgAppAdminRule.getApplicationInfo().getName();
 +        HashMap<String, Object> payload = payloadBuilder(appName);
 +
 +        OrganizationInfo orgMade = null;
 +        ApplicationInfo appMade = null;
 +        for ( int i = 0; i < 5; i++ ) {
 +            orgMade = setup.getMgmtSvc().createOrganization( "minorboss" + i, adminUser, true );
 +            for ( int j = 0; j < 5; j++ ) {
 +                appMade = setup.getMgmtSvc().createApplication( orgMade.getUuid(), "superapp" + j );
 +
 +                EntityManager customMaker = setup.getEmf().getEntityManager( appMade.getId() );
 +                customMaker.createApplicationCollection( "superappCol" + j );
 +                //intialize user object to be posted
 +                Map<String, Object> entityLevelProperties = null;
 +                Entity[] entNotCopied;
 +                entNotCopied = new Entity[1];
 +                //creates entities
 +                for ( int index = 0; index < 1; index++ ) {
 +                    entityLevelProperties = new LinkedHashMap<String, Object>();
 +                    entityLevelProperties.put( "derp", "bacon" );
 +                    entNotCopied[index] = customMaker.create( "superappCol" + j, entityLevelProperties );
 +                }
 +            }
 +        }
 +
 +        payload.put( "organizationId", orgMade.getUuid() );
 +
 +        UUID exportUUID = exportService.schedule( payload );
 +        assertNotNull( exportUUID );
 +
 +        Thread.sleep( 3000 );
 +
 +        String accessId = System.getProperty( SDKGlobalConfiguration.ACCESS_KEY_ENV_VAR );
 +        String secretKey = System.getProperty( SDKGlobalConfiguration.SECRET_KEY_ENV_VAR );
 +
 +        Properties overrides = new Properties();
 +        overrides.setProperty( "s3" + ".identity", accessId );
 +        overrides.setProperty( "s3" + ".credential", secretKey );
 +
 +        BlobStore blobStore = null;
 +
 +        try {
 +            final Iterable<? extends Module> MODULES = ImmutableSet.of(
 +                new JavaUrlHttpCommandExecutorServiceModule(),
 +                new Log4JLoggingModule(),
 +                new NettyPayloadModule() );
 +
 +            BlobStoreContext context = ContextBuilder.newBuilder( "s3" )
 +                .credentials(accessId, secretKey )
 +                .modules(MODULES )
 +                .overrides(overrides )
 +                .buildView(BlobStoreContext.class );
 +
 +            blobStore = context.getBlobStore();
 +
 +            //Grab Number of files
 +            Long numOfFiles = blobStore.countBlobs( bucketName );
 +
 +            String expectedFileName = ((ExportServiceImpl)exportService)
 +                .prepareOutputFileName(organization.getName(), "applications");
 +
 +            //delete container containing said files
 +            Blob bo = blobStore.getBlob(bucketName, expectedFileName);
 +            Long numWeWant = 5L;
 +            blobStore.deleteContainer( bucketName );
 +
 +            //asserts that the correct number of files was transferred over
 +            assertEquals( numWeWant, numOfFiles );
 +
 +        }
 +        finally {
 +            blobStore.deleteContainer( bucketName );
 +        }
 +    }
 +
 +
 +    @Ignore("Why is this ignored")
 +    @Test
 +    public void testIntegration100EntitiesOnOneOrg() throws Exception {
 +
 +        S3Export s3Export = new S3ExportImpl();
 +        ExportService exportService = setup.getExportService();
 +
 +        String appName = newOrgAppAdminRule.getApplicationInfo().getName();
 +        HashMap<String, Object> payload = payloadBuilder(appName);
 +
 +        payload.put( "organizationId", organization.getUuid() );
 +        payload.put( "applicationId", applicationId );
 +
 +        OrganizationInfo orgMade = null;
 +        ApplicationInfo appMade = null;
 +        for ( int i = 0; i < 100; i++ ) {
 +            orgMade = setup.getMgmtSvc().createOrganization( "largerboss" + i, adminUser, true );
 +            appMade = setup.getMgmtSvc().createApplication( orgMade.getUuid(), "superapp" + i );
 +
 +            EntityManager customMaker = setup.getEmf().getEntityManager( appMade.getId() );
 +            customMaker.createApplicationCollection( "superappCol" + i );
 +            //intialize user object to be posted
 +            Map<String, Object> entityLevelProperties = null;
 +            Entity[] entNotCopied;
 +            entNotCopied = new Entity[20];
 +            //creates entities
 +            for ( int index = 0; index < 20; index++ ) {
 +                entityLevelProperties = new LinkedHashMap<String, Object>();
 +                entityLevelProperties.put( "username", "bobso" + index );
 +                entityLevelProperties.put( "email", "derp" + index + "@anuff.com" );
 +                entNotCopied[index] = customMaker.create( "superappCol", entityLevelProperties );
 +            }
 +        }
 +
 +        EntityManager em = setup.getEmf().getEntityManager( applicationId );
 +
 +        //intialize user object to be posted
 +        Map<String, Object> userProperties = null;
 +        Entity[] entity;
 +        entity = new Entity[100];
 +
 +        //creates entities
 +        for ( int i = 0; i < 100; i++ ) {
 +            userProperties = new LinkedHashMap<String, Object>();
 +            userProperties.put( "username", "bido" + i );
 +            userProperties.put( "email", "bido" + i + "@anuff.com" );
 +
 +            entity[i] = em.create( "user", userProperties );
 +        }
 +
 +        UUID exportUUID = exportService.schedule( payload );
 +
 +        while ( !exportService.getState( exportUUID ).equals( "FINISHED" ) ) {}
 +
 +        String accessId = System.getProperty( SDKGlobalConfiguration.ACCESS_KEY_ENV_VAR );
 +        String secretKey = System.getProperty( SDKGlobalConfiguration.SECRET_KEY_ENV_VAR );
 +
 +        Properties overrides = new Properties();
 +        overrides.setProperty( "s3" + ".identity", accessId );
 +        overrides.setProperty( "s3" + ".credential", secretKey );
 +
 +        Blob bo = null;
 +        BlobStore blobStore = null;
 +
 +        try {
 +            final Iterable<? extends Module> MODULES = ImmutableSet.of( new JavaUrlHttpCommandExecutorServiceModule(),
 +                new Log4JLoggingModule(), new NettyPayloadModule() );
 +
 +            BlobStoreContext context = ContextBuilder.newBuilder( "s3" )
 +                .credentials( accessId, secretKey )
 +                .modules( MODULES )
 +                .overrides( overrides )
 +                .buildView( BlobStoreContext.class );
 +
 +            String expectedFileName = ((ExportServiceImpl)exportService)
 +                .prepareOutputFileName(organization.getName(), "applications");
 +
 +            blobStore = context.getBlobStore();
 +            if ( !blobStore.blobExists( bucketName, expectedFileName ) ) {
 +                assert ( false );
 +            }
 +            Long numOfFiles = blobStore.countBlobs( bucketName );
 +            Long numWeWant = Long.valueOf( 1 );
 +            assertEquals( numOfFiles, numWeWant );
 +
 +            bo = blobStore.getBlob( bucketName, expectedFileName );
 +        }
 +        catch ( Exception e ) {
 +            assert ( false );
 +        }
 +
 +        assertNotNull( bo );
 +        blobStore.deleteContainer( bucketName );
 +    }
 +
 +    public JobData jobDataCreator(HashMap<String, Object> payload,UUID exportUUID, S3Export s3Export) {
 +        JobData jobData = new JobData();
 +
 +        jobData.setProperty( "jobName", "exportJob" );
 +        jobData.setProperty( "exportInfo", payload );
 +        jobData.setProperty( "exportId", exportUUID );
 +        jobData.setProperty( "s3Export", s3Export );
 +
 +        return jobData;
 +    }
 +
 +    /*Creates fake payload for testing purposes.*/
 +    public HashMap<String, Object> payloadBuilder( String orgOrAppName ) {
 +        HashMap<String, Object> payload = new HashMap<String, Object>();
 +        Map<String, Object> properties = new HashMap<String, Object>();
 +        Map<String, Object> storage_info = new HashMap<String, Object>();
 +        storage_info.put( SDKGlobalConfiguration.SECRET_KEY_ENV_VAR,
 +            System.getProperty( SDKGlobalConfiguration.SECRET_KEY_ENV_VAR ) );
 +        storage_info.put( SDKGlobalConfiguration.ACCESS_KEY_ENV_VAR,
 +            System.getProperty( SDKGlobalConfiguration.ACCESS_KEY_ENV_VAR ) );
 +        storage_info.put( "bucket_location",  bucketName );
 +
 +        properties.put( "storage_provider", "s3" );
 +        properties.put( "storage_info", storage_info );
 +
 +        payload.put( "path", orgOrAppName );
 +        payload.put( "properties", properties );
 +        return payload;
 +    }
 +}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/bedf5afb/stack/services/src/test/java/org/apache/usergrid/management/importer/ImportCollectionIT.java
----------------------------------------------------------------------
diff --cc stack/services/src/test/java/org/apache/usergrid/management/importer/ImportCollectionIT.java
index d0a984d,0000000..d8e104d
mode 100644,000000..100644
--- a/stack/services/src/test/java/org/apache/usergrid/management/importer/ImportCollectionIT.java
+++ b/stack/services/src/test/java/org/apache/usergrid/management/importer/ImportCollectionIT.java
@@@ -1,684 -1,0 +1,684 @@@
 +/*
 + * 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.management.importer;
 +
 +
 +import java.io.File;
 +import java.util.ArrayList;
 +import java.util.HashMap;
 +import java.util.List;
 +import java.util.Map;
 +import java.util.Properties;
 +import java.util.UUID;
 +
 +import org.jclouds.ContextBuilder;
 +import org.jclouds.blobstore.BlobStore;
 +import org.jclouds.blobstore.BlobStoreContext;
 +import org.jclouds.blobstore.ContainerNotFoundException;
 +import org.jclouds.blobstore.domain.PageSet;
 +import org.jclouds.blobstore.domain.StorageMetadata;
 +import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule;
 +import org.jclouds.logging.log4j.config.Log4JLoggingModule;
 +import org.jclouds.netty.config.NettyPayloadModule;
 +import org.junit.After;
 +import org.junit.AfterClass;
 +import org.junit.Assert;
 +import org.junit.Assume;
 +import org.junit.Before;
 +import org.junit.BeforeClass;
 +import org.junit.ClassRule;
 +import org.junit.Rule;
 +import org.junit.Test;
 +import org.slf4j.Logger;
 +import org.slf4j.LoggerFactory;
 +
 +import org.apache.commons.lang.RandomStringUtils;
 +import org.apache.commons.lang3.StringUtils;
 +
 +import org.apache.usergrid.NewOrgAppAdminRule;
 +import org.apache.usergrid.ServiceITSetup;
 +import org.apache.usergrid.ServiceITSetupImpl;
 +import org.apache.usergrid.batch.service.JobSchedulerService;
 +import org.apache.usergrid.cassandra.ClearShiroSubject;
 +import org.apache.usergrid.management.OrganizationInfo;
 +import org.apache.usergrid.management.UserInfo;
 +import org.apache.usergrid.management.export.ExportService;
 +import org.apache.usergrid.persistence.ConnectionRef;
 +import org.apache.usergrid.persistence.Entity;
 +import org.apache.usergrid.persistence.EntityManager;
 +import org.apache.usergrid.persistence.EntityRef;
 +import org.apache.usergrid.persistence.Results;
 +import org.apache.usergrid.persistence.SimpleEntityRef;
 +import org.apache.usergrid.persistence.entities.FileImport;
 +import org.apache.usergrid.persistence.entities.Import;
 +import org.apache.usergrid.persistence.index.query.Query;
 +import org.apache.usergrid.persistence.index.query.Query.Level;
 +import org.apache.usergrid.setup.ConcurrentProcessSingleton;
 +
 +import com.amazonaws.SDKGlobalConfiguration;
 +import com.google.common.collect.ImmutableSet;
 +import com.google.common.util.concurrent.Service;
 +import com.google.inject.Module;
 +
 +import static org.junit.Assert.assertEquals;
 +import static org.junit.Assert.assertNotNull;
 +import static org.junit.Assert.assertTrue;
 +
 +
 +public class ImportCollectionIT {
 +
 +    private static final Logger logger = LoggerFactory.getLogger(ImportCollectionIT.class);
 +
 +    // app-level data generated only once
 +    private static UserInfo adminUser;
 +    private static OrganizationInfo organization;
 +    private static UUID applicationId;
 +
 +    private static String bucketPrefix;
 +
 +    private String bucketName;
 +
 +
 +    @Rule
 +    public ClearShiroSubject clearShiroSubject = new ClearShiroSubject();
 +
 +    @ClassRule
 +    public static final ServiceITSetup setup = new ServiceITSetupImpl(  );
 +
 +    @Rule
 +    public NewOrgAppAdminRule newOrgAppAdminRule = new NewOrgAppAdminRule( setup );
 +
 +
 +    @BeforeClass
 +    public static void setup() throws Exception {
 +
 +        bucketPrefix = System.getProperty( "bucketName" );
 +
 +        // start the scheduler after we're all set up
 +        JobSchedulerService jobScheduler = ConcurrentProcessSingleton.getInstance()
 +            .getSpringResource().getBean( JobSchedulerService.class );
 +
 +        if ( jobScheduler.state() != Service.State.RUNNING ) {
-             jobScheduler.startAndWait();
++            jobScheduler.startAsync();
++            jobScheduler.awaitRunning();
 +        }
- 
 +    }
 +
 +
 +    @AfterClass
 +    public static void tearDown() {
 +        if ( !StringUtils.isEmpty( bucketPrefix )) {
 +            deleteBucketsWithPrefix();
 +        }
 +    }
 +
 +
 +    @Before
 +    public void before() {
 +
 +        boolean configured =
 +                   !StringUtils.isEmpty(System.getProperty( SDKGlobalConfiguration.SECRET_KEY_ENV_VAR))
 +                && !StringUtils.isEmpty(System.getProperty( SDKGlobalConfiguration.ACCESS_KEY_ENV_VAR))
 +                && !StringUtils.isEmpty(System.getProperty("bucketName"));
 +
 +        if ( !configured ) {
 +            logger.warn("Skipping test because {}, {} and bucketName not " +
 +                "specified as system properties, e.g. in your Maven settings.xml file.",
 +                new Object[] {
 +                    SDKGlobalConfiguration.SECRET_KEY_ENV_VAR,
 +                    SDKGlobalConfiguration.ACCESS_KEY_ENV_VAR
 +                });
 +        }
 +
 +        Assume.assumeTrue( configured );
 +
 +        adminUser = newOrgAppAdminRule.getAdminInfo();
 +        organization = newOrgAppAdminRule.getOrganizationInfo();
 +        applicationId = newOrgAppAdminRule.getApplicationInfo().getId();
 +
 +
 +        bucketName = bucketPrefix + RandomStringUtils.randomAlphanumeric(10).toLowerCase();
 +    }
 +
 +
 +    @After
 +    public void after() throws Exception {
 +//        if (listener != null) {
 +//            listener.stop();
 +//            listener = null;
 +//        }
 +    }
 +
 +
 +    // test case to check if a collection file is imported correctly
 +    @Test
 +    public void testExportImportCollection() throws Exception {
 +
 +        // create a collection of "thing" entities in the first application, export to S3
 +        try {
 +
 +            final UUID targetAppId = setup.getMgmtSvc().createApplication(
 +                organization.getUuid(), "target" + RandomStringUtils.randomAlphanumeric(10)).getId();
 +
 +            final EntityManager emApp1 = setup.getEmf().getEntityManager( targetAppId );
 +            Map<UUID, Entity> thingsMap = new HashMap<>();
 +            List<Entity> things = new ArrayList<>();
 +            createTestEntities(emApp1, thingsMap, things, "thing");
 +
 +            deleteBucket();
 +            exportCollection( emApp1, "things" );
 +
 +            // create new second application, import the data from S3
 +
 +            final UUID appId2 = setup.getMgmtSvc().createApplication(
 +                organization.getUuid(), "second" + RandomStringUtils.randomAlphanumeric(10)).getId();
 +
 +            final EntityManager emApp2 = setup.getEmf().getEntityManager(appId2);
 +            importCollections(emApp2);
 +
 +            // make sure that it worked
 +
 +            logger.debug("\n\nCheck connections\n");
 +
 +            List<Entity> importedThings = emApp2.getCollection(
 +                appId2, "things", null, Level.ALL_PROPERTIES).getEntities();
 +            assertTrue( !importedThings.isEmpty() );
 +
 +            // two things have connections
 +
 +            int conCount = 0;
 +            for ( Entity e : importedThings ) {
 +                Results r = emApp2.getConnectedEntities( e, "related", null, Level.IDS);
 +                List<ConnectionRef> connections = r.getConnections();
 +                conCount += connections.size();
 +            }
 +            assertEquals( 2, conCount );
 +
 +            logger.debug("\n\nCheck dictionaries\n");
 +
 +            // first two items have things in dictionary
 +
 +            EntityRef entity0 = importedThings.get(0);
 +            Map connected0 = emApp2.getDictionaryAsMap(entity0, "connected_types");
 +            Map connecting0 = emApp2.getDictionaryAsMap(entity0, "connected_types");
 +            Assert.assertEquals( 1, connected0.size() );
 +            Assert.assertEquals( 1, connecting0.size() );
 +
 +            EntityRef entity1 = importedThings.get(1);
 +            Map connected1 = emApp2.getDictionaryAsMap(entity1, "connected_types");
 +            Map connecting1 = emApp2.getDictionaryAsMap(entity1, "connected_types");
 +            Assert.assertEquals( 1, connected1.size() );
 +            Assert.assertEquals( 1, connecting1.size() );
 +
 +            // the rest rest do not have connections
 +
 +            EntityRef entity2 = importedThings.get(2);
 +            Map connected2 = emApp2.getDictionaryAsMap(entity2, "connected_types");
 +            Map connecting2 = emApp2.getDictionaryAsMap(entity2, "connected_types");
 +            Assert.assertEquals( 0, connected2.size() );
 +            Assert.assertEquals( 0, connecting2.size() );
 +
 +            // if entities are deleted from app1, they still exist in app2
 +
 +            logger.debug("\n\nCheck dictionary\n");
 +            for ( Entity importedThing : importedThings ) {
 +                emApp1.delete( importedThing );
 +            }
 +            emApp1.refreshIndex();
 +            emApp2.refreshIndex();
 +
 +            importedThings = emApp2.getCollection(
 +                appId2, "things", null, Level.ALL_PROPERTIES).getEntities();
 +            assertTrue( !importedThings.isEmpty() );
 +
 +        } finally {
 +            deleteBucket();
 +        }
 +    }
 +
 +
 +    /**
 +     * Test that an existing collection of entities can be updated
 +     * by doing an import of entities identified by UUIDs.
 +     */
 +    @Test
 +    public void testUpdateByImport() throws Exception {
 +
 +        // create collection of things in first application, export them to S3
 +
 +        final UUID targetAppId = setup.getMgmtSvc().createApplication(
 +            organization.getUuid(), "target" + RandomStringUtils.randomAlphanumeric(10)).getId();
 +
 +        final EntityManager emApp1 = setup.getEmf().getEntityManager( targetAppId );
 +
 +        Map<UUID, Entity> thingsMap = new HashMap<>();
 +        List<Entity> things = new ArrayList<>();
 +        createTestEntities(emApp1, thingsMap, things, "thing");
 +
 +        deleteBucket();
 +
 +        try {
 +            exportCollection(emApp1, "things");
 +
 +            // create new second application and import those things from S3
 +
 +            final UUID appId2 = setup.getMgmtSvc().createApplication(
 +                organization.getUuid(), "second" + RandomStringUtils.randomAlphanumeric(10)).getId();
 +
 +            final EntityManager emApp2 = setup.getEmf().getEntityManager(appId2);
 +            importCollections(emApp2);
 +
 +
 +            // update the things in the second application, export to S3
 +
 +            for (UUID uuid : thingsMap.keySet()) {
 +                Entity entity = emApp2.get(uuid);
 +                entity.setProperty("fuel_source", "Hydrogen");
 +                emApp2.update(entity);
 +            }
 +
 +            deleteBucket();
 +            exportCollection(emApp2, "things");
 +
 +
 +            // import the updated things back into the first application, check that they've been updated
 +
 +            importCollections(emApp1);
 +
 +            for (UUID uuid : thingsMap.keySet()) {
 +                Entity entity = emApp1.get(uuid);
 +                Assert.assertEquals("Hydrogen", entity.getProperty("fuel_source"));
 +            }
 +
 +        } finally {
 +            deleteBucket();
 +        }
 +    }
 +
 +
 +   /**
 +     * Simple import test but with multiple files.
 +     */
 +    @Test
 +    public void testImportWithMultipleFiles() throws Exception {
 +
 +        deleteBucket();
 +
 +        try {
 +
 +            String targetAppName = "import-test-target-" + RandomStringUtils.randomAlphanumeric(10);
 +            UUID targetAppId = setup.getMgmtSvc().createApplication(organization.getUuid(), targetAppName).getId();
 +
 +            // create 4 applications each with collection of 10 things, export all to S3
 +            logger.debug("\n\nCreating 10 applications with 10 entities each\n");
 +
 +            for (int i = 0; i < 10; i++) {
 +
 +                String appName = "import-test-" + i + RandomStringUtils.randomAlphanumeric(10);
 +                UUID appId = setup.getMgmtSvc().createApplication(organization.getUuid(), appName).getId();
 +                EntityManager emApp = setup.getEmf().getEntityManager(appId);
 +
 +                Map<UUID, Entity> thingsMap = new HashMap<>();
 +                List<Entity> things = new ArrayList<>();
 +                createTestEntities(emApp, thingsMap, things, "thing");
 +
 +                exportCollection(emApp, "things");
 +            }
 +
 +            // import all those exports from S3 into the default test application
 +            logger.debug("\n\nImporting\n");
 +
 +            final EntityManager emDefaultApp = setup.getEmf().getEntityManager(targetAppId);
 +            importCollections(emDefaultApp);
 +
 +            // we should now have 100 Entities in the default app
 +
 +            logger.debug("\n\nQuery to see if we now have 100 entities\n");
 +
 +            Query query = Query.fromQL("select *").withLimit(101);
 +
 +            List<Entity> importedThings = emDefaultApp.getCollection(
 +                emDefaultApp.getApplicationId(), "things", query, Level.ALL_PROPERTIES).getEntities();
 +
 +            assertNotNull("importedThings must not be null", !importedThings.isEmpty());
 +            assertTrue("importedThings must not be empty", !importedThings.isEmpty());
 +            assertEquals("there must be 100 importedThings", 100, importedThings.size());
 +
 +        } finally {
 +            deleteBucket();
 +        }
 +    }
 +
 +
 +    /**
 +     * TODO: Test that importing bad JSON will result in an informative error message.
 +     */
 +    @Test
 +    public void testImportBadJson() throws Exception {
 +
 +        deleteBucket();
 +
 +        // export and upload a bad JSON file to the S3 bucket
 +
 +        File cwd = new File(".");
 +        String basePath = System.getProperty("target.directory")
 +            + File.separator + "test-classes" + File.separator;
 +
 +        List<String> filenames = new ArrayList<>( 1 );
 +        filenames.add( basePath + "testimport-bad-json.json");
 +
 +        S3Upload s3Upload = new S3Upload();
 +        s3Upload.copyToS3(
 +            System.getProperty(SDKGlobalConfiguration.ACCESS_KEY_ENV_VAR),
 +            System.getProperty(SDKGlobalConfiguration.SECRET_KEY_ENV_VAR),
 +            bucketName, filenames );
 +
 +        // import bad JSON from from the S3 bucket
 +
 +        String appName = "import-test-" + RandomStringUtils.randomAlphanumeric(10);
 +        UUID appId = setup.getMgmtSvc().createApplication(organization.getUuid(), appName).getId();
 +
 +        final EntityManager em = setup.getEmf().getEntityManager( appId );
 +        UUID importId = importCollections(em);
 +
 +
 +        // check that we got an informative error message back
 +
 +        List<Entity> importedThings = em.getCollection(
 +            em.getApplicationId(), "things", null, Level.ALL_PROPERTIES).getEntities();
 +
 +        assertTrue("No entities should have been imported", importedThings.isEmpty());
 +
 +        ImportService importService = setup.getImportService();
 +        Results results = importService.getFileImports( appId, importId, null, null );
 +
 +        assertEquals( "There is one", 1, results.size() );
 +
 +        assertEquals( "Entity is FileImport object",
 +            FileImport.class, results.getEntity().getClass() );
 +
 +        FileImport fileImport = (FileImport)results.getEntity();
 +
 +        assertTrue( fileImport.getFileName().endsWith("testimport-bad-json.json"));
 +
 +        assertTrue( "Error message is correct",
 +            fileImport.getErrorMessage().startsWith("Unexpected character ('<' (code 60))"));
 +    }
 +
 +    @Test
 +    public void testImportWithMultipleFilesSomeBad() throws Exception {
 +
 +        deleteBucket();
 +
 +        // upload good and badly formatted files to our S3 bucket
 +
 +        String basePath = System.getProperty("target.directory")
 +            + File.separator + "test-classes" + File.separator;
 +
 +        List<String> filenames = new ArrayList<>( 3 );
 +        filenames.add( basePath + "testimport-with-connections.json" );
 +        filenames.add( basePath + "testimport-qtmagics.json" );
 +        filenames.add( basePath + "testimport-bad-connection.json" );
 +        filenames.add( basePath + "testimport-bad-json.json" );
 +
 +        S3Upload s3Upload = new S3Upload();
 +        s3Upload.copyToS3(
 +            System.getProperty( SDKGlobalConfiguration.ACCESS_KEY_ENV_VAR),
 +            System.getProperty( SDKGlobalConfiguration.SECRET_KEY_ENV_VAR),
 +            bucketName, filenames );
 +
 +        // import all those files into the default test application
 +
 +        String targetAppName = "import-test-target-" + RandomStringUtils.randomAlphanumeric(10);
 +        UUID targetAppId = setup.getMgmtSvc().createApplication(organization.getUuid(), targetAppName).getId();
 +
 +        final EntityManager emDefaultApp = setup.getEmf().getEntityManager( targetAppId );
 +        UUID importId = importCollections(emDefaultApp);
 +
 +        {
 +            List<Entity> importedThings = emDefaultApp.getCollection(
 +                emDefaultApp.getApplicationId(), "connfails", null, Level.ALL_PROPERTIES).getEntities();
 +            assertTrue( !importedThings.isEmpty());
 +            assertEquals( 1, importedThings.size() );
 +        }
 +
 +        {
 +            List<Entity> importedThings = emDefaultApp.getCollection(
 +                emDefaultApp.getApplicationId(), "qtmagics", null, Level.ALL_PROPERTIES).getEntities();
 +            assertTrue(!importedThings.isEmpty());
 +            assertEquals(5, importedThings.size());
 +        }
 +
 +        {
 +            List<Entity> importedThings = emDefaultApp.getCollection(
 +                emDefaultApp.getApplicationId(), "badjsons", null, Level.ALL_PROPERTIES).getEntities();
 +            assertTrue(!importedThings.isEmpty());
 +            assertEquals( 4, importedThings.size() );
 +        }
 +
 +        {
 +            List<Entity> importedThings = emDefaultApp.getCollection(
 +                emDefaultApp.getApplicationId(), "things", null, Level.ALL_PROPERTIES).getEntities();
 +            assertTrue(!importedThings.isEmpty());
 +            assertEquals( 10, importedThings.size() );
 +        }
 +
 +        Thread.sleep(3000);
 +
 +        ImportService importService = setup.getImportService();
 +        Results results = importService.getFileImports( targetAppId, importId, null, null );
 +
 +        assertEquals( "There four file imports", 4, results.size() );
 +
 +    }
 +
 +
 +   //---------------------------------------------------------------------------------------------
 +
 +
 +    /**
 +     * Start import job that will import all collections in all data files in the S3 bucket.
 +     */
 +    private UUID importCollections(final EntityManager em) throws Exception {
 +
 +        logger.debug("\n\nImport into new app {}\n", em.getApplication().getName() );
 +
 +        final ImportService importService = setup.getImportService();
 +
 +        final Import importEntity = importService.schedule(em.getApplication().getUuid(),
 +            new HashMap<String, Object>() {{
 +            put( "path", organization.getName() + em.getApplication().getName() );
 +            put( "organizationId", organization.getUuid() );
 +            put( "applicationId", em.getApplication().getUuid() );
 +            put( "properties", new HashMap<String, Object>() {{
 +                put( "storage_provider", "s3" );
 +                put( "storage_info", new HashMap<String, Object>() {{
 +                    put( "s3_access_id",
 +                        System.getProperty( SDKGlobalConfiguration.ACCESS_KEY_ENV_VAR) );
 +                    put( "s3_key",
 +                        System.getProperty( SDKGlobalConfiguration.SECRET_KEY_ENV_VAR ) );
 +                    put( "bucket_location", bucketName );
 +                }} );
 +            }} );
 +        }});
 +
 +        int maxRetries = 30;
 +        int retries = 0;
 +        Import.State state = importService.getState(importEntity.getUuid());
 +        while (     !state.equals( Import.State.FINISHED )
 +                 && !state.equals( Import.State.FAILED )
 +                 && retries++ < maxRetries ) {
 +
 +            logger.debug("Waiting for import ({}) ...", state.toString());
 +            Thread.sleep(1000);
 +
 +            state = importService.getState(importEntity.getUuid());
 +        }
 +
 +        if ( retries >= maxRetries ) {
 +            throw new RuntimeException("Max retries reached");
 +        }
 +        em.refreshIndex();
 +
 +        return importEntity.getUuid();
 +    }
 +
 +
 +    /**
 +     * Start export job that wilk export a specific collection to the S3 bucket.
 +     */
 +    private void exportCollection(
 +        final EntityManager em, final String collectionName ) throws Exception {
 +
 +        logger.debug("\n\nExporting {} collection from application {}\n",
 +            collectionName, em.getApplication().getName() );
 +
 +        em.refreshIndex();
 +
 +        ExportService exportService = setup.getExportService();
 +        UUID exportUUID = exportService.schedule( new HashMap<String, Object>() {{
 +            put( "path", organization.getName() + em.getApplication().getName());
 +            put( "organizationId",  organization.getUuid());
 +            put( "applicationId", em.getApplication().getUuid() );
 +            put( "collectionName", collectionName);
 +            put( "properties", new HashMap<String, Object>() {{
 +                 put( "storage_provider", "s3" );
 +                 put( "storage_info", new HashMap<String, Object>() {{
 +                     put( "s3_access_id",
 +                         System.getProperty( SDKGlobalConfiguration.ACCESS_KEY_ENV_VAR) );
 +                     put("s3_key",
 +                         System.getProperty(SDKGlobalConfiguration.SECRET_KEY_ENV_VAR));
 +                    put( "bucket_location", bucketName );
 +                }});
 +            }});
 +        }});
 +
 +        int maxRetries = 30;
 +        int retries = 0;
 +        while ( !exportService.getState( exportUUID ).equals( "FINISHED" ) && retries++ < maxRetries ) {
 +            logger.debug("Waiting for export...");
 +            Thread.sleep(1000);
 +        }
 +
 +        if ( retries >= maxRetries ) {
 +            throw new RuntimeException("Max retries reached");
 +        }
 +    }
 +
 +
 +    /**
 +     * Create test entities of a specified type.
 +     * First two entities are connected.
 +     */
 +    private void createTestEntities(final EntityManager em,
 +        Map<UUID, Entity> thingsMap, List<Entity> things, final String type) throws Exception {
 +
 +        logger.debug("\n\nCreating new {} collection in application {}\n",
 +            type, em.getApplication().getName());
 +
 +        em.refreshIndex();
 +
 +        List<Entity> created = new ArrayList<>();
 +        for (int i = 0; i < 10; i++) {
 +            final int count = i;
 +            Entity e = em.create(type, new HashMap<String, Object>() {{
 +                put("name", em.getApplication().getName() + "-" + type + "-" + count);
 +                put("originalAppId", em.getApplication().getUuid());
 +                put("originalAppName", em.getApplication().getName());
 +            }});
 +            thingsMap.put(e.getUuid(), e);
 +            things.add(e);
 +            created.add(e);
 +        }
 +
 +        // first two things are related to each other
 +        em.createConnection(new SimpleEntityRef(type, created.get(0).getUuid()),
 +            "related", new SimpleEntityRef(type, created.get(1).getUuid()));
 +        em.createConnection(new SimpleEntityRef(type, created.get(1).getUuid()),
 +            "related", new SimpleEntityRef(type, created.get(0).getUuid()));
 +
 +        em.refreshIndex();
 +    }
 +
 +
 +    /**
 +     * Delete the configured s3 bucket.
 +     */
 +    public void deleteBucket() {
 +
 +        logger.debug("\n\nDelete bucket\n");
 +
 +        String accessId = System.getProperty(SDKGlobalConfiguration.ACCESS_KEY_ENV_VAR);
 +        String secretKey = System.getProperty(SDKGlobalConfiguration.SECRET_KEY_ENV_VAR);
 +
 +        Properties overrides = new Properties();
 +        overrides.setProperty("s3" + ".identity", accessId);
 +        overrides.setProperty("s3" + ".credential", secretKey);
 +
 +        final Iterable<? extends Module> MODULES = ImmutableSet
 +            .of(new JavaUrlHttpCommandExecutorServiceModule(),
 +                new Log4JLoggingModule(),
 +                new NettyPayloadModule());
 +
 +        BlobStoreContext context =
 +            ContextBuilder.newBuilder("s3").credentials(accessId, secretKey).modules(MODULES)
 +                .overrides(overrides).buildView(BlobStoreContext.class);
 +
 +        BlobStore blobStore = context.getBlobStore();
 +        blobStore.deleteContainer( bucketName );
 +    }
 +
 +
 +    // might be handy if you need to clean up buckets
 +    private static void deleteBucketsWithPrefix() {
 +
 +        logger.debug("\n\nDelete buckets with prefix {}\n", bucketPrefix );
 +
 +        String accessId = System.getProperty(SDKGlobalConfiguration.ACCESS_KEY_ENV_VAR);
 +        String secretKey = System.getProperty(SDKGlobalConfiguration.SECRET_KEY_ENV_VAR);
 +
 +        Properties overrides = new Properties();
 +        overrides.setProperty("s3" + ".identity", accessId);
 +        overrides.setProperty("s3" + ".credential", secretKey);
 +
 +        final Iterable<? extends Module> MODULES = ImmutableSet
 +            .of(new JavaUrlHttpCommandExecutorServiceModule(),
 +                new Log4JLoggingModule(),
 +                new NettyPayloadModule());
 +
 +        BlobStoreContext context =
 +            ContextBuilder.newBuilder("s3").credentials(accessId, secretKey).modules(MODULES)
 +                .overrides(overrides).buildView(BlobStoreContext.class);
 +
 +        BlobStore blobStore = context.getBlobStore();
 +        final PageSet<? extends StorageMetadata> blobStoreList = blobStore.list();
 +
 +        for ( Object o : blobStoreList.toArray() ) {
 +            StorageMetadata s = (StorageMetadata)o;
 +
 +            if ( s.getName().startsWith( bucketPrefix )) {
 +                try {
 +                    blobStore.deleteContainer(s.getName());
 +                } catch ( ContainerNotFoundException cnfe ) {
 +                    logger.warn("Attempted to delete bucket {} but it is already deleted", cnfe );
 +                }
 +                logger.debug("Deleted bucket {}", s.getName());
 +            }
 +        }
 +    }
 +}


[21/50] [abbrv] incubator-usergrid git commit: Added fix for circular decencies and added support for multiple key spaces.

Posted by sn...@apache.org.
Added fix for circular decencies and added support for multiple key spaces.


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

Branch: refs/heads/two-dot-o
Commit: 08c1f1d08c7c6bb9ce3a4cf979e09fb0d733ef46
Parents: aac4a2f
Author: grey <gr...@apigee.com>
Authored: Mon Feb 23 16:25:31 2015 -0800
Committer: grey <gr...@apigee.com>
Committed: Mon Feb 23 16:25:31 2015 -0800

----------------------------------------------------------------------
 .../usergrid/corepersistence/GuiceFactory.java  | 25 ++++++++------------
 .../main/resources/usergrid-core-context.xml    |  4 ++--
 2 files changed, 12 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/08c1f1d0/stack/core/src/main/java/org/apache/usergrid/corepersistence/GuiceFactory.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/GuiceFactory.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/GuiceFactory.java
index 77831fe..566430f 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/GuiceFactory.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/GuiceFactory.java
@@ -32,6 +32,7 @@ import org.springframework.context.ApplicationContextAware;
 import org.apache.commons.lang.StringUtils;
 
 import org.apache.usergrid.persistence.cassandra.CassandraService;
+import org.apache.usergrid.persistence.core.guice.CommonModule;
 
 import com.google.inject.Guice;
 import com.google.inject.Injector;
@@ -39,6 +40,7 @@ import com.google.inject.Singleton;
 import com.netflix.config.ConfigurationManager;
 
 import me.prettyprint.cassandra.service.CassandraHost;
+import me.prettyprint.cassandra.service.CassandraHostConfigurator;
 
 
 /**
@@ -49,8 +51,7 @@ public class GuiceFactory implements FactoryBean<Injector>, ApplicationContextAw
 
     private static final Logger logger = LoggerFactory.getLogger( GuiceFactory.class );
 
-
-    private final CassandraService cass;
+    private final CassandraHostConfigurator chc;
 
     private final Properties systemProperties;
 
@@ -61,8 +62,8 @@ public class GuiceFactory implements FactoryBean<Injector>, ApplicationContextAw
 
 
 
-    public GuiceFactory( final CassandraService cass, final Properties systemProperties ) {
-        this.cass = cass;
+    public GuiceFactory( final CassandraHostConfigurator chc, final Properties systemProperties  ) {
+        this.chc = chc;
         this.systemProperties = systemProperties;
     }
 
@@ -74,14 +75,12 @@ public class GuiceFactory implements FactoryBean<Injector>, ApplicationContextAw
             return injector;
         }
 
-
         try {
 
-            cass.init();
             logger.info( "Loading Core Persistence properties" );
 
             String hostsString = "";
-            CassandraHost[] hosts = cass.getCassandraHostConfigurator().buildCassandraHosts();
+            CassandraHost[] hosts = chc.buildCassandraHosts();
             if ( hosts.length == 0 ) {
                 throw new RuntimeException( "Fatal error: no Cassandra hosts configured" );
             }
@@ -101,9 +100,9 @@ public class GuiceFactory implements FactoryBean<Injector>, ApplicationContextAw
             // Some Usergrid properties must be mapped to Core Persistence properties
             cpProps.put( "cassandra.hosts", hostsString );
             cpProps.put( "cassandra.port", hosts[0].getPort() );
-            cpProps.put( "cassandra.cluster_name", cass.getProperties().get( "cassandra.cluster" ) );
+            cpProps.put( "cassandra.cluster_name",  systemProperties.getProperty( "cassandra.cluster" ) );
 
-            String cassRemoteString = ( String ) cass.getProperties().get( "cassandra.use_remote" );
+            String cassRemoteString = ( String ) systemProperties.getProperty( "cassandra.use_remote" );
             if ( cassRemoteString != null && cassRemoteString.equals( "false" ) ) {
                 cpProps.put( "cassandra.embedded", "true" );
             }
@@ -112,21 +111,17 @@ public class GuiceFactory implements FactoryBean<Injector>, ApplicationContextAw
             }
 
             cpProps.put( "collections.keyspace.strategy.class",
-                cass.getProperties().get( "cassandra.keyspace.strategy" ) );
+                systemProperties.getProperty( "cassandra.keyspace.strategy" ) );
 
             cpProps.put( "collections.keyspace.strategy.options",
-                cass.getProperties().get( "cassandra.keyspace.replication" ) );
-
+                systemProperties.getProperty( "cassandra.keyspace.replication" ) );
 
             logger.debug( "Set Cassandra properties for Core Persistence: " + cpProps.toString() );
 
             // Make all Usergrid properties into Core Persistence config
-            cpProps.putAll( cass.getProperties() );
             cpProps.putAll( systemProperties );
             //logger.debug("All properties fed to Core Persistence: " + cpProps.toString() );
 
-
-
             ConfigurationManager.loadProperties( cpProps );
         }
         catch ( Exception e ) {

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/08c1f1d0/stack/core/src/main/resources/usergrid-core-context.xml
----------------------------------------------------------------------
diff --git a/stack/core/src/main/resources/usergrid-core-context.xml b/stack/core/src/main/resources/usergrid-core-context.xml
index f0e5bd4..1c9aeb1 100644
--- a/stack/core/src/main/resources/usergrid-core-context.xml
+++ b/stack/core/src/main/resources/usergrid-core-context.xml
@@ -95,9 +95,9 @@
 
     <bean id="injector"
    		class="org.apache.usergrid.corepersistence.GuiceFactory">
-   		<constructor-arg ref="cassandraService" />
+   		<constructor-arg ref="cassandraHostConfigurator" />
         <constructor-arg ref="properties" />
-   	</bean>
+    </bean>
 
 	<bean id="cassandraService"
 		class="org.apache.usergrid.persistence.cassandra.CassandraService" init-method="init" destroy-method="destroy">


[46/50] [abbrv] incubator-usergrid git commit: Merge branch 'USERGRID-273' of https://github.com/apache/incubator-usergrid into USERGRID-273

Posted by sn...@apache.org.
Merge branch 'USERGRID-273' of https://github.com/apache/incubator-usergrid into USERGRID-273


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

Branch: refs/heads/two-dot-o
Commit: 9435fa35ea207b46fade5249ea402ad6739d0a36
Parents: bedf5af 48a2be7
Author: Dave Johnson <sn...@apache.org>
Authored: Thu Feb 26 09:48:47 2015 -0500
Committer: Dave Johnson <sn...@apache.org>
Committed: Thu Feb 26 09:48:47 2015 -0500

----------------------------------------------------------------------
 .../usergrid/corepersistence/CpSetup.java       | 54 +++++----------
 .../usergrid/corepersistence/GuiceFactory.java  | 25 +++----
 .../persistence/cassandra/CassandraService.java | 71 +++++++++-----------
 .../cassandra/EntityManagerFactoryImpl.java     | 20 +++---
 .../persistence/cassandra/SetupImpl.java        | 60 ++++++-----------
 .../main/resources/usergrid-core-context.xml    |  5 +-
 .../usergrid/persistence/CoreSchemaManager.java |  4 +-
 .../cassandra/EntityManagerFactoryImplIT.java   |  6 --
 .../core/astyanax/AstyanaxKeyspaceProvider.java |  2 +-
 .../persistence/core/astyanax/CassandraFig.java | 10 +--
 .../tokens/cassandra/TokenServiceImpl.java      | 14 ++--
 11 files changed, 109 insertions(+), 162 deletions(-)
----------------------------------------------------------------------



[49/50] [abbrv] incubator-usergrid git commit: Merge branch 'two-dot-o' of https://git-wip-us.apache.org/repos/asf/incubator-usergrid into two-dot-o

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

Conflicts:
	stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/BrowserCompatibilityTest.java
	stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/CollectionsResourceIT.java
	stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/DuplicateNameIT.java
	stack/rest/src/test/java/org/apache/usergrid/rest/management/organizations/AdminEmailEncodingIT.java
	stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/model/Entity.java


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

Branch: refs/heads/two-dot-o
Commit: 4eca431852063bb08609ab82239ffc2e2fa114a5
Parents: 0b63317 b4727f1
Author: Dave Johnson <sn...@apache.org>
Authored: Thu Feb 26 11:05:42 2015 -0500
Committer: Dave Johnson <sn...@apache.org>
Committed: Thu Feb 26 11:05:42 2015 -0500

----------------------------------------------------------------------
 .../apache/usergrid/rest/PartialUpdateTest.java |   2 +-
 .../collection/BrowserCompatibilityTest.java    |  67 +++--
 .../collection/CollectionsResourceIT.java       | 253 +++++++++++--------
 .../collection/DuplicateNameIT.java             |  10 -
 .../collection/groups/GroupResourceIT.java      |   2 +-
 .../rest/management/ImportResourceIT.java       |   4 +-
 .../organizations/AdminEmailEncodingIT.java     |   8 +-
 .../endpoints/CollectionEndpoint.java           |  58 ++++-
 .../endpoints/EntityEndpoint.java               |   2 -
 .../rest/test/resource2point0/model/Entity.java |   9 +-
 10 files changed, 243 insertions(+), 172 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/4eca4318/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/BrowserCompatibilityTest.java
----------------------------------------------------------------------
diff --cc stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/BrowserCompatibilityTest.java
index dfdbdd8,841d98b..2c3d9d7
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/BrowserCompatibilityTest.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/BrowserCompatibilityTest.java
@@@ -17,34 -17,27 +17,28 @@@
  package org.apache.usergrid.rest.applications.collection;
  
  
- import java.util.Map;
- import java.util.UUID;
- 
- import com.fasterxml.jackson.databind.JsonNode;
  import java.io.IOException;
- import org.junit.Rule;
+ import org.apache.usergrid.rest.test.resource2point0.model.Entity;
  import org.junit.Test;
- 
 -import org.apache.usergrid.cassandra.Concurrent;
 -import org.apache.usergrid.rest.test.resource2point0.AbstractRestIT;
 +import org.apache.usergrid.rest.AbstractRestIT;
 +import org.apache.usergrid.rest.TestContextSetup;
 +import org.apache.usergrid.rest.test.resource.CustomCollection;
- 
+ import org.apache.usergrid.rest.test.resource2point0.model.Collection;
+ import org.apache.usergrid.rest.test.resource2point0.model.Entity;
  import static junit.framework.Assert.assertNotNull;
  import static org.junit.Assert.assertEquals;
- import static org.apache.usergrid.utils.MapUtils.hashMap;
  
  
  /**
   * Simple tests to test querying at the REST tier
   */
 -@Concurrent()
 -public class BrowserCompatibilityTest extends AbstractRestIT {
 +
- public class BrowserCompatibilityTest extends AbstractRestIT {
- 
- 
-     @Rule
-     public TestContextSetup context = new TestContextSetup( this );
++public class BrowserCompatibilityTest extends org.apache.usergrid.rest.test.resource2point0.AbstractRestIT {
  
  
+     /**
+      * Test to check chrome type accept headers
+      */
      @Test
      public void testChromeHtmlTypes() throws Exception {
          testBrowserAccept( "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8" );

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/4eca4318/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/CollectionsResourceIT.java
----------------------------------------------------------------------
diff --cc stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/CollectionsResourceIT.java
index 115c9af,b9e1191..6dbaf7f
--- 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,35 -17,32 +17,30 @@@
  package org.apache.usergrid.rest.applications.collection;
  
  
- import java.util.HashMap;
- import java.util.Map;
- import java.util.UUID;
- 
- import javax.ws.rs.core.MediaType;
- 
+ import java.io.IOException;
 -import java.util.NoSuchElementException;
  import com.fasterxml.jackson.databind.JsonNode;
- import org.junit.Assert;
+ import com.sun.jersey.api.client.UniformInterfaceException;
+ import org.apache.usergrid.rest.test.resource2point0.AbstractRestIT;
+ import org.apache.usergrid.rest.test.resource2point0.model.Collection;
+ import org.apache.usergrid.rest.test.resource2point0.model.Entity;
+ 
+ import org.apache.usergrid.rest.test.resource2point0.model.QueryParameters;
+ import org.junit.Ignore;
  import org.junit.Test;
  import org.slf4j.Logger;
  import org.slf4j.LoggerFactory;
 -import org.apache.usergrid.cassandra.Concurrent;
  
- import org.apache.usergrid.rest.AbstractRestIT;
- import org.apache.usergrid.utils.UUIDUtils;
- 
- import com.sun.jersey.api.client.UniformInterfaceException;
- import java.io.IOException;
- 
- import static org.junit.Assert.assertEquals;
- import static org.junit.Assert.assertNotNull;
- import static org.junit.Assert.assertNull;
- import static org.apache.usergrid.utils.MapUtils.hashMap;
+ import static org.junit.Assert.*;
  
  
  /**
   * @author zznate
   * @author tnine
+  * @author rockerston
+  *
+  *  misc tests for collections
   */
 -@Concurrent()
 +
  public class CollectionsResourceIT extends AbstractRestIT {
  
      private static Logger log = LoggerFactory.getLogger( CollectionsResourceIT.class );
@@@ -129,42 -178,37 +176,36 @@@
  
      @Test
      public void stringWithSpaces() throws IOException {
-         Map<String, String> payload = hashMap( "summaryOverview", "My Summary" ).map( "caltype", "personal" );
  
-         JsonNode node = mapper.readTree( resource().path( "/test-organization/test-app/calendarlists" )
-                 .queryParam( "access_token", access_token ).accept( MediaType.APPLICATION_JSON )
-                 .type( MediaType.APPLICATION_JSON_TYPE ).post( String.class, payload ));
- 
- 
-         UUID id = getEntityId( node, 0 );
+         // create entity with a property with spaces
+         String collection = "calendarlists";
+         String summaryOverview = "My Summary";
+         String calType = "personal";
+         Entity payload = new Entity();
+         payload.put("summaryOverview", summaryOverview);
+         payload.put("caltype", calType);
+         Entity calendarlistOne = this.app().collection(collection).post(payload);
+         assertEquals(calendarlistOne.get("summaryOverview"), summaryOverview);
+         assertEquals(calendarlistOne.get("caltype"), calType);
 -        String calendarlistOneUUID = calendarlistOne.getString("uuid");
+         this.refreshIndex();
  
          //post a second entity
+         payload = new Entity();
+         String summaryOverviewTwo = "Your Summary";
+         String calTypeTwo = "personal";
+         payload.put("summaryOverview", summaryOverviewTwo);
+         payload.put("caltype", calTypeTwo);
+         Entity calendarlistTwo = this.app().collection(collection).post(payload);
+         assertEquals(calendarlistTwo.get("summaryOverview"), summaryOverviewTwo);
+         assertEquals(calendarlistTwo.get("caltype"), calTypeTwo);
  
  
-         payload = hashMap( "summaryOverview", "Your Summary" ).map( "caltype", "personal" );
- 
-         node = mapper.readTree( resource().path( "/test-organization/test-app/calendarlists" ).queryParam( "access_token", access_token )
-                 .accept( MediaType.APPLICATION_JSON ).type( MediaType.APPLICATION_JSON_TYPE )
-                 .post( String.class, payload ));
- 
- 
-         refreshIndex("test-organization", "test-app");
- 
          //query for the first entity
- 
          String query = "summaryOverview = 'My Summary'";
+         QueryParameters queryParameters = new QueryParameters().setQuery(query);
+         Collection calendarListCollection = this.app().collection(collection).get(queryParameters);
+         assertEquals(calendarListCollection.hasNext(), false);
  
- 
-         JsonNode queryResponse = mapper.readTree( resource().path( "/test-organization/test-app/calendarlists" )
-                 .queryParam( "access_token", access_token ).queryParam( "ql", query )
-                 .accept( MediaType.APPLICATION_JSON ).type( MediaType.APPLICATION_JSON_TYPE ).get( String.class ));
- 
- 
-         UUID returnedId = getEntityId( queryResponse, 0 );
- 
-         assertEquals( id, returnedId );
- 
-         assertEquals( 1, queryResponse.get( "entities" ).size() );
      }
  
  

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/4eca4318/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/groups/GroupResourceIT.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/4eca4318/stack/rest/src/test/java/org/apache/usergrid/rest/management/ImportResourceIT.java
----------------------------------------------------------------------
diff --cc stack/rest/src/test/java/org/apache/usergrid/rest/management/ImportResourceIT.java
index 0b87548,0000000..9a96997
mode 100644,000000..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
@@@ -1,770 -1,0 +1,770 @@@
 +/*
 + * 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.management;
 +
 +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;
 +import org.apache.usergrid.ServiceITSetupImpl;
 +import org.apache.usergrid.batch.service.JobSchedulerService;
 +import org.apache.usergrid.cassandra.CassandraResource;
 +import org.apache.usergrid.management.importer.S3Upload;
 +import org.apache.usergrid.persistence.index.impl.ElasticSearchResource;
 +import org.apache.usergrid.persistence.index.utils.UUIDUtils;
 +import org.apache.usergrid.rest.test.resource2point0.AbstractRestIT;
 +import org.apache.usergrid.rest.test.resource2point0.model.ApiResponse;
 +import org.apache.usergrid.rest.test.resource2point0.model.Collection;
 +import org.apache.usergrid.rest.test.resource2point0.model.Entity;
 +import org.apache.usergrid.rest.test.resource2point0.model.Organization;
 +import org.apache.usergrid.rest.test.resource2point0.model.Token;
 +import org.apache.usergrid.setup.ConcurrentProcessSingleton;
 +
 +import org.jclouds.ContextBuilder;
 +import org.jclouds.blobstore.BlobStore;
 +import org.jclouds.blobstore.BlobStoreContext;
 +import org.jclouds.blobstore.ContainerNotFoundException;
 +import org.jclouds.blobstore.domain.PageSet;
 +import org.jclouds.blobstore.domain.StorageMetadata;
 +import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule;
 +import org.jclouds.logging.log4j.config.Log4JLoggingModule;
 +import org.jclouds.netty.config.NettyPayloadModule;
 +import org.junit.*;
 +import org.slf4j.Logger;
 +import org.slf4j.LoggerFactory;
 +
 +import java.util.ArrayList;
 +import java.util.HashMap;
 +import java.util.List;
 +import java.util.Properties;
 +
 +import static org.junit.Assert.*;
 +
 +
 +public class ImportResourceIT extends AbstractRestIT {
 +
 +    private static final Logger logger = LoggerFactory.getLogger(ImportResourceIT.class);
 +
 +
 +    private static String bucketPrefix;
 +
 +    private String bucketName;
 +
 +    boolean configured;
 +
 +
 +    public ImportResourceIT() throws Exception {
 +
 +    }
 +
 +
 +    @ClassRule
 +    public static final ServiceITSetup setup =
 +        new ServiceITSetupImpl();
 +
 +    @BeforeClass
 +    public static void setup() throws Exception {
 +
 +        bucketPrefix = System.getProperty("bucketName");
 +
 +        // start the scheduler after we're all set up
 +        JobSchedulerService jobScheduler = ConcurrentProcessSingleton.getInstance().getSpringResource().getBean( JobSchedulerService.class );
 +        if (jobScheduler.state() != Service.State.RUNNING) {
 +            jobScheduler.startAsync();
 +            jobScheduler.awaitRunning();
 +        }
 +
 +    }
 +
 +    @Before
 +    public void before() {
 +        configured =
 +            !StringUtils.isEmpty(System.getProperty( SDKGlobalConfiguration.SECRET_KEY_ENV_VAR ))
 +                && !StringUtils.isEmpty(System.getProperty( SDKGlobalConfiguration.ACCESS_KEY_ENV_VAR ))
 +                && !StringUtils.isEmpty(System.getProperty("bucketName"));
 +
 +
 +        if (!configured) {
 +            logger.warn("Skipping test because {}, {} and bucketName not " +
 +                    "specified as system properties, e.g. in your Maven settings.xml file.",
 +                new Object[]{
 +                    "s3_key",
 +                    "s3_access_id"
 +                });
 +        }
 +
 +        if (!StringUtils.isEmpty(bucketPrefix)) {
 +            deleteBucketsWithPrefix();
 +        }
 +
 +        bucketName = bucketPrefix + RandomStringUtils.randomAlphanumeric(10).toLowerCase();
 +    }
 +
 +
 +    /**
 +     * Verify that we can get call the import endpoint and get the job state back.
 +     *
 +     * @throws Exception
 +     */
 +    @Test
 +    public void importGetCollectionJobStatTest() throws Exception {
 +
 +        String org = clientSetup.getOrganizationName();
 +        String app = clientSetup.getAppName();
 +        Entity payload = payloadBuilder();
 +
 +        ///management/orgs/orgname/apps/appname/import
 +        Entity entity = this.management()
 +            .orgs()
 +            .organization(org)
 +            .app()
 +            .addToPath(app)
 +            .addToPath("imports")
 +            .post(payload);
 +
 +        assertNotNull(entity);
 +
 +        entity = this.management()
 +            .orgs()
 +            .organization(org)
 +            .app()
 +            .addToPath(app)
 +            .addToPath("imports")
 +            .addToPath(entity.getUuid().toString())
 +            .get();
 +
-         assertNotNull(entity.getString("state"));
++        assertNotNull(entity.getAsString("state"));
 +    }
 +
 +    /**
 +     * Verify that import job can only be read with an authorized token and cannot be read
 +     * with an invalid/notAllowed token.
 +     */
 +    @Test
 +    public void importTokenAuthorizationTest() throws Exception {
 +
 +        // this test should post one import job with one token,
 +        // then try to read back the job with another token
 +
 +        // create an import job
 +        String org = clientSetup.getOrganizationName();
 +        String app = clientSetup.getAppName();
 +        Entity payload = payloadBuilder();
 +
 +        // /management/orgs/orgname/apps/appname/import
 +        Entity entity = this.management()
 +            .orgs()
 +            .organization(org)
 +            .app()
 +            .addToPath(app)
 +            .addToPath("imports")
 +            .post(payload);
 +
 +
 +        assertNotNull(entity);
 +
 +        // test that you can access the organization using the currently set token.
 +        this.management().orgs().organization(org).app().addToPath(app)
 +            .addToPath("imports").addToPath(entity.getUuid().toString()).get();
 +
 +        //create a new org/app
 +        String newOrgName = "org" + UUIDUtils.newTimeUUID();
 +        String newOrgUsername = "orgusername" + UUIDUtils.newTimeUUID();
 +        String newOrgEmail = UUIDUtils.newTimeUUID() + "@usergrid.com";
 +        String newOrgPassword = "password1";
 +        Organization orgPayload = new Organization(
 +            newOrgName, newOrgUsername, newOrgEmail, newOrgName, newOrgPassword, null);
 +        Organization orgCreatedResponse = clientSetup.getRestClient().management().orgs().post(orgPayload);
 +        this.refreshIndex();
 +        assertNotNull(orgCreatedResponse);
 +
 +
 +        //log into the new org/app and get a token
 +        Token tokenPayload = new Token("password", newOrgUsername, newOrgPassword);
 +        Token newOrgToken = clientSetup.getRestClient().management().token().post(tokenPayload);
 +
 +        //save the old token and set the newly issued token as current
 +        context().setToken(newOrgToken);
 +
 +
 +        //try to read with the new token, which should fail as unauthorized
 +        try {
 +            this.management().orgs().organization(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) {
 +            errorParse(401, "unauthorized", ex);
 +        }
 +
 +    }
 +
 +
 +    @Test
 +    public void importPostApplicationNullPointerProperties() throws Exception {
 +        String org = clientSetup.getOrganizationName();
 +        String app = clientSetup.getAppName();
 +        ClientResponse.Status responseStatus = ClientResponse.Status.OK;
 +
 +        Entity payload = new Entity();
 +
 +        try {
 +            this.management().orgs().organization(org).app().addToPath(app).addToPath("imports").post(payload);
 +        } catch (UniformInterfaceException uie) {
 +            responseStatus = uie.getResponse().getClientResponseStatus();
 +        }
 +        assertEquals(ClientResponse.Status.BAD_REQUEST, responseStatus);
 +    }
 +
 +    @Test
 +    public void importPostApplicationNullPointerStorageInfo() throws Exception {
 +        String org = clientSetup.getOrganizationName();
 +        String app = clientSetup.getAppName();
 +        ClientResponse.Status responseStatus = ClientResponse.Status.OK;
 +
 +        Entity payload = payloadBuilder();
 +        Entity properties = (Entity) payload.get("properties");
 +        //remove storage_info field
 +        properties.remove("storage_info");
 +
 +        try {
 +            this.management().orgs().organization(org).app().addToPath(app).addToPath("imports").post(payload);
 +        } catch (UniformInterfaceException uie) {
 +            responseStatus = uie.getResponse().getClientResponseStatus();
 +        }
 +        assertEquals(ClientResponse.Status.BAD_REQUEST, responseStatus);
 +    }
 +
 +
 +    @Test
 +    public void importPostApplicationNullPointerStorageProvider() throws Exception {
 +        String org = clientSetup.getOrganizationName();
 +        String app = clientSetup.getAppName();
 +        ClientResponse.Status responseStatus = ClientResponse.Status.OK;
 +
 +        Entity payload = payloadBuilder();
 +        Entity properties = (Entity) payload.get("properties");
 +        //remove storage_info field
 +        properties.remove("storage_provider");
 +
 +
 +        try {
 +            this.management().orgs().organization(org).app().addToPath(app).addToPath("imports").post(payload);
 +        } catch (UniformInterfaceException uie) {
 +            responseStatus = uie.getResponse().getClientResponseStatus();
 +        }
 +        assertEquals(ClientResponse.Status.BAD_REQUEST, responseStatus);
 +    }
 +
 +
 +    @Test
 +    public void importPostApplicationNullPointerStorageVerification() throws Exception {
 +        String org = clientSetup.getOrganizationName();
 +        String app = clientSetup.getAppName();
 +        ClientResponse.Status responseStatus = ClientResponse.Status.OK;
 +
 +        Entity payload = payloadBuilder();
 +
 +        Entity properties = (Entity) payload.get("properties");
 +        Entity storage_info = (Entity) properties.get("storage_info");
 +        //remove storage_key field
 +        storage_info.remove("s3_key");
 +
 +        try {
 +            this.management().orgs().organization(org).app().addToPath(app).addToPath("imports").post(payload);
 +        } catch (UniformInterfaceException uie) {
 +            responseStatus = uie.getResponse().getClientResponseStatus();
 +        }
 +        assertEquals(ClientResponse.Status.BAD_REQUEST, responseStatus);
 +
 +        payload = payloadBuilder();
 +        properties = (Entity) payload.get("properties");
 +        storage_info = (Entity) properties.get("storage_info");
 +        //remove storage_key field
 +        storage_info.remove("s3_access_id");
 +
 +        try {
 +            this.management().orgs().organization(org).app().addToPath(app).addToPath("imports").post(payload);
 +        } catch (UniformInterfaceException uie) {
 +            responseStatus = uie.getResponse().getClientResponseStatus();
 +        }
 +        assertEquals(ClientResponse.Status.BAD_REQUEST, responseStatus);
 +
 +        payload = payloadBuilder();
 +        properties = (Entity) payload.get("properties");
 +        storage_info = (Entity) properties.get("storage_info");
 +        //remove storage_key field
 +        storage_info.remove("bucket_location");
 +
 +        try {
 +            this.management().orgs().organization(org).app().addToPath(app).addToPath("imports").post(payload);
 +        } catch (UniformInterfaceException uie) {
 +            responseStatus = uie.getResponse().getClientResponseStatus();
 +        }
 +        assertEquals(ClientResponse.Status.BAD_REQUEST, responseStatus);
 +    }
 +
 +//    @Test
 +//    public void testExportImportCollection() throws Exception {
 +//        Assume.assumeTrue( configured );
 +//        // create a collection of "thing" entities in the first application, export to S3
 +//        try {
 +//
 +//            Map<UUID, org.apache.usergrid.persistence.Entity> thingsMap = new HashMap<>();
 +//            List<org.apache.usergrid.persistence.Entity> things = new ArrayList<>();
 +//            createTestEntities(emApp1, thingsMap, things, "thing");
 +//
 +//            deleteBucket();
 +//            exportCollection( emApp1, "things" );
 +//
 +//            // create new second application, import the data from S3
 +//
 +//            final UUID appId2 = setup.getMgmtSvc().createApplication(
 +//                organization.getUuid(), "second").getId();
 +//
 +//            final EntityManager emApp2 = setup.getEmf().getEntityManager(appId2);
 +//            importCollection( emApp2, "things" );
 +//
 +//
 +//            // make sure that it worked
 +//
 +//            logger.debug("\n\nCheck connections\n");
 +//
 +//            List<org.apache.usergrid.persistence.Entity> importedThings = emApp2.getCollection(
 +//                appId2, "things", null, Query.Level.ALL_PROPERTIES).getEntities();
 +//            assertTrue( !importedThings.isEmpty() );
 +//
 +//            // two things have connections
 +//
 +//            int conCount = 0;
 +//            for ( org.apache.usergrid.persistence.Entity e : importedThings ) {
 +//                Results r = emApp2.getConnectedEntities( e, "related", null, Query.Level.IDS);
 +//                List<ConnectionRef> connections = r.getConnections();
 +//                conCount += connections.size();
 +//            }
 +//            assertEquals( 2, conCount );
 +//
 +//            logger.debug("\n\nCheck dictionaries\n");
 +//
 +//            // first two items have things in dictionary
 +//
 +//            EntityRef entity0 = importedThings.get(0);
 +//            Map connected0 = emApp2.getDictionaryAsMap(entity0, "connected_types");
 +//            Map connecting0 = emApp2.getDictionaryAsMap(entity0, "connected_types");
 +//            Assert.assertEquals( 1, connected0.size() );
 +//            Assert.assertEquals( 1, connecting0.size() );
 +//
 +//            EntityRef entity1 = importedThings.get(1);
 +//            Map connected1 = emApp2.getDictionaryAsMap(entity1, "connected_types");
 +//            Map connecting1 = emApp2.getDictionaryAsMap(entity1, "connected_types");
 +//            Assert.assertEquals( 1, connected1.size() );
 +//            Assert.assertEquals( 1, connecting1.size() );
 +//
 +//            // the rest rest do not have connections
 +//
 +//            EntityRef entity2 = importedThings.get(2);
 +//            Map connected2 = emApp2.getDictionaryAsMap(entity2, "connected_types");
 +//            Map connecting2 = emApp2.getDictionaryAsMap(entity2, "connected_types");
 +//            Assert.assertEquals( 0, connected2.size() );
 +//            Assert.assertEquals( 0, connecting2.size() );
 +//
 +//            // if entities are deleted from app1, they still exist in app2
 +//
 +//            logger.debug("\n\nCheck dictionary\n");
 +//            for ( org.apache.usergrid.persistence.Entity importedThing : importedThings ) {
 +//                emApp1.delete( importedThing );
 +//            }
 +//            emApp1.refreshIndex();
 +//            emApp2.refreshIndex();
 +//
 +//            importedThings = emApp2.getCollection(
 +//                appId2, "things", null, Query.Level.ALL_PROPERTIES).getEntities();
 +//            assertTrue( !importedThings.isEmpty() );
 +//
 +//        } finally {
 +//            deleteBucket();
 +//        }
 +//    }
 +
 +
 +    /**
 +     * TODO: Test that importing bad JSON will result in an informative error message.
 +     */
 +    @Test
 +    public void testImportGoodJson() throws Exception {
 +        // import from a bad JSON file
 +        Assume.assumeTrue(configured);
 +
 +        String org = clientSetup.getOrganizationName();
 +        String app = clientSetup.getAppName();
 +
 +
 +        //list out all the files in the resource directory you want uploaded
 +        List<String> filenames = new ArrayList<>(1);
 +
 +        filenames.add("testImportCorrect.testCol.1.json");
 +        // create 10 applications each with collection of 10 things, export all to S3
 +        S3Upload s3Upload = new S3Upload();
 +        s3Upload.copyToS3(
 +            System.getProperty( SDKGlobalConfiguration.ACCESS_KEY_ENV_VAR ),
 +            System.getProperty( SDKGlobalConfiguration.SECRET_KEY_ENV_VAR ),
 +            bucketName, filenames);
 +
 +        // import all those exports from S3 into the default test application
 +
 +        Entity importEntity = importCollection();
 +
 +        Entity importGet = this.management().orgs().organization( org ).app().addToPath( app )
 +            .addToPath( "imports" ).addToPath( importEntity.getUuid().toString() ).get();
 +
 +
 +        refreshIndex();
 +
 +        Entity importGetIncludes = this.management().orgs().organization(org).app().addToPath(app)
 +                                       .addToPath("imports" ).addToPath(importEntity.getUuid().toString() )
 +                                       .addToPath("files" ).get();
 +
 +        ApiResponse importGetIncludesResponse = importGetIncludes.getResponse();
 +
 +        assertNotNull(importGet);
 +        assertNotNull( importGetIncludes );
 +        assertEquals( 1,importGetIncludesResponse.getEntityCount());
 +
 +
 +        final Entity includesEntity = importGetIncludesResponse.getEntities().get( 0 );
 +
-         assertEquals( "testImportCorrect.testCol.1.json", includesEntity.getString( "fileName" ) );
++        assertEquals( "testImportCorrect.testCol.1.json", includesEntity.getAsString( "fileName" ) );
 +        assertEquals(1, includesEntity.get( "importedConnectionCount" ));
 +        assertEquals(1, includesEntity.get( "importedEntityCount" ));
 +
 +        assertEquals("FINISHED", importGet.get("state"));
 +        assertEquals(1, importGet.get("fileCount"));
 +
 +        Collection collection = this.app().collection("things").get();
 +
 +        assertNotNull(collection);
 +        assertEquals(1, collection.getNumOfEntities());
 +        assertEquals("thing0", collection.getResponse().getEntities().get(0).get("name"));
 +
 +
 +        //TODO: make sure it checks the actual imported entities. And the progress they have made.
 +
 +    }
 +
 +    /**
 +     * TODO: Test that importing bad JSON will result in an informative error message.
 +     */
 +    @Test
 +    public void testImportOneGoodOneBad() throws Exception {
 +        // import from a bad JSON file
 +        Assume.assumeTrue(configured);
 +
 +        String org = clientSetup.getOrganizationName();
 +        String app = clientSetup.getAppName();
 +
 +
 +        //list out all the files in the resource directory you want uploaded
 +        List<String> filenames = new ArrayList<>(1);
 +
 +        filenames.add("testImportCorrect.testCol.1.json");
 +        filenames.add("testImport.testApplication.2.json");
 +        // create 10 applications each with collection of 10 things, export all to S3
 +        S3Upload s3Upload = new S3Upload();
 +        s3Upload.copyToS3(
 +            System.getProperty( SDKGlobalConfiguration.ACCESS_KEY_ENV_VAR ),
 +            System.getProperty( SDKGlobalConfiguration.SECRET_KEY_ENV_VAR ),
 +            bucketName, filenames);
 +
 +        // import all those exports from S3 into the default test application
 +
 +        Entity importEntity = importCollection();
 +
 +        Entity importGet = this.management().orgs().organization(org).app().addToPath(app)
 +            .addToPath( "imports" ).addToPath(importEntity.getUuid().toString() ).get();
 +
 +
 +        assertNotNull(importGet);
 +
 +        assertEquals("FAILED", importGet.get("state"));
 +        assertEquals(2, importGet.get("fileCount"));
 +
 +        Collection collection = this.app().collection("things").get();
 +
 +        assertNotNull(collection);
 +        assertEquals(1, collection.getNumOfEntities());
 +        assertEquals("thing0", collection.getResponse().getEntities().get(0).get("name"));
 +
 +
 +    }
 +
 +    /**
 +     * TODO: Test that importing bad JSON will result in an informative error message.
 +     */
 +    @Test
 +    public void testImportOneBadFile() throws Exception {
 +        // import from a bad JSON file
 +        Assume.assumeTrue(configured);
 +
 +        String org = clientSetup.getOrganizationName();
 +        String app = clientSetup.getAppName();
 +
 +
 +        //list out all the files in the resource directory you want uploaded
 +        List<String> filenames = new ArrayList<>(1);
 +
 +        filenames.add("testImport.testApplication.2.json");
 +        // create 10 applications each with collection of 10 things, export all to S3
 +        S3Upload s3Upload = new S3Upload();
 +        s3Upload.copyToS3(
 +            System.getProperty( SDKGlobalConfiguration.ACCESS_KEY_ENV_VAR ),
 +            System.getProperty( SDKGlobalConfiguration.SECRET_KEY_ENV_VAR ),
 +            bucketName, filenames);
 +
 +        // import all those exports from S3 into the default test application
 +
 +        Entity importEntity = importCollection();
 +
 +        Entity importGet = this.management().orgs().organization(org).app().addToPath(app)
 +            .addToPath("imports" ).addToPath(importEntity.getUuid().toString() ).get();
 +
 +
 +        assertNotNull(importGet);
 +
 +        assertEquals("FAILED", importGet.get("state"));
 +        assertEquals(1, importGet.get("fileCount"));
 +
 +
 +        Collection collection = this.app().collection("things").get();
 +
 +        assertNotNull(collection);
 +        assertEquals(0, collection.getNumOfEntities());
 +
 +
 +    }
 +//export with two files and import the two files.
 +    //also test the includes endpoint.
 +
 +    /**
 +     * TODO: Test that importing bad JSON will result in an informative error message.
 +     */
 +    @Test
 +    public void testImportBadJson() throws Exception {
 +        // import from a bad JSON file
 +        Assume.assumeTrue(configured);
 +
 +        String org = clientSetup.getOrganizationName();
 +        String app = clientSetup.getAppName();
 +
 +        //list out all the files in the resource directory you want uploaded
 +        List<String> filenames = new ArrayList<>(1);
 +        filenames.add("testImportInvalidJson.testApplication.3.json");
 +        // create 10 applications each with collection of 10 things, export all to S3
 +        S3Upload s3Upload = new S3Upload();
 +        s3Upload.copyToS3(System.getProperty( SDKGlobalConfiguration.ACCESS_KEY_ENV_VAR ),
 +            System.getProperty( SDKGlobalConfiguration.SECRET_KEY_ENV_VAR ),
 +            bucketName, filenames);
 +
 +        // import all those exports from S3 into the default test application
 +
 +        Entity importEntity = importCollection();
 +
 +        // we should now have 100 Entities in the default app
 +
 +        Entity importGet = this.management().orgs().organization( org ).app().addToPath( app ).addToPath("imports")
 +            .addToPath( importEntity.getUuid().toString() ).get();
 +
 +        Entity importGetIncludes = this.management().orgs().organization(org).app().addToPath(app)
 +            .addToPath("imports" ).addToPath(importEntity.getUuid().toString() )
 +            .addToPath("files" ).get();
 +
 +        assertNotNull(importGet);
 +        //TODO: needs better error checking
 +        assertNotNull(importGetIncludes);
 +
 +        // check that error message indicates JSON parsing error
 +    }
 +
 +    /**
 +     * Call importService to import files from the configured S3 bucket.
 +     */
 +    private Entity importCollection() throws Exception {
 +
 +        String org = clientSetup.getOrganizationName();
 +        String app = clientSetup.getAppName();
 +
 +        logger.debug("\n\nImport into new app {}\n", app);
 +
 +        Entity importPayload = new Entity(new HashMap<String, Object>() {{
 +            put("properties", new HashMap<String, Object>() {{
 +                put("storage_provider", "s3");
 +                put("storage_info", new HashMap<String, Object>() {{
 +                    put("s3_key",
 +                        System.getProperty( SDKGlobalConfiguration.SECRET_KEY_ENV_VAR ));
 +                    put("s3_access_id",
 +                        System.getProperty( SDKGlobalConfiguration.ACCESS_KEY_ENV_VAR ));
 +                    put("bucket_location", bucketName);
 +                }});
 +            }});
 +        }});
 +
 +        Entity importEntity = this.management().orgs().organization(org).app().addToPath(app).addToPath("imports")
 +                                  .post(importPayload);
 +
 +        int maxRetries = 120;
 +        int retries = 0;
 +
 +        while (retries++ < maxRetries) {
 +
 +            Entity importGet = this.management()
 +                .orgs()
 +                .organization(org)
 +                .app()
 +                .addToPath(app)
 +                .addToPath("imports")
 +                .addToPath(importEntity.getUuid().toString())
 +                .get();
 +
 +            if (importGet.get("state").equals("FINISHED") || importGet.get( "state" ).equals( "FAILED" )) {
 +                break;
 +            }
 +
 +            logger.debug("Waiting for import...");
 +            Thread.sleep(1000);
 +        }
 +
 +        refreshIndex();
 +
 +        return importEntity;
 +    }
 +
 +    /**
 +     * Create test entities of a specified type.
 +     * First two entities are connected.
 +     */
 +    private void createTestEntities() throws Exception {
 +
 +        logger.debug("\n\nCreating users in application {}\n",
 +            clientSetup.getAppName());
 +
 +        List<org.apache.usergrid.persistence.Entity> created = new ArrayList<>();
 +        for (int i = 0; i < 10; i++) {
 +            String name = "test" + i;
 +            Entity payload = new Entity();
 +            payload.put("name", name);
 +            payload.put("username", name);
 +            payload.put("email", name + "@test.com");
 +            this.app().collection("users").post(payload);
 +
 +
 +        }
 +
 +        this.refreshIndex();
 +
 +//        // first two things are related to each other
 +//        em.createConnection(new SimpleEntityRef(type, created.get(0).getUuid()),
 +//            "related", new SimpleEntityRef(type, created.get(1).getUuid()));
 +//        em.createConnection(new SimpleEntityRef(type, created.get(1).getUuid()),
 +//            "related", new SimpleEntityRef(type, created.get(0).getUuid()));
 +//
 +//        em.refreshIndex();
 +    }
 +
 +    /**
 +     * Delete the configured s3 bucket.
 +     */
 +    public void deleteBucket() {
 +
 +        logger.debug("\n\nDelete bucket\n");
 +
 +        String accessId = System.getProperty( SDKGlobalConfiguration.ACCESS_KEY_ENV_VAR );
 +        String secretKey = System.getProperty( SDKGlobalConfiguration.SECRET_KEY_ENV_VAR );
 +
 +        Properties overrides = new Properties();
 +        overrides.setProperty("s3" + ".identity", accessId);
 +        overrides.setProperty("s3" + ".credential", secretKey);
 +
 +        final Iterable<? extends Module> MODULES = ImmutableSet.of(new JavaUrlHttpCommandExecutorServiceModule(),
 +            new Log4JLoggingModule(), new NettyPayloadModule());
 +
 +        BlobStoreContext context =
 +            ContextBuilder.newBuilder("s3").credentials(accessId, secretKey).modules(MODULES)
 +                .overrides(overrides ).buildView(BlobStoreContext.class);
 +
 +        BlobStore blobStore = context.getBlobStore();
 +        blobStore.deleteContainer(bucketName);
 +    }
 +
 +    // might be handy if you need to clean up buckets
 +    private static void deleteBucketsWithPrefix() {
 +
 +        logger.debug("\n\nDelete buckets with prefix {}\n", bucketPrefix);
 +
 +        String accessId = System.getProperty( SDKGlobalConfiguration.ACCESS_KEY_ENV_VAR );
 +        String secretKey = System.getProperty( SDKGlobalConfiguration.SECRET_KEY_ENV_VAR );
 +
 +        Properties overrides = new Properties();
 +        overrides.setProperty("s3" + ".identity", accessId);
 +        overrides.setProperty("s3" + ".credential", secretKey);
 +
 +        final Iterable<? extends Module> MODULES = ImmutableSet
 +            .of(new JavaUrlHttpCommandExecutorServiceModule(),
 +                new Log4JLoggingModule(),
 +                new NettyPayloadModule());
 +
 +        BlobStoreContext context =
 +            ContextBuilder.newBuilder("s3").credentials(accessId, secretKey).modules(MODULES)
 +                .overrides(overrides ).buildView(BlobStoreContext.class);
 +
 +        BlobStore blobStore = context.getBlobStore();
 +        final PageSet<? extends StorageMetadata> blobStoreList = blobStore.list();
 +
 +        for (Object o : blobStoreList.toArray()) {
 +            StorageMetadata s = (StorageMetadata) o;
 +
 +            if (s.getName().startsWith(bucketPrefix)) {
 +                try {
 +                    blobStore.deleteContainer(s.getName());
 +                } catch (ContainerNotFoundException cnfe) {
 +                    logger.warn("Attempted to delete bucket {} but it is already deleted", cnfe);
 +                }
 +                logger.debug("Deleted bucket {}", s.getName());
 +            }
 +        }
 +    }
 +
 +
 +    /*Creates fake payload for testing purposes.*/
 +    public Entity payloadBuilder() {
 +        Entity payload = new Entity();
 +        Entity properties = new Entity();
 +        Entity storage_info = new Entity();
 +        //TODO: always put dummy values here and ignore this test.
 +        //TODO: add a ret for when s3 values are invalid.
 +        storage_info.put("s3_key", "insert key here");
 +        storage_info.put("s3_access_id", "insert access id here");
 +        storage_info.put("bucket_location", "insert bucket name here");
 +        properties.put("storage_provider", "s3");
 +        properties.put("storage_info", storage_info);
 +        payload.put("properties", properties);
 +        return payload;
 +    }
 +}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/4eca4318/stack/rest/src/test/java/org/apache/usergrid/rest/management/organizations/AdminEmailEncodingIT.java
----------------------------------------------------------------------
diff --cc stack/rest/src/test/java/org/apache/usergrid/rest/management/organizations/AdminEmailEncodingIT.java
index 4a24c56,648abd1..379a359
--- 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
@@@ -28,10 -29,12 +28,11 @@@ import org.junit.Test
  import org.slf4j.Logger;
  import org.slf4j.LoggerFactory;
  
+ import java.io.IOException;
  import java.util.UUID;
  
 +import static junit.framework.TestCase.assertNotNull;
  import static org.junit.Assert.assertEquals;
 -import static org.junit.Assert.assertNotNull;
 -
  
  /**
   * Tests for admin emails with + signs create accounts correctly, and can get tokens in both the POST and GET forms of
@@@ -39,7 -42,7 +40,6 @@@
   *
   * @author tnine
   */
- 
 -@Concurrent()
  public class AdminEmailEncodingIT extends AbstractRestIT {
      private static Logger log = LoggerFactory.getLogger(AdminEmailEncodingIT.class);
  
@@@ -88,7 -91,9 +88,13 @@@
       * Given an organization name and an arbitrary character or string,
       * ensure that an organization and admin user can be created when
       * the given string is a part of the admin email address
++<<<<<<< HEAD
++     * @param symbol
++=======
+      *
       * @param symbol
+      * @throws IOException
++>>>>>>> b4727f1db4b3e3e312b6f40d25a42ee66246cfd7
       */
      private void doTest(String symbol) throws UniformInterfaceException {
  

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/4eca4318/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/model/Entity.java
----------------------------------------------------------------------
diff --cc stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/model/Entity.java
index 540cfdb,d7fd09a..b616be8
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/model/Entity.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/model/Entity.java
@@@ -135,10 -131,7 +135,12 @@@ public class Entity implements Serializ
          //All values are strings , so doing the cast here saves doing the cast elsewhere
          return getDynamicProperties().get( key );
      }
++
 +    public Map<String, Map<String, Object>> getMap(Object key){
 +        return (LinkedHashMap<String, Map<String, Object>>) getDynamicProperties().get( key );
 +    }
-     public String getString( final Object key ) {
++
+     public String getAsString( final Object key ) {
          //All values are strings , so doing the cast here saves doing the cast elsewhere
          return (String) getDynamicProperties().get( key );
      }


[08/50] [abbrv] incubator-usergrid git commit: Merge branch 'USERGRID-273' into app-rebuild-fix

Posted by sn...@apache.org.
Merge branch 'USERGRID-273' into app-rebuild-fix

Conflicts:
	stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/impl/EntityCollectionManagerImpl.java
	stack/services/src/test/java/org/apache/usergrid/management/importer/ImportCollectionIT.java


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

Branch: refs/heads/two-dot-o
Commit: fe8f4044a55e6d43373aaba8e0ee9be312d2a2f1
Parents: 2f077f1 011a5e0
Author: Dave Johnson <dm...@apigee.com>
Authored: Fri Feb 20 15:31:35 2015 -0500
Committer: Dave Johnson <dm...@apigee.com>
Committed: Fri Feb 20 15:31:35 2015 -0500

----------------------------------------------------------------------
 .../src/main/groovy/configure_usergrid.groovy   |   2 +-
 .../main/resources/usergrid-default.properties  |  15 +-
 .../usergrid/corepersistence/CpSetup.java       |   3 +
 .../entities/FailedImportEntity.java            |  11 +-
 .../EntityCollectionManagerFactoryImpl.java     |  37 ++--
 .../collection/mvcc/stage/write/WriteStart.java |  31 ++--
 .../mvcc/stage/TestEntityGenerator.java         |  54 +++---
 .../mvcc/stage/write/WriteStartTest.java        |  51 +++++-
 .../persistence/model/entity/Entity.java        |   5 +
 .../datagenerators/EntityDataGenerator.scala    |  17 +-
 .../datagenerators/FeederGenerator.scala        |  24 ++-
 .../usergrid/scenarios/EntityScenarios.scala    |  20 +-
 .../org/apache/usergrid/settings/Settings.scala |   2 +
 .../PostCustomEntitySimulation.scala            |  27 ++-
 stack/mongo-emulator/pom.xml                    |  15 +-
 stack/pom.xml                                   |  63 ++-----
 stack/rest/README.md                            |  14 +-
 stack/rest/pom.xml                              |  20 +-
 .../org/apache/usergrid/rest/IndexResource.java |  50 +++++
 .../usergrid/rest/filters/MeteringFilter.java   |   2 +
 .../security/SecuredResourceFilterFactory.java  |   2 +
 .../security/shiro/filters/SecurityFilter.java  |   3 +
 .../apache/usergrid/rest/AbstractRestIT.java    |   9 +-
 .../usergrid/rest/DatabaseInitializer.java      | 146 ---------------
 .../rest/management/OrganizationsIT.java        |   2 +-
 .../test/resource2point0/AbstractRestIT.java    |  22 +++
 stack/rest/src/test/resources/arquillian.xml    |  24 ++-
 .../resources/usergrid-deployment.properties    |   2 -
 .../management/export/S3ExportImpl.java         |   6 +-
 .../management/importer/ImportServiceImpl.java  |   5 +-
 .../management/importer/S3ImportImpl.java       |  28 ++-
 .../services/assets/data/BinaryStore.java       |   3 +-
 .../services/assets/data/S3BinaryStore.java     |  18 +-
 .../org/apache/usergrid/ServiceITSetupImpl.java |   1 +
 .../usergrid/management/OrganizationIT.java     |  30 +--
 .../management/export/ExportServiceIT.java      | 183 ++++++++++++-------
 .../importer/FileImportTrackerTest.java         |  55 +++---
 .../management/importer/ImportCollectionIT.java |  73 +++++---
 .../usergrid/management/importer/S3Upload.java  |  18 +-
 .../services/ApplicationsServiceIT.java         |   8 +-
 .../usergrid/services/ServiceInvocationIT.java  |   7 +
 .../src/test/resources/project.properties       |   1 +
 .../usergrid/cassandra/ClearShiroSubject.java   |  18 ++
 43 files changed, 626 insertions(+), 501 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/fe8f4044/stack/rest/src/main/java/org/apache/usergrid/rest/IndexResource.java
----------------------------------------------------------------------
diff --cc stack/rest/src/main/java/org/apache/usergrid/rest/IndexResource.java
index 251e25c,acce2d8..85f27ed
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/IndexResource.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/IndexResource.java
@@@ -193,9 -186,9 +193,59 @@@ public class IndexResource extends Abst
          response.setSuccess();
  
          return new JSONWithPadding( response, callback );
+     }
+ 
+     @RequireSystemAccess
++    @PUT
++    @Path( "rebuildinternal" )
++    public JSONWithPadding rebuildInternalIndexes(
++        @Context UriInfo ui,
++        @PathParam( "applicationId" ) String applicationIdStr,
++        @QueryParam( "callback" ) @DefaultValue( "callback" ) String callback,
++        @QueryParam( "delay" ) @DefaultValue( "10" ) final long delay )  throws Exception {
++
++
++        final UUID appId = UUIDUtils.tryExtractUUID(applicationIdStr);
++        ApiResponse response = createApiResponse();
++        response.setAction( "rebuild indexes started" );
++
++        final EntityManagerFactory.ProgressObserver po = new EntityManagerFactory.ProgressObserver() {
++
++            @Override
++            public void onProgress( final EntityRef entity ) {
++                logger.info( "Indexing entity {}:{}", entity.getType(), entity.getUuid() );
++            }
++
++
++            @Override
++            public long getWriteDelayTime() {
++                return delay;
++            }
++        };
++
++        final Thread rebuild = new Thread() {
++
++            @Override
++            public void run() {
++                try {
++                    emf.rebuildInternalIndexes( po );
++                }
++                catch ( Exception e ) {
++                    logger.error( "Unable to re-index internals", e );
++                }
++            }
++        };
++
++        rebuild.setName( String.format( "Index rebuild for app %s", appId ) );
++        rebuild.setDaemon( true );
++        rebuild.start();
++
++        response.setSuccess();
++
++        return new JSONWithPadding( response, callback );
 +    }
 +
 +    @RequireSystemAccess
      @POST
      @Path( RootResource.APPLICATION_ID_PATH )
      public JSONWithPadding addIndex(@Context UriInfo ui,

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/fe8f4044/stack/services/src/test/java/org/apache/usergrid/management/importer/ImportCollectionIT.java
----------------------------------------------------------------------
diff --cc stack/services/src/test/java/org/apache/usergrid/management/importer/ImportCollectionIT.java
index 7fcfc57,acd3077..d10b611
--- a/stack/services/src/test/java/org/apache/usergrid/management/importer/ImportCollectionIT.java
+++ b/stack/services/src/test/java/org/apache/usergrid/management/importer/ImportCollectionIT.java
@@@ -110,8 -110,9 +110,9 @@@ public class ImportCollectionIT 
          bucketPrefix = System.getProperty( "bucketName" );
  
          // start the scheduler after we're all set up
 -        JobSchedulerService jobScheduler = ConcurrentProcessSingleton
 -            .getInstance().getSpringResource().getBean( JobSchedulerService.class );
 +        JobSchedulerService jobScheduler = ConcurrentProcessSingleton.getInstance()
 +            .getSpringResource().getBean( JobSchedulerService.class );
+ 
          if ( jobScheduler.state() != Service.State.RUNNING ) {
              jobScheduler.startAsync();
              jobScheduler.awaitRunning();
@@@ -480,14 -499,14 +499,14 @@@
  
          logger.debug("\n\nImport into new app {}\n", em.getApplication().getName() );
  
--        ImportService importService = setup.getImportService();
++        final ImportService importService = setup.getImportService();
  
--        Import importEntity = importService.schedule(em.getApplication().getUuid(),
++        final Import importEntity = importService.schedule(em.getApplication().getUuid(),
              new HashMap<String, Object>() {{
 -                put( "path", organization.getName() + em.getApplication().getName() );
 -                put( "organizationId", organization.getUuid() );
 -                put( "applicationId", em.getApplication().getUuid() );
 -                put( "properties", new HashMap<String, Object>() {{
 +            put( "path", organization.getName() + em.getApplication().getName() );
 +            put( "organizationId", organization.getUuid() );
 +            put( "applicationId", em.getApplication().getUuid() );
 +            put( "properties", new HashMap<String, Object>() {{
                  put( "storage_provider", "s3" );
                  put( "storage_info", new HashMap<String, Object>() {{
                      put( "s3_access_id",


[14/50] [abbrv] incubator-usergrid git commit: Adding a CATALINA_BASE to the rest module so we can configure Tomcat as we need it configured for Maven Surefire testing with Arquillian.

Posted by sn...@apache.org.
Adding a CATALINA_BASE to the rest module so we can configure Tomcat as we need it configured for Maven Surefire testing with Arquillian.


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

Branch: refs/heads/two-dot-o
Commit: 13da256f1ac40cc12cce42a93811a697b4385cb0
Parents: a607a16
Author: Dave Johnson <dm...@apigee.com>
Authored: Mon Feb 23 10:48:11 2015 -0500
Committer: Dave Johnson <dm...@apigee.com>
Committed: Mon Feb 23 10:48:11 2015 -0500

----------------------------------------------------------------------
 stack/rest/catalina_base/conf/server.xml        |  144 +
 stack/rest/catalina_base/conf/tomcat-users.xml  |   36 +
 stack/rest/catalina_base/conf/web.xml           | 4614 ++++++++++++++++++
 .../lib/usergrid-deployment.properties          |  113 +
 stack/rest/catalina_base/webapps/ROOT           |    1 +
 .../webapps/host-manager/META-INF/context.xml   |   27 +
 .../webapps/host-manager/WEB-INF/jsp/401.jsp    |   70 +
 .../webapps/host-manager/WEB-INF/jsp/403.jsp    |   84 +
 .../webapps/host-manager/WEB-INF/jsp/404.jsp    |   61 +
 .../webapps/host-manager/WEB-INF/web.xml        |  144 +
 .../webapps/host-manager/images/add.gif         |  Bin 0 -> 1037 bytes
 .../webapps/host-manager/images/asf-logo.gif    |  Bin 0 -> 7279 bytes
 .../webapps/host-manager/images/code.gif        |  Bin 0 -> 394 bytes
 .../webapps/host-manager/images/design.gif      |  Bin 0 -> 608 bytes
 .../webapps/host-manager/images/docs.gif        |  Bin 0 -> 261 bytes
 .../webapps/host-manager/images/fix.gif         |  Bin 0 -> 345 bytes
 .../webapps/host-manager/images/tomcat.gif      |  Bin 0 -> 1934 bytes
 .../webapps/host-manager/images/update.gif      |  Bin 0 -> 627 bytes
 .../webapps/host-manager/images/void.gif        |  Bin 0 -> 43 bytes
 .../webapps/host-manager/index.jsp              |   18 +
 .../webapps/host-manager/manager.xml            |   26 +
 .../webapps/manager/META-INF/context.xml        |   27 +
 .../webapps/manager/WEB-INF/jsp/401.jsp         |   79 +
 .../webapps/manager/WEB-INF/jsp/403.jsp         |   94 +
 .../webapps/manager/WEB-INF/jsp/404.jsp         |   62 +
 .../manager/WEB-INF/jsp/sessionDetail.jsp       |  197 +
 .../manager/WEB-INF/jsp/sessionsList.jsp        |  172 +
 .../webapps/manager/WEB-INF/web.xml             |  209 +
 .../webapps/manager/images/add.gif              |  Bin 0 -> 1037 bytes
 .../webapps/manager/images/asf-logo.gif         |  Bin 0 -> 7279 bytes
 .../webapps/manager/images/code.gif             |  Bin 0 -> 394 bytes
 .../webapps/manager/images/design.gif           |  Bin 0 -> 608 bytes
 .../webapps/manager/images/docs.gif             |  Bin 0 -> 261 bytes
 .../webapps/manager/images/fix.gif              |  Bin 0 -> 345 bytes
 .../webapps/manager/images/tomcat.gif           |  Bin 0 -> 2066 bytes
 .../webapps/manager/images/update.gif           |  Bin 0 -> 627 bytes
 .../webapps/manager/images/void.gif             |  Bin 0 -> 43 bytes
 .../catalina_base/webapps/manager/index.jsp     |   18 +
 .../catalina_base/webapps/manager/status.xsd    |   84 +
 .../catalina_base/webapps/manager/xform.xsl     |  125 +
 stack/rest/catalina_base/webapps/portal         |    1 +
 .../manager/org/apache/jsp/index_jsp.java       |   83 +
 stack/rest/src/test/resources/arquillian.xml    |   10 +-
 43 files changed, 6490 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/13da256f/stack/rest/catalina_base/conf/server.xml
----------------------------------------------------------------------
diff --git a/stack/rest/catalina_base/conf/server.xml b/stack/rest/catalina_base/conf/server.xml
new file mode 100644
index 0000000..df638a3
--- /dev/null
+++ b/stack/rest/catalina_base/conf/server.xml
@@ -0,0 +1,144 @@
+<?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.
+-->
+<!-- Note:  A "Server" is not itself a "Container", so you may not
+     define subcomponents such as "Valves" at this level.
+     Documentation at /docs/config/server.html
+ -->
+<Server port="8005" shutdown="SHUTDOWN">
+  <Listener className="org.apache.catalina.startup.VersionLoggerListener" />
+  <!-- Security listener. Documentation at /docs/config/listeners.html
+  <Listener className="org.apache.catalina.security.SecurityListener" />
+  -->
+  <!--APR library loader. Documentation at /docs/apr.html -->
+  <Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />
+  <!--Initialize Jasper prior to webapps are loaded. Documentation at /docs/jasper-howto.html -->
+  <Listener className="org.apache.catalina.core.JasperListener" />
+  <!-- Prevent memory leaks due to use of particular java/javax APIs-->
+  <Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" />
+  <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />
+  <Listener className="org.apache.catalina.core.ThreadLocalLeakPreventionListener" />
+
+  <!-- Global JNDI resources
+       Documentation at /docs/jndi-resources-howto.html
+  -->
+  <GlobalNamingResources>
+    <!-- Editable user database that can also be used by
+         UserDatabaseRealm to authenticate users
+    -->
+    <Resource name="UserDatabase" auth="Container"
+              type="org.apache.catalina.UserDatabase"
+              description="User database that can be updated and saved"
+              factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
+              pathname="conf/tomcat-users.xml" />
+  </GlobalNamingResources>
+
+  <!-- A "Service" is a collection of one or more "Connectors" that share
+       a single "Container" Note:  A "Service" is not itself a "Container",
+       so you may not define subcomponents such as "Valves" at this level.
+       Documentation at /docs/config/service.html
+   -->
+  <Service name="Catalina">
+
+    <!--The connectors can use a shared executor, you can define one or more named thread pools-->
+    <!--
+    <Executor name="tomcatThreadPool" namePrefix="catalina-exec-"
+        maxThreads="150" minSpareThreads="4"/>
+    -->
+
+
+    <!-- A "Connector" represents an endpoint by which requests are received
+         and responses are returned. Documentation at :
+         Java HTTP Connector: /docs/config/http.html (blocking & non-blocking)
+         Java AJP  Connector: /docs/config/ajp.html
+         APR (HTTP/AJP) Connector: /docs/apr.html
+         Define a non-SSL HTTP/1.1 Connector on port 8080
+    -->
+    <Connector port="8080" protocol="HTTP/1.1"
+               connectionTimeout="20000"
+               redirectPort="8443" />
+    <!-- A "Connector" using the shared thread pool-->
+    <!--
+    <Connector executor="tomcatThreadPool"
+               port="8080" protocol="HTTP/1.1"
+               connectionTimeout="20000"
+               redirectPort="8443" />
+    -->
+    <!-- Define a SSL HTTP/1.1 Connector on port 8443
+         This connector uses the BIO implementation that requires the JSSE
+         style configuration. When using the APR/native implementation, the
+         OpenSSL style configuration is required as described in the APR/native
+         documentation -->
+    <!--
+    <Connector port="8443" protocol="org.apache.coyote.http11.Http11Protocol"
+               maxThreads="150" SSLEnabled="true" scheme="https" secure="true"
+               clientAuth="false" sslProtocol="TLS" />
+    -->
+
+    <!-- Define an AJP 1.3 Connector on port 8009 -->
+    <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />
+
+
+    <!-- An Engine represents the entry point (within Catalina) that processes
+         every request.  The Engine implementation for Tomcat stand alone
+         analyzes the HTTP headers included with the request, and passes them
+         on to the appropriate Host (virtual host).
+         Documentation at /docs/config/engine.html -->
+
+    <!-- You should set jvmRoute to support load-balancing via AJP ie :
+    <Engine name="Catalina" defaultHost="localhost" jvmRoute="jvm1">
+    -->
+    <Engine name="Catalina" defaultHost="localhost">
+
+      <!--For clustering, please take a look at documentation at:
+          /docs/cluster-howto.html  (simple how to)
+          /docs/config/cluster.html (reference documentation) -->
+      <!--
+      <Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster"/>
+      -->
+
+      <!-- Use the LockOutRealm to prevent attempts to guess user passwords
+           via a brute-force attack -->
+      <Realm className="org.apache.catalina.realm.LockOutRealm">
+        <!-- This Realm uses the UserDatabase configured in the global JNDI
+             resources under the key "UserDatabase".  Any edits
+             that are performed against this UserDatabase are immediately
+             available for use by the Realm.  -->
+        <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
+               resourceName="UserDatabase"/>
+      </Realm>
+
+      <Host name="localhost"  appBase="webapps"
+            unpackWARs="true" autoDeploy="true">
+
+        <!-- SingleSignOn valve, share authentication between web applications
+             Documentation at: /docs/config/valve.html -->
+        <!--
+        <Valve className="org.apache.catalina.authenticator.SingleSignOn" />
+        -->
+
+        <!-- Access log processes all example.
+             Documentation at: /docs/config/valve.html
+             Note: The pattern used is equivalent to using pattern="common" -->
+        <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
+               prefix="localhost_access_log." suffix=".txt"
+               pattern="%h %l %u %t &quot;%r&quot; %s %b" />
+
+      </Host>
+    </Engine>
+  </Service>
+</Server>

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/13da256f/stack/rest/catalina_base/conf/tomcat-users.xml
----------------------------------------------------------------------
diff --git a/stack/rest/catalina_base/conf/tomcat-users.xml b/stack/rest/catalina_base/conf/tomcat-users.xml
new file mode 100644
index 0000000..576ab39
--- /dev/null
+++ b/stack/rest/catalina_base/conf/tomcat-users.xml
@@ -0,0 +1,36 @@
+<?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.
+-->
+<!--
+  NOTE:  By default, no user is included in the "manager-gui" role required
+  to operate the "/manager/html" web application.  If you wish to use this app,
+  you must define such a user - the username and password are arbitrary.
+-->
+<!--
+  NOTE:  The sample user and role entries below are wrapped in a comment
+  and thus are ignored when reading this file. Do not forget to remove
+  <!.. ..> that surrounds them.
+-->
+<tomcat-users>
+    <role rolename="manager-gui"/>
+    <role rolename="manager-jmx"/>
+    <role rolename="manager-script"/>
+    <role rolename="manager-status"/>
+   <!-- this username and password is set into src/test/resources/arquillian.xml -->
+    <user username="usergrid" password="testpassword" roles="manager-script,manager-jmx,manager-gui,manager-status"/>
+</tomcat-users>
+


[35/50] [abbrv] incubator-usergrid git commit: Revert "Removed extraneous CF. Made the remaining code compile."

Posted by sn...@apache.org.
Revert "Removed extraneous CF. Made the remaining code compile."

This reverts commit ded674359eccf08509aa4933892018041a1eeda0.


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

Branch: refs/heads/two-dot-o
Commit: 35bae2687bb7edd7779395d5aa4c2ede61292def
Parents: ded6743
Author: grey <gr...@apigee.com>
Authored: Wed Feb 25 07:58:05 2015 -0800
Committer: grey <gr...@apigee.com>
Committed: Wed Feb 25 07:58:05 2015 -0800

----------------------------------------------------------------------
 .../usergrid/corepersistence/CpSetup.java       |  45 +++---
 .../persistence/cassandra/CassandraService.java |  31 ++--
 .../cassandra/EntityManagerFactoryImpl.java     | 147 ++++++++++++++++---
 .../persistence/cassandra/SetupImpl.java        |  32 +++-
 .../cassandra/EntityManagerFactoryImplIT.java   |   5 +
 5 files changed, 199 insertions(+), 61 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/35bae268/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpSetup.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpSetup.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpSetup.java
index 53123bc..c71c172 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpSetup.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpSetup.java
@@ -39,14 +39,14 @@ import me.prettyprint.hector.api.ddl.ComparatorType;
 
 import static me.prettyprint.hector.api.factory.HFactory.createColumnFamilyDefinition;
 import static org.apache.usergrid.persistence.cassandra.CassandraPersistenceUtils.getCfDefs;
-//import static org.apache.usergrid.persistence.cassandra.CassandraService.APPLICATIONS_CF;
+import static org.apache.usergrid.persistence.cassandra.CassandraService.APPLICATIONS_CF;
 import static org.apache.usergrid.persistence.cassandra.CassandraService.DEFAULT_APPLICATION;
 import static org.apache.usergrid.persistence.cassandra.CassandraService.DEFAULT_ORGANIZATION;
 import static org.apache.usergrid.persistence.cassandra.CassandraService.MANAGEMENT_APPLICATION;
 import static org.apache.usergrid.persistence.cassandra.CassandraService.PRINCIPAL_TOKEN_CF;
-//import static org.apache.usergrid.persistence.cassandra.CassandraService.PROPERTIES_CF;
+import static org.apache.usergrid.persistence.cassandra.CassandraService.PROPERTIES_CF;
 import static org.apache.usergrid.persistence.cassandra.CassandraService.TOKENS_CF;
-//import static org.apache.usergrid.persistence.cassandra.CassandraService.USE_VIRTUAL_KEYSPACES;
+import static org.apache.usergrid.persistence.cassandra.CassandraService.USE_VIRTUAL_KEYSPACES;
 import static org.apache.usergrid.persistence.cassandra.CassandraService.getApplicationKeyspace;
 import static org.apache.usergrid.persistence.cassandra.CassandraService.keyspaceForApplication;
 
@@ -145,11 +145,11 @@ public class CpSetup implements Setup {
 
         migrate();
 
-//        cass.createColumnFamily( getApplicationKeyspace(),
-//            createColumnFamilyDefinition( getApplicationKeyspace(), APPLICATIONS_CF, ComparatorType.BYTESTYPE ) );
-//
-//        cass.createColumnFamily( getApplicationKeyspace(),
-//            createColumnFamilyDefinition( getApplicationKeyspace(), PROPERTIES_CF, ComparatorType.BYTESTYPE ) );
+        cass.createColumnFamily( getApplicationKeyspace(),
+            createColumnFamilyDefinition( getApplicationKeyspace(), APPLICATIONS_CF, ComparatorType.BYTESTYPE ) );
+
+        cass.createColumnFamily( getApplicationKeyspace(),
+            createColumnFamilyDefinition( getApplicationKeyspace(), PROPERTIES_CF, ComparatorType.BYTESTYPE ) );
 
         cass.createColumnFamily( getApplicationKeyspace(),
             createColumnFamilyDefinition( getApplicationKeyspace(), TOKENS_CF, ComparatorType.BYTESTYPE ) );
@@ -176,18 +176,19 @@ public class CpSetup implements Setup {
 
         // Need this legacy stuff for queues
 
+        if ( !USE_VIRTUAL_KEYSPACES ) {
+
+            String app_keyspace = keyspaceForApplication( applicationId );
 
-//            String app_keyspace = keyspaceForApplication( applicationId );
+            logger.info( "Creating application keyspace " + app_keyspace + " for " + applicationName + " application" );
 
-//            logger.info( "Creating application keyspace " + app_keyspace + " for " + applicationName + " application" );
-//
-//            cass.createColumnFamily( app_keyspace,
-//                createColumnFamilyDefinition( getApplicationKeyspace(), APPLICATIONS_CF, ComparatorType.BYTESTYPE ) );
-//
-//            cass.createColumnFamilies( app_keyspace, getCfDefs( ApplicationCF.class, app_keyspace ) );
-//
-//            cass.createColumnFamilies( app_keyspace, getCfDefs( QueuesCF.class, app_keyspace ) );
+            cass.createColumnFamily( app_keyspace,
+                createColumnFamilyDefinition( getApplicationKeyspace(), APPLICATIONS_CF, ComparatorType.BYTESTYPE ) );
 
+            cass.createColumnFamilies( app_keyspace, getCfDefs( ApplicationCF.class, app_keyspace ) );
+
+            cass.createColumnFamilies( app_keyspace, getCfDefs( QueuesCF.class, app_keyspace ) );
+        }
     }
 
 
@@ -198,20 +199,20 @@ public class CpSetup implements Setup {
 
         // Need this legacy stuff for queues
 
-      //  if ( USE_VIRTUAL_KEYSPACES ) {
+        if ( USE_VIRTUAL_KEYSPACES ) {
 
             logger.info( "Creating static application keyspace " + getApplicationKeyspace() );
 
-//            cass.createColumnFamily( getApplicationKeyspace(),
-//                createColumnFamilyDefinition( getApplicationKeyspace(), APPLICATIONS_CF,
-//                    ComparatorType.BYTESTYPE ) );
+            cass.createColumnFamily( getApplicationKeyspace(),
+                createColumnFamilyDefinition( getApplicationKeyspace(), APPLICATIONS_CF,
+                    ComparatorType.BYTESTYPE ) );
 
             cass.createColumnFamilies( getApplicationKeyspace(),
                 getCfDefs( ApplicationCF.class, getApplicationKeyspace() ) );
 
             cass.createColumnFamilies( getApplicationKeyspace(),
                 getCfDefs( QueuesCF.class, getApplicationKeyspace() ) );
-       // }
+        }
     }
 
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/35bae268/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/CassandraService.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/CassandraService.java b/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/CassandraService.java
index 32174ff..2c74e77 100644
--- a/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/CassandraService.java
+++ b/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/CassandraService.java
@@ -97,10 +97,10 @@ public class CassandraService {
    // public static String SYSTEM_KEYSPACE = "Usergrid";
 
     public static String applicationKeyspace;
-    //public static final boolean USE_VIRTUAL_KEYSPACES = true;
+    public static final boolean USE_VIRTUAL_KEYSPACES = true;
 
-    //public static final String APPLICATIONS_CF = "Applications";
-    //public static final String PROPERTIES_CF = "Properties";
+    public static final String APPLICATIONS_CF = "Applications";
+    public static final String PROPERTIES_CF = "Properties";
     public static final String TOKENS_CF = "Tokens";
     public static final String PRINCIPAL_TOKEN_CF = "PrincipalTokens";
 
@@ -238,26 +238,35 @@ public class CassandraService {
 
     /** @return keyspace for application UUID */
     public static String keyspaceForApplication( UUID applicationId ) {
-        return getApplicationKeyspace();
-
+        if ( USE_VIRTUAL_KEYSPACES ) {
+            return getApplicationKeyspace();
+        }
+        else {
+            return "Application_" + applicationId.toString().replace( '-', '_' );
+        }
     }
 
 
     public static UUID prefixForApplication( UUID applicationId ) {
+        if ( USE_VIRTUAL_KEYSPACES ) {
             return applicationId;
+        }
+        else {
+            return null;
+        }
     }
 
 
     public Keyspace getKeyspace( String keyspace, UUID prefix ) {
         Keyspace ko = null;
-//        if ( USE_VIRTUAL_KEYSPACES && ( prefix != null ) ) {
+        if ( USE_VIRTUAL_KEYSPACES && ( prefix != null ) ) {
             ko = createVirtualKeyspace( keyspace, prefix, ue, cluster, consistencyLevelPolicy,
                     ON_FAIL_TRY_ALL_AVAILABLE, accessMap );
-//        }
-//        else {
-//            ko = HFactory.createKeyspace( keyspace, cluster, consistencyLevelPolicy, ON_FAIL_TRY_ALL_AVAILABLE,
-//                    accessMap );
-//        }
+        }
+        else {
+            ko = HFactory.createKeyspace( keyspace, cluster, consistencyLevelPolicy, ON_FAIL_TRY_ALL_AVAILABLE,
+                    accessMap );
+        }
         return ko;
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/35bae268/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/EntityManagerFactoryImpl.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/EntityManagerFactoryImpl.java b/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/EntityManagerFactoryImpl.java
index f4a151f..9a90e59 100644
--- a/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/EntityManagerFactoryImpl.java
+++ b/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/EntityManagerFactoryImpl.java
@@ -62,8 +62,8 @@ import static org.apache.usergrid.persistence.Schema.TYPE_APPLICATION;
 import static org.apache.usergrid.persistence.cassandra.CassandraPersistenceUtils.addInsertToMutator;
 import static org.apache.usergrid.persistence.cassandra.CassandraPersistenceUtils.asMap;
 import static org.apache.usergrid.persistence.cassandra.CassandraPersistenceUtils.batchExecute;
-//import static org.apache.usergrid.persistence.cassandra.CassandraService.APPLICATIONS_CF;
-//import static org.apache.usergrid.persistence.cassandra.CassandraService.PROPERTIES_CF;
+import static org.apache.usergrid.persistence.cassandra.CassandraService.APPLICATIONS_CF;
+import static org.apache.usergrid.persistence.cassandra.CassandraService.PROPERTIES_CF;
 import static org.apache.usergrid.persistence.cassandra.CassandraService.RETRY_COUNT;
 import static org.apache.usergrid.utils.ConversionUtils.uuid;
 import static org.apache.usergrid.persistence.cassandra.Serializers.*;
@@ -189,8 +189,22 @@ public class EntityManagerFactoryImpl implements EntityManagerFactory, Applicati
     public UUID createApplication( String organizationName, String name, Map<String, Object> properties )
             throws Exception {
 
-        throw new UnsupportedOperationException( "We no longer support the 1.0 entity manager anymore" );
+        String appName = buildAppName( organizationName, name );
 
+        HColumn<String, ByteBuffer> column =
+                cass.getColumn( cass.getUsergridApplicationKeyspace(), APPLICATIONS_CF, appName, PROPERTY_UUID );
+        if ( column != null ) {
+            throw new ApplicationAlreadyExistsException( name );
+            // UUID uuid = uuid(column.getValue());
+            // return uuid;
+        }
+
+        UUID applicationId = UUIDUtils.newTimeUUID();
+        logger.info( "New application id " + applicationId.toString() );
+
+        initializeApplication( organizationName, applicationId, appName, properties );
+
+        return applicationId;
     }
 
 
@@ -206,20 +220,69 @@ public class EntityManagerFactoryImpl implements EntityManagerFactory, Applicati
     }
 
 
+    public UUID initializeApplication( String organizationName, UUID applicationId, String name,
+                                       Map<String, Object> properties ) throws Exception {
+
+        String appName = buildAppName( organizationName, name );
+        // check for pre-existing
+        if ( lookupApplication( appName ) != null ) {
+            throw new ApplicationAlreadyExistsException( appName );
+        }
+        if ( properties == null ) {
+            properties = new TreeMap<String, Object>( CASE_INSENSITIVE_ORDER );
+        }
+
+        properties.put( PROPERTY_NAME, appName );
+
+        getSetup().setupApplicationKeyspace( applicationId, appName );
+
+        Keyspace ko = cass.getUsergridApplicationKeyspace();
+        Mutator<ByteBuffer> m = CountingMutator.createFlushingMutator( ko, be );
+
+        long timestamp = cass.createTimestamp();
+
+        addInsertToMutator( m, APPLICATIONS_CF, appName, PROPERTY_UUID, applicationId, timestamp );
+        addInsertToMutator( m, APPLICATIONS_CF, appName, PROPERTY_NAME, appName, timestamp );
+
+        batchExecute( m, RETRY_COUNT );
+
+        EntityManager em = getEntityManager( applicationId );
+        em.create( TYPE_APPLICATION, APPLICATION_ENTITY_CLASS, properties );
+
+        em.resetRoles();
+
+        return applicationId;
+    }
+
+
     @Override
     public UUID importApplication( String organizationName, UUID applicationId, String name,
                                    Map<String, Object> properties ) throws Exception {
 
-        throw new UnsupportedOperationException( "We no longer support the 1.0 entity manager anymore" );
+        name = buildAppName( organizationName, name );
 
+        HColumn<String, ByteBuffer> column =
+                cass.getColumn( cass.getUsergridApplicationKeyspace(), APPLICATIONS_CF, name, PROPERTY_UUID );
+        if ( column != null ) {
+            throw new ApplicationAlreadyExistsException( name );
+            // UUID uuid = uuid(column.getValue());
+            // return uuid;
+        }
+
+        return initializeApplication( organizationName, applicationId, name, properties );
     }
 
 
     @Override
     @Metered(group = "core", name = "EntityManagerFactory_lookupApplication_byName")
     public UUID lookupApplication( String name ) throws Exception {
-        throw new UnsupportedOperationException( "We no longer support the 1.0 entity manager anymore" );
-
+        name = name.toLowerCase();
+        HColumn<String, ByteBuffer> column =
+                cass.getColumn( cass.getUsergridApplicationKeyspace(), APPLICATIONS_CF, name, PROPERTY_UUID );
+        if ( column != null ) {
+            return uuid( column.getValue() );
+        }
+        return null;
     }
 
 
@@ -234,48 +297,86 @@ public class EntityManagerFactoryImpl implements EntityManagerFactory, Applicati
      */
     @Metered(group = "core", name = "EntityManagerFactory_getApplication")
     public Application getApplication( String name ) throws Exception {
-        throw new UnsupportedOperationException( "We no longer support the 1.0 entity manager anymore" );
+        name = name.toLowerCase();
+        HColumn<String, ByteBuffer> column =
+                cass.getColumn( cass.getUsergridApplicationKeyspace(), APPLICATIONS_CF, name, PROPERTY_UUID );
+        if ( column == null ) {
+            return null;
+        }
 
+        UUID applicationId = uuid( column.getValue() );
+
+        EntityManager em = getEntityManager( applicationId );
+        return ( ( EntityManagerImpl ) em ).getEntity( applicationId, Application.class );
     }
 
 
     @Override
     public Map<String, UUID> getApplications() throws Exception {
-        throw new UnsupportedOperationException( "We no longer support the 1.0 entity manager anymore" );
-
+        Map<String, UUID> applications = new TreeMap<String, UUID>( CASE_INSENSITIVE_ORDER );
+        Keyspace ko = cass.getUsergridApplicationKeyspace();
+        RangeSlicesQuery<String, String, UUID> q = createRangeSlicesQuery( ko, se, se, ue );
+        q.setKeys( "", "\uFFFF" );
+        q.setColumnFamily( APPLICATIONS_CF );
+        q.setColumnNames( PROPERTY_UUID );
+        q.setRowCount( 10000 );
+        QueryResult<OrderedRows<String, String, UUID>> r = q.execute();
+        Rows<String, String, UUID> rows = r.get();
+        for ( Row<String, String, UUID> row : rows ) {
+            ColumnSlice<String, UUID> slice = row.getColumnSlice();
+            HColumn<String, UUID> column = slice.getColumnByName( PROPERTY_UUID );
+            applications.put( row.getKey(), column.getValue() );
+        }
+        return applications;
     }
 
    @Override
     public boolean setServiceProperty( String name, String value ) {
-       throw new UnsupportedOperationException( "We no longer support the 1.0 entity manager anymore" );
-
+        try {
+            cass.setColumn( cass.getUsergridApplicationKeyspace(), PROPERTIES_CF, PROPERTIES_CF, name, value );
+            return true;
+        }
+        catch ( Exception e ) {
+            logger.error( "Unable to set property " + name + ": " + e.getMessage() );
+        }
+        return false;
     }
 
 
     @Override
     public boolean deleteServiceProperty( String name ) {
-        throw new UnsupportedOperationException( "We no longer support the 1.0 entity manager anymore" );
-
-    }
-
-
-    @Override
-    public UUID initializeApplication( final String orgName, final UUID appId, final String appName,
-                                       final Map<String, Object> props ) throws Exception {
-        return null;
+        try {
+            cass.deleteColumn( cass.getUsergridApplicationKeyspace(), PROPERTIES_CF, PROPERTIES_CF, name );
+            return true;
+        }
+        catch ( Exception e ) {
+            logger.error( "Unable to delete property " + name + ": " + e.getMessage() );
+        }
+        return false;
     }
 
 
     @Override
     public boolean updateServiceProperties( Map<String, String> properties ) {
-        throw new UnsupportedOperationException( "We no longer support the 1.0 entity manager anymore" );
-
+        try {
+            cass.setColumns( cass.getUsergridApplicationKeyspace(), PROPERTIES_CF, PROPERTIES_CF.getBytes(), properties );
+            return true;
+        }
+        catch ( Exception e ) {
+            logger.error( "Unable to update properties: " + e.getMessage() );
+        }
+        return false;
     }
 
 
     @Override
     public Map<String, String> getServiceProperties() {
-
+        try {
+            return asMap( cass.getAllColumns( cass.getUsergridApplicationKeyspace(), PROPERTIES_CF, PROPERTIES_CF, se, se ) );
+        }
+        catch ( Exception e ) {
+            logger.error( "Unable to load properties: " + e.getMessage() );
+        }
         return null;
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/35bae268/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/SetupImpl.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/SetupImpl.java b/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/SetupImpl.java
index 62b85de..775f43b 100644
--- a/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/SetupImpl.java
+++ b/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/SetupImpl.java
@@ -23,11 +23,14 @@ import static me.prettyprint.hector.api.factory.HFactory.createColumnFamilyDefin
 import org.apache.usergrid.mq.cassandra.QueuesCF;
 import org.apache.usergrid.persistence.EntityManagerFactory;
 import static org.apache.usergrid.persistence.cassandra.CassandraPersistenceUtils.getCfDefs;
+import static org.apache.usergrid.persistence.cassandra.CassandraService.APPLICATIONS_CF;
 import static org.apache.usergrid.persistence.cassandra.CassandraService.DEFAULT_APPLICATION;
 import static org.apache.usergrid.persistence.cassandra.CassandraService.DEFAULT_ORGANIZATION;
 import static org.apache.usergrid.persistence.cassandra.CassandraService.MANAGEMENT_APPLICATION;
 import static org.apache.usergrid.persistence.cassandra.CassandraService.PRINCIPAL_TOKEN_CF;
+import static org.apache.usergrid.persistence.cassandra.CassandraService.PROPERTIES_CF;
 import static org.apache.usergrid.persistence.cassandra.CassandraService.TOKENS_CF;
+import static org.apache.usergrid.persistence.cassandra.CassandraService.USE_VIRTUAL_KEYSPACES;
 import static org.apache.usergrid.persistence.cassandra.CassandraService.getApplicationKeyspace;
 import static org.apache.usergrid.persistence.cassandra.CassandraService.keyspaceForApplication;
 import org.apache.usergrid.persistence.entities.Application;
@@ -77,6 +80,12 @@ public class SetupImpl implements Setup {
         logger.info( "Initialize system keyspace" );
 
         cass.createColumnFamily( getApplicationKeyspace(), createColumnFamilyDefinition(
+                getApplicationKeyspace(), APPLICATIONS_CF, ComparatorType.BYTESTYPE ) );
+
+        cass.createColumnFamily( getApplicationKeyspace(), createColumnFamilyDefinition(
+                getApplicationKeyspace(), PROPERTIES_CF, ComparatorType.BYTESTYPE ) );
+
+        cass.createColumnFamily( getApplicationKeyspace(), createColumnFamilyDefinition(
                 getApplicationKeyspace(), TOKENS_CF, ComparatorType.BYTESTYPE ) );
 
         cass.createColumnFamily( getApplicationKeyspace(), createColumnFamilyDefinition(
@@ -98,30 +107,36 @@ public class SetupImpl implements Setup {
     public void setupApplicationKeyspace(
             final UUID applicationId, String applicationName ) throws Exception {
 
+        if ( !USE_VIRTUAL_KEYSPACES ) {
             String app_keyspace = keyspaceForApplication( applicationId );
 
             logger.info( "Creating application keyspace " + app_keyspace + " for "
                     + applicationName + " application" );
 
-
+            cass.createColumnFamily( app_keyspace, createColumnFamilyDefinition(
+                    getApplicationKeyspace(), APPLICATIONS_CF, ComparatorType.BYTESTYPE ) );
 
             cass.createColumnFamilies( app_keyspace, getCfDefs( ApplicationCF.class, app_keyspace));
             cass.createColumnFamilies( app_keyspace, getCfDefs( QueuesCF.class, app_keyspace ) );
-
+        }
     }
 
 
     public void setupStaticKeyspace() throws Exception {
 
-
+        if ( USE_VIRTUAL_KEYSPACES ) {
 
             logger.info( "Creating static application keyspace " + getApplicationKeyspace() );
 
+            cass.createColumnFamily( getApplicationKeyspace(),
+                    createColumnFamilyDefinition( getApplicationKeyspace(), APPLICATIONS_CF,
+                            ComparatorType.BYTESTYPE ) );
+
             cass.createColumnFamilies( getApplicationKeyspace(),
                     getCfDefs( ApplicationCF.class, getApplicationKeyspace() ) );
             cass.createColumnFamilies( getApplicationKeyspace(),
                     getCfDefs( QueuesCF.class, getApplicationKeyspace() ) );
-
+        }
     }
 
 
@@ -131,7 +146,14 @@ public class SetupImpl implements Setup {
 
 
     public static void logCFPermissions() {
-
+        System.out.println( getApplicationKeyspace() + "." + APPLICATIONS_CF + ".<rw>=usergrid" );
+        System.out.println( getApplicationKeyspace() + "." + PROPERTIES_CF + ".<rw>=usergrid" );
+        for ( CFEnum cf : ApplicationCF.values() ) {
+            System.out.println( getApplicationKeyspace() + "." + cf + ".<rw>=usergrid" );
+        }
+        for ( CFEnum cf : QueuesCF.values() ) {
+            System.out.println( getApplicationKeyspace() + "." + cf + ".<rw>=usergrid" );
+        }
     }
 
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/35bae268/stack/core/src/test/java/org/apache/usergrid/persistence/cassandra/EntityManagerFactoryImplIT.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/cassandra/EntityManagerFactoryImplIT.java b/stack/core/src/test/java/org/apache/usergrid/persistence/cassandra/EntityManagerFactoryImplIT.java
index 42f2af1..850ac6b 100644
--- a/stack/core/src/test/java/org/apache/usergrid/persistence/cassandra/EntityManagerFactoryImplIT.java
+++ b/stack/core/src/test/java/org/apache/usergrid/persistence/cassandra/EntityManagerFactoryImplIT.java
@@ -50,6 +50,8 @@ import static org.junit.Assert.assertTrue;
 
 public class EntityManagerFactoryImplIT extends AbstractCoreIT {
 
+    @SuppressWarnings("PointlessBooleanExpression")
+    public static final boolean USE_DEFAULT_DOMAIN = !CassandraService.USE_VIRTUAL_KEYSPACES;
 
     private static final Logger logger = LoggerFactory.getLogger( EntityManagerFactoryImplIT.class );
 
@@ -78,6 +80,9 @@ public class EntityManagerFactoryImplIT extends AbstractCoreIT {
 
 
     public UUID createApplication( String organizationName, String applicationName ) throws Exception {
+        if ( USE_DEFAULT_DOMAIN ) {
+            return emf.getDefaultAppId();
+        }
         return emf.createApplication( organizationName, applicationName );
     }
 


[05/50] [abbrv] incubator-usergrid git commit: Fixes cache bug and null emission issue

Posted by sn...@apache.org.
Fixes cache bug and null emission issue


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

Branch: refs/heads/two-dot-o
Commit: 139984935e8a9dce26025f390974ba7b574dfe36
Parents: d2a0ff2
Author: Todd Nine <tn...@apigee.com>
Authored: Thu Feb 19 23:29:37 2015 -0700
Committer: Todd Nine <tn...@apigee.com>
Committed: Thu Feb 19 23:29:37 2015 -0700

----------------------------------------------------------------------
 .../cache/CachedEntityCollectionManager.java           |  2 +-
 .../collection/impl/EntityCollectionManagerImpl.java   | 13 ++++++++-----
 .../java/org/apache/usergrid/rest/IndexResource.java   |  2 +-
 3 files changed, 10 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/13998493/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/cache/CachedEntityCollectionManager.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/cache/CachedEntityCollectionManager.java b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/cache/CachedEntityCollectionManager.java
index 5430759..186aafa 100644
--- a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/cache/CachedEntityCollectionManager.java
+++ b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/cache/CachedEntityCollectionManager.java
@@ -100,7 +100,7 @@ public class CachedEntityCollectionManager implements EntityCollectionManager {
             return Observable.just( entity );
         }
 
-        return Observable.empty();
+        return targetEntityCollectionManager.load( entityId ).doOnNext( cacheAdd );
 
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/13998493/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/impl/EntityCollectionManagerImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/impl/EntityCollectionManagerImpl.java b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/impl/EntityCollectionManagerImpl.java
index 8c754c1..7c467c6 100644
--- a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/impl/EntityCollectionManagerImpl.java
+++ b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/impl/EntityCollectionManagerImpl.java
@@ -230,21 +230,24 @@ public class EntityCollectionManagerImpl implements EntityCollectionManager {
         Preconditions.checkNotNull( entityId.getUuid(), "Entity id uuid required in load stage" );
         Preconditions.checkNotNull( entityId.getType(), "Entity id type required in load stage" );
 
-        return load( Collections.singleton( entityId ) ).map( new Func1<EntitySet, Entity>() {
+        return load( Collections.singleton( entityId ) ).flatMap( new Func1<EntitySet, Observable<Entity>>() {
             @Override
-            public Entity call( final EntitySet entitySet ) {
+            public Observable<Entity> call( final EntitySet entitySet ) {
                 final MvccEntity entity = entitySet.getEntity( entityId );
 
-                if ( entity == null ) {
-                    return null;
+                if ( entity == null || !entity.getEntity().isPresent() ) {
+                    return Observable.empty();
                 }
 
-                return entity.getEntity().orNull();
+                return Observable.from( entity.getEntity().get() );
             }
         } );
     }
 
 
+
+
+
     @Override
     public Observable<EntitySet> load( final Collection<Id> entityIds ) {
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/13998493/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 acce2d8..7b391a1 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
@@ -142,7 +142,7 @@ public class IndexResource extends AbstractContextResource {
                     emf.rebuildApplicationIndexes( appId, po );
                 }
                 catch ( Exception e ) {
-                    logger.error( "Unable to re-index application" );
+                    logger.error( "Unable to re-index application", e );
                 }
             }
         };


[48/50] [abbrv] incubator-usergrid git commit: Adding some feedback so you can tell that test is running and not just hanging.

Posted by sn...@apache.org.
Adding some feedback so you can tell that test is running and not just hanging.


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

Branch: refs/heads/two-dot-o
Commit: 0b63317f26cf5e694f5db071df1a7ee0f0b9e976
Parents: 04ff584
Author: Dave Johnson <sn...@apache.org>
Authored: Thu Feb 26 10:41:30 2015 -0500
Committer: Dave Johnson <sn...@apache.org>
Committed: Thu Feb 26 10:41:30 2015 -0500

----------------------------------------------------------------------
 .../apache/usergrid/utils/UUIDUtilsTest.java    | 76 +++++++++++---------
 1 file changed, 44 insertions(+), 32 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/0b63317f/stack/core/src/test/java/org/apache/usergrid/utils/UUIDUtilsTest.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/utils/UUIDUtilsTest.java b/stack/core/src/test/java/org/apache/usergrid/utils/UUIDUtilsTest.java
index 71777ae..e59dac8 100644
--- a/stack/core/src/test/java/org/apache/usergrid/utils/UUIDUtilsTest.java
+++ b/stack/core/src/test/java/org/apache/usergrid/utils/UUIDUtilsTest.java
@@ -43,39 +43,39 @@ import static org.junit.Assert.assertTrue;
 
 public class UUIDUtilsTest {
 
-    private static final Logger LOG = LoggerFactory.getLogger( UUIDUtilsTest.class );
+    private static final Logger logger = LoggerFactory.getLogger( UUIDUtilsTest.class );
 
 
     @Test
     public void testUUIDUtils() {
         UUID uuid = UUIDUtils.newTimeUUID();
-        LOG.info( "" + uuid );
-        LOG.info( "" + uuid.timestamp() );
-        LOG.info( "" + UUIDUtils.getTimestampInMillis( uuid ) );
-
-        LOG.info( "" + UUIDUtils.getTimestampInMillis( UUIDUtils.newTimeUUID() ) );
-        LOG.info( "" + System.currentTimeMillis() );
-
-        LOG.info( "" + UUIDUtils.getTimestampInMicros( UUIDUtils.newTimeUUID() ) );
-        LOG.info( "" + ( System.currentTimeMillis() * 1000 ) );
-
-        LOG.info( "" + UUIDUtils.MIN_TIME_UUID );
-        LOG.info( "" + UUIDUtils.MIN_TIME_UUID.variant() );
-        LOG.info( "" + UUIDUtils.MIN_TIME_UUID.version() );
-        LOG.info( "" + UUIDUtils.MIN_TIME_UUID.clockSequence() );
-        LOG.info( "" + UUIDUtils.MIN_TIME_UUID.timestamp() );
-
-        LOG.info( "" + UUIDUtils.MAX_TIME_UUID );
-        LOG.info( "" + UUIDUtils.MAX_TIME_UUID.variant() );
-        LOG.info( "" + UUIDUtils.MAX_TIME_UUID.version() );
-        LOG.info( "" + UUIDUtils.MAX_TIME_UUID.clockSequence() );
-        LOG.info( "" + UUIDUtils.MAX_TIME_UUID.timestamp() );
+        logger.info("" + uuid);
+        logger.info("" + uuid.timestamp());
+        logger.info("" + UUIDUtils.getTimestampInMillis(uuid));
+
+        logger.info("" + UUIDUtils.getTimestampInMillis(UUIDUtils.newTimeUUID()));
+        logger.info("" + System.currentTimeMillis());
+
+        logger.info("" + UUIDUtils.getTimestampInMicros(UUIDUtils.newTimeUUID()));
+        logger.info("" + (System.currentTimeMillis() * 1000));
+
+        logger.info("" + UUIDUtils.MIN_TIME_UUID);
+        logger.info("" + UUIDUtils.MIN_TIME_UUID.variant());
+        logger.info("" + UUIDUtils.MIN_TIME_UUID.version());
+        logger.info("" + UUIDUtils.MIN_TIME_UUID.clockSequence());
+        logger.info("" + UUIDUtils.MIN_TIME_UUID.timestamp());
+
+        logger.info("" + UUIDUtils.MAX_TIME_UUID);
+        logger.info("" + UUIDUtils.MAX_TIME_UUID.variant());
+        logger.info("" + UUIDUtils.MAX_TIME_UUID.version());
+        logger.info("" + UUIDUtils.MAX_TIME_UUID.clockSequence());
+        logger.info("" + UUIDUtils.MAX_TIME_UUID.timestamp());
     }
 
 
     @Test
     public void testAppProvidedTimestamp() {
-        LOG.info( "UUIDUtilsTest.testAppProvidedTimestamp" );
+        logger.info("UUIDUtilsTest.testAppProvidedTimestamp");
         long ts = System.currentTimeMillis();
         System.out.println( ts );
 
@@ -83,7 +83,7 @@ public class UUIDUtilsTest {
 
         int count = 1000000;
 
-        LOG.info( "Generating " + count + " UUIDs..." );
+        logger.info("Generating " + count + " UUIDs...");
         for ( int i = 0; i < count; i++ ) {
             UUID uuid = newTimeUUID( ts );
 
@@ -91,14 +91,18 @@ public class UUIDUtilsTest {
             uuids.add( uuid );
 
             assertEquals( "Incorrect UUID timestamp value", ts, getTimestampInMillis( uuid ) );
+
+            if ( i % 1000 == 0 ) {
+                logger.info("testAppProvidedTimestamp processed " + i);
+            }
         }
-        LOG.info( "UUIDs checked" );
+        logger.info("UUIDs checked");
     }
 
 
     @Test
     public void testAppProvidedTimestampOrdering() {
-        LOG.info( "UUIDUtilsTest.testAppProvidedTimestamp" );
+        logger.info("UUIDUtilsTest.testAppProvidedTimestamp");
         long ts = System.currentTimeMillis();
         System.out.println( ts );
 
@@ -119,13 +123,17 @@ public class UUIDUtilsTest {
 
         List<UUID> uuids = new ArrayList<UUID>( count );
 
-        LOG.info( "Generating " + count + " UUIDs..." );
+        logger.info("Generating " + count + " UUIDs...");
         for ( int i = 0; i < count; i++ ) {
             UUID uuid = newTimeUUID( ts, i );
 
             uuids.add( uuid );
 
             assertEquals( "Incorrect UUID timestamp value", ts, getTimestampInMillis( uuid ) );
+
+            if ( i % 1000 == 0 ) {
+                logger.info("timeUUIDOrdering processed " + i);
+            }
         }
 
         for ( int i = 0; i < count - 1; i++ ) {
@@ -174,7 +182,7 @@ public class UUIDUtilsTest {
 
         Set created = buildTsMicros( count );
 
-        LOG.info( "execution took {}", System.currentTimeMillis() - startTime );
+        logger.info("execution took {}", System.currentTimeMillis() - startTime);
         assertEquals( count, created.size() );
         assertTrue( created.size() > 0 );
     }
@@ -186,11 +194,11 @@ public class UUIDUtilsTest {
         List<Future> jobs = executeFrob();
 
         for ( Future f : jobs ) {
-            LOG.info( "waiting on job..." );
+            logger.info("waiting on job...");
             f.get();
         }
 
-        LOG.info( "execution took {}", System.currentTimeMillis() - startTime );
+        logger.info("execution took {}", System.currentTimeMillis() - startTime);
     }
 
 
@@ -202,7 +210,7 @@ public class UUIDUtilsTest {
             jobs.add( exec.submit( new Callable<Object>() {
                 @Override
                 public Object call() throws Exception {
-                    LOG.info( "call invoked" );
+                    logger.info("call invoked");
 
                     int count = 1000 * 100;
                     Set created = buildTsMicros( count );
@@ -210,7 +218,7 @@ public class UUIDUtilsTest {
                     assertEquals( count, created.size() );
                     assertTrue( created.size() > 0 );
 
-                    LOG.info( "run complete" );
+                    logger.info("run complete");
                     return null;
                 }
             } ) );
@@ -352,6 +360,10 @@ public class UUIDUtilsTest {
 
             assertEquals( -1, current.compareTo( previous ) );
 
+            if ( i % 1000 == 0 ) {
+                logger.info("testDecrement processed " + i);
+            }
+
             previous = current;
         }
     }


[50/50] [abbrv] incubator-usergrid git commit: Ignoring intermittently failing test

Posted by sn...@apache.org.
Ignoring intermittently failing test


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

Branch: refs/heads/two-dot-o
Commit: 567db37ca03daa621dfde0c29f803b9384da5e7e
Parents: 4eca431
Author: Dave Johnson <sn...@apache.org>
Authored: Thu Feb 26 11:26:50 2015 -0500
Committer: Dave Johnson <sn...@apache.org>
Committed: Thu Feb 26 11:26:50 2015 -0500

----------------------------------------------------------------------
 .../java/org/apache/usergrid/count/BatchCountParallelismTest.java  | 2 ++
 1 file changed, 2 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/567db37c/stack/core/src/test/java/org/apache/usergrid/count/BatchCountParallelismTest.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/count/BatchCountParallelismTest.java b/stack/core/src/test/java/org/apache/usergrid/count/BatchCountParallelismTest.java
index c5b46b2..37beeac 100644
--- a/stack/core/src/test/java/org/apache/usergrid/count/BatchCountParallelismTest.java
+++ b/stack/core/src/test/java/org/apache/usergrid/count/BatchCountParallelismTest.java
@@ -29,6 +29,7 @@ import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicLong;
 
 import org.junit.Before;
+import org.junit.Ignore;
 import org.junit.Test;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -61,6 +62,7 @@ public class BatchCountParallelismTest {
 
 
     @Test
+    @Ignore("This test causes the build to hang when all stack tests are run")
     public void verifyConcurrentAdd() throws Exception {
 
         final long startCount = batcher.invocationCounter.count();


[37/50] [abbrv] incubator-usergrid git commit: Removes wait from progress observer, since this is no longer used.

Posted by sn...@apache.org.
Removes wait from progress observer, since this is no longer used.


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

Branch: refs/heads/two-dot-o
Commit: d0e3782d75b2127934ab2e3f5f7145c48530e406
Parents: ba7a11a
Author: Todd Nine <tn...@apigee.com>
Authored: Wed Feb 25 09:11:42 2015 -0700
Committer: Todd Nine <tn...@apigee.com>
Committed: Wed Feb 25 09:11:42 2015 -0700

----------------------------------------------------------------------
 .../corepersistence/CpEntityManagerFactory.java |  7 ++---
 .../persistence/EntityManagerFactory.java       |  5 ----
 .../PerformanceEntityRebuildIndexTest.java      | 13 +++-------
 .../cassandra/EntityManagerFactoryImplIT.java   |  5 ----
 .../org/apache/usergrid/rest/IndexResource.java | 27 +++-----------------
 5 files changed, 9 insertions(+), 48 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/d0e3782d/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManagerFactory.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManagerFactory.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManagerFactory.java
index ebb3136..3c63bd6 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManagerFactory.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManagerFactory.java
@@ -358,12 +358,9 @@ public class CpEntityManagerFactory implements EntityManagerFactory, Application
         this.rebuildApplicationIndexes(applicationId, new ProgressObserver() {
             @Override
             public void onProgress(EntityRef entity) {
-                logger.debug("Restored entity {}:{}", entity.getType(), entity.getUuid());
-            }
-            @Override
-            public long getWriteDelayTime() {
-                return 0;
+                logger.info("Restored entity {}:{}", entity.getType(), entity.getUuid());
             }
+
         });
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/d0e3782d/stack/core/src/main/java/org/apache/usergrid/persistence/EntityManagerFactory.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/persistence/EntityManagerFactory.java b/stack/core/src/main/java/org/apache/usergrid/persistence/EntityManagerFactory.java
index 2881111..b668e24 100644
--- a/stack/core/src/main/java/org/apache/usergrid/persistence/EntityManagerFactory.java
+++ b/stack/core/src/main/java/org/apache/usergrid/persistence/EntityManagerFactory.java
@@ -176,10 +176,5 @@ public interface EntityManagerFactory {
 
         public void onProgress( EntityRef entity);
 
-        /**
-         * Get the write delay time from the progress observer.  Used to throttle writes
-         * @return
-         */
-        public long getWriteDelayTime();
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/d0e3782d/stack/core/src/test/java/org/apache/usergrid/persistence/PerformanceEntityRebuildIndexTest.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/PerformanceEntityRebuildIndexTest.java b/stack/core/src/test/java/org/apache/usergrid/persistence/PerformanceEntityRebuildIndexTest.java
index 4bbce9c..def9ed5 100644
--- a/stack/core/src/test/java/org/apache/usergrid/persistence/PerformanceEntityRebuildIndexTest.java
+++ b/stack/core/src/test/java/org/apache/usergrid/persistence/PerformanceEntityRebuildIndexTest.java
@@ -202,7 +202,7 @@ public class PerformanceEntityRebuildIndexTest extends AbstractCoreIT {
 
                 meter.mark();
                 logger.debug("Indexing {}:{}", entity.getType(), entity.getUuid());
-                if ( !logger.isDebugEnabled() && counter % 100 == 0 ) {
+                if ( counter % 100 == 0 ) {
                     logger.info("Reindexed {} entities", counter );
                 }
                 counter++;
@@ -210,10 +210,6 @@ public class PerformanceEntityRebuildIndexTest extends AbstractCoreIT {
 
 
 
-            @Override
-            public long getWriteDelayTime() {
-                return 0;
-            }
         };
 
         try {
@@ -347,16 +343,13 @@ public class PerformanceEntityRebuildIndexTest extends AbstractCoreIT {
 
                 meter.mark();
                 logger.debug("Indexing {}:{}", entity.getType(), entity.getUuid());
-                if ( !logger.isDebugEnabled() && counter % 100 == 0 ) {
+                if ( counter % 100 == 0 ) {
                     logger.info("Reindexed {} entities", counter );
                 }
                 counter++;
             }
 
-            @Override
-            public long getWriteDelayTime() {
-                return 0;
-            }
+
         };
 
         try {

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/d0e3782d/stack/core/src/test/java/org/apache/usergrid/persistence/cassandra/EntityManagerFactoryImplIT.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/cassandra/EntityManagerFactoryImplIT.java b/stack/core/src/test/java/org/apache/usergrid/persistence/cassandra/EntityManagerFactoryImplIT.java
index 850ac6b..d224440 100644
--- a/stack/core/src/test/java/org/apache/usergrid/persistence/cassandra/EntityManagerFactoryImplIT.java
+++ b/stack/core/src/test/java/org/apache/usergrid/persistence/cassandra/EntityManagerFactoryImplIT.java
@@ -160,11 +160,6 @@ public class EntityManagerFactoryImplIT extends AbstractCoreIT {
             public void onProgress(EntityRef entity) {
                 logger.debug("Reindexing {}:{}", entity.getType(), entity.getUuid() );
             }
-
-            @Override
-            public long getWriteDelayTime() {
-                return 0;
-            }
         });
 
         // test to see that app now works and is happy

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/d0e3782d/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 85f27ed..f5338c5 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
@@ -72,11 +72,6 @@ public class IndexResource extends AbstractContextResource {
                 logger.info( "Indexing entity {}:{} ", entity.getType(), entity.getUuid() );
             }
 
-
-            @Override
-            public long getWriteDelayTime() {
-                return 0;
-            }
         };
 
 
@@ -127,10 +122,6 @@ public class IndexResource extends AbstractContextResource {
             }
 
 
-            @Override
-            public long getWriteDelayTime() {
-                return delay;
-            }
         };
 
 
@@ -165,8 +156,7 @@ public class IndexResource extends AbstractContextResource {
         @PathParam( "applicationId" ) final String applicationIdStr,
         @PathParam( "collectionName" ) final String collectionName,
         @QueryParam( "reverse" ) @DefaultValue( "false" ) final Boolean reverse,
-        @QueryParam( "callback" ) @DefaultValue( "callback" ) String callback,
-        @QueryParam( "delay" ) @DefaultValue( "10" ) final long delay ) throws Exception {
+        @QueryParam( "callback" ) @DefaultValue( "callback" ) String callback) throws Exception {
 
         final UUID appId = UUIDUtils.tryExtractUUID( applicationIdStr );
         ApiResponse response = createApiResponse();
@@ -177,7 +167,7 @@ public class IndexResource extends AbstractContextResource {
             public void run() {
 
                 try {
-                    rebuildCollection( appId, collectionName, reverse, delay );
+                    rebuildCollection( appId, collectionName, reverse );
                 } catch (Exception e) {
 
                     // TODO: handle this in rebuildCollection() instead
@@ -216,11 +206,6 @@ public class IndexResource extends AbstractContextResource {
                 logger.info( "Indexing entity {}:{}", entity.getType(), entity.getUuid() );
             }
 
-
-            @Override
-            public long getWriteDelayTime() {
-                return delay;
-            }
         };
 
         final Thread rebuild = new Thread() {
@@ -276,8 +261,7 @@ public class IndexResource extends AbstractContextResource {
     private void rebuildCollection(
         final UUID applicationId,
         final String collectionName,
-        final boolean reverse,
-        final long delay ) throws Exception {
+        final boolean reverse) throws Exception {
 
         EntityManagerFactory.ProgressObserver po = new EntityManagerFactory.ProgressObserver() {
 
@@ -285,10 +269,7 @@ public class IndexResource extends AbstractContextResource {
             public void onProgress( final EntityRef entity ) {
                 logger.info( "Indexing entity {}:{}", entity.getType(), entity.getUuid() );
             }
-            @Override
-            public long getWriteDelayTime() {
-                return delay;
-            }
+
         };
 
         logger.info( "Reindexing for app id: {} and collection {}", applicationId, collectionName );


[47/50] [abbrv] incubator-usergrid git commit: Tone down the DEBUG and TRACE level logging that we do during tests.

Posted by sn...@apache.org.
Tone down the DEBUG and TRACE level logging that we do during tests.


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

Branch: refs/heads/two-dot-o
Commit: 04ff58413614972d385ef9a49176e31db715645f
Parents: 9435fa3
Author: Dave Johnson <sn...@apache.org>
Authored: Thu Feb 26 10:10:55 2015 -0500
Committer: Dave Johnson <sn...@apache.org>
Committed: Thu Feb 26 10:10:55 2015 -0500

----------------------------------------------------------------------
 .../collection/src/test/resources/log4j.properties           | 2 +-
 .../common/src/test/resources/log4j.properties               | 6 +++---
 .../graph/src/test/resources/log4j.properties                | 8 ++++----
 .../queryindex/src/test/resources/log4j.properties           | 4 ++--
 stack/services/src/test/resources/log4j.properties           | 4 ++--
 5 files changed, 12 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/04ff5841/stack/corepersistence/collection/src/test/resources/log4j.properties
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/test/resources/log4j.properties b/stack/corepersistence/collection/src/test/resources/log4j.properties
index 53714a8..acf5c39 100644
--- a/stack/corepersistence/collection/src/test/resources/log4j.properties
+++ b/stack/corepersistence/collection/src/test/resources/log4j.properties
@@ -32,5 +32,5 @@ log4j.logger.com.amazonaws.request=ERROR
 log4j.logger.cassandra.db=ERROR
 
 #log4j.logger.org.apache.usergrid=DEBUG
-log4j.logger.org.apache.usergrid.persistence.collection=TRACE
+#log4j.logger.org.apache.usergrid.persistence.collection=TRACE
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/04ff5841/stack/corepersistence/common/src/test/resources/log4j.properties
----------------------------------------------------------------------
diff --git a/stack/corepersistence/common/src/test/resources/log4j.properties b/stack/corepersistence/common/src/test/resources/log4j.properties
index 08d897c..9a0ecb0 100644
--- a/stack/corepersistence/common/src/test/resources/log4j.properties
+++ b/stack/corepersistence/common/src/test/resources/log4j.properties
@@ -24,7 +24,7 @@ log4j.appender.stdout=org.apache.log4j.ConsoleAppender
 log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
 log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %p %c{3}.%M(%L)<%t>- %m%n
 
-log4j.logger.org.safehaus.chop.plugin=DEBUG
+#log4j.logger.org.safehaus.chop.plugin=DEBUG
 log4j.logger.org.safehaus.guicyfig=ERROR
 log4j.logger.org.safehaus.chop.api.store.amazon=DEBUG
 log4j.logger.org.apache.http=ERROR
@@ -33,7 +33,7 @@ log4j.logger.cassandra.db=ERROR
 
 #log4j.logger.org.apache.usergrid=DEBUG
 
-log4j.logger.org.apache.usergrid.persistence.graph=TRACE
-log4j.logger.org.apache.usergrid.persistence.core.rx=TRACE
+#log4j.logger.org.apache.usergrid.persistence.graph=TRACE
+#log4j.logger.org.apache.usergrid.persistence.core.rx=TRACE
 #log4j.logger.org.apache.usergrid.persistence.graph.serialization.impl.parse=TRACE
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/04ff5841/stack/corepersistence/graph/src/test/resources/log4j.properties
----------------------------------------------------------------------
diff --git a/stack/corepersistence/graph/src/test/resources/log4j.properties b/stack/corepersistence/graph/src/test/resources/log4j.properties
index f9ea207..608ee03 100644
--- a/stack/corepersistence/graph/src/test/resources/log4j.properties
+++ b/stack/corepersistence/graph/src/test/resources/log4j.properties
@@ -24,7 +24,7 @@ log4j.appender.stdout=org.apache.log4j.ConsoleAppender
 log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
 log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %p %c{3}.%M(%L)<%t>- %m%n
 
-log4j.logger.org.safehaus.chop.plugin=DEBUG
+#log4j.logger.org.safehaus.chop.plugin=DEBUG
 log4j.logger.org.safehaus.guicyfig=ERROR
 log4j.logger.org.safehaus.chop.api.store.amazon=DEBUG
 log4j.logger.org.apache.http=ERROR
@@ -33,8 +33,8 @@ log4j.logger.cassandra.db=ERROR
 
 #log4j.logger.org.apache.usergrid=DEBUG
 
-log4j.logger.org.apache.usergrid.persistence.graph=TRACE
-log4j.logger.org.apache.usergrid.persistence.core.rx=TRACE
-log4j.logger.org.apache.usergrid.persistence.core.astyanax=TRACE
+#log4j.logger.org.apache.usergrid.persistence.graph=TRACE
+#log4j.logger.org.apache.usergrid.persistence.core.rx=TRACE
+#log4j.logger.org.apache.usergrid.persistence.core.astyanax=TRACE
 #log4j.logger.org.apache.usergrid.persistence.graph.serialization.impl.parse=TRACE
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/04ff5841/stack/corepersistence/queryindex/src/test/resources/log4j.properties
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/test/resources/log4j.properties b/stack/corepersistence/queryindex/src/test/resources/log4j.properties
index e84489c..a13ce23 100644
--- a/stack/corepersistence/queryindex/src/test/resources/log4j.properties
+++ b/stack/corepersistence/queryindex/src/test/resources/log4j.properties
@@ -29,9 +29,9 @@ log4j.appender.stdout.layout.ConversionPattern=%d %p (%t) %c{1} - %m%n
 log4j.logger.org.apache.usergrid=INFO
 
 #log4j.logger.org.apache.usergrid.persistence.index=DEBUG
-log4j.logger.org.apache.usergrid.persistence.index.impl=DEBUG
+#log4j.logger.org.apache.usergrid.persistence.index.impl=DEBUG
 #log4j.logger.org.apache.usergrid.persistence.index.query=DEBUG
 #log4j.logger.org.apache.usergrid.persistence.index.query.tree=DEBUG
 #log4j.logger.org.apache.usergrid.persistence.index.utils=DEBUG
 
-#log4j.logger.org.apache.cassandra.service.StorageProxy=DEBUG, stdout
\ No newline at end of file
+#log4j.logger.org.apache.cassandra.service.StorageProxy=DEBUG, stdout

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/04ff5841/stack/services/src/test/resources/log4j.properties
----------------------------------------------------------------------
diff --git a/stack/services/src/test/resources/log4j.properties b/stack/services/src/test/resources/log4j.properties
index a63d719..e1c378f 100644
--- a/stack/services/src/test/resources/log4j.properties
+++ b/stack/services/src/test/resources/log4j.properties
@@ -58,7 +58,7 @@ log4j.logger.org.apache.usergrid.locking.singlenode.SingleNodeLockManagerImpl=DE
 
 #log4j.logger.org.apache.usergrid.persistence.index=DEBUG
 #log4j.logger.org.apache.usergrid.batch=DEBUG
-log4j.logger.org.apache.usergrid.management.export=DEBUG
-log4j.logger.org.apache.usergrid.management.importer=DEBUG
+#log4j.logger.org.apache.usergrid.management.export=DEBUG
+#log4j.logger.org.apache.usergrid.management.importer=DEBUG
 
 


[10/50] [abbrv] incubator-usergrid git commit: Oops. Compile error fixes.

Posted by sn...@apache.org.
Oops. Compile error fixes.


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

Branch: refs/heads/two-dot-o
Commit: a607a166935f090349e8ed4a00a03f3773e6e087
Parents: f004f5a
Author: Dave Johnson <dm...@apigee.com>
Authored: Mon Feb 23 10:44:18 2015 -0500
Committer: Dave Johnson <dm...@apigee.com>
Committed: Mon Feb 23 10:44:18 2015 -0500

----------------------------------------------------------------------
 .../apache/usergrid/corepersistence/CpEntityManagerFactory.java | 1 -
 .../persistence/cassandra/EntityManagerFactoryImpl.java         | 5 -----
 2 files changed, 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/a607a166/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManagerFactory.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManagerFactory.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManagerFactory.java
index 59f2c9e..ebb3136 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManagerFactory.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManagerFactory.java
@@ -459,7 +459,6 @@ public class CpEntityManagerFactory implements EntityManagerFactory, Application
     }
 
 
-    @Override
     @Metered(group = "core", name = "EntityManagerFactory_getApplication")
     public Map<String, UUID> getApplications(boolean deleted) throws Exception {
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/a607a166/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/EntityManagerFactoryImpl.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/EntityManagerFactoryImpl.java b/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/EntityManagerFactoryImpl.java
index 05cbf5e..8b5906c 100644
--- a/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/EntityManagerFactoryImpl.java
+++ b/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/EntityManagerFactoryImpl.java
@@ -485,9 +485,4 @@ public class EntityManagerFactoryImpl implements EntityManagerFactory, Applicati
         throw new UnsupportedOperationException("Not supported in v1");
     }
 
-    @Override
-    public Map<String, UUID> getApplications(boolean deleted) throws Exception {
-        throw new UnsupportedOperationException("Not supported in v1");
-    }
-
 }


[43/50] [abbrv] incubator-usergrid git commit: This closes #159

Posted by sn...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/bedf5afb/stack/services/src/test/java/org/apache/usergrid/management/importer/ImportServiceIT.java
----------------------------------------------------------------------
diff --cc stack/services/src/test/java/org/apache/usergrid/management/importer/ImportServiceIT.java
index cb64b59,0000000..4932ad7
mode 100644,000000..100644
--- a/stack/services/src/test/java/org/apache/usergrid/management/importer/ImportServiceIT.java
+++ b/stack/services/src/test/java/org/apache/usergrid/management/importer/ImportServiceIT.java
@@@ -1,673 -1,0 +1,674 @@@
 +/*
 + * 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.management.importer;
 +
 +import com.amazonaws.SDKGlobalConfiguration;
 +import com.google.common.collect.BiMap;
 +import com.google.common.collect.ImmutableSet;
 +import com.google.common.util.concurrent.Service;
 +import com.google.inject.Module;
 +import org.apache.commons.lang.RandomStringUtils;
 +import org.apache.commons.lang3.StringUtils;
 +import org.apache.usergrid.ServiceITSetup;
 +import org.apache.usergrid.ServiceITSetupImpl;
 +import org.apache.usergrid.batch.JobExecution;
 +import org.apache.usergrid.batch.service.JobSchedulerService;
 +import org.apache.usergrid.cassandra.CassandraResource;
 +import org.apache.usergrid.cassandra.ClearShiroSubject;
 +import org.apache.usergrid.management.OrganizationInfo;
 +import org.apache.usergrid.management.UserInfo;
 +import org.apache.usergrid.management.export.ExportService;
 +import org.apache.usergrid.management.export.S3Export;
 +import org.apache.usergrid.management.export.S3ExportImpl;
 +import org.apache.usergrid.persistence.*;
 +import org.apache.usergrid.persistence.entities.Import;
 +import org.apache.usergrid.persistence.entities.JobData;
 +import org.apache.usergrid.persistence.exceptions.EntityNotFoundException;
 +import org.apache.usergrid.persistence.index.impl.ElasticSearchResource;
 +import org.apache.usergrid.persistence.index.query.Query.Level;
 +import org.apache.usergrid.persistence.index.utils.UUIDUtils;
 +import org.apache.usergrid.services.notifications.QueueListener;
 +import org.apache.usergrid.setup.ConcurrentProcessSingleton;
 +
 +import org.jclouds.ContextBuilder;
 +import org.jclouds.blobstore.BlobStore;
 +import org.jclouds.blobstore.BlobStoreContext;
 +import org.jclouds.blobstore.domain.Blob;
 +import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule;
 +import org.jclouds.logging.log4j.config.Log4JLoggingModule;
 +import org.jclouds.netty.config.NettyPayloadModule;
 +import org.junit.*;
 +import org.slf4j.Logger;
 +import org.slf4j.LoggerFactory;
 +import java.util.*;
 +
 +import java.util.UUID;
 +
 +import static org.hamcrest.core.Is.is;
 +import static org.hamcrest.core.IsNot.not;
 +import static org.junit.Assert.*;
 +import static org.mockito.Mockito.mock;
 +import static org.mockito.Mockito.when;
 +
 +
 +//@Concurrent
 +public class ImportServiceIT {
 +
 +    private static final Logger logger = LoggerFactory.getLogger(ImportServiceIT.class);
 +
 +    // app-level data generated only once
 +    private static UserInfo adminUser;
 +    private static OrganizationInfo organization;
 +    private static UUID applicationId;
 +
 +    QueueListener listener;
 +
 +    final String bucketName = System.getProperty( "bucketName" )
 +        + RandomStringUtils.randomAlphanumeric(10).toLowerCase();
 +
 +    @Rule
 +    public ClearShiroSubject clearShiroSubject = new ClearShiroSubject();
 +
 +    @ClassRule
 +    public static final ServiceITSetup setup =
 +        new ServiceITSetupImpl(  );
 +
 +
 +    @BeforeClass
 +    public static void setup() throws Exception {
 +        String username = "test"+ UUIDUtils.newTimeUUID();
 +
 +        // start the scheduler after we're all set up
 +         // start the scheduler after we're all set up
 +        JobSchedulerService jobScheduler = ConcurrentProcessSingleton
 +            .getInstance().getSpringResource().getBean( JobSchedulerService.class );
 +
 +        if ( jobScheduler.state() != Service.State.RUNNING ) {
-             jobScheduler.startAndWait();
++            jobScheduler.startAsync();
++            jobScheduler.awaitRunning();
 +        }
 +
 +        //creates sample test application
 +        adminUser = setup.getMgmtSvc().createAdminUser(
 +            username, username, username+"@test.com", username, false, false );
 +        organization = setup.getMgmtSvc().createOrganization( username, adminUser, true );
 +        applicationId = setup.getMgmtSvc().createApplication( organization.getUuid(), username+"app" ).getId();
 +    }
 +
 +
 +    @Before
 +    public void before() {
 +
 +        boolean configured =
 +                   !StringUtils.isEmpty(System.getProperty( SDKGlobalConfiguration.SECRET_KEY_ENV_VAR))
 +                && !StringUtils.isEmpty(System.getProperty( SDKGlobalConfiguration.ACCESS_KEY_ENV_VAR))
 +                && !StringUtils.isEmpty(System.getProperty("bucketName"));
 +
 +        if ( !configured ) {
 +            logger.warn("Skipping test because {}, {} and bucketName not " +
 +                "specified as system properties, e.g. in your Maven settings.xml file.",
 +                new Object[] {
 +                    SDKGlobalConfiguration.SECRET_KEY_ENV_VAR,
 +                    SDKGlobalConfiguration.ACCESS_KEY_ENV_VAR
 +                });
 +        }
 +
 +        Assume.assumeTrue( configured );
 +   }
 +
 +    @After
 +    public void after() throws Exception {
 +        if(listener != null) {
 +            listener.stop();
 +            listener = null;
 +        }
 +    }
 +
 +    // test case to check if application is imported correctly
 +    @Test
 +    @Ignore("Import organization not supported")
 +    public void testImportApplication() throws Exception {
 +
 +        EntityManager em = setup.getEmf().getEntityManager( applicationId );
 +
 +        // Create five user entities (we already have one admin user)
 +        List<Entity> entities = new ArrayList<>();
 +        for ( int i = 0; i < 5; i++ ) {
 +            Map<String, Object> userProperties =  new LinkedHashMap<>();
 +            userProperties.put( "parameter1", "user" + i );
 +            userProperties.put( "parameter2", "user" + i + "@test.com" );
 +            entities.add( em.create( "custom", userProperties ) );
 +        }
 +        // Creates connections
 +        em.createConnection( new SimpleEntityRef( "custom",  entities.get(0).getUuid() ),
 +                  "related", new SimpleEntityRef( "custom",  entities.get(1).getUuid() ) );
 +        em.createConnection( new SimpleEntityRef( "custom",  entities.get(1).getUuid() ),
 +                  "related", new SimpleEntityRef( "custom",  entities.get(0).getUuid() ) );
 +
 +        logger.debug("\n\nExport the application\n\n");
 +
 +        // Export the application which needs to be tested for import
 +        ExportService exportService = setup.getExportService();
 +        S3Export s3Export = new S3ExportImpl();
 +        HashMap<String, Object> payload = payloadBuilder();
 +        payload.put( "organizationId",  organization.getUuid());
 +        payload.put( "applicationId", applicationId );
 +
 +        // Schedule the export job
 +        UUID exportUUID = exportService.schedule( payload );
 +
 +        // Create and initialize jobData returned in JobExecution.
 +        JobData jobData = jobExportDataCreator(payload, exportUUID, s3Export);
 +
 +        JobExecution jobExecution = mock( JobExecution.class );
 +        when( jobExecution.getJobData() ).thenReturn( jobData );
 +
 +        // Export the application and wait for the export job to finish
 +        exportService.doExport( jobExecution );
 +        while ( !exportService.getState( exportUUID ).equals( "FINISHED" ) ) {
 +           // wait...
 +        }
 +
 +        logger.debug("\n\nImport the application\n\n");
 +
 +        // import
 +        S3Import s3Import = new S3ImportImpl();
 +        ImportService importService = setup.getImportService();
 +
 +        // scheduele the import job
 +        final Import importEntity = importService.schedule( null,  payload );
 +        final UUID importUUID = importEntity.getUuid();
 +
 +        //create and initialize jobData returned in JobExecution.
 +        jobData = jobImportDataCreator( payload,importUUID, s3Import );
 +
 +        jobExecution = mock( JobExecution.class );
 +        when( jobExecution.getJobData() ).thenReturn( jobData );
 +
 +        // import the application file and wait for it to finish
 +        importService.doImport(jobExecution);
 +        while ( !importService.getState( importUUID ).equals( "FINISHED" ) ) {
 +           // wait...
 +        }
 +
 +        logger.debug("\n\nVerify Import\n\n");
 +
 +        try {
 +            //checks if temp import files are created i.e. downloaded from S3
 +            //assertThat(importService.getEphemeralFile().size(), is(not(0)));
 +
 +            Set<String> collections = em.getApplicationCollections();
 +
 +            // check if all collections in the application are updated
 +            for (String collectionName : collections) {
 +                logger.debug("Checking collection {}", collectionName);
 +
 +                Results collection = em.getCollection(applicationId, collectionName, null, Level.ALL_PROPERTIES);
 +
 +                for (Entity eachEntity : collection.getEntities() ) {
 +
 +                    logger.debug("Checking entity {} {}:{}",
 +                        new Object[] { eachEntity.getName(), eachEntity.getType(), eachEntity.getUuid()} );
 +
 +                    //check for dictionaries --> checking permissions in the dictionaries
 +                    EntityRef er;
 +                    Map<Object, Object> dictionaries;
 +
 +                    //checking for permissions for the roles collection
 +                    if (collectionName.equals("roles")) {
 +                        if (eachEntity.getName().equalsIgnoreCase("admin")) {
 +                            er = eachEntity;
 +                            dictionaries = em.getDictionaryAsMap(er, "permissions");
 +                            assertThat(dictionaries.size(), is(not(0))); // admin has permission
 +                        } else {
 +                            er = eachEntity;
 +                            dictionaries = em.getDictionaryAsMap(er, "permissions");
 +                            assertThat(dictionaries.size(), is(0)); // other roles do not
 +                        }
 +                    }
 +                }
 +
 +                if (collectionName.equals("customs")) {
 +                    // check if connections are created for only the 1st 2 entities in the custom collection
 +                    Results r;
 +                    List<ConnectionRef> connections;
 +                    for (int i = 0; i < 2; i++) {
 +                        r = em.getConnectedEntities(entities.get(i), "related", null, Level.IDS);
 +                        connections = r.getConnections();
 +                        assertNotNull(connections);
 +                    }
 +                }
 +            }
 +        }
 +        finally {
 +            //delete bucket
 +            deleteBucket();
 +        }
 +    }
 +
 +    // test case to check if all applications file for an organization are imported correctly
 +    @Test
 +    @Ignore("Import organization not supported")
 +    public void testImportOrganization() throws Exception {
 +
 +        // creates 5 entities in usertests collection
 +        EntityManager em = setup.getEmf().getEntityManager( applicationId );
 +
 +        //intialize user object to be posted
 +        Map<String, Object> userProperties = null;
 +
 +        Entity entity[] = new Entity[5];
 +        //creates entities
 +        for ( int i = 0; i < 5; i++ ) {
 +            userProperties = new LinkedHashMap<String, Object>();
 +            userProperties.put( "name", "user" + i );
 +            userProperties.put( "email", "user" + i + "@test.com" );
 +            entity[i] = em.create( "usertests", userProperties );
 +            em.getCollections(entity[i]).contains("usertests");
 +        }
 +
 +        //creates test connections between first 2 entities in usertests collection
 +        ConnectedEntityRef ref = em.createConnection( entity[0], "related", entity[1]);
 +
 +        em.createConnection( entity[1], "related", entity[0]);
 +
 +        //create 2nd test application, add entities to it, create connections and set permissions
 +        createAndSetup2ndApplication();
 +
 +        //export all applications in an organization
 +        ExportService exportService = setup.getExportService();
 +        S3Export s3Export = new S3ExportImpl();
 +        HashMap<String, Object> payload = payloadBuilder();
 +
 +        payload.put( "organizationId",  organization.getUuid());
 +
 +        //schdeule the export job
 +        UUID exportUUID = exportService.schedule( payload );
 +
 +        //create and initialize jobData returned in JobExecution.
 +        JobData jobData = jobExportDataCreator(payload, exportUUID, s3Export);
 +
 +        JobExecution jobExecution = mock( JobExecution.class );
 +        when( jobExecution.getJobData() ).thenReturn( jobData );
 +
 +        //export organization data and wait for the export job to finish
 +        exportService.doExport( jobExecution );
 +        while ( !exportService.getState( exportUUID ).equals( "FINISHED" ) ) {
 +            ;
 +        }
 +        //TODO: can check if the temp files got created
 +
 +        // import
 +        S3Import s3Import = new S3ImportImpl();
 +        ImportService importService = setup.getImportService();
 +
 +        //schedule the import job
 +        final Import importEntity = importService.schedule(  null, payload );
 +        final UUID importUUID = importEntity.getUuid();
 +
 +        //create and initialize jobData returned in JobExecution.
 +        jobData = jobImportDataCreator( payload,importUUID, s3Import );
 +
 +        jobExecution = mock( JobExecution.class );
 +        when( jobExecution.getJobData() ).thenReturn( jobData );
 +
 +        //import the all application files for the organization and wait for the import to finish
 +        importService.doImport(jobExecution);
 +        while ( !importService.getState( importUUID ).equals( Import.State.FINISHED ) ) {
 +            ;
 +        }
 +
 +        try {
 +            //checks if temp import files are created i.e. downloaded from S3
 +            //assertThat(importService.getEphemeralFile().size(), is(not(0)));
 +
 +            //get all applications for an organization
 +            BiMap<UUID, String> applications =
 +                setup.getMgmtSvc().getApplicationsForOrganization(organization.getUuid());
 +
 +            for (BiMap.Entry<UUID, String> app : applications.entrySet()) {
 +
 +                //check if all collections-entities are updated - created and modified should be different
 +                UUID appID = app.getKey();
 +                em = setup.getEmf().getEntityManager(appID);
 +                Set<String> collections = em.getApplicationCollections();
 +                Iterator<String> itr = collections.iterator();
 +                while (itr.hasNext()) {
 +                    String collectionName = itr.next();
 +                    Results collection = em.getCollection(appID, collectionName, null, Level.ALL_PROPERTIES);
 +                    List<Entity> entities = collection.getEntities();
 +
 +                    if (collectionName.equals("usertests")) {
 +
 +                        // check if connections are created for only the 1st 2 entities in user collection
 +                        Results r;
 +                        List<ConnectionRef> connections;
 +                        for (int i = 0; i < 2; i++) {
 +                            r = em.getConnectedEntities(entities.get(i), "related", null, Level.IDS);
 +                            connections = r.getConnections();
 +                            assertNotNull(connections);
 +                        }
 +
 +                        //check if dictionary is created
 +                        EntityRef er;
 +                        Map<Object, Object> dictionaries1, dictionaries2;
 +                        for (int i = 0; i < 3; i++) {
 +                            er = entities.get(i);
 +                            dictionaries1 = em.getDictionaryAsMap(er, "connected_types");
 +                            dictionaries2 = em.getDictionaryAsMap(er, "connecting_types");
 +
 +                            if (i == 2) {
 +                                //for entity 2, these should be empty
 +                                assertThat(dictionaries1.size(), is(0));
 +                                assertThat(dictionaries2.size(), is(0));
 +                            } else {
 +                                assertThat(dictionaries1.size(), is(not(0)));
 +                                assertThat(dictionaries2.size(), is(not(0)));
 +                            }
 +                        }
 +                    }
 +                }
 +            }
 +        }
 +        finally {
 +            //delete bucket
 +            deleteBucket();
 +        }
 +    }
 +
 +    /**
 +     * Test to schedule a job with null config
 +     */
 +    @Test(expected=NullPointerException.class)
 +    public void testScheduleJobWithNullConfig() throws Exception {
 +        HashMap<String, Object> payload = null;
 +
 +        ImportService importService = setup.getImportService();
 +        final Import importEntity = importService.schedule( null,  payload );
 +
 +
 +        assertNull(importEntity);
 +    }
 +
 +    /**
 +     * Test to get state of a job with null UUID
 +     */
 +    @Test(expected = NullPointerException.class)
 +    public void testGetStateWithNullUUID() throws Exception {
 +        UUID uuid= null;
 +
 +        ImportService importService = setup.getImportService();
 +        Import.State state = importService.getState( uuid );
 +
 +    }
 +
 +    /**
 +     * Test to get state of a job with fake UUID
 +     */
 +    @Test(expected = EntityNotFoundException.class)
 +    public void testGetStateWithFakeUUID() throws Exception {
 +        UUID fake = UUID.fromString( "AAAAAAAA-FFFF-FFFF-FFFF-AAAAAAAAAAAA" );
 +
 +        ImportService importService = setup.getImportService();
 +        Import.State state = importService.getState( fake );
 +
 +    }
 +
 +
 +    /**
 +     * Test to get error message of a job with null state
 +     */
 +    @Test
 +    public void testErrorMessageWithNullState() throws Exception {
 +        UUID state = null;
 +        ImportService importService = setup.getImportService();
 +        String error = importService.getErrorMessage(state);
 +
 +        assertEquals(error,"UUID passed in cannot be null");
 +    }
 +
 +    /**
 +     * Test to get error message of a job with fake UUID
 +     */
 +    @Test
 +    public void testErrorMessageWithFakeUUID() throws Exception {
 +        UUID state = UUID.fromString( "AAAAAAAA-FFFF-FFFF-FFFF-AAAAAAAAAAAA" );
 +        ImportService importService = setup.getImportService();
 +        String error = importService.getErrorMessage(state);
 +
 +        assertEquals(error,"No Such Element found");
 +    }
 +
 +    /**
 +     * Test to the doImport method with null organziation ID
 +     */
 +    @Test
 +    @Ignore("Import organization not supported")
 +    public void testDoImportWithNullOrganizationID() throws Exception {
 +        // import
 +        S3Import s3Import = new S3ImportImpl();
 +        ImportService importService = setup.getImportService();
 +
 +        HashMap<String, Object> payload = payloadBuilder();
 +
 +        //schedule the import job
 +        final Import importEntity = importService.schedule( null,  payload );
 +        final UUID importUUID = importEntity.getUuid();
 +
 +        //create and initialize jobData returned in JobExecution.
 +        JobData jobData = jobImportDataCreator(payload, importUUID, s3Import);
 +
 +        JobExecution jobExecution = mock( JobExecution.class );
 +        when( jobExecution.getJobData() ).thenReturn( jobData );
 +
 +        importService.doImport(jobExecution);
 +        assertEquals(importService.getState(importUUID),Import.State.FAILED);
 +    }
 +
 +    /**
 +     * Test to the doImport method with fake organization ID
 +     */
 +    @Test
 +    @Ignore("Import organization not supported")
 +    public void testDoImportWithFakeOrganizationID() throws Exception {
 +
 +        UUID fakeOrgId = UUID.fromString( "AAAAAAAA-FFFF-FFFF-FFFF-AAAAAAAAAAAA" );
 +        // import
 +        S3Import s3Import = new S3ImportImpl();
 +        ImportService importService = setup.getImportService();
 +
 +        HashMap<String, Object> payload = payloadBuilder();
 +
 +        payload.put("organizationId",fakeOrgId);
 +        //schedule the import job
 +        final Import importEntity = importService.schedule( null,  payload );
 +        final UUID importUUID = importEntity.getUuid();
 +
 +        //create and initialize jobData returned in JobExecution.
 +        JobData jobData = jobImportDataCreator(payload, importUUID, s3Import);
 +
 +        JobExecution jobExecution = mock( JobExecution.class );
 +        when( jobExecution.getJobData() ).thenReturn( jobData );
 +
 +        //import the all application files for the organization and wait for the import to finish
 +        importService.doImport(jobExecution);
 +        assertEquals(Import.State.FAILED, importService.getState(importUUID));
 +    }
 +
 +    /**
 +     * Test to the doImport method with fake application ID
 +     */
 +    @Test
 +    @Ignore("Import application not supported")
 +    public void testDoImportWithFakeApplicationID() throws Exception {
 +
 +        UUID fakeappId = UUID.fromString( "AAAAAAAA-FFFF-FFFF-FFFF-AAAAAAAAAAAA" );
 +        // import
 +        S3Import s3Import = new S3ImportImpl();
 +        ImportService importService = setup.getImportService();
 +
 +        HashMap<String, Object> payload = payloadBuilder();
 +
 +        payload.put("organizationId",organization.getUuid());
 +        payload.put("applicationId",fakeappId);
 +
 +        //schedule the import job
 +        final Import importEntity = importService.schedule(  null, payload );
 +        final UUID importUUID = importEntity.getUuid();
 +
 +        //create and initialize jobData returned in JobExecution.
 +        JobData jobData = jobImportDataCreator(payload, importUUID, s3Import);
 +
 +        JobExecution jobExecution = mock( JobExecution.class );
 +        when( jobExecution.getJobData() ).thenReturn( jobData );
 +
 +        //import the application files for the organization and wait for the import to finish
 +        importService.doImport(jobExecution);
 +        assertEquals(Import.State.FAILED, importService.getState(importUUID));
 +    }
 +
 +    /**
 +     * Test to the doImport Collection method with fake application ID
 +     */
 +    @Test
 +    @Ignore("Import application not supported")
 +    public void testDoImportCollectionWithFakeApplicationID() throws Exception {
 +
 +        UUID fakeappId = UUID.fromString( "AAAAAAAA-FFFF-FFFF-FFFF-AAAAAAAAAAAA" );
 +        // import
 +        S3Import s3Import = new S3ImportImpl();
 +        ImportService importService = setup.getImportService();
 +
 +        HashMap<String, Object> payload = payloadBuilder();
 +
 +        payload.put("organizationId",organization.getUuid());
 +        payload.put("applicationId",fakeappId);
 +        payload.put("collectionName","custom-test");
 +
 +        //schedule the import job
 +        final Import importEntity = importService.schedule( null,  payload );
 +        final UUID importUUID = importEntity.getUuid();
 +
 +        //create and initialize jobData returned in JobExecution.
 +        JobData jobData = jobImportDataCreator(payload, importUUID, s3Import);
 +
 +        JobExecution jobExecution = mock( JobExecution.class );
 +        when( jobExecution.getJobData() ).thenReturn( jobData );
 +
 +        //import the all collection files for the organization-application and wait for the import to finish
 +        importService.doImport(jobExecution);
 +        assertEquals(importService.getState(importUUID),Import.State.FAILED);
 +    }
 +
 +    /*Creates fake payload for testing purposes.*/
 +    public HashMap<String, Object> payloadBuilder() {
 +
 +        HashMap<String, Object> payload = new HashMap<String, Object>();
 +        Map<String, Object> properties = new HashMap<String, Object>();
 +        Map<String, Object> storage_info = new HashMap<String, Object>();
 +        storage_info.put( "bucket_location", bucketName );
 +
 +        storage_info.put( SDKGlobalConfiguration.SECRET_KEY_ENV_VAR,
 +            System.getProperty( SDKGlobalConfiguration.SECRET_KEY_ENV_VAR ) );
 +        storage_info.put( SDKGlobalConfiguration.ACCESS_KEY_ENV_VAR,
 +            System.getProperty( SDKGlobalConfiguration.ACCESS_KEY_ENV_VAR ) );
 +
 +        properties.put( "storage_provider", "s3" );
 +        properties.put( "storage_info", storage_info );
 +
 +        payload.put( "path","test-organization/test-app" );
 +        payload.put( "properties", properties );
 +        return payload;
 +    }
 +
 +    //creates fake import job
 +    public JobData jobImportDataCreator(HashMap<String, Object> payload,UUID importUUID,S3Import s3Import) {
 +        JobData jobData = new JobData();
 +
 +        jobData.setProperty( "jobName", "importJob" );
 +        jobData.setProperty( "importInfo", payload );
 +        jobData.setProperty( "importId", importUUID );
 +        jobData.setProperty( "s3Import", s3Import );
 +
 +        return jobData;
 +    }
 +
 +    //creates fake export job
 +    public JobData jobExportDataCreator(HashMap<String, Object> payload,UUID exportUUID,S3Export s3Export) {
 +        JobData jobData = new JobData();
 +
 +        jobData.setProperty( "jobName", "exportJob" );
 +        jobData.setProperty( "exportInfo", payload );
 +        jobData.setProperty( "exportId", exportUUID );
 +        jobData.setProperty( "s3Export", s3Export);
 +
 +        return jobData;
 +    }
 +
 +    // delete the s3 bucket which was created for testing
 +    public void deleteBucket() {
 +
 +        String accessId = System.getProperty( SDKGlobalConfiguration.ACCESS_KEY_ENV_VAR );
 +        String secretKey = System.getProperty( SDKGlobalConfiguration.SECRET_KEY_ENV_VAR );
 +
 +        Properties overrides = new Properties();
 +        overrides.setProperty( "s3" + ".identity", accessId );
 +        overrides.setProperty( "s3" + ".credential", secretKey );
 +
 +        Blob bo = null;
 +        BlobStore blobStore = null;
 +        final Iterable<? extends Module> MODULES = ImmutableSet
 +                .of(new JavaUrlHttpCommandExecutorServiceModule(), new Log4JLoggingModule(),
 +                        new NettyPayloadModule());
 +
 +        BlobStoreContext context =
 +                ContextBuilder.newBuilder("s3").credentials( accessId, secretKey ).modules( MODULES )
 +                        .overrides( overrides ).buildView( BlobStoreContext.class );
 +
 +        blobStore = context.getBlobStore();
 +        blobStore.deleteContainer( bucketName );
 +    }
 +
 +    //creates 2nd application for testing import from an organization having multiple applications
 +    void createAndSetup2ndApplication() throws Exception {
 +
 +        UUID appId = setup.getMgmtSvc().createApplication( organization.getUuid(), "test-app-2" ).getId();
 +        EntityManager emTest = setup.getEmf().getEntityManager(appId);
 +
 +        Map<String, Object> userProperties = null;
 +
 +        Entity entityTest[] = new Entity[5];
 +
 +        //creates entities and set permissions
 +        for ( int i = 0; i < 5; i++ ) {
 +            userProperties = new LinkedHashMap<String, Object>();
 +            userProperties.put( "name", "user" + i );
 +            userProperties.put( "email", "user" + i + "@test.com" );
 +            entityTest[i] = emTest.create( "testobject", userProperties );
 +        }
 +
 +        //create connection
 +        emTest.createConnection( new SimpleEntityRef( "testobject",  entityTest[0].getUuid()),
 +            "related",
 +            new SimpleEntityRef( "testobject",  entityTest[1].getUuid()));
 +
 +        emTest.createConnection( new SimpleEntityRef( "testobject",  entityTest[1].getUuid()),
 +            "related",
 +            new SimpleEntityRef( "testobject",  entityTest[0].getUuid()));
 +    }
 +}


[09/50] [abbrv] incubator-usergrid git commit: 1) PUT on // will not restore a deleted app and 2) /applications?deleted=true will return list of deleted applications.

Posted by sn...@apache.org.
1) PUT on /<org-name>/<app-id> will not restore a deleted app and 2) /applications?deleted=true will return list of deleted applications.


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

Branch: refs/heads/two-dot-o
Commit: f004f5a31c32bc329e859fd203315cea41a55fe9
Parents: fe8f404
Author: Dave Johnson <dm...@apigee.com>
Authored: Sat Feb 21 09:02:01 2015 -0500
Committer: Dave Johnson <dm...@apigee.com>
Committed: Sat Feb 21 09:02:01 2015 -0500

----------------------------------------------------------------------
 .../corepersistence/CpEntityManagerFactory.java | 112 +++++++++++++++----
 .../corepersistence/util/CpNamingUtils.java     |   3 +
 .../persistence/EntityManagerFactory.java       |   7 ++
 .../cassandra/EntityManagerFactoryImpl.java     |  21 +++-
 .../PerformanceEntityRebuildIndexTest.java      |  16 ++-
 .../cassandra/EntityManagerFactoryImplIT.java   |  66 ++++++++++-
 stack/pom.xml                                   |   6 +-
 stack/rest/pom.xml                              |  43 ++++---
 .../org/apache/usergrid/rest/RootResource.java  |  25 +++--
 .../rest/applications/ApplicationResource.java  |  72 ++++++++----
 .../applications/ApplicationsResource.java      |  28 +++--
 11 files changed, 293 insertions(+), 106 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/f004f5a3/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManagerFactory.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManagerFactory.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManagerFactory.java
index 01691d4..59f2c9e 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManagerFactory.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManagerFactory.java
@@ -22,15 +22,7 @@ import com.google.inject.Injector;
 import com.yammer.metrics.annotation.Metered;
 import static java.lang.String.CASE_INSENSITIVE_ORDER;
 
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.TreeMap;
-import java.util.UUID;
+import java.util.*;
 import java.util.concurrent.atomic.AtomicBoolean;
 
 import org.apache.commons.lang.StringUtils;
@@ -59,6 +51,7 @@ import org.apache.usergrid.persistence.core.util.Health;
 import org.apache.usergrid.persistence.entities.Application;
 import org.apache.usergrid.persistence.exceptions.ApplicationAlreadyExistsException;
 import org.apache.usergrid.persistence.exceptions.DuplicateUniquePropertyExistsException;
+import org.apache.usergrid.persistence.exceptions.EntityNotFoundException;
 import org.apache.usergrid.persistence.exceptions.OrganizationAlreadyExistsException;
 import org.apache.usergrid.persistence.graph.Edge;
 import org.apache.usergrid.persistence.graph.GraphManager;
@@ -317,6 +310,8 @@ public class CpEntityManagerFactory implements EntityManagerFactory, Application
     @Override
     public void deleteApplication(UUID applicationId) throws Exception {
 
+        //throw new UnsupportedOperationException("Delete application not supported");
+
         // remove old appinfo Entity, which is in the System App's appinfos collection
         EntityManager em = getEntityManager(CpNamingUtils.SYSTEM_APP_ID);
         Query q = Query.fromQL(String.format("select * where applicationUuid = '%s'", applicationId.toString()));
@@ -337,6 +332,43 @@ public class CpEntityManagerFactory implements EntityManagerFactory, Application
 
 
     @Override
+    public void restoreApplication(UUID applicationId) throws Exception {
+
+        // remove old delete_appinfos Entity
+        EntityManager em = getEntityManager(CpNamingUtils.SYSTEM_APP_ID);
+        Query q = Query.fromQL(String.format("select * where applicationUuid = '%s'", applicationId.toString()));
+        Results results = em.searchCollection( em.getApplicationRef(), "deleted_appinfos", q);
+        Entity appToRestore = results.getEntity();
+
+        if ( appToRestore == null ) {
+            throw new EntityNotFoundException("Cannot restore. Deleted Application not found: " + applicationId );
+        }
+
+        em.delete( appToRestore );
+
+        // restore entity in appinfo collection
+        Map<String, Object> appProps = appToRestore.getProperties();
+        appProps.remove("uuid");
+        appProps.put("type", "appinfo");
+        Entity restoredApp = em.create("appinfo", appToRestore.getProperties());
+
+        em.refreshIndex();
+
+        // rebuild the apps index
+        this.rebuildApplicationIndexes(applicationId, new ProgressObserver() {
+            @Override
+            public void onProgress(EntityRef entity) {
+                logger.debug("Restored entity {}:{}", entity.getType(), entity.getUuid());
+            }
+            @Override
+            public long getWriteDelayTime() {
+                return 0;
+            }
+        });
+    }
+
+
+    @Override
     public UUID importApplication(
             String organization, UUID applicationId,
             String name, Map<String, Object> properties) throws Exception {
@@ -380,31 +412,56 @@ public class CpEntityManagerFactory implements EntityManagerFactory, Application
     public UUID lookupApplication( String name ) throws Exception {
         init();
 
-        EntityManager em = getEntityManager( CpNamingUtils.SYSTEM_APP_ID );
+        // TODO: why does this not work for restored apps
+
+//        EntityManager em = getEntityManager( CpNamingUtils.SYSTEM_APP_ID );
+//        final EntityRef alias = em.getAlias( CpNamingUtils.APPINFOS, name );
+//        if ( alias == null ) {
+//            return null;
+//        }
+//        final Entity entity = em.get( alias );
+//        if ( entity == null ) {
+//            return null;
+//        }
+//        final UUID property = ( UUID ) entity.getProperty( "applicationUuid" );
+//        return property;
 
+        Query q = Query.fromQL( PROPERTY_NAME + " = '" + name + "'");
 
-        final EntityRef alias = em.getAlias( CpNamingUtils.APPINFOS, name );
+        EntityManager em = getEntityManager(CpNamingUtils.SYSTEM_APP_ID);
 
-        if ( alias == null ) {
+        Results results = em.searchCollection( em.getApplicationRef(), "appinfos", q);
+
+        if ( results.isEmpty() ) {
             return null;
         }
 
-        final Entity entity = em.get( alias );
-
-        if ( entity == null ) {
-            return null;
+        Entity entity = results.iterator().next();
+        Object uuidObject = entity.getProperty("applicationUuid");
+        if ( uuidObject instanceof UUID ) {
+            return (UUID)uuidObject;
         }
+        return UUIDUtils.tryExtractUUID( entity.getProperty("applicationUuid").toString() );
+    }
 
 
-        final UUID property = ( UUID ) entity.getProperty( "applicationUuid" );
+    @Override
+    @Metered(group = "core", name = "EntityManagerFactory_getApplication")
+    public Map<String, UUID> getApplications() throws Exception {
+        return getApplications( false );
+    }
 
-        return property;
+
+    @Override
+    @Metered(group = "core", name = "EntityManagerFactory_getApplication")
+    public Map<String, UUID> getDeletedApplications() throws Exception {
+        return getApplications( true );
     }
 
 
     @Override
     @Metered(group = "core", name = "EntityManagerFactory_getApplication")
-    public Map<String, UUID> getApplications() throws Exception {
+    public Map<String, UUID> getApplications(boolean deleted) throws Exception {
 
         Map<String, UUID> appMap = new HashMap<String, UUID>();
 
@@ -415,7 +472,15 @@ public class CpEntityManagerFactory implements EntityManagerFactory, Application
         Application app = em.getApplication();
         Id fromEntityId = new SimpleId( app.getUuid(), app.getType() );
 
-        String edgeType = CpNamingUtils.getEdgeTypeFromCollectionName( CpNamingUtils.APPINFOS );
+        final String scopeName;
+        final String edgeType;
+        if ( deleted ) {
+            edgeType = CpNamingUtils.getEdgeTypeFromCollectionName(CpNamingUtils.DELETED_APPINFOS);
+            scopeName = CpNamingUtils.getCollectionScopeNameFromCollectionName(CpNamingUtils.DELETED_APPINFOS);
+        } else {
+            edgeType = CpNamingUtils.getEdgeTypeFromCollectionName(CpNamingUtils.APPINFOS);
+            scopeName = CpNamingUtils.getCollectionScopeNameFromCollectionName(CpNamingUtils.APPINFOS);
+        }
 
         logger.debug("getApplications(): Loading edges of edgeType {} from {}:{}",
             new Object[] { edgeType, fromEntityId.getType(), fromEntityId.getUuid() } );
@@ -436,9 +501,9 @@ public class CpEntityManagerFactory implements EntityManagerFactory, Application
             });
 
             CollectionScope collScope = new CollectionScopeImpl(
-                    appScope.getApplication(),
-                    appScope.getApplication(),
-                    CpNamingUtils.getCollectionScopeNameFromCollectionName( CpNamingUtils.APPINFOS ));
+                appScope.getApplication(),
+                appScope.getApplication(),
+                scopeName);
 
             org.apache.usergrid.persistence.model.entity.Entity e =
                     managerCache.getEntityCollectionManager( collScope ).load( targetId )
@@ -779,4 +844,5 @@ public class CpEntityManagerFactory implements EntityManagerFactory, Application
 
         return ecm.getHealth();
     }
+
 }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/f004f5a3/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 0d7b6ff..8208855 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
@@ -66,6 +66,9 @@ public class CpNamingUtils {
      * The app infos entity object type. This holds the app name, appId, and org name
      */
     public static final String APPINFOS = "appinfos";
+
+    public static final String DELETED_APPINFOS = "deleted_appinfos";
+
     /**
      * The name of the map that holds our entity id->type mapping
      */

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/f004f5a3/stack/core/src/main/java/org/apache/usergrid/persistence/EntityManagerFactory.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/persistence/EntityManagerFactory.java b/stack/core/src/main/java/org/apache/usergrid/persistence/EntityManagerFactory.java
index 6a9095d..2881111 100644
--- a/stack/core/src/main/java/org/apache/usergrid/persistence/EntityManagerFactory.java
+++ b/stack/core/src/main/java/org/apache/usergrid/persistence/EntityManagerFactory.java
@@ -19,6 +19,8 @@ package org.apache.usergrid.persistence;
 
 import java.util.Map;
 import java.util.UUID;
+
+import com.yammer.metrics.annotation.Metered;
 import org.apache.usergrid.persistence.core.util.Health;
 import org.apache.usergrid.persistence.index.EntityIndex;
 import org.springframework.context.ApplicationContext;
@@ -95,8 +97,11 @@ public interface EntityManagerFactory {
      *
      * @throws Exception the exception
      */
+    @Metered(group = "core", name = "EntityManagerFactory_getApplication")
     public abstract Map<String, UUID> getApplications() throws Exception;
 
+    public Map<String, UUID> getDeletedApplications() throws Exception;
+
     public abstract void setup() throws Exception;
 
     public abstract Map<String, String> getServiceProperties();
@@ -165,6 +170,8 @@ public interface EntityManagerFactory {
 
     public Health getEntityStoreHealth();
 
+    void restoreApplication(UUID applicationId) throws Exception;
+
     public interface ProgressObserver {
 
         public void onProgress( EntityRef entity);

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/f004f5a3/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/EntityManagerFactoryImpl.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/EntityManagerFactoryImpl.java b/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/EntityManagerFactoryImpl.java
index 535a14e..05cbf5e 100644
--- a/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/EntityManagerFactoryImpl.java
+++ b/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/EntityManagerFactoryImpl.java
@@ -330,8 +330,7 @@ public class EntityManagerFactoryImpl implements EntityManagerFactory, Applicati
         return applications;
     }
 
-
-    @Override
+   @Override
     public boolean setServiceProperty( String name, String value ) {
         try {
             cass.setColumn( cass.getSystemKeyspace(), PROPERTIES_CF, PROPERTIES_CF, name, value );
@@ -473,6 +472,22 @@ public class EntityManagerFactoryImpl implements EntityManagerFactory, Applicati
 
     @Override
     public Health getEntityStoreHealth() {
-        throw new UnsupportedOperationException("Not supported yet.");
+        throw new UnsupportedOperationException("Not supported in v1.");
+    }
+
+    @Override
+    public void restoreApplication(UUID applicationId) throws Exception {
+        throw new UnsupportedOperationException("Not supported in v1");
     }
+
+    @Override
+    public Map<String, UUID> getDeletedApplications() throws Exception {
+        throw new UnsupportedOperationException("Not supported in v1");
+    }
+
+    @Override
+    public Map<String, UUID> getApplications(boolean deleted) throws Exception {
+        throw new UnsupportedOperationException("Not supported in v1");
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/f004f5a3/stack/core/src/test/java/org/apache/usergrid/persistence/PerformanceEntityRebuildIndexTest.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/PerformanceEntityRebuildIndexTest.java b/stack/core/src/test/java/org/apache/usergrid/persistence/PerformanceEntityRebuildIndexTest.java
index 52b6fe4..4bbce9c 100644
--- a/stack/core/src/test/java/org/apache/usergrid/persistence/PerformanceEntityRebuildIndexTest.java
+++ b/stack/core/src/test/java/org/apache/usergrid/persistence/PerformanceEntityRebuildIndexTest.java
@@ -218,8 +218,12 @@ public class PerformanceEntityRebuildIndexTest extends AbstractCoreIT {
 
         try {
 
+            // do it forwards
             setup.getEmf().rebuildCollectionIndex( em.getApplicationId(), "catherders", false, po );
 
+            // and backwards, just to make sure both cases are covered
+            setup.getEmf().rebuildCollectionIndex( em.getApplicationId(), "catherders", true, po );
+
             reporter.report();
             registry.remove( meterName );
             logger.info("Rebuilt index");
@@ -312,9 +316,13 @@ public class PerformanceEntityRebuildIndexTest extends AbstractCoreIT {
         // ----------------- delete the system and application indexes
 
         logger.debug("Deleting app index and system app index");
-        //deleteIndex( CpNamingUtils.SYSTEM_APP_ID );
+
         deleteIndex( em.getApplicationId() );
 
+        // deleting sytem app index will interfere with other concurrently running tests
+        //deleteIndex( CpNamingUtils.SYSTEM_APP_ID );
+
+
         // ----------------- test that we can read them, should fail
 
         logger.debug("Reading data, should fail this time ");
@@ -335,7 +343,7 @@ public class PerformanceEntityRebuildIndexTest extends AbstractCoreIT {
             int counter = 0;
 
             @Override
-               public void onProgress( final EntityRef entity ) {
+            public void onProgress( final EntityRef entity ) {
 
                 meter.mark();
                 logger.debug("Indexing {}:{}", entity.getType(), entity.getUuid());
@@ -345,8 +353,6 @@ public class PerformanceEntityRebuildIndexTest extends AbstractCoreIT {
                 counter++;
             }
 
-
-
             @Override
             public long getWriteDelayTime() {
                 return 0;
@@ -355,6 +361,8 @@ public class PerformanceEntityRebuildIndexTest extends AbstractCoreIT {
 
         try {
 
+            setup.getEmf().rebuildInternalIndexes( po );
+
             setup.getEmf().rebuildApplicationIndexes( em.getApplicationId(), po );
 
             reporter.report();

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/f004f5a3/stack/core/src/test/java/org/apache/usergrid/persistence/cassandra/EntityManagerFactoryImplIT.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/cassandra/EntityManagerFactoryImplIT.java b/stack/core/src/test/java/org/apache/usergrid/persistence/cassandra/EntityManagerFactoryImplIT.java
index 09e7ce1..850ac6b 100644
--- a/stack/core/src/test/java/org/apache/usergrid/persistence/cassandra/EntityManagerFactoryImplIT.java
+++ b/stack/core/src/test/java/org/apache/usergrid/persistence/cassandra/EntityManagerFactoryImplIT.java
@@ -23,6 +23,7 @@ import java.util.List;
 import java.util.Map;
 import java.util.UUID;
 
+import org.apache.usergrid.persistence.*;
 import org.junit.AfterClass;
 import org.junit.Before;
 import org.junit.BeforeClass;
@@ -33,11 +34,6 @@ import org.slf4j.LoggerFactory;
 import org.apache.commons.lang3.RandomStringUtils;
 
 import org.apache.usergrid.AbstractCoreIT;
-import org.apache.usergrid.persistence.Entity;
-import org.apache.usergrid.persistence.EntityManager;
-import org.apache.usergrid.persistence.EntityManagerFactory;
-import org.apache.usergrid.persistence.Results;
-import org.apache.usergrid.persistence.SimpleEntityRef;
 import org.apache.usergrid.persistence.cassandra.util.TraceTag;
 import org.apache.usergrid.persistence.cassandra.util.TraceTagManager;
 import org.apache.usergrid.persistence.cassandra.util.TraceTagReporter;
@@ -123,10 +119,27 @@ public class EntityManagerFactoryImplIT extends AbstractCoreIT {
 
         em.refreshIndex();
 
+        // TODO: this assertion should work!
+        //assertNotNull( "cannot lookup app by name", setup.getEmf().lookupApplication("test-app-" + rand) );
+
         // delete the application
 
         setup.getEmf().deleteApplication( applicationId );
 
+        em.refreshIndex();
+
+        boolean found = false;
+        Map<String, UUID> deletedApps = emf.getDeletedApplications();
+        for ( String appName : deletedApps.keySet() ) {
+            UUID appId = deletedApps.get( appName );
+            if ( appId.equals( applicationId )) {
+                found = true;
+                break;
+            }
+        }
+
+        assertTrue("Deleted app not found in deleted apps collection", found );
+
         // attempt to get entities in application's collections in various ways should all fail
 
         assertNull( setup.getEmf().lookupApplication("test-app-" + rand) );
@@ -138,6 +151,49 @@ public class EntityManagerFactoryImplIT extends AbstractCoreIT {
             assertNotEquals( appName, "test-app-" + rand );
         }
 
+        // restore the app
+
+        emf.restoreApplication( applicationId );
+
+        emf.rebuildAllIndexes(new EntityManagerFactory.ProgressObserver() {
+            @Override
+            public void onProgress(EntityRef entity) {
+                logger.debug("Reindexing {}:{}", entity.getType(), entity.getUuid() );
+            }
+
+            @Override
+            public long getWriteDelayTime() {
+                return 0;
+            }
+        });
+
+        // test to see that app now works and is happy
+
+        // it should not be found in the deleted apps collection
+        found = false;
+        deletedApps = emf.getDeletedApplications();
+        for ( String appName : deletedApps.keySet() ) {
+            UUID appId = deletedApps.get( appName );
+            if ( appId.equals( applicationId )) {
+                found = true;
+                break;
+            }
+        }
+        assertFalse("Restored app found in deleted apps collection", found);
+
+        found = false;
+        appMap = setup.getEmf().getApplications();
+        for ( String appName : appMap.keySet() ) {
+            UUID appId = appMap.get( appName );
+            if ( appId.equals( applicationId )) {
+                found = true;
+                break;
+            }
+        }
+        assertTrue("Restored app not found in apps collection", found);
+
+        // TODO: this assertion should work!
+        //assertNotNull(setup.getEmf().lookupApplication("test-app-" + rand));
     }
 
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/f004f5a3/stack/pom.xml
----------------------------------------------------------------------
diff --git a/stack/pom.xml b/stack/pom.xml
index 12fac3f..2735366 100644
--- a/stack/pom.xml
+++ b/stack/pom.xml
@@ -1565,12 +1565,14 @@
                     <exclude>**/aws.properties</exclude>
                     <exclude>**/tempExport*</exclude>
                     <exclude>loadtests/loadtest_setup.sh</exclude>
-                    <exclude>loadtests/gatling/user-files/request-bodies/**</exclude>
+		    <exclude>loadtests/gatling/user-files/request-bodies/**</exclude>
+
                     <!-- other -->
                     <exclude>**/m2/**</exclude>
                     <exclude>**/*.asc</exclude>
                     <exclude>**/dummy.txt</exclude>
-                    <exclude>**/cloudbees.xml</exclude>
+		    <exclude>**/cloudbees.xml</exclude>
+		    <exclude>**/catalina_base/**</exclude>
                     <exlude>loadtests/gatling/lib/**</exlude>
                     <exlude>loadtests/gatling/user-files/**</exlude>
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/f004f5a3/stack/rest/pom.xml
----------------------------------------------------------------------
diff --git a/stack/rest/pom.xml b/stack/rest/pom.xml
index e07e218..0680da2 100644
--- a/stack/rest/pom.xml
+++ b/stack/rest/pom.xml
@@ -45,12 +45,11 @@
             <id>arquillian-tomcat</id>
 
             <activation>
-                <activeByDefault>true</activeByDefault>
+                <activeByDefault>false</activeByDefault>
             </activation>
 
             <dependencies>
 
-
                 <!--embedded mode-->
                 <!--<dependency>-->
                    <!--<groupId>org.apache.tomcat.embed</groupId>-->
@@ -429,26 +428,26 @@
 
         <!-- Some arquillian dependency runs and old version of guice. We're overridding it here so that we include
           the right value into the test scope -->
-        <dependency>
-          <groupId>com.google.inject</groupId>
-          <artifactId>guice</artifactId>
-          <version>${guice.version}</version>
-            <scope>test</scope>
-        </dependency>
+        <!--<dependency>-->
+          <!--<groupId>com.google.inject</groupId>-->
+          <!--<artifactId>guice</artifactId>-->
+          <!--<version>${guice.version}</version>-->
+            <!--<scope>test</scope>-->
+        <!--</dependency>-->
 
-        <dependency>
-          <groupId>com.google.inject.extensions</groupId>
-          <artifactId>guice-multibindings</artifactId>
-          <version>${guice.version}</version>
-            <scope>test</scope>
-        </dependency>
+        <!--<dependency>-->
+          <!--<groupId>com.google.inject.extensions</groupId>-->
+          <!--<artifactId>guice-multibindings</artifactId>-->
+          <!--<version>${guice.version}</version>-->
+            <!--<scope>test</scope>-->
+        <!--</dependency>-->
 
-        <dependency>
-          <groupId>com.google.inject.extensions</groupId>
-          <artifactId>guice-assistedinject</artifactId>
-          <version>${guice.version}</version>
-            <scope>test</scope>
-        </dependency>
+        <!--<dependency>-->
+          <!--<groupId>com.google.inject.extensions</groupId>-->
+          <!--<artifactId>guice-assistedinject</artifactId>-->
+          <!--<version>${guice.version}</version>-->
+            <!--<scope>test</scope>-->
+        <!--</dependency>-->
 
 
         <!-- documentation here
@@ -463,10 +462,6 @@
               <type>pom</type>
             </dependency>
 
-
-
-
-
         <!--  use the external test client.  Just depend on the maven jetty plugin to launch jetty -->
         <dependency>
             <groupId>com.sun.jersey.jersey-test-framework</groupId>

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/f004f5a3/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 f324d28..27eff28 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
@@ -111,9 +111,10 @@ public class RootResource extends AbstractContextResource implements MetricProce
     @RequireSystemAccess
     @GET
     @Path("applications")
-    public JSONWithPadding getAllApplications( @Context UriInfo ui,
-                                               @QueryParam("callback") @DefaultValue("callback") String callback )
-            throws URISyntaxException {
+    public JSONWithPadding getAllApplications(
+        @Context UriInfo ui,
+        @QueryParam("deleted") @DefaultValue("false") Boolean deleted,
+        @QueryParam("callback") @DefaultValue("callback") String callback ) throws URISyntaxException {
 
         logger.info( "RootResource.getAllApplications" );
 
@@ -122,7 +123,11 @@ public class RootResource extends AbstractContextResource implements MetricProce
 
         Map<String, UUID> applications = null;
         try {
-            applications = emf.getApplications();
+            if ( deleted ) {
+                applications = emf.getDeletedApplications();
+            } else {
+                applications = emf.getApplications();
+            }
             response.setSuccess();
             response.setApplications( applications );
         }
@@ -141,7 +146,7 @@ public class RootResource extends AbstractContextResource implements MetricProce
     public JSONWithPadding getAllApplications2( @Context UriInfo ui,
                                                 @QueryParam("callback") @DefaultValue("callback") String callback )
             throws URISyntaxException {
-        return getAllApplications( ui, callback );
+        return getAllApplications( ui, false, callback );
     }
 
 
@@ -162,16 +167,16 @@ public class RootResource extends AbstractContextResource implements MetricProce
 
     /**
      * Return status of this Usergrid instance in JSON format.
-     * 
+     *
      * By Default this end-point will ignore errors but if you call it with ignore_status=false
      * then it will return HTTP 500 if either the Entity store or the Index for the management
      * application are in a bad state.
-     * 
+     *
      * @param ignoreError Ignore any errors and return status no matter what.
      */
     @GET
     @Path("status")
-    public JSONWithPadding getStatus( 
+    public JSONWithPadding getStatus(
             @QueryParam("ignore_error") @DefaultValue("true") Boolean ignoreError,
             @QueryParam("callback") @DefaultValue("callback") String callback ) {
 
@@ -195,10 +200,10 @@ public class RootResource extends AbstractContextResource implements MetricProce
         node.put( "version", usergridSystemMonitor.getBuildNumber() );
 
         // Hector status, for backwards compatibility
-        node.put( "cassandraAvailable", usergridSystemMonitor.getIsCassandraAlive() ); 
+        node.put( "cassandraAvailable", usergridSystemMonitor.getIsCassandraAlive() );
 
         // Core Persistence Collections module status
-        node.put( "cassandraStatus", emf.getEntityStoreHealth().toString() ); 
+        node.put( "cassandraStatus", emf.getEntityStoreHealth().toString() );
 
         // Core Persistence Query Index module status for Management App Index
         EntityManager em = emf.getEntityManager( emf.getManagementAppId() );

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/f004f5a3/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 6a3c94c..2c252e7 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
@@ -20,18 +20,10 @@ package org.apache.usergrid.rest.applications;
 import java.io.UnsupportedEncodingException;
 import java.net.URLEncoder;
 import java.util.Map;
+import java.util.Properties;
 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.*;
 import javax.ws.rs.core.Context;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.PathSegment;
@@ -328,9 +320,9 @@ public class ApplicationResource extends ServiceResource {
     @POST
     @Path("token")
     @Consumes(APPLICATION_JSON)
-    public Response getAccessTokenPostJson( @Context UriInfo ui, 
-            @HeaderParam("Authorization") String authorization, 
-            Map<String, Object> json, 
+    public Response getAccessTokenPostJson( @Context UriInfo ui,
+            @HeaderParam("Authorization") String authorization,
+            Map<String, Object> json,
             @QueryParam("callback") @DefaultValue("") String callback ) throws Exception {
 
         String grant_type = ( String ) json.get( "grant_type" );
@@ -352,7 +344,7 @@ public class ApplicationResource extends ServiceResource {
             }
         }
 
-        return getAccessToken( ui, authorization, grant_type, username, password, pin, client_id, 
+        return getAccessToken( ui, authorization, grant_type, username, password, pin, client_id,
                 client_secret, code, ttl, redirect_uri, callback );
     }
 
@@ -384,7 +376,7 @@ public class ApplicationResource extends ServiceResource {
     @Path("credentials")
     @RequireApplicationAccess
     @Produces(MediaType.APPLICATION_JSON)
-    public JSONWithPadding generateKeys( @Context UriInfo ui, 
+    public JSONWithPadding generateKeys( @Context UriInfo ui,
         @QueryParam("callback") @DefaultValue("callback") String callback ) throws Exception {
 
         logger.debug( "AuthResource.keys" );
@@ -393,7 +385,7 @@ public class ApplicationResource extends ServiceResource {
             throw new UnauthorizedException();
         }
 
-        ClientCredentialsInfo kp = new ClientCredentialsInfo( 
+        ClientCredentialsInfo kp = new ClientCredentialsInfo(
             management.getClientIdForApplication( services.getApplicationId() ),
             management.newClientSecretForApplication( services.getApplicationId() ) );
 
@@ -405,12 +397,12 @@ public class ApplicationResource extends ServiceResource {
 
     @GET
     @Path("authorize")
-    public Viewable showAuthorizeForm( 
-            @Context UriInfo ui, 
+    public Viewable showAuthorizeForm(
+            @Context UriInfo ui,
             @QueryParam("response_type") String response_type,
             @QueryParam("client_id") String client_id,
             @QueryParam("redirect_uri") String redirect_uri,
-            @QueryParam("scope") String scope, 
+            @QueryParam("scope") String scope,
             @QueryParam("state") String state ) {
 
         try {
@@ -443,7 +435,7 @@ public class ApplicationResource extends ServiceResource {
     @POST
     @Path("authorize")
     @Produces(MediaType.TEXT_HTML)
-    public Response handleAuthorizeForm( @Context UriInfo ui, 
+    public Response handleAuthorizeForm( @Context UriInfo ui,
             @FormParam("response_type") String response_type,
             @FormParam("client_id") String client_id,
             @FormParam("redirect_uri") String redirect_uri,
@@ -501,21 +493,55 @@ public class ApplicationResource extends ServiceResource {
     }
 
 
+    @PUT
+    @RequireOrganizationAccess
+    @Override
+    public JSONWithPadding executePut(  @Context UriInfo ui, String body,
+        @QueryParam("callback") @DefaultValue("callback") String callback ) throws Exception {
+
+        if ( applicationId == null ) {
+            throw new IllegalArgumentException("Application ID not specified in request");
+        }
+
+        ApplicationInfo app = management.getApplicationInfo( applicationId );
+        if ( app == null ) {
+            throw new EntityNotFoundException("Application ID " + applicationId + " not found");
+        }
+
+        emf.restoreApplication( applicationId );
+
+        ApiResponse response = createApiResponse();
+        response.setAction( "restore" );
+        response.setApplication( services.getApplication() );
+        response.setParams( ui.getQueryParameters() );
+
+        return new JSONWithPadding( response, callback );
+    }
+
+
     @DELETE
     @RequireOrganizationAccess
     @Override
     public JSONWithPadding executeDelete(  @Context UriInfo ui,
         @QueryParam("callback") @DefaultValue("callback") String callback ) throws Exception {
-        
+
+        Properties props = management.getProperties();
+
+        // for now, only works in test mode
+        String testProp = ( String ) props.get( "usergrid.test" );
+        if ( testProp == null || !Boolean.parseBoolean( testProp ) ) {
+            throw new UnsupportedOperationException();
+        }
+
         if ( applicationId == null ) {
             throw new IllegalArgumentException("Application ID not specified in request");
         }
-        
+
         ApplicationInfo app = management.getApplicationInfo( applicationId );
         if ( app == null ) {
             throw new EntityNotFoundException("Application ID " + applicationId + " not found");
         }
-        
+
         emf.deleteApplication( applicationId );
 
         ApiResponse response = createApiResponse();

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/f004f5a3/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 1d2c504..56d2f98 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
@@ -21,15 +21,7 @@ import java.util.LinkedHashMap;
 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.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.Produces;
-import javax.ws.rs.QueryParam;
+import javax.ws.rs.*;
 import javax.ws.rs.core.Context;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.UriInfo;
@@ -78,9 +70,10 @@ public class ApplicationsResource extends AbstractContextResource {
 
     @RequireOrganizationAccess
     @GET
-    public JSONWithPadding getOrganizationApplications( @Context UriInfo ui,
-                                                        @QueryParam( "callback" ) @DefaultValue( "callback" )
-                                                        String callback ) throws Exception {
+    public JSONWithPadding getOrganizationApplications(
+        @Context UriInfo ui,
+        @QueryParam( "deleted" ) @DefaultValue( "false" ) Boolean deleted, // only return deleted apps if true
+        @QueryParam( "callback" ) @DefaultValue( "callback" ) String callback ) throws Exception {
 
         ApiResponse response = createApiResponse();
         response.setAction( "get organization application" );
@@ -148,6 +141,17 @@ public class ApplicationsResource extends AbstractContextResource {
 
 
     @RequireOrganizationAccess
+    @Path(RootResource.APPLICATION_ID_PATH)
+    public ApplicationResource restoreApplicationFromOrganizationByApplicationId(
+        @Context UriInfo ui,
+        @PathParam( "applicationId" )
+        String applicationIdStr ) throws Exception {
+
+        return getSubResource( ApplicationResource.class ).init( organization, UUID.fromString( applicationIdStr ) );
+    }
+
+
+    @RequireOrganizationAccess
     @Path( "{applicationName}" )
     public ApplicationResource applicationFromOrganizationByApplicationName( @Context UriInfo ui,
                                                                              @PathParam( "applicationName" )


[19/50] [abbrv] incubator-usergrid git commit: Not needed in git.

Posted by sn...@apache.org.
Not needed in git.


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

Branch: refs/heads/two-dot-o
Commit: 949c22a043728e4c329c38c985641ad148148378
Parents: 2d2bdae
Author: Dave Johnson <dm...@apigee.com>
Authored: Mon Feb 23 16:59:14 2015 -0500
Committer: Dave Johnson <dm...@apigee.com>
Committed: Mon Feb 23 16:59:14 2015 -0500

----------------------------------------------------------------------
 stack/rest/catalina_base/webapps/ROOT | 1 -
 1 file changed, 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/949c22a0/stack/rest/catalina_base/webapps/ROOT
----------------------------------------------------------------------
diff --git a/stack/rest/catalina_base/webapps/ROOT b/stack/rest/catalina_base/webapps/ROOT
deleted file mode 120000
index e92f674..0000000
--- a/stack/rest/catalina_base/webapps/ROOT
+++ /dev/null
@@ -1 +0,0 @@
-../../target/ROOT
\ No newline at end of file


[02/50] [abbrv] incubator-usergrid git commit: Cleanup

Posted by sn...@apache.org.
Cleanup


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

Branch: refs/heads/two-dot-o
Commit: 5d05f86590eb3c4bd740b8aef3c45c7d8bd66ecf
Parents: 4ecaa4d
Author: grey <gr...@apigee.com>
Authored: Thu Feb 19 10:58:59 2015 -0800
Committer: grey <gr...@apigee.com>
Committed: Thu Feb 19 10:58:59 2015 -0800

----------------------------------------------------------------------
 stack/rest/src/test/resources/usergrid-deployment.properties | 2 --
 1 file changed, 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/5d05f865/stack/rest/src/test/resources/usergrid-deployment.properties
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/resources/usergrid-deployment.properties b/stack/rest/src/test/resources/usergrid-deployment.properties
index 24f3da9..34b0aa7 100644
--- a/stack/rest/src/test/resources/usergrid-deployment.properties
+++ b/stack/rest/src/test/resources/usergrid-deployment.properties
@@ -43,8 +43,6 @@ hystrix.threadpool.graph_user.coreSize=10
 hystrix.threadpool.graph_async.coreSize=10
 
 elasticsearch.cluster_name=usergrid
-#elasticsearch.cluster_name=grindrgw-prod
-#elasticsearch.cluster_name=rea1dug001-prod
 elasticsearch.index_prefix=usergrid
 elasticsearch.hosts=127.0.0.1
 elasticsearch.port=9300


[27/50] [abbrv] incubator-usergrid git commit: Merge branch 'USERGRID-273' of https://git-wip-us.apache.org/repos/asf/incubator-usergrid into USERGRID-409

Posted by sn...@apache.org.
Merge branch 'USERGRID-273' of https://git-wip-us.apache.org/repos/asf/incubator-usergrid into USERGRID-409

# By Dave Johnson
# Via Dave Johnson
* 'USERGRID-273' of https://git-wip-us.apache.org/repos/asf/incubator-usergrid:
  Effort to use arquillian-suite-extension
  Adding some JVM options to help with the OOM PermGen problems, and removing all tests from except for one (for now)
  changes to get REST tests working with Arquillian: - Add setenv.sh to set memory and debug options for Tomcat - Make Arqillian profile active by default - Add shutdown hook to stop job service when Usergrid is underplayed


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

Branch: refs/heads/two-dot-o
Commit: 53e73fbeffe8dbe956ed2500918abc6332ef0fbc
Parents: 07755c1 99d694b
Author: grey <gr...@apigee.com>
Authored: Tue Feb 24 12:28:07 2015 -0800
Committer: grey <gr...@apigee.com>
Committed: Tue Feb 24 12:28:07 2015 -0800

----------------------------------------------------------------------
 stack/rest/catalina_base/bin/setenv.sh          |  8 +++
 stack/rest/pom.xml                              | 67 +++++++-----------
 .../usergrid/rest/JobServiceBoostrap.java       |  4 +-
 .../apache/usergrid/rest/ShutdownListener.java  | 73 ++++++++++++++++++++
 .../applications/ApplicationsResource.java      |  1 +
 stack/rest/src/main/webapp/WEB-INF/web.xml      | 13 ++--
 .../apache/usergrid/rest/AbstractRestIT.java    |  7 +-
 .../java/org/apache/usergrid/rest/BasicIT.java  |  5 +-
 stack/rest/src/test/resources/arquillian.xml    | 14 +---
 9 files changed, 123 insertions(+), 69 deletions(-)
----------------------------------------------------------------------



[42/50] [abbrv] incubator-usergrid git commit: Added fix for full use of virtual keyspaces and for token generation using the getKeyspace method.

Posted by sn...@apache.org.
Added fix for full use of virtual keyspaces and for token generation using the getKeyspace method.


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

Branch: refs/heads/two-dot-o
Commit: 48a2be7a6e4c7166b2ce392a278eec7c2544d184
Parents: 95ac7af
Author: grey <gr...@apigee.com>
Authored: Wed Feb 25 16:08:08 2015 -0800
Committer: grey <gr...@apigee.com>
Committed: Wed Feb 25 16:08:08 2015 -0800

----------------------------------------------------------------------
 .../org/apache/usergrid/corepersistence/CpSetup.java | 13 -------------
 .../persistence/cassandra/CassandraService.java      | 11 +++++++++--
 .../usergrid/persistence/cassandra/SetupImpl.java    | 15 +++------------
 3 files changed, 12 insertions(+), 27 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/48a2be7a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpSetup.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpSetup.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpSetup.java
index 345473a..d70c16c 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpSetup.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpSetup.java
@@ -172,19 +172,6 @@ public class CpSetup implements Setup {
     public void setupApplicationKeyspace( final UUID applicationId, String applicationName ) throws Exception {
 
         migrate();
-
-        // Need this legacy stuff for queues
-
-        String app_keyspace = keyspaceForApplication( applicationId );
-
-        logger.info( "Creating application keyspace " + app_keyspace + " for " + applicationName + " application" );
-
-        cass.createColumnFamily( app_keyspace,
-            createColumnFamilyDefinition( getApplicationKeyspace(), APPLICATIONS_CF, ComparatorType.BYTESTYPE ) );
-
-        cass.createColumnFamilies( app_keyspace, getCfDefs( ApplicationCF.class, app_keyspace ) );
-
-        cass.createColumnFamilies( app_keyspace, getCfDefs( QueuesCF.class, app_keyspace ) );
     }
 
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/48a2be7a/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/CassandraService.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/CassandraService.java b/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/CassandraService.java
index 38d9555..96d3fd9 100644
--- a/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/CassandraService.java
+++ b/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/CassandraService.java
@@ -247,8 +247,15 @@ public class CassandraService {
 
 
     public Keyspace getKeyspace( String keyspace, UUID prefix ) {
-        Keyspace ko = createVirtualKeyspace( keyspace, prefix, ue, cluster, consistencyLevelPolicy,
+        Keyspace ko = null;
+        if ( ( prefix != null ) ) {
+            ko = createVirtualKeyspace( keyspace, prefix, ue, cluster, consistencyLevelPolicy,
                     ON_FAIL_TRY_ALL_AVAILABLE, accessMap );
+        }
+        else {
+            ko = HFactory.createKeyspace( keyspace, cluster, consistencyLevelPolicy, ON_FAIL_TRY_ALL_AVAILABLE,
+                    accessMap );
+        }
         return ko;
     }
 
@@ -262,7 +269,7 @@ public class CassandraService {
 
     /** The Usergrid_Applications keyspace directly */
     public Keyspace getUsergridApplicationKeyspace() {
-        return getKeyspace( getApplicationKeyspace(), null );
+        return getKeyspace( getApplicationKeyspace(),  null );
     }
 
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/48a2be7a/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/SetupImpl.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/SetupImpl.java b/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/SetupImpl.java
index e6c52bd..23c0489 100644
--- a/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/SetupImpl.java
+++ b/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/SetupImpl.java
@@ -103,18 +103,9 @@ public class SetupImpl implements Setup {
      * @throws Exception the exception
      */
     @Override
-    public void setupApplicationKeyspace(final UUID applicationId, String applicationName ) throws Exception {
-
-        String app_keyspace = keyspaceForApplication( applicationId );
-
-        logger.info( "Creating application keyspace " + app_keyspace + " for "
-                + applicationName + " application" );
-
-        cass.createColumnFamily( app_keyspace, createColumnFamilyDefinition(
-                getApplicationKeyspace(), APPLICATIONS_CF, ComparatorType.BYTESTYPE ) );
-
-        cass.createColumnFamilies( app_keyspace, getCfDefs( ApplicationCF.class, app_keyspace));
-        cass.createColumnFamilies( app_keyspace, getCfDefs( QueuesCF.class, app_keyspace ) );
+    public void setupApplicationKeyspace(
+            final UUID applicationId, String applicationName ) throws Exception {
+        logger.info("This method no longer needed due to using virtual keyspaces all the time.");
     }
 
 


[31/50] [abbrv] incubator-usergrid git commit: Fixes startup order bug.

Posted by sn...@apache.org.
Fixes startup order bug.

Still broken.  Need to fix mock mail tests.


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

Branch: refs/heads/two-dot-o
Commit: ba7a11aee0c7cc2e66e90acfd6c5dc45f122ed09
Parents: e05800e
Author: Todd Nine <tn...@apigee.com>
Authored: Tue Feb 24 19:21:33 2015 -0700
Committer: Todd Nine <tn...@apigee.com>
Committed: Tue Feb 24 19:21:33 2015 -0700

----------------------------------------------------------------------
 .../apache/usergrid/rest/AbstractRestIT.java    |  14 +-
 .../java/org/apache/usergrid/rest/ITSetup.java  |  48 +----
 .../apache/usergrid/rest/TomcatResource.java    | 182 ------------------
 .../org/apache/usergrid/rest/TomcatRuntime.java | 192 +++++++++++++++++++
 .../rest/management/RegistrationIT.java         |   9 +-
 .../test/resource2point0/AbstractRestIT.java    |  12 +-
 6 files changed, 221 insertions(+), 236 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/ba7a11ae/stack/rest/src/test/java/org/apache/usergrid/rest/AbstractRestIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/AbstractRestIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/AbstractRestIT.java
index 15b2882..082e436 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/AbstractRestIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/AbstractRestIT.java
@@ -28,6 +28,9 @@ 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.java.client.Client;
+import org.apache.usergrid.management.ManagementService;
+import org.apache.usergrid.setup.ConcurrentProcessSingleton;
+
 import org.junit.AfterClass;
 import org.junit.Before;
 import org.junit.Rule;
@@ -64,6 +67,9 @@ public abstract class AbstractRestIT extends JerseyTest {
     private static final Logger LOG = LoggerFactory.getLogger( AbstractRestIT.class );
     private static boolean usersSetup = false;
 
+    protected static TomcatRuntime tomcatRuntime = TomcatRuntime.getInstance();
+
+    protected static final ITSetup setup = ITSetup.getInstance();
 
     private static ClientConfig clientConfig = new DefaultClientConfig();
 
@@ -75,10 +81,6 @@ public abstract class AbstractRestIT extends JerseyTest {
 
     protected static final AppDescriptor descriptor;
 
-    public static ITSetup setup = new ITSetup();
-
-    @Rule
-    public TomcatResource tomcatResource = new TomcatResource();
 
     //private static final URI baseURI = setup.getBaseURI();
 
@@ -186,7 +188,7 @@ public abstract class AbstractRestIT extends JerseyTest {
         setUserPassword( "ed@anuff.com", "sesame" );
 
         client = new Client( "test-organization", "test-app" ).withApiUrl(
-                UriBuilder.fromUri( "http://localhost/" ).port( setup.getTomcatPort() ).build().toString() );
+                UriBuilder.fromUri( "http://localhost/" ).port(tomcatRuntime.getPort() ).build().toString() );
 
         org.apache.usergrid.java.client.response.ApiResponse response =
                 client.authorizeAppUser( "ed@anuff.com", "sesame" );
@@ -206,7 +208,7 @@ public abstract class AbstractRestIT extends JerseyTest {
     @Override
     protected URI getBaseURI() {
         try {
-            return new URI("http://localhost:" + tomcatResource.getPort());
+            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/incubator-usergrid/blob/ba7a11ae/stack/rest/src/test/java/org/apache/usergrid/rest/ITSetup.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/ITSetup.java b/stack/rest/src/test/java/org/apache/usergrid/rest/ITSetup.java
index 7888061..510c992 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/ITSetup.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/ITSetup.java
@@ -35,45 +35,37 @@ import org.apache.usergrid.setup.ConcurrentProcessSingleton;
 /** A {@link org.junit.rules.TestRule} that sets up services. */
 public class ITSetup  {
 
-    private ServiceManagerFactory smf;
+    private static ITSetup instance;
+
     private EntityManagerFactory emf;
-    private ApplicationCreator applicationCreator;
-    private TokenService tokenService;
-    private SignInProviderFactory providerFactory;
     private Properties properties;
     private ManagementService managementService;
-    private TomcatResource tomcatResource;
 
-    private URI uri;
 
     private SpringResource springResource;
 
 
-    public ITSetup( ) {
+    private ITSetup( ) {
 
         this.springResource = ConcurrentProcessSingleton.getInstance().getSpringResource();
 
         emf =                springResource.getBean( EntityManagerFactory.class );
-        smf =                springResource.getBean( ServiceManagerFactory.class );
-        tokenService =       springResource.getBean( TokenService.class );
-        providerFactory =    springResource.getBean( SignInProviderFactory.class );
-        applicationCreator = springResource.getBean( ApplicationCreator.class );
         managementService =  springResource.getBean( ManagementService.class );
+        properties = springResource.getBean( "properties", Properties.class );
 
-        tomcatResource = TomcatResource.instance;
-        tomcatResource.setWebAppsPath( "src/main/webapp" );
 
-        // Initialize Jersey Client
-        //TODO, make this port a resource that's filtered by maven build for the port number
-        uri = UriBuilder.fromUri("http://localhost/").port( 8080 ).build();
     }
 
+    public static synchronized ITSetup getInstance(){
+        if(instance == null){
+            instance = new ITSetup();
+        }
 
-    public int getTomcatPort() {
-        return 8080;
+        return instance;
     }
 
 
+
     public ManagementService getMgmtSvc() {
         return managementService;
     }
@@ -83,28 +75,8 @@ public class ITSetup  {
         return emf;
     }
 
-
-    public ServiceManagerFactory getSmf() {
-        return smf;
-    }
-
-
-    public ApplicationCreator getAppCreator() {
-        return applicationCreator;
-    }
-
-
-    public TokenService getTokenSvc() {
-        return tokenService;
-    }
-
-
     public Properties getProps() {
         return properties;
     }
 
-
-    public SignInProviderFactory getProviderFactory() {
-        return providerFactory;
-    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/ba7a11ae/stack/rest/src/test/java/org/apache/usergrid/rest/TomcatResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/TomcatResource.java b/stack/rest/src/test/java/org/apache/usergrid/rest/TomcatResource.java
deleted file mode 100644
index 5f00f7b..0000000
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/TomcatResource.java
+++ /dev/null
@@ -1,182 +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.rest;
-
-import com.google.common.io.Files;
-import com.sun.jersey.api.client.Client;
-import com.sun.jersey.api.client.WebResource;
-import org.apache.catalina.LifecycleException;
-import org.apache.catalina.startup.Tomcat;
-import org.apache.commons.lang.math.RandomUtils;
-import org.apache.usergrid.cassandra.AvailablePortFinder;
-import org.junit.rules.ExternalResource;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.context.ConfigurableApplicationContext;
-import org.springframework.context.support.ClassPathXmlApplicationContext;
-
-import javax.servlet.ServletException;
-import java.io.File;
-import java.util.concurrent.atomic.AtomicInteger;
-
-
-/**
- * Start and stop embedded Tomcat.
- */
-public class TomcatResource extends ExternalResource {
-    private static final Logger log = LoggerFactory.getLogger(TomcatResource.class);
-
-    public static final TomcatResource instance = new TomcatResource();
-
-    private static final Object mutex = new Object();
-    private String webAppsPath = "src/main/webapp";
-    private int port;
-    private boolean started = false;
-
-    private static AtomicInteger clientCount = new AtomicInteger(0);
-
-    Tomcat tomcat = null;
-    Process process = null;
-
-
-    public TomcatResource() {
-        try {
-            String[] locations = { "usergrid-properties-context.xml" };
-            ConfigurableApplicationContext appContext =
-                new ClassPathXmlApplicationContext( locations );
-
-        } catch (Exception ex) {
-            throw new RuntimeException("Error getting properties", ex);
-        }
-    }
-
-
-    @Override
-    protected void after() {
-        log.info("Entering after");
-
-        synchronized (mutex) {
-
-            if ( clientCount.decrementAndGet() < 1 ) {
-
-                log.info("----------------------------------------------------------------------");
-                log.info("Destroying Tomcat running on port " + port);
-                log.info("----------------------------------------------------------------------");
-
-                if ( process != null ) {
-                    process.destroy();
-
-                } else if ( tomcat != null ) {
-                    try {
-                        tomcat.stop();
-                        tomcat.destroy();
-                    } catch (LifecycleException ex) {
-                        log.error("Error stopping Tomcat", ex);
-                    }
-                }
-                started = false;
-
-            } else {
-                log.info("NOT stopping Tomcat because it is still in use by {}", clientCount.get());
-            }
-        }
-
-        log.info("Leaving after");
-    }
-
-
-    @Override
-    protected void before() throws Throwable {
-        log.info("Entering before");
-
-        synchronized (mutex) {
-
-            clientCount.incrementAndGet();
-
-            if (started) {
-                log.info("NOT starting Tomcat because it is already started");
-                log.info("Leaving before: {} users of Tomcat", clientCount.get());
-                return;
-            }
-
-            startTomcatEmbedded();
-
-            log.info("Leaving before: Started Tomcat, now {} users", clientCount.get());
-        }
-
-    }
-
-
-    private void waitForTomcat() throws RuntimeException {
-        String url = "http://localhost:" + port + "/status";
-        int count = 0;
-        while (count++ < 30) {
-            try {
-                Thread.sleep(1000);
-                Client c = Client.create();
-                WebResource wr = c.resource( url );
-                wr.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.");
-        }
-    }
-
-
-    private void startTomcatEmbedded() throws ServletException, LifecycleException {
-
-        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", "2000");
-        tomcat.addWebapp( "/", new File( getWebAppsPath() ).getAbsolutePath() );
-
-        log.info("-----------------------------------------------------------------");
-        log.info("Starting Tomcat embedded port {} dir {}", port, dataDir.getAbsolutePath());
-        log.info("-----------------------------------------------------------------");
-        tomcat.start();
-
-        waitForTomcat();
-
-        mutex.notifyAll();
-    }
-
-    public int getPort() {
-        return port;
-    }
-
-    public String getWebAppsPath() {
-        return webAppsPath;
-    }
-
-    public void setWebAppsPath(String webAppsPath) {
-        this.webAppsPath = webAppsPath;
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/ba7a11ae/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
new file mode 100644
index 0000000..ab22450
--- /dev/null
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/TomcatRuntime.java
@@ -0,0 +1,192 @@
+/*
+ * 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 java.io.File;
+
+import org.junit.rules.ExternalResource;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.catalina.LifecycleException;
+import org.apache.catalina.startup.Tomcat;
+import org.apache.commons.lang.math.RandomUtils;
+
+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;
+
+
+/**
+ * Start and stop embedded Tomcat.
+ */
+public class TomcatRuntime extends ExternalResource {
+    private static final Logger log = LoggerFactory.getLogger( TomcatRuntime.class );
+
+
+    private static final String WEBAPPS_PATH = "src/main/webapp";
+
+    private static TomcatRuntime instance;
+
+    public final TomcatInstance tomcat;
+
+
+    private TomcatRuntime() {
+
+        //before we run tomcat, we need to cleanup our data
+        ConcurrentProcessSingleton.getInstance();
+
+        tomcat = new TomcatInstance( WEBAPPS_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 = Client.create();
+                    WebResource wr = c.resource( url );
+                    wr.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/incubator-usergrid/blob/ba7a11ae/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 aca33ba..f949da3 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
@@ -43,6 +43,7 @@ import org.slf4j.LoggerFactory;
 import org.apache.usergrid.management.UserInfo;
 import org.apache.usergrid.persistence.model.util.UUIDGenerator;
 import org.apache.usergrid.rest.AbstractRestIT;
+import org.apache.usergrid.rest.ITSetup;
 import org.apache.usergrid.rest.TestContextSetup;
 import org.apache.usergrid.rest.test.security.TestAppUser;
 import org.apache.usergrid.rest.test.security.TestUser;
@@ -71,6 +72,8 @@ public class RegistrationIT extends AbstractRestIT {
 
     private static final Logger logger = LoggerFactory.getLogger( RegistrationIT.class );
 
+    private static final ITSetup setup = ITSetup.getInstance();
+
     @Rule
     public TestContextSetup context = new TestContextSetup( this );
 
@@ -100,7 +103,7 @@ public class RegistrationIT extends AbstractRestIT {
             context.createAppForOrg();
 
             final UUID owner_uuid = context.getActiveUser().getUuid();
-            
+
 //            refreshIndex("test-organization", "test-app");
 //
 //            UUID owner_uuid =
@@ -309,7 +312,7 @@ public class RegistrationIT extends AbstractRestIT {
             String adminUserName = "AdminUserFromOtherOrg";
             String adminUserEmail = "AdminUserFromOtherOrg@otherorg.com";
 
-            UserInfo adminUser = setup.getMgmtSvc().createAdminUser( 
+            UserInfo adminUser = setup.getMgmtSvc().createAdminUser(
                     adminUserEmail, adminUserEmail, adminUserEmail, "password1", true, false );
 
             refreshIndex("test-organization", "test-app");
@@ -323,7 +326,7 @@ public class RegistrationIT extends AbstractRestIT {
             // this should NOT send resetpwd link in email to newly added org admin user(that
             // already exists in usergrid) only "User Invited To Organization" email
             String adminToken = adminToken();
-            JsonNode node = postAddAdminToOrg( "test-organization", 
+            JsonNode node = postAddAdminToOrg( "test-organization",
                     adminUserEmail, "password1", adminToken );
             String uuid = node.get( "data" ).get( "user" ).get( "uuid" ).textValue();
             UUID userId = UUID.fromString( uuid );

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/ba7a11ae/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/AbstractRestIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/AbstractRestIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/AbstractRestIT.java
index 43d0ba4..90d3d55 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/AbstractRestIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/AbstractRestIT.java
@@ -28,7 +28,7 @@ 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.ITSetup;
-import org.apache.usergrid.rest.TomcatResource;
+import org.apache.usergrid.rest.TomcatRuntime;
 import org.apache.usergrid.rest.test.resource2point0.endpoints.ApplicationsResource;
 import org.apache.usergrid.rest.test.resource2point0.endpoints.OrganizationResource;
 import org.apache.usergrid.rest.test.resource2point0.endpoints.mgmt.ManagementResource;
@@ -53,12 +53,10 @@ public class AbstractRestIT extends JerseyTest {
 
     private static ClientConfig clientConfig = new DefaultClientConfig();
 
-    @Rule
-    public TomcatResource tomcatResource = new TomcatResource();
+    public static TomcatRuntime tomcatRuntime = TomcatRuntime.getInstance();
+
+
 
-    public static ITSetup setup = new ITSetup(  );
-//
-//    TODO: Allow the client to be setup seperately
     @Rule
     public ClientSetup clientSetup = new ClientSetup( this.getBaseURI().toString() );
 
@@ -112,7 +110,7 @@ public class AbstractRestIT extends JerseyTest {
     @Override
     protected URI getBaseURI() {
         try {
-            return new URI("http://localhost:" + tomcatResource.getPort());
+            return new URI("http://localhost:" + tomcatRuntime.getPort());
         } catch (URISyntaxException e) {
             throw new RuntimeException("Error determining baseURI", e);
         }