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/07/10 15:37:55 UTC

[49/50] [abbrv] incubator-usergrid git commit: Merge branch 'master' into two-dot-o

Merge branch 'master' into two-dot-o

Conflicts:
	stack/core/src/main/resources/usergrid-core-context.xml
	stack/rest/src/test/java/org/apache/usergrid/rest/applications/ApplicationResourceIT.java
	stack/services/src/main/java/org/apache/usergrid/security/shiro/Realm.java
	stack/tools/src/main/java/org/apache/usergrid/tools/ExportAdmins.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/81082f35
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/81082f35
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/81082f35

Branch: refs/heads/two-dot-o-import
Commit: 81082f3588279fa5c0c3495a36f9aee6bc41d2b7
Parents: e1cdc73 107a465
Author: Dave Johnson <dm...@apigee.com>
Authored: Fri Jun 19 10:42:11 2015 -0400
Committer: Dave Johnson <dm...@apigee.com>
Committed: Fri Jun 19 10:42:11 2015 -0400

----------------------------------------------------------------------
 .../main/resources/usergrid-core-context.xml    |   2 +-
 .../applications/ApplicationResourceIT.java     | 112 ++--
 .../cassandra/ManagementServiceImpl.java        |   3 +-
 .../apache/usergrid/management/EmailFlowIT.java |   6 +-
 .../org/apache/usergrid/tools/ExportAdmins.java | 469 +++++++++++----
 .../org/apache/usergrid/tools/ImportAdmins.java | 598 ++++++++++++++-----
 6 files changed, 872 insertions(+), 318 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/81082f35/stack/core/src/main/resources/usergrid-core-context.xml
----------------------------------------------------------------------
diff --cc stack/core/src/main/resources/usergrid-core-context.xml
index 4424896,7e69e19..53ae4e2
--- a/stack/core/src/main/resources/usergrid-core-context.xml
+++ b/stack/core/src/main/resources/usergrid-core-context.xml
@@@ -54,9 -54,7 +54,9 @@@
  		<constructor-arg value="${cassandra.url}" />
          <!-- set the pool size if it's available.  If not go with 50 -->
          <property name="maxActive" value="${cassandra.connections:20}"/>
 +        <property name="cassandraThriftSocketTimeout" value="${cassandra.thriftSocketTimeout:0}" />
 +        <property name="useSocketKeepalive" value="${cassandra.useSocketKeepalive:false}" />
-         <!-- <property name="clockResolution" ref="microsecondsTimeResolution" /> -->
+         <!-- Fails on Java 8: <property name="clockResolution" ref="microsecondsTimeResolution" />-->
          <property name="opTimer" ref="taggedOpTimer"/>
          <property name="loadBalancingPolicy" ref="loadBalancingPolicy"/>
  	</bean>

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/81082f35/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 104d436,469bf60..8629ccb
--- 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,29 -16,32 +16,29 @@@
   */
  package org.apache.usergrid.rest.applications;
  
 -
 -import java.util.HashMap;
 -import java.util.Map;
 -
 -import javax.ws.rs.core.MediaType;
 -
 -import org.codehaus.jackson.JsonNode;
 -import org.junit.Ignore;
 -import org.junit.Test;
 -import org.apache.usergrid.cassandra.Concurrent;
 -import org.apache.usergrid.management.ApplicationInfo;
 -import org.apache.usergrid.management.OrganizationInfo;
 -import org.apache.usergrid.rest.AbstractRestIT;
 -import org.apache.usergrid.rest.management.organizations.OrganizationsResource;
 -
 -import org.apache.shiro.codec.Base64;
 -
 -import com.sun.jersey.api.client.ClientResponse;
 +import com.fasterxml.jackson.databind.JsonNode;
- 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.persistence.index.utils.UUIDUtils;
++import org.apache.usergrid.management.ApplicationInfo;
 +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 java.util.HashMap;
++import java.util.Map;
  
 -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 static org.junit.Assert.*;
  
  
  /**
@@@ -78,83 -71,45 +78,121 @@@ public class ApplicationResourceIT exte
      @Test
      public void applicationWithAppCredentials() throws Exception {
  
 -        String orgName = "MiXedApplicationResourceTest";
 -        String appName = "mgmt-org-app-test";
 -
 -        //create new org
 -        Map payload = hashMap( "email", "test-user-1@mockserver.com" ).map( "username", "ApplicationAppCredsTest" )
 -                                                                      .map( "name", "App Creds User" )
 -                                                                      .map( "password", "password" )
 -                                                                      .map( "organization",
 -                                                                              orgName );
 -
 -        resource().path( "/management/organizations" ).accept( MediaType.APPLICATION_JSON )
 -                                  .type( MediaType.APPLICATION_JSON_TYPE ).post( JsonNode.class, payload );
 -
 -        //create new app
 -        Map<String, String> data = new HashMap<String, String>();
 -        data.put( "name", appName );
 -
 -        JsonNode appdata = resource().path( "/management/orgs/" + orgName + "/applications" )
 -                                     .queryParam( "access_token", superAdminToken() ).accept( MediaType.APPLICATION_JSON )
 -                                     .type( MediaType.APPLICATION_JSON_TYPE ).post( JsonNode.class, data );
 -
 -
 -        ApplicationInfo appInfo = setup.getMgmtSvc().getApplicationInfo(orgName+"/"+appName );//"test-organization/test-app" );
 -
 -        //don't know what kind of creds these are but they sure aren't app creds...
 -        String clientId = setup.getMgmtSvc().getClientIdForApplication( appInfo.getId() );
 -        String clientSecret = setup.getMgmtSvc().getClientSecretForApplication( appInfo.getId() );
 -
 -        JsonNode applicationCredentials = resource().path( "/"+orgName.toLowerCase()+"/"+appName+"/credentials" ).queryParam( "client_id", clientId )
 +        //retrieve the credentials
 +        Credentials appCredentials = getAppCredentials();
 +
 +        //retrieve the app using only the org credentials
 +        ApiResponse apiResponse = this.app().getResource(false)
 +            .queryParam("grant_type", "client_credentials")
 +            .queryParam("client_id", appCredentials.getClientId())
 +            .queryParam("client_secret", appCredentials.getClientSecret())
 +            .accept(MediaType.APPLICATION_JSON)
 +            .type(MediaType.APPLICATION_JSON_TYPE)
 +            .get(ApiResponse.class);
 +        //assert that a valid response is returned without error
 +        assertNotNull(apiResponse);
 +        assertNull(apiResponse.getError());
 +    }
  
 -                                                    .queryParam( "client_secret", clientSecret ).accept( MediaType.APPLICATION_JSON )
 -                                                    .type( MediaType.APPLICATION_JSON_TYPE ).get( JsonNode.class );
 +    /**
 +     * Retrieve an collection using the application client credentials
 +     */
 +    @Test
 +    public void applicationCollectionWithAppCredentials() throws Exception {
 +
 +        //retrieve the credentials
 +        Credentials appCredentials = getAppCredentials();
 +
 +        //retrieve the app using only the org credentials
 +        ApiResponse apiResponse = this.app().collection( "roles" ).getResource( false )
 +                                      .queryParam("grant_type", "client_credentials")
 +                                      .queryParam("client_id", appCredentials.getClientId())
 +                                      .queryParam("client_secret", appCredentials.getClientSecret())
 +                                      .accept(MediaType.APPLICATION_JSON)
 +                                      .type(MediaType.APPLICATION_JSON_TYPE)
 +                                      .get(ApiResponse.class);
 +        //assert that a valid response is returned without error
 +        assertNotNull(apiResponse);
 +        assertNull(apiResponse.getError());
 +
 +        Collection roles = new Collection(apiResponse);
 +        //assert that we have the correct number of default roles
 +        assertEquals(3, roles.getNumOfEntities());
 +    }
  
-     /**
-      * Retrieve an collection using the application client credentials
-      */
-     @Test
-     public void applicationCollectionWithAppToken() throws Exception {
- 
-         Credentials appCredentials = getAppCredentials();
- 
-         QueryParameters queryParameters = new QueryParameters();
-         queryParameters.addParam("grant_type", "client_credentials");
-         queryParameters.addParam("client_id", appCredentials.getClientId());
-         queryParameters.addParam("client_secret", appCredentials.getClientSecret());
- 
-         Entity testUser = new Entity(  );
-         testUser.chainPut( "name","temp" ).chainPut( "password","temp1" );
-         
-         Token appToken = this.app().token().post(new Token("client_credentials",appCredentials.getClientId(),appCredentials.getClientSecret() ));
- 
- 
-         //retrieve the credentials
- 
-         //retrieve the app using only the org credentials
-         ApiResponse apiResponse = this.app().collection( "roles" ).getResource( true, appToken )
-                                       .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());
- 
-         Collection roles = new Collection(apiResponse);
-         //assert that we have the correct number of default roles
-         assertEquals(3, roles.getNumOfEntities());
-     }
 -        JsonNode node = resource().path( "/"+orgName.toLowerCase()+"/"+appName+"/users" ).queryParam( "client_id", applicationCredentials.get( "credentials" ).get( "client_id" ).asText())
 -                .queryParam( "client_secret", applicationCredentials.get( "credentials" ).get( "client_secret" ).asText() ).accept( MediaType.APPLICATION_JSON )
 -                .type( MediaType.APPLICATION_JSON_TYPE ).get( JsonNode.class );
++    // TODO: rewrite with new framework in two-dot-o-dev
++//    /**
++//     * Retrieve an collection using the application client credentials
++//     */
++//    @Test
++//    public void applicationCollectionWithAppToken() throws Exception {
++//
++//        Credentials appCredentials = getAppCredentials();
++//
++//        QueryParameters queryParameters = new QueryParameters();
++//        queryParameters.addParam("grant_type", "client_credentials");
++//        queryParameters.addParam("client_id", appCredentials.getClientId());
++//        queryParameters.addParam("client_secret", appCredentials.getClientSecret());
++//
++//        Entity testUser = new Entity(  );
++//        testUser.chainPut( "name","temp" ).chainPut( "password","temp1" );
++//
++//        Token appToken = this.app().token().post(
++//            new Token("client_credentials",appCredentials.getClientId(),appCredentials.getClientSecret() ));
++//
++//        String orgName = "MiXedApplicationResourceTest";
++//        String appName = "mgmt-org-app-test";
++//
++//        //create new org
++//        Map payload = hashMap( "email", "test-user-1@mockserver.com" ).map( "username", "ApplicationAppCredsTest" )
++//                                                                      .map( "name", "App Creds User" )
++//                                                                      .map( "password", "password" )
++//                                                                      .map( "organization", orgName );
++//
++//        resource().path( "/management/organizations" ).accept( MediaType.APPLICATION_JSON )
++//                                  .type( MediaType.APPLICATION_JSON_TYPE ).post( JsonNode.class, payload );
++//
++//        //create new app
++//        Map<String, String> data = new HashMap<String, String>();
++//        data.put( "name", appName );
++//
++//        JsonNode appdata = resource().path( "/management/orgs/" + orgName + "/applications" )
++//                                     .queryParam( "access_token", superAdminToken() ).accept( MediaType.APPLICATION_JSON )
++//                                     .type( MediaType.APPLICATION_JSON_TYPE ).post( JsonNode.class, data );
++//
++//
++//        ApplicationInfo appInfo = setup.getMgmtSvc().getApplicationInfo(orgName+"/"+appName );//"test-organization/test-app" );
++//
++//        //don't know what kind of creds these are but they sure aren't app creds...
++//        String clientId = setup.getMgmtSvc().getClientIdForApplication( appInfo.getId() );
++//        String clientSecret = setup.getMgmtSvc().getClientSecretForApplication( appInfo.getId() );
++//
++//        JsonNode applicationCredentials = resource().path( "/"+orgName.toLowerCase()+"/"+appName+"/credentials" ).queryParam( "client_id", clientId )
++//
++//                                                    .queryParam( "client_secret", clientSecret ).accept( MediaType.APPLICATION_JSON )
++//                                                    .type( MediaType.APPLICATION_JSON_TYPE ).get( JsonNode.class );
++//
++//        JsonNode node = resource().path( "/"+orgName.toLowerCase()+"/"+appName+"/users" ).queryParam( "client_id", applicationCredentials.get( "credentials" ).get( "client_id" ).asText())
++//                .queryParam( "client_secret", applicationCredentials.get( "credentials" ).get( "client_secret" ).asText() ).accept( MediaType.APPLICATION_JSON )
++//                .type( MediaType.APPLICATION_JSON_TYPE ).get( JsonNode.class );
++//
++//
++//        //retrieve the credentials
++//
++//        //retrieve the app using only the org credentials
++//        ApiResponse apiResponse = this.app().collection( "roles" ).getResource( true, appToken )
++//                                      .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());
++//
++//        Collection roles = new Collection(apiResponse);
++//        //assert that we have the correct number of default roles
++//        assertEquals(3, roles.getNumOfEntities());
++//    }
  
 -        assertNotNull( node.get( "entities" ) );
 -    }
  
      /**
       * Verifies that we return JSON even when no accept header is specified.

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/81082f35/stack/services/src/main/java/org/apache/usergrid/management/cassandra/ManagementServiceImpl.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/81082f35/stack/services/src/test/java/org/apache/usergrid/management/EmailFlowIT.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/81082f35/stack/tools/src/main/java/org/apache/usergrid/tools/ExportAdmins.java
----------------------------------------------------------------------
diff --cc stack/tools/src/main/java/org/apache/usergrid/tools/ExportAdmins.java
index 5bbad14,e781a1c..75064a2
--- a/stack/tools/src/main/java/org/apache/usergrid/tools/ExportAdmins.java
+++ b/stack/tools/src/main/java/org/apache/usergrid/tools/ExportAdmins.java
@@@ -17,22 -17,24 +17,31 @@@
  
  package org.apache.usergrid.tools;
  
- import org.apache.usergrid.persistence.index.query.Query;
 -
  import com.google.common.collect.BiMap;
  import org.apache.commons.cli.CommandLine;
+ import org.apache.commons.cli.Option;
+ import org.apache.commons.cli.OptionBuilder;
+ import org.apache.commons.cli.Options;
 -import org.apache.usergrid.persistence.*;
 +import org.apache.usergrid.corepersistence.util.CpNamingUtils;
 +import org.apache.usergrid.persistence.ConnectionRef;
 +import org.apache.usergrid.persistence.Entity;
 +import org.apache.usergrid.persistence.EntityManager;
 +import org.apache.usergrid.persistence.Results;
+ import org.apache.usergrid.persistence.Results.Level;
+ import org.apache.usergrid.persistence.cassandra.CassandraService;
++import org.apache.usergrid.persistence.index.query.Query;
+ import org.apache.usergrid.utils.StringUtils;
  import org.codehaus.jackson.JsonGenerator;
  import org.slf4j.Logger;
  import org.slf4j.LoggerFactory;
  
 -import java.util.*;
 +import java.util.List;
 +import java.util.Map;
 +import java.util.Set;
 +import java.util.UUID;
+ import java.util.concurrent.BlockingQueue;
+ import java.util.concurrent.LinkedBlockingQueue;
+ import java.util.concurrent.TimeUnit;
  
  
  /**