usergrid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From toddn...@apache.org
Subject [1/2] Merging from lastest stable changes
Date Thu, 05 Dec 2013 22:41:00 GMT
Updated Branches:
  refs/heads/master da6eb8524 -> e2ee790de


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e2ee790d/stack/rest/src/test/java/org/usergrid/rest/applications/ApplicationResourceIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/usergrid/rest/applications/ApplicationResourceIT.java
b/stack/rest/src/test/java/org/usergrid/rest/applications/ApplicationResourceIT.java
index f799c5a..e316bef 100644
--- a/stack/rest/src/test/java/org/usergrid/rest/applications/ApplicationResourceIT.java
+++ b/stack/rest/src/test/java/org/usergrid/rest/applications/ApplicationResourceIT.java
@@ -63,7 +63,6 @@ public class ApplicationResourceIT extends AbstractRestIT {
         assertNotNull( node.get( "entities" ) );
     }
 
-
     @Test
     public void applicationWithAppCredentials() throws Exception {
 
@@ -79,6 +78,46 @@ public class ApplicationResourceIT extends AbstractRestIT {
         assertNotNull( node.get( "entities" ) );
     }
 
+    /**
+     * Verifies that we return JSON even when no accept header is specified.
+     * (for backwards compatibility)
+     */
+    @Test
+    public void jsonForNoAccepts() 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()
);
+
+        JsonNode node = resource()
+                .path( "/test-organization/test-app" )
+                .queryParam( "client_id", clientId )
+                .queryParam( "client_secret", clientSecret )
+                .get( JsonNode.class );
+
+        assertNotNull( node.get( "entities" ) );
+    }
+
+    /**
+     * Verifies that we return JSON even when text/html is requested. 
+     * (for backwards compatibility)
+     */
+    @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()
);
+
+        JsonNode node = resource()
+                .path( "/test-organization/test-app" )
+                .queryParam( "client_id", clientId )
+                .queryParam( "client_secret", clientSecret )
+                .accept( MediaType.TEXT_HTML )
+                .get( JsonNode.class );
+
+        assertNotNull( node.get( "entities" ) );
+    }
 
     @Test
     public void applicationWithJsonCreds() throws Exception {
@@ -295,7 +334,6 @@ public class ApplicationResourceIT extends AbstractRestIT {
 
 
     @Test
-    @Ignore("We need to fix JSPs in our test harness")
     public void authorizationCodeWithWrongCredentials() throws Exception {
         ApplicationInfo appInfo = setup.getMgmtSvc().getApplicationInfo( "test-organization/test-app"
);
         String clientId = setup.getMgmtSvc().getClientIdForApplication( appInfo.getId() );
@@ -316,7 +354,6 @@ public class ApplicationResourceIT extends AbstractRestIT {
     }
 
 
-    @Ignore("Our JSPs in the test runtime are borked. TODO zznate")
     @Test
     public void authorizeWithInvalidClientIdRaisesError() throws Exception {
         String result =

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e2ee790d/stack/rest/src/test/java/org/usergrid/rest/applications/collection/BadGrammarQueryTest.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/usergrid/rest/applications/collection/BadGrammarQueryTest.java
b/stack/rest/src/test/java/org/usergrid/rest/applications/collection/BadGrammarQueryTest.java
new file mode 100644
index 0000000..11fa979
--- /dev/null
+++ b/stack/rest/src/test/java/org/usergrid/rest/applications/collection/BadGrammarQueryTest.java
@@ -0,0 +1,60 @@
+package org.usergrid.rest.applications.collection;
+
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.codehaus.jackson.JsonNode;
+import org.junit.Rule;
+import org.junit.Test;
+import org.usergrid.rest.AbstractRestIT;
+import org.usergrid.rest.TestContextSetup;
+import org.usergrid.rest.test.resource.CustomCollection;
+
+import com.sun.jersey.api.client.ClientResponse;
+import com.sun.jersey.api.client.UniformInterfaceException;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+import static org.usergrid.utils.MapUtils.hashMap;
+
+
+/**
+ * @author tnine
+ */
+public class BadGrammarQueryTest extends AbstractRestIT {
+
+    @Rule
+    public TestContextSetup context = new TestContextSetup( this );
+
+
+    @Test
+    public void catchBadQueryGrammar() {
+
+        CustomCollection things = context.collection( "things" );
+
+        Map actor = hashMap( "displayName", "Erin" );
+        Map props = new HashMap();
+        props.put( "actor", actor );
+        props.put( "content", "bragh" );
+
+        JsonNode activity = things.create( props );
+
+        String query = "select * where name != 'go'";
+
+        ClientResponse.Status status = null;
+
+        try {
+
+            JsonNode incorrectNode = things.query( query, "limit", Integer.toString( 10 )
);
+            fail( "This should throw an exception" );
+        }
+        catch ( UniformInterfaceException uie ) {
+             status = uie.getResponse().getClientResponseStatus();
+
+
+        }
+
+        assertEquals( 400, status.getStatusCode() );
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e2ee790d/stack/rest/src/test/java/org/usergrid/rest/applications/collection/BrowserCompatibilityTest.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/usergrid/rest/applications/collection/BrowserCompatibilityTest.java
b/stack/rest/src/test/java/org/usergrid/rest/applications/collection/BrowserCompatibilityTest.java
new file mode 100644
index 0000000..b363193
--- /dev/null
+++ b/stack/rest/src/test/java/org/usergrid/rest/applications/collection/BrowserCompatibilityTest.java
@@ -0,0 +1,86 @@
+/*******************************************************************************
+ * Copyright 2012 Apigee Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ******************************************************************************/
+package org.usergrid.rest.applications.collection;
+
+
+import java.util.Map;
+import java.util.UUID;
+
+import org.codehaus.jackson.JsonNode;
+import org.junit.Rule;
+import org.junit.Test;
+import org.usergrid.cassandra.Concurrent;
+import org.usergrid.rest.AbstractRestIT;
+import org.usergrid.rest.TestContextSetup;
+import org.usergrid.rest.test.resource.CustomCollection;
+
+import static junit.framework.Assert.assertNotNull;
+import static org.junit.Assert.assertEquals;
+import static org.usergrid.utils.MapUtils.hashMap;
+
+
+/**
+ * Simple tests to test querying at the REST tier
+ */
+@Concurrent()
+public class BrowserCompatibilityTest extends AbstractRestIT {
+
+
+    @Rule
+    public TestContextSetup context = new TestContextSetup( this );
+
+
+    @Test
+    public void testChromeHtmlTypes() throws Exception {
+        testBrowserAccept( "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8"
);
+    }
+
+
+    @Test
+    public void testFireFoxHtmlTypes() throws Exception {
+        testBrowserAccept( "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"
);
+    }
+
+
+    @Test
+    public void testSafariTypes() throws Exception {
+        testBrowserAccept( "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"
);
+    }
+
+
+    private void testBrowserAccept( String acceptHeader ) {
+
+
+        CustomCollection things = context.application().collection( "things" );
+
+        Map<String, String> entity = hashMap( "name", "thing1" );
+        JsonNode response = things.create( entity );
+
+        UUID entityId = getEntityId( response, 0 );
+
+        assertNotNull( entityId );
+
+        //now get it with "text/html" in the type
+
+        //now try and retrieve it
+        response = things.entity( entityId ).withAccept( acceptHeader ).get();
+
+        UUID returnedEntityId = getEntityId( response, 0 );
+
+
+        assertEquals( entityId, returnedEntityId );
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e2ee790d/stack/rest/src/test/java/org/usergrid/rest/applications/users/ActivityResourceIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/usergrid/rest/applications/users/ActivityResourceIT.java
b/stack/rest/src/test/java/org/usergrid/rest/applications/users/ActivityResourceIT.java
index 7dd830a..b0e7fdb 100644
--- a/stack/rest/src/test/java/org/usergrid/rest/applications/users/ActivityResourceIT.java
+++ b/stack/rest/src/test/java/org/usergrid/rest/applications/users/ActivityResourceIT.java
@@ -68,6 +68,7 @@ public class ActivityResourceIT extends AbstractRestIT {
         try {
             ApiResponse groupActivity = client.postGroupActivity( GROUP, null );
             fail = (groupActivity.getError() != null);
+            
         }
         catch ( Exception e ) {
             fail = true;

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e2ee790d/stack/rest/src/test/java/org/usergrid/rest/applications/users/GroupResourceIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/usergrid/rest/applications/users/GroupResourceIT.java
b/stack/rest/src/test/java/org/usergrid/rest/applications/users/GroupResourceIT.java
index 291d73e..c440d9b 100644
--- a/stack/rest/src/test/java/org/usergrid/rest/applications/users/GroupResourceIT.java
+++ b/stack/rest/src/test/java/org/usergrid/rest/applications/users/GroupResourceIT.java
@@ -70,7 +70,6 @@ public class GroupResourceIT extends AbstractRestIT {
     }
 
 
-    //    @Ignore
     @Test
     public void failGroupNameValidation() {
 
@@ -82,8 +81,7 @@ public class GroupResourceIT extends AbstractRestIT {
             try {
                 ApiResponse groupResponse = client.createGroup( "groupName withspace" );
                 failed = groupResponse.getError() != null;
-            } 
-            catch ( Exception e ) {
+            } catch ( Exception e ) {
                 failed = true;
             }
             assertTrue( failed );

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e2ee790d/stack/rest/src/test/java/org/usergrid/rest/management/organizations/OrganizationsResourceIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/usergrid/rest/management/organizations/OrganizationsResourceIT.java
b/stack/rest/src/test/java/org/usergrid/rest/management/organizations/OrganizationsResourceIT.java
index 69180bb..ecaa8a4 100644
--- a/stack/rest/src/test/java/org/usergrid/rest/management/organizations/OrganizationsResourceIT.java
+++ b/stack/rest/src/test/java/org/usergrid/rest/management/organizations/OrganizationsResourceIT.java
@@ -36,6 +36,7 @@ import static org.usergrid.management.AccountCreationProps.PROPERTIES_SYSADMIN_E
 import static org.usergrid.utils.MapUtils.hashMap;
 
 
+/** @author zznate */
 public class OrganizationsResourceIT extends AbstractRestIT {
     private static final Logger LOG = LoggerFactory.getLogger( OrganizationsResourceIT.class
);
 
@@ -252,4 +253,4 @@ public class OrganizationsResourceIT extends AbstractRestIT {
 
         assertEquals( Status.NOT_IMPLEMENTED, status );
     }
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e2ee790d/stack/rest/src/test/java/org/usergrid/rest/management/users/MUUserResourceIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/usergrid/rest/management/users/MUUserResourceIT.java
b/stack/rest/src/test/java/org/usergrid/rest/management/users/MUUserResourceIT.java
index 8cc8daa..31e4517 100644
--- a/stack/rest/src/test/java/org/usergrid/rest/management/users/MUUserResourceIT.java
+++ b/stack/rest/src/test/java/org/usergrid/rest/management/users/MUUserResourceIT.java
@@ -40,6 +40,9 @@ import org.usergrid.management.UserInfo;
 import org.usergrid.rest.AbstractRestIT;
 import org.usergrid.rest.TestContextSetup;
 import org.usergrid.rest.management.organizations.OrganizationsResource;
+import org.usergrid.rest.test.resource.mgmt.Organization;
+import org.usergrid.rest.test.security.TestAdminUser;
+import org.usergrid.rest.test.security.TestUser;
 import org.usergrid.security.AuthPrincipalInfo;
 import org.usergrid.security.AuthPrincipalType;
 import org.usergrid.utils.UUIDUtils;
@@ -79,7 +82,7 @@ public class MUUserResourceIT extends AbstractRestIT {
      * From USERGRID-2075
      */
     @Test
-    @Ignore( "aok - check this please" )
+//    @Ignore( "aok - check this please" )
     public void testCaseSensitivityAdminUser() throws Exception {
         LOG.info( "Starting testCaseSensitivityAdminUser()" );
         UserInfo mixcaseUser = setup.getMgmtSvc()
@@ -320,13 +323,26 @@ public class MUUserResourceIT extends AbstractRestIT {
         Map<String, Object> properties = new HashMap<String, Object>();
         properties.put( "securityLevel", 5 );
         payload.put( OrganizationsResource.ORGANIZATION_PROPERTIES, properties );
-        JsonNode node = resource().path( "/management/organizations/test-organization" )
-                .queryParam( "access_token", superAdminToken() ).accept( MediaType.APPLICATION_JSON
)
-                .type( MediaType.APPLICATION_JSON_TYPE ).put( JsonNode.class, payload );
 
-        // ensure the organization property is included
-        node = resource().path( "/management/users/test@usergrid.com" ).queryParam( "access_token",
adminAccessToken )
-                .accept( MediaType.APPLICATION_JSON ).type( MediaType.APPLICATION_JSON_TYPE
).get( JsonNode.class );
+
+        /**
+         * Get the original org admin before we overwrite the property as a super user
+         */
+        final TestUser orgAdmin = context.getActiveUser();
+        final String orgName = context.getOrgName();
+        final String superAdminToken = superAdminToken();
+
+        TestAdminUser superAdmin = new TestAdminUser( "super", "super", "superuser@usergrid.com"
);
+        superAdmin.setToken( superAdminToken );
+
+        Organization org = context.withUser( superAdmin ).management().orgs().organization(
orgName );
+
+        org.put( payload );
+
+
+        //now get the org
+        JsonNode node = context.withUser( orgAdmin ).management().users().user( orgAdmin.getUser()
).get();
+
         logNode( node );
 
         JsonNode applications = node.findValue( "applications" );
@@ -343,19 +359,33 @@ public class MUUserResourceIT extends AbstractRestIT {
     @Test
     public void getUserShallow() throws Exception {
 
+
         // set an organization property
         HashMap<String, Object> payload = new HashMap<String, Object>();
         Map<String, Object> properties = new HashMap<String, Object>();
         properties.put( "securityLevel", 5 );
         payload.put( OrganizationsResource.ORGANIZATION_PROPERTIES, properties );
-        JsonNode node = resource().path( "/management/organizations/test-organization" )
-                .queryParam( "access_token", superAdminToken() ).accept( MediaType.APPLICATION_JSON
)
-                .type( MediaType.APPLICATION_JSON_TYPE ).put( JsonNode.class, payload );
 
-        // ensure the organization property is included
-        node = resource().path( "/management/users/test@usergrid.com" ).queryParam( "access_token",
adminAccessToken )
-                .queryParam( "shallow", "true" ).accept( MediaType.APPLICATION_JSON )
-                .type( MediaType.APPLICATION_JSON_TYPE ).get( JsonNode.class );
+
+        /**
+         * Get the original org admin before we overwrite the property as a super user
+         */
+        final TestUser orgAdmin = context.getActiveUser();
+        final String orgName = context.getOrgName();
+        final String superAdminToken  = superAdminToken();
+
+        TestAdminUser superAdmin = new TestAdminUser( "super", "super", "superuser@usergrid.com"
);
+        superAdmin.setToken( superAdminToken );
+
+        Organization org = context.withUser( superAdmin ).management().orgs().organization(
orgName );
+
+        org.put( payload );
+
+
+        //now get the org
+        JsonNode node = context.withUser( orgAdmin ).management().users().user( orgAdmin.getUser()
).withParam(
+                "shallow", "true" ).get();
+
         logNode( node );
 
         JsonNode applications = node.findValue( "applications" );
@@ -405,10 +435,12 @@ public class MUUserResourceIT extends AbstractRestIT {
 
 
     @Test
-    @Ignore( "because of that jstl classloader error thing" )
+//    @Ignore( "because of that jstl classloader error thing" )
     public void checkPasswordReset() throws Exception {
 
-        String email = "test@usergrid.com";
+        TestUser user = context.getActiveUser();
+
+        String email = user.getEmail();
         UserInfo userInfo = setup.getMgmtSvc().getAdminUserByEmail( email );
         String resetToken = setup.getMgmtSvc().getPasswordResetTokenForAdminUser( userInfo.getUuid(),
15000 );
 
@@ -510,10 +542,11 @@ public class MUUserResourceIT extends AbstractRestIT {
 
 
     @Test
-    @Ignore( "because of that jstl classloader error thing" )
+//    @Ignore( "because of that jstl classloader error thing" )
     public void checkPasswordChangeTime() throws Exception {
 
-        String email = "test@usergrid.com";
+        final TestUser user = context.getActiveUser();
+        String email = user.getEmail();
         UserInfo userInfo = setup.getMgmtSvc().getAdminUserByEmail( email );
         String resetToken = setup.getMgmtSvc().getPasswordResetTokenForAdminUser( userInfo.getUuid(),
15000 );
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e2ee790d/stack/rest/src/test/java/org/usergrid/rest/test/resource/NamedResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/usergrid/rest/test/resource/NamedResource.java b/stack/rest/src/test/java/org/usergrid/rest/test/resource/NamedResource.java
index 285eefe..c8b0e73 100644
--- a/stack/rest/src/test/java/org/usergrid/rest/test/resource/NamedResource.java
+++ b/stack/rest/src/test/java/org/usergrid/rest/test/resource/NamedResource.java
@@ -28,13 +28,17 @@ import com.sun.jersey.api.client.WebResource;
 import com.sun.jersey.api.client.WebResource.Builder;
 
 
-/** @author tnine */
+/**
+ * @author tnine
+ */
 public abstract class NamedResource {
 
     protected static final String SLASH = "/";
 
     protected NamedResource parent;
 
+    protected String accept;
+
 
     /**
      *
@@ -44,7 +48,9 @@ public abstract class NamedResource {
     }
 
 
-    /** Get the url to this resource */
+    /**
+     * Get the url to this resource
+     */
     public String url() {
         StringBuilder buff = new StringBuilder();
         addToUrl( buff );
@@ -52,21 +58,36 @@ public abstract class NamedResource {
     }
 
 
-    /** Get the resource for calling the url.  Will have the token pre-loaded if the token
is set */
+    /**
+     * Get the resource for calling the url.  Will have the token pre-loaded if the token
is set
+     */
     protected WebResource resource() {
         return parent.resource();
     }
 
 
-    /** Get the token for this request */
+    /**
+     * Get the token for this request
+     */
     protected String token() {
         return parent.token();
     }
 
 
-    /** Set the media type on the webResource */
+    /**
+     * Set the media type on the webResource
+     */
     protected Builder jsonMedia( WebResource resource ) {
-        return resource.accept( MediaType.APPLICATION_JSON ).type( MediaType.APPLICATION_JSON_TYPE
);
+
+        Builder builder = resource.type( MediaType.APPLICATION_JSON_TYPE );
+
+        if(accept == null){
+            builder = builder.accept( MediaType.APPLICATION_JSON );
+        } else{
+            builder = builder.accept( accept );
+        }
+
+        return builder;
     }
 
 
@@ -83,37 +104,55 @@ public abstract class NamedResource {
     }
 
 
-    /** Method to add params to the generated url.  Subclasses can override it */
+    public <T extends ValueResource> T withAccept( String accept ) {
+        this.accept = accept;
+        return ( T ) this;
+    }
+
+
+    /**
+     * Method to add params to the generated url.  Subclasses can override it
+     */
     protected WebResource withParams( WebResource resource ) {
         return resource;
     }
 
 
-    /** Get the entity from the entity array in the response */
+    /**
+     * Get the entity from the entity array in the response
+     */
     protected JsonNode getEntity( JsonNode response, int index ) {
         return response.get( "entities" ).get( index );
     }
 
 
-    /** Get the entity from the entity array in the response */
+    /**
+     * Get the entity from the entity array in the response
+     */
     protected JsonNode getEntity( JsonNode response, String name ) {
         return response.get( "entities" ).get( name );
     }
 
 
-    /** Get the uuid from the entity at the specified index */
+    /**
+     * Get the uuid from the entity at the specified index
+     */
     protected UUID getEntityId( JsonNode response, int index ) {
         return UUID.fromString( getEntity( response, index ).get( "uuid" ).asText() );
     }
 
 
-    /** Parse the root response and return each entity as a json node in a list */
+    /**
+     * Parse the root response and return each entity as a json node in a list
+     */
     protected List<JsonNode> getEntries( JsonNode response ) {
         return getNodesAsList( "path", response );
     }
 
 
-    /** Get nodes as a list */
+    /**
+     * Get nodes as a list
+     */
     protected List<JsonNode> getNodesAsList( String path, JsonNode response ) {
         JsonNode entities = response.path( path );
 
@@ -131,12 +170,16 @@ public abstract class NamedResource {
     }
 
 
-    /** Get the error response */
+    /**
+     * Get the error response
+     */
     protected JsonNode getError( JsonNode response ) {
         return response.get( "error" );
     }
 
 
-    /** Add itself to the end of the URL. Should not append a final "/"  Shouldn't ever be
used by the client! */
+    /**
+     * Add itself to the end of the URL. Should not append a final "/"  Shouldn't ever be
used by the client!
+     */
     public abstract void addToUrl( StringBuilder buffer );
 }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e2ee790d/stack/rest/src/test/java/org/usergrid/rest/test/resource/ValueResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/usergrid/rest/test/resource/ValueResource.java b/stack/rest/src/test/java/org/usergrid/rest/test/resource/ValueResource.java
index 72c4eea..f5c8d18 100644
--- a/stack/rest/src/test/java/org/usergrid/rest/test/resource/ValueResource.java
+++ b/stack/rest/src/test/java/org/usergrid/rest/test/resource/ValueResource.java
@@ -112,6 +112,7 @@ public abstract class ValueResource extends NamedResource {
     }
 
 
+
     @SuppressWarnings("unchecked")
     public <T extends ValueResource> T withCursor( String cursor ) {
         this.cursor = cursor;
@@ -154,12 +155,29 @@ public abstract class ValueResource extends NamedResource {
     }
 
 
+    @Override
+    protected WebResource withParams( final WebResource resource ) {
+        WebResource withParams = super.withParams( resource );
+
+        if(customParams == null){
+            return withParams;
+        }
+
+        for(Entry<String, String> param : customParams.entrySet()){
+            withParams = withParams.queryParam( param.getKey(), param.getValue());
+        }
+
+        return withParams;
+    }
+
+
     /** Get entities in this collection. Cursor is optional */
     protected JsonNode getInternal() {
 
 
         WebResource resource = withParams( withToken( resource() ) );
 
+
         if ( query != null ) {
             resource = resource.queryParam( "ql", query );
         }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e2ee790d/stack/rest/src/test/java/org/usergrid/rest/test/security/TestUser.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/usergrid/rest/test/security/TestUser.java b/stack/rest/src/test/java/org/usergrid/rest/test/security/TestUser.java
index e150094..4f67dd2 100644
--- a/stack/rest/src/test/java/org/usergrid/rest/test/security/TestUser.java
+++ b/stack/rest/src/test/java/org/usergrid/rest/test/security/TestUser.java
@@ -55,6 +55,14 @@ public abstract class TestUser {
     }
 
 
+    /**
+     * Manually set our token for this user.
+     * @param token
+     */
+    public void setToken(String token){
+        this.token = token;
+    }
+
     /** Log out */
     public void logout() {
         token = null;

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e2ee790d/stack/services/pom.xml
----------------------------------------------------------------------
diff --git a/stack/services/pom.xml b/stack/services/pom.xml
index 692e839..fc312ea 100644
--- a/stack/services/pom.xml
+++ b/stack/services/pom.xml
@@ -531,4 +531,4 @@
       <scope>test</scope>
     </dependency>
   </dependencies>
-</project>
\ No newline at end of file
+</project>

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e2ee790d/stack/tools/src/main/java/org/usergrid/tools/OrganizationExport.java
----------------------------------------------------------------------
diff --git a/stack/tools/src/main/java/org/usergrid/tools/OrganizationExport.java b/stack/tools/src/main/java/org/usergrid/tools/OrganizationExport.java
index 51baa98..f5c2dc6 100644
--- a/stack/tools/src/main/java/org/usergrid/tools/OrganizationExport.java
+++ b/stack/tools/src/main/java/org/usergrid/tools/OrganizationExport.java
@@ -4,6 +4,7 @@ package org.usergrid.tools;
 import java.io.FileWriter;
 import java.text.SimpleDateFormat;
 import java.util.Date;
+import java.util.UUID;
 
 import org.usergrid.management.UserInfo;
 import org.usergrid.persistence.Entity;
@@ -56,7 +57,7 @@ public class OrganizationExport extends ExportingToolBase {
 
         CSVWriter writer = new CSVWriter( new FileWriter( outputDir.getAbsolutePath() + "/admins.csv"
), ',' );
 
-        writer.writeNext( new String[] { "Organization Name", "Admin Name", "Admin Email",
"Admin Created Date" } );
+        writer.writeNext( new String[] { "Org uuid", "Org Name", "Admin uuid", "Admin Name",
"Admin Email", "Admin Created Date" } );
 
         Results organizations = null;
 
@@ -65,9 +66,10 @@ public class OrganizationExport extends ExportingToolBase {
             organizations = getOrganizations( query );
 
             for ( Entity organization : organizations.getEntities() ) {
-                String orgName = organization.getProperty( "path" ).toString();
+                final String orgName = organization.getProperty( "path" ).toString();
+                final UUID orgId = organization.getUuid();
 
-                logger.info( "Org Name: {} key: {}", orgName, organization.getUuid() );
+                logger.info( "Org Name: {} key: {}", orgName, orgId );
 
                 for ( UserInfo user : managementService.getAdminUsersForOrganization( organization.getUuid()
) ) {
 
@@ -75,8 +77,8 @@ public class OrganizationExport extends ExportingToolBase {
 
                     Long createdDate = ( Long ) admin.getProperties().get( "created" );
 
-                    writer.writeNext( new String[] {
-                            orgName, user.getName(), user.getEmail(),
+                    writer.writeNext( new String[] { orgId.toString(),
+                            orgName, user.getUuid().toString(), user.getName(), user.getEmail(),
                             createdDate == null ? "Unknown" : sdf.format( new Date( createdDate
) )
                     } );
                 }


Mime
View raw message