You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@usergrid.apache.org by to...@apache.org on 2013/12/05 23:41:00 UTC
[1/2] Merging from lastest stable changes
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 ) )
} );
}
[2/2] git commit: Merging from lastest stable changes
Posted by to...@apache.org.
Merging from lastest stable changes
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/e2ee790d
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/e2ee790d
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/e2ee790d
Branch: refs/heads/master
Commit: e2ee790dee4ffc7314c6c7e1fa58c2cc6d89e287
Parents: da6eb85
Author: Todd Nine <to...@apache.org>
Authored: Thu Dec 5 15:40:41 2013 -0700
Committer: Todd Nine <to...@apache.org>
Committed: Thu Dec 5 15:40:41 2013 -0700
----------------------------------------------------------------------
.../main/resources/usergrid-default.properties | 3 +
stack/core/pom.xml | 2 +-
.../persistence/query/tree/QueryFilter.g | 34 +-
.../batch/service/JobSchedulerService.java | 2 +-
.../usergrid/count/CassandraCounterStore.java | 4 +-
.../cassandra/HectorLockManagerImpl.java | 24 +-
.../mq/cassandra/QueueManagerFactoryImpl.java | 6 +-
.../usergrid/mq/cassandra/QueueManagerImpl.java | 12 +-
.../mq/cassandra/io/ConsumerTransaction.java | 28 +-
.../persistence/cassandra/CassandraService.java | 4 +
.../persistence/cassandra/QueryProcessor.java | 9 +
.../exceptions/QueryIterationException.java | 13 +
.../exceptions/QueryTokenException.java | 52 ++
.../usergrid/persistence/query/ir/NotNode.java | 1 +
.../query/ir/result/SliceIterator.java | 16 +-
.../main/resources/usergrid-core-context.xml | 1 +
.../usergrid/batch/job/SchedulerRuntime2IT.java | 4 +-
.../locking/cassandra/HectorLockManagerIT.java | 8 +
.../query/AbstractIteratingQueryIT.java | 63 ++
.../query/NotOrderByCollectionIT.java | 28 +
.../query/NotOrderByConnectionIT.java | 28 +
.../persistence/query/tree/GrammarTreeTest.java | 25 +
stack/launcher/pom.xml | 12 +
stack/mongo-emulator/pom.xml | 2 +-
stack/pom.xml | 108 ++--
stack/rest/pom.xml | 46 +-
.../rest/JacksonCustomMapperProvider.java | 2 +-
.../org/usergrid/rest/TextToJsonSwapWriter.java | 119 ++++
.../rest/applications/ServiceResource.java | 1 +
.../exceptions/QueryParseExceptionMapper.java | 34 ++
.../exceptions/QueryTokenExceptionMapper.java | 36 ++
stack/rest/src/main/webapp/WEB-INF/c.tld | 572 +++++++++++++++++++
.../users/UserResource/resetpw_email_form.jsp | 4 +-
stack/rest/src/main/webapp/WEB-INF/web.xml | 18 +-
stack/rest/src/main/webapp/css/styles.css | 7 +-
.../java/org/usergrid/rest/AbstractRestIT.java | 2 +-
.../test/java/org/usergrid/rest/ITSetup.java | 37 +-
.../java/org/usergrid/rest/TomcatResource.java | 74 +++
.../applications/ApplicationResourceIT.java | 43 +-
.../collection/BadGrammarQueryTest.java | 60 ++
.../collection/BrowserCompatibilityTest.java | 86 +++
.../applications/users/ActivityResourceIT.java | 1 +
.../applications/users/GroupResourceIT.java | 4 +-
.../organizations/OrganizationsResourceIT.java | 3 +-
.../rest/management/users/MUUserResourceIT.java | 69 ++-
.../rest/test/resource/NamedResource.java | 71 ++-
.../rest/test/resource/ValueResource.java | 18 +
.../usergrid/rest/test/security/TestUser.java | 8 +
stack/services/pom.xml | 2 +-
.../org/usergrid/tools/OrganizationExport.java | 12 +-
50 files changed, 1648 insertions(+), 170 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e2ee790d/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 c51e176..62107da 100644
--- a/stack/config/src/main/resources/usergrid-default.properties
+++ b/stack/config/src/main/resources/usergrid-default.properties
@@ -98,6 +98,9 @@ usergrid.sysadmin.approve.organizations=false
usergrid.temp.files=/tmp/usergrid
+#The timeout in locks from reading messages transactionally from a queue. Number of seconds to wait
+usergrid.queue.lock.timeout=30
+
######
#Scheduler setup
######
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e2ee790d/stack/core/pom.xml
----------------------------------------------------------------------
diff --git a/stack/core/pom.xml b/stack/core/pom.xml
index d5e5a94..0059ba3 100644
--- a/stack/core/pom.xml
+++ b/stack/core/pom.xml
@@ -544,4 +544,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/core/src/main/antlr3/org/usergrid/persistence/query/tree/QueryFilter.g
----------------------------------------------------------------------
diff --git a/stack/core/src/main/antlr3/org/usergrid/persistence/query/tree/QueryFilter.g b/stack/core/src/main/antlr3/org/usergrid/persistence/query/tree/QueryFilter.g
index ff29933..918f0bd 100644
--- a/stack/core/src/main/antlr3/org/usergrid/persistence/query/tree/QueryFilter.g
+++ b/stack/core/src/main/antlr3/org/usergrid/persistence/query/tree/QueryFilter.g
@@ -8,6 +8,7 @@ options {
@rulecatch { }
+
@header {
package org.usergrid.persistence.query.tree;
@@ -18,13 +19,6 @@ import org.usergrid.persistence.Query.SortPredicate;
}
-@lexer::header {
-package org.usergrid.persistence.query.tree;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-}
@members {
Query query = new Query();
@@ -37,16 +31,40 @@ import org.slf4j.LoggerFactory;
logger.info(msg);
}
}
-
+
+
+@lexer::header {
+package org.usergrid.persistence.query.tree;
+
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.usergrid.persistence.exceptions.QueryTokenException;
+
+}
+
@lexer::members {
+
+
private static final Logger logger = LoggerFactory
.getLogger(QueryFilterLexer.class);
+
+
+
@Override
public void emitErrorMessage(String msg) {
logger.info(msg);
}
+
+ @Override
+ public void recover(RecognitionException e) {
+ //We don't want to recover, we want to re-throw to the user since they passed us invalid input
+ throw new QueryTokenException(e);
+ }
+
+
}
//these must come before ID. Otherwise lt, lte, eq, etc will be returned as id tokens
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e2ee790d/stack/core/src/main/java/org/usergrid/batch/service/JobSchedulerService.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/usergrid/batch/service/JobSchedulerService.java b/stack/core/src/main/java/org/usergrid/batch/service/JobSchedulerService.java
index 9cb07ba..c35a9c8 100644
--- a/stack/core/src/main/java/org/usergrid/batch/service/JobSchedulerService.java
+++ b/stack/core/src/main/java/org/usergrid/batch/service/JobSchedulerService.java
@@ -312,4 +312,4 @@ public class JobSchedulerService extends AbstractScheduledService {
public JobListener getJobListener() {
return jobListener;
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e2ee790d/stack/core/src/main/java/org/usergrid/count/CassandraCounterStore.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/usergrid/count/CassandraCounterStore.java b/stack/core/src/main/java/org/usergrid/count/CassandraCounterStore.java
index 3eda1d2..216d80f 100644
--- a/stack/core/src/main/java/org/usergrid/count/CassandraCounterStore.java
+++ b/stack/core/src/main/java/org/usergrid/count/CassandraCounterStore.java
@@ -36,6 +36,8 @@ import me.prettyprint.hector.api.mutation.Mutator;
/**
* Encapsulate counter writes to Cassandra
+ *
+ * @author zznate
*/
public class CassandraCounterStore implements CounterStore {
private Logger log = LoggerFactory.getLogger( CassandraCounterStore.class );
@@ -95,4 +97,4 @@ public class CassandraCounterStore implements CounterStore {
}
}
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e2ee790d/stack/core/src/main/java/org/usergrid/locking/cassandra/HectorLockManagerImpl.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/usergrid/locking/cassandra/HectorLockManagerImpl.java b/stack/core/src/main/java/org/usergrid/locking/cassandra/HectorLockManagerImpl.java
index eb54206..9d8e9a7 100644
--- a/stack/core/src/main/java/org/usergrid/locking/cassandra/HectorLockManagerImpl.java
+++ b/stack/core/src/main/java/org/usergrid/locking/cassandra/HectorLockManagerImpl.java
@@ -20,16 +20,17 @@ import java.util.UUID;
import javax.annotation.PostConstruct;
-import org.springframework.util.Assert;
-import org.usergrid.locking.Lock;
-import org.usergrid.locking.LockManager;
-import org.usergrid.locking.LockPathBuilder;
-
import me.prettyprint.cassandra.locking.HLockManagerImpl;
import me.prettyprint.hector.api.Cluster;
+import me.prettyprint.hector.api.ConsistencyLevelPolicy;
import me.prettyprint.hector.api.locking.HLockManager;
import me.prettyprint.hector.api.locking.HLockManagerConfigurator;
+import org.springframework.util.Assert;
+import org.usergrid.locking.Lock;
+import org.usergrid.locking.LockManager;
+import org.usergrid.locking.LockPathBuilder;
+
/**
* Uses the hector based locking implementation to obtain locks
@@ -43,6 +44,7 @@ public class HectorLockManagerImpl implements LockManager {
private String keyspaceName;
private Cluster cluster;
private HLockManager lm;
+ private ConsistencyLevelPolicy consistencyLevelPolicy;
/**
@@ -60,6 +62,10 @@ public class HectorLockManagerImpl implements LockManager {
hlc.setNumberOfLockObserverThreads( numberOfLockObserverThreads );
hlc.setLocksTTLInMillis( lockTtl );
lm = new HLockManagerImpl( cluster, hlc );
+ if ( consistencyLevelPolicy != null ) {
+ lm.getKeyspace().setConsistencyLevelPolicy(consistencyLevelPolicy);
+ }
+ // if consistencyLevelPolicy == null, use hector's default, which is QuorumAll, no need to explicitly set
lm.init();
}
@@ -124,4 +130,12 @@ public class HectorLockManagerImpl implements LockManager {
public void setCluster( Cluster cluster ) {
this.cluster = cluster;
}
+
+
+ /**
+ * @param consistencyLevelPolicy the consistencyLevelPolicy to set
+ */
+ public void setConsistencyLevelPolicy(ConsistencyLevelPolicy consistencyLevelPolicy) {
+ this.consistencyLevelPolicy = consistencyLevelPolicy;
+ }
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e2ee790d/stack/core/src/main/java/org/usergrid/mq/cassandra/QueueManagerFactoryImpl.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/usergrid/mq/cassandra/QueueManagerFactoryImpl.java b/stack/core/src/main/java/org/usergrid/mq/cassandra/QueueManagerFactoryImpl.java
index 3c64ba3..4783452 100644
--- a/stack/core/src/main/java/org/usergrid/mq/cassandra/QueueManagerFactoryImpl.java
+++ b/stack/core/src/main/java/org/usergrid/mq/cassandra/QueueManagerFactoryImpl.java
@@ -43,6 +43,7 @@ public class QueueManagerFactoryImpl implements QueueManagerFactory {
private CassandraService cass;
private CounterUtils counterUtils;
private LockManager lockManager;
+ private int lockTimeout;
public static final StringSerializer se = new StringSerializer();
public static final ByteBufferSerializer be = new ByteBufferSerializer();
@@ -58,10 +59,11 @@ public class QueueManagerFactoryImpl implements QueueManagerFactory {
* @param cass the cassandra client pool
* @param counterUtils the CounterUtils
*/
- public QueueManagerFactoryImpl( CassandraService cass, CounterUtils counterUtils, LockManager lockManager ) {
+ public QueueManagerFactoryImpl( CassandraService cass, CounterUtils counterUtils, LockManager lockManager, int lockTimeout ) {
this.cass = cass;
this.counterUtils = counterUtils;
this.lockManager = lockManager;
+ this.lockTimeout = lockTimeout;
}
@@ -74,7 +76,7 @@ public class QueueManagerFactoryImpl implements QueueManagerFactory {
@Override
public QueueManager getQueueManager( UUID applicationId ) {
QueueManagerImpl qm = new QueueManagerImpl();
- qm.init( cass, counterUtils, lockManager, applicationId );
+ qm.init( cass, counterUtils, lockManager, applicationId, lockTimeout );
return qm;
//return applicationContext.getAutowireCapableBeanFactory()
// .createBean(QueueManagerImpl.class)
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e2ee790d/stack/core/src/main/java/org/usergrid/mq/cassandra/QueueManagerImpl.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/usergrid/mq/cassandra/QueueManagerImpl.java b/stack/core/src/main/java/org/usergrid/mq/cassandra/QueueManagerImpl.java
index 630b2d3..fd18e55 100644
--- a/stack/core/src/main/java/org/usergrid/mq/cassandra/QueueManagerImpl.java
+++ b/stack/core/src/main/java/org/usergrid/mq/cassandra/QueueManagerImpl.java
@@ -150,6 +150,7 @@ public class QueueManagerImpl implements QueueManager {
private CassandraService cass;
private CounterUtils counterUtils;
private LockManager lockManager;
+ private int lockTimeout;
public static final StringSerializer se = new StringSerializer();
public static final ByteBufferSerializer be = new ByteBufferSerializer();
@@ -164,11 +165,12 @@ public class QueueManagerImpl implements QueueManager {
public QueueManagerImpl init( CassandraService cass, CounterUtils counterUtils, LockManager lockManager,
- UUID applicationId ) {
+ UUID applicationId, int lockTimeout ) {
this.cass = cass;
this.counterUtils = counterUtils;
this.applicationId = applicationId;
this.lockManager = lockManager;
+ this.lockTimeout = lockTimeout;
return this;
}
@@ -392,7 +394,7 @@ public class QueueManagerImpl implements QueueManager {
else if ( query.getPosition() == LAST || query.getPosition() == CONSUMER ) {
if ( query.getTimeout() > 0 ) {
- search = new ConsumerTransaction( applicationId, ko, lockManager, cass );
+ search = new ConsumerTransaction( applicationId, ko, lockManager, cass, lockTimeout );
}
else {
search = new NoTransactionSearch( ko );
@@ -1307,7 +1309,7 @@ public class QueueManagerImpl implements QueueManager {
public UUID renewTransaction( String queuePath, UUID transactionId, QueueQuery query )
throws TransactionNotFoundException {
Keyspace ko = cass.getApplicationKeyspace( applicationId );
- return new ConsumerTransaction( applicationId, ko, lockManager, cass )
+ return new ConsumerTransaction( applicationId, ko, lockManager, cass, lockTimeout )
.renewTransaction( queuePath, transactionId, query );
}
@@ -1327,7 +1329,7 @@ public class QueueManagerImpl implements QueueManager {
@Override
public void commitTransaction( String queuePath, UUID transactionId, QueueQuery query ) {
Keyspace ko = cass.getApplicationKeyspace( applicationId );
- new ConsumerTransaction( applicationId, ko, lockManager, cass )
+ new ConsumerTransaction( applicationId, ko, lockManager, cass, lockTimeout )
.deleteTransaction( queuePath, transactionId, query );
}
@@ -1343,7 +1345,7 @@ public class QueueManagerImpl implements QueueManager {
Keyspace ko = cass.getApplicationKeyspace( applicationId );
- return new ConsumerTransaction( applicationId, ko, lockManager, cass )
+ return new ConsumerTransaction( applicationId, ko, lockManager, cass , lockTimeout)
.hasOutstandingTransactions( queueId, consumerId );
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e2ee790d/stack/core/src/main/java/org/usergrid/mq/cassandra/io/ConsumerTransaction.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/usergrid/mq/cassandra/io/ConsumerTransaction.java b/stack/core/src/main/java/org/usergrid/mq/cassandra/io/ConsumerTransaction.java
index cda99aa..6466c47 100644
--- a/stack/core/src/main/java/org/usergrid/mq/cassandra/io/ConsumerTransaction.java
+++ b/stack/core/src/main/java/org/usergrid/mq/cassandra/io/ConsumerTransaction.java
@@ -21,6 +21,7 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.UUID;
+import java.util.concurrent.TimeUnit;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -51,26 +52,32 @@ import static org.usergrid.mq.cassandra.QueuesCF.CONSUMER_QUEUE_TIMEOUTS;
/**
* Reads from the queue and starts a transaction
+ *
+ * @author tnine
*/
public class ConsumerTransaction extends NoTransactionSearch
{
private static final Logger logger = LoggerFactory.getLogger( ConsumerTransaction.class );
private static final int MAX_READ = 10000;
- private LockManager lockManager;
- private UUID applicationId;
- protected CassandraService cass;
+ private final LockManager lockManager;
+ private final UUID applicationId;
+ protected final CassandraService cass;
+
+ //timeout on reading lock
+ private final int lockTimeout;
/**
* @param ko
*/
- public ConsumerTransaction( UUID applicationId, Keyspace ko, LockManager lockManager, CassandraService cass )
+ public ConsumerTransaction( UUID applicationId, Keyspace ko, LockManager lockManager, CassandraService cass, int lockTimeout )
{
super( ko );
this.applicationId = applicationId;
this.lockManager = lockManager;
this.cass = cass;
+ this.lockTimeout = lockTimeout;
}
@@ -191,7 +198,10 @@ public class ConsumerTransaction extends NoTransactionSearch
try
{
- lock.lock();
+ //only try to get a lock with a timeout, if we can't bail
+ if(!lock.tryLock(lockTimeout, TimeUnit.SECONDS)){
+ throw new QueueException( "Unable to obtain a lock on queue '" + queuePath + "' after '" + lockTimeout + "'seconds" );
+ }
long startTime = System.currentTimeMillis();
@@ -299,8 +309,10 @@ public class ConsumerTransaction extends NoTransactionSearch
/**
* Get all pending transactions that have timed out
*
- * @param startId The time to start seeking from
- * @param lastId The
+ * @param queueId The queue id
+ * @param consumerId The consumer id
+ * @param params The server params
+ * @param startTimeUUID The start time
*/
protected List<TransactionPointer> getConsumerIds( UUID queueId, UUID consumerId, SearchParam params,
UUID startTimeUUID )
@@ -456,4 +468,4 @@ public class ConsumerTransaction extends NoTransactionSearch
return "TransactionPointer [expiration=" + expiration + ", targetMessage=" + targetMessage + "]";
}
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e2ee790d/stack/core/src/main/java/org/usergrid/persistence/cassandra/CassandraService.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/usergrid/persistence/cassandra/CassandraService.java b/stack/core/src/main/java/org/usergrid/persistence/cassandra/CassandraService.java
index ecea925..9ca1819 100644
--- a/stack/core/src/main/java/org/usergrid/persistence/cassandra/CassandraService.java
+++ b/stack/core/src/main/java/org/usergrid/persistence/cassandra/CassandraService.java
@@ -306,6 +306,10 @@ public class CassandraService {
//add the cf
if ( !cfExists( keyspace, cfDef.getName() ) ) {
+
+ //default read repair chance to 0.1
+ cfDef.setReadRepairChance( 0.1d );
+
cluster.addColumnFamily( cfDef, true );
logger.info( "Created column family {} in keyspace {}", cfDef.getName(), keyspace );
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e2ee790d/stack/core/src/main/java/org/usergrid/persistence/cassandra/QueryProcessor.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/usergrid/persistence/cassandra/QueryProcessor.java b/stack/core/src/main/java/org/usergrid/persistence/cassandra/QueryProcessor.java
index b616de2..33c84db 100644
--- a/stack/core/src/main/java/org/usergrid/persistence/cassandra/QueryProcessor.java
+++ b/stack/core/src/main/java/org/usergrid/persistence/cassandra/QueryProcessor.java
@@ -650,6 +650,15 @@ public class QueryProcessor {
/** @return the pageSizeHint */
public int getPageSizeHint( QueryNode node ) {
+ /*****
+ * DO NOT REMOVE THIS PIECE OF CODE!!!!!!!!!!!
+ * It is crucial that the root iterator only needs the result set size per page
+ * otherwise our cursor logic will fail when passing cursor data to the leaf nodes
+ *******/
+ if(node == rootNode){
+ return size;
+ }
+
return pageSizeHint;
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e2ee790d/stack/core/src/main/java/org/usergrid/persistence/exceptions/QueryIterationException.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/usergrid/persistence/exceptions/QueryIterationException.java b/stack/core/src/main/java/org/usergrid/persistence/exceptions/QueryIterationException.java
new file mode 100644
index 0000000..dfc31a9
--- /dev/null
+++ b/stack/core/src/main/java/org/usergrid/persistence/exceptions/QueryIterationException.java
@@ -0,0 +1,13 @@
+package org.usergrid.persistence.exceptions;
+
+
+/**
+ * Thrown when an error occurs during query iteration
+ *
+ * @author tnine
+ */
+public class QueryIterationException extends RuntimeException {
+ public QueryIterationException( final String message ) {
+ super( message );
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e2ee790d/stack/core/src/main/java/org/usergrid/persistence/exceptions/QueryTokenException.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/usergrid/persistence/exceptions/QueryTokenException.java b/stack/core/src/main/java/org/usergrid/persistence/exceptions/QueryTokenException.java
new file mode 100644
index 0000000..b9f473b
--- /dev/null
+++ b/stack/core/src/main/java/org/usergrid/persistence/exceptions/QueryTokenException.java
@@ -0,0 +1,52 @@
+/*******************************************************************************
+ * 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.persistence.exceptions;
+
+
+/**
+ * An exception thrown when a query encounters a token it doesn't recognize
+ * @author tnine
+ */
+public class QueryTokenException extends RuntimeException {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+
+
+
+
+ /**
+ * @param arg0
+ */
+ public QueryTokenException( Throwable arg0 ) {
+ super( arg0 );
+ }
+
+
+ @Override
+ public String getMessage() {
+ //antlr errors or strange. We have to do this, there's no message
+ return getCause().toString();
+ }
+
+
+ @Override
+ public String getLocalizedMessage() {
+ return getMessage();
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e2ee790d/stack/core/src/main/java/org/usergrid/persistence/query/ir/NotNode.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/usergrid/persistence/query/ir/NotNode.java b/stack/core/src/main/java/org/usergrid/persistence/query/ir/NotNode.java
index e534431..2784d65 100644
--- a/stack/core/src/main/java/org/usergrid/persistence/query/ir/NotNode.java
+++ b/stack/core/src/main/java/org/usergrid/persistence/query/ir/NotNode.java
@@ -26,6 +26,7 @@ public class NotNode extends QueryNode {
public NotNode( QueryNode subtractNode, QueryNode keepNode ) {
this.subtractNode = subtractNode;
this.keepNode = keepNode;
+// throw new RuntimeException( "I'm a not node" );
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e2ee790d/stack/core/src/main/java/org/usergrid/persistence/query/ir/result/SliceIterator.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/usergrid/persistence/query/ir/result/SliceIterator.java b/stack/core/src/main/java/org/usergrid/persistence/query/ir/result/SliceIterator.java
index d573cd4..205e8f4 100644
--- a/stack/core/src/main/java/org/usergrid/persistence/query/ir/result/SliceIterator.java
+++ b/stack/core/src/main/java/org/usergrid/persistence/query/ir/result/SliceIterator.java
@@ -23,8 +23,11 @@ import java.util.LinkedHashSet;
import java.util.Set;
import java.util.UUID;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.usergrid.persistence.cassandra.CursorCache;
import org.usergrid.persistence.cassandra.index.IndexScanner;
+import org.usergrid.persistence.exceptions.QueryIterationException;
import org.usergrid.persistence.query.ir.QuerySlice;
import me.prettyprint.hector.api.beans.HColumn;
@@ -37,6 +40,8 @@ import me.prettyprint.hector.api.beans.HColumn;
*/
public class SliceIterator implements ResultIterator {
+ private static final Logger logger = LoggerFactory.getLogger( SliceIterator.class );
+
private final LinkedHashMap<UUID, ScanColumn> cols;
private final QuerySlice slice;
private final SliceParser parser;
@@ -188,9 +193,16 @@ public class SliceIterator implements ResultIterator {
*/
@Override
public void finalizeCursor( CursorCache cache, UUID lastLoaded ) {
- int sliceHash = slice.hashCode();
+ final int sliceHash = slice.hashCode();
+
+ final ScanColumn col = cols.get( lastLoaded );
+
+ if(col == null){
+ logger.error( "An iterator attempted to access a slice that was not iterated over. This will result in the cursor construction failing" );
+ throw new QueryIterationException( "An iterator attempted to access a slice that was not iterated over. This will result in the cursor construction failing" );
+ }
- ByteBuffer bytes = cols.get( lastLoaded ).getCursorValue();
+ final ByteBuffer bytes = col.getCursorValue();
if ( bytes == null ) {
return;
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e2ee790d/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 5e22c37..482ee25 100644
--- a/stack/core/src/main/resources/usergrid-core-context.xml
+++ b/stack/core/src/main/resources/usergrid-core-context.xml
@@ -102,6 +102,7 @@
<constructor-arg ref="cassandraService" />
<constructor-arg ref="counterUtils"/>
<constructor-arg ref="lockManager"/>
+ <constructor-arg value="${usergrid.queue.lock.timeout}"/>
</bean>
<bean id="simpleBatcher" class="org.usergrid.count.SimpleBatcher">
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e2ee790d/stack/core/src/test/java/org/usergrid/batch/job/SchedulerRuntime2IT.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/usergrid/batch/job/SchedulerRuntime2IT.java b/stack/core/src/test/java/org/usergrid/batch/job/SchedulerRuntime2IT.java
index db00e1b..fa6f33d 100644
--- a/stack/core/src/test/java/org/usergrid/batch/job/SchedulerRuntime2IT.java
+++ b/stack/core/src/test/java/org/usergrid/batch/job/SchedulerRuntime2IT.java
@@ -42,7 +42,7 @@ public class SchedulerRuntime2IT extends AbstractSchedulerRuntimeIT {
}
// now wait until everything fires
- boolean waited = getJobListener().blockTilDone( getCount(), 5000L );
+ boolean waited = getJobListener().blockTilDone( getCount(), 15000L );
assertTrue( "Jobs ran", waited );
assertTrue( getCount() + " successful jobs ran", getCount() == getJobListener().getSuccessCount() );
@@ -57,7 +57,7 @@ public class SchedulerRuntime2IT extends AbstractSchedulerRuntimeIT {
}
// now wait until everything fires
- waited = getJobListener().blockTilDone( 2 * getCount(), 5000L );
+ waited = getJobListener().blockTilDone( 2 * getCount(), 15000L );
assertTrue( "Jobs ran", waited );
assertTrue( 2 * getCount() + " successful jobs ran",
( 2 * getCount() ) == getJobListener().getSuccessCount() );
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e2ee790d/stack/core/src/test/java/org/usergrid/locking/cassandra/HectorLockManagerIT.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/usergrid/locking/cassandra/HectorLockManagerIT.java b/stack/core/src/test/java/org/usergrid/locking/cassandra/HectorLockManagerIT.java
index 55f06a5..fc82ede 100644
--- a/stack/core/src/test/java/org/usergrid/locking/cassandra/HectorLockManagerIT.java
+++ b/stack/core/src/test/java/org/usergrid/locking/cassandra/HectorLockManagerIT.java
@@ -24,6 +24,10 @@ import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
+import me.prettyprint.cassandra.model.ConfigurableConsistencyLevel;
+import me.prettyprint.hector.api.ConsistencyLevelPolicy;
+import me.prettyprint.hector.api.HConsistencyLevel;
+
import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.BeforeClass;
@@ -56,6 +60,10 @@ public class HectorLockManagerIT extends AbstractCoreIT {
hlockManager.setLockTtl( 2000 );
hlockManager.setNumberOfLockObserverThreads( 1 );
hlockManager.setReplicationFactor( 1 );
+ ConsistencyLevelPolicy consistencyLevel = new ConfigurableConsistencyLevel();
+ ((ConfigurableConsistencyLevel) consistencyLevel).setDefaultReadConsistencyLevel(HConsistencyLevel.ONE);
+ ((ConfigurableConsistencyLevel) consistencyLevel).setDefaultWriteConsistencyLevel(HConsistencyLevel.ONE);
+ hlockManager.setConsistencyLevelPolicy(consistencyLevel);
hlockManager.init();
manager = hlockManager;
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e2ee790d/stack/core/src/test/java/org/usergrid/persistence/query/AbstractIteratingQueryIT.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/usergrid/persistence/query/AbstractIteratingQueryIT.java b/stack/core/src/test/java/org/usergrid/persistence/query/AbstractIteratingQueryIT.java
index 838cfe7..b06539e 100644
--- a/stack/core/src/test/java/org/usergrid/persistence/query/AbstractIteratingQueryIT.java
+++ b/stack/core/src/test/java/org/usergrid/persistence/query/AbstractIteratingQueryIT.java
@@ -1132,6 +1132,69 @@ public abstract class AbstractIteratingQueryIT {
/**
+ * Tests that when an empty query is issued, we page through all entities correctly
+ *
+ * @param io the io helper
+ */
+ public void notOrderBy( IoHelper io ) throws Exception {
+
+ io.doSetup();
+
+ /**
+ * Leave this as a large size. We have to write over 1k to reproduce this issue
+ */
+ int size = 3000;
+
+ long start = System.currentTimeMillis();
+
+ LOG.info( "Writing {} entities.", size );
+
+ for ( int i = 0; i < size; i++ ) {
+ Map<String, Object> entity = new HashMap<String, Object>();
+ entity.put( "name", String.valueOf( i ) );
+ entity.put( "boolean", !(i % 100 == 0));
+ entity.put( "index", i);
+
+ io.writeEntity( entity );
+ }
+
+ long stop = System.currentTimeMillis();
+
+ LOG.info( "Writes took {} ms", stop - start );
+
+ Query query = Query.fromQL("select * where NOT boolean = false order by index asc");
+ query.setLimit( 20 );
+
+ int index = 0;
+ int count = 0;
+
+ Results results;
+
+ start = System.currentTimeMillis();
+
+ do {
+
+ // now do simple ordering, should be returned in order
+ results = io.getResults( query );
+
+ for ( int i = 0; i < results.size(); i++ ) {
+// assertEquals( String.valueOf( index ), results.getEntities().get( i ).getName() );
+// index +=2;
+ count++;
+ }
+
+ query.setCursor( results.getCursor() );
+ }
+ while ( results.getCursor() != null );
+
+ stop = System.currentTimeMillis();
+ LOG.info( "Query took {} ms to return {} entities", stop - start, count );
+
+ assertEquals( size/2, count );
+ }
+
+
+ /**
* Interface to abstract actually doing I/O targets. The same test logic can be applied to both collections and
* connections
*
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e2ee790d/stack/core/src/test/java/org/usergrid/persistence/query/NotOrderByCollectionIT.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/usergrid/persistence/query/NotOrderByCollectionIT.java b/stack/core/src/test/java/org/usergrid/persistence/query/NotOrderByCollectionIT.java
new file mode 100644
index 0000000..24a0f2c
--- /dev/null
+++ b/stack/core/src/test/java/org/usergrid/persistence/query/NotOrderByCollectionIT.java
@@ -0,0 +1,28 @@
+/*******************************************************************************
+ * 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.persistence.query;
+
+
+import org.junit.Test;
+
+
+/** @author tnine */
+public class NotOrderByCollectionIT extends AbstractIteratingQueryIT {
+ @Test
+ public void orderByWithNot() throws Exception {
+ notOrderBy( new CollectionIoHelper() );
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e2ee790d/stack/core/src/test/java/org/usergrid/persistence/query/NotOrderByConnectionIT.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/usergrid/persistence/query/NotOrderByConnectionIT.java b/stack/core/src/test/java/org/usergrid/persistence/query/NotOrderByConnectionIT.java
new file mode 100644
index 0000000..6ea23c8
--- /dev/null
+++ b/stack/core/src/test/java/org/usergrid/persistence/query/NotOrderByConnectionIT.java
@@ -0,0 +1,28 @@
+/*******************************************************************************
+ * 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.persistence.query;
+
+
+import org.junit.Test;
+
+
+/** @author tnine */
+public class NotOrderByConnectionIT extends AbstractIteratingQueryIT {
+ @Test
+ public void orderByWithNot() throws Exception {
+ notOrderBy( new ConnectionHelper() );
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e2ee790d/stack/core/src/test/java/org/usergrid/persistence/query/tree/GrammarTreeTest.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/usergrid/persistence/query/tree/GrammarTreeTest.java b/stack/core/src/test/java/org/usergrid/persistence/query/tree/GrammarTreeTest.java
index 40205c8..9d1574e 100644
--- a/stack/core/src/test/java/org/usergrid/persistence/query/tree/GrammarTreeTest.java
+++ b/stack/core/src/test/java/org/usergrid/persistence/query/tree/GrammarTreeTest.java
@@ -27,9 +27,12 @@ import org.junit.Test;
import org.usergrid.persistence.Query;
import org.usergrid.persistence.exceptions.QueryParseException;
+import antlr.NoViableAltException;
+
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
/** @author tnine */
@@ -529,4 +532,26 @@ public class GrammarTreeTest {
assertEquals( "The query cannot be parsed. The token '<EOF>' " + "at column 13 on line 1 cannot be parsed",
error );
}
+
+ @Test
+ public void badOperand() throws QueryParseException {
+ // from isn't allowed
+ String s = "select * where name != 'bob'";
+
+ String error = null;
+
+ try {
+ Query.fromQL( s );
+ fail("should throw an exception");
+ }
+ catch ( RuntimeException qpe ) {
+ error = qpe.getMessage();
+ }
+
+ assertEquals( "NoViableAltException('!'@[1:1: Tokens : ( T__31 | T__32 | T__33 | T__34 | T__35 | T__36 | T__37 | T__38 | T__39 | T__40 | LT | LTE | EQ | GT | GTE | BOOLEAN | AND | OR | NOT | ASC | DESC | CONTAINS | WITHIN | OF | UUID | ID | LONG | FLOAT | STRING | WS );])",
+ error );
+ }
+
+
+
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e2ee790d/stack/launcher/pom.xml
----------------------------------------------------------------------
diff --git a/stack/launcher/pom.xml b/stack/launcher/pom.xml
index 77b6242..1458e6d 100644
--- a/stack/launcher/pom.xml
+++ b/stack/launcher/pom.xml
@@ -134,6 +134,18 @@
<dependency>
<groupId>org.apache.tomcat</groupId>
<artifactId>jasper</artifactId>
+ <version>6.0.33</version>
+ <exclusions>
+ <exclusion>
+ <artifactId>servlet-api</artifactId>
+ <groupId>org.apache.tomcat</groupId>
+ </exclusion>
+
+ <exclusion>
+ <groupId>org.apache.tomcat</groupId>
+ <artifactId>juli</artifactId>
+ </exclusion>
+ </exclusions>
</dependency>
<dependency>
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e2ee790d/stack/mongo-emulator/pom.xml
----------------------------------------------------------------------
diff --git a/stack/mongo-emulator/pom.xml b/stack/mongo-emulator/pom.xml
index 2a4ca6c..910394b 100644
--- a/stack/mongo-emulator/pom.xml
+++ b/stack/mongo-emulator/pom.xml
@@ -165,4 +165,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/pom.xml
----------------------------------------------------------------------
diff --git a/stack/pom.xml b/stack/pom.xml
index f97677f..19ea946 100644
--- a/stack/pom.xml
+++ b/stack/pom.xml
@@ -86,8 +86,7 @@
<hector-test-version>1.1-4</hector-test-version>
<jackson-version>1.9.9</jackson-version>
<jclouds.version>1.6.2-incubating</jclouds.version>
- <jersey-version>1.17</jersey-version>
- <jetty.version>8.1.8.v20121106</jetty.version>
+ <jersey-version>1.18</jersey-version>
<junit-version>4.11</junit-version>
<log4j-version>1.2.16</log4j-version>
<metrics-version>2.1.2</metrics-version>
@@ -95,7 +94,7 @@
<shiro-version>1.2.0</shiro-version>
<slf4j-version>1.6.1</slf4j-version>
<snakeyaml-version>1.8</snakeyaml-version>
- <tomcat-version>6.0.33</tomcat-version>
+ <tomcat-version>7.0.42</tomcat-version>
<antlr.version>3.4</antlr.version>
<tika.version>1.4</tika.version>
@@ -400,6 +399,11 @@
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-mapper-asl</artifactId>
</exclusion>
+
+ <exclusion>
+ <artifactId>snappy-java</artifactId>
+ <groupId>org.xerial.snappy</groupId>
+ </exclusion>
</exclusions>
</dependency>
@@ -423,6 +427,18 @@
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</exclusion>
+
+
+ <exclusion>
+ <artifactId>servlet-api</artifactId>
+ <groupId>javax.servlet</groupId>
+ </exclusion>
+
+ <exclusion>
+ <groupId>org.mortbay.jetty</groupId>
+ <artifactId>servlet-api</artifactId>
+ </exclusion>
+
</exclusions>
</dependency>
@@ -666,9 +682,9 @@
</dependency>
<dependency>
- <groupId>javax.servlet</groupId>
- <artifactId>servlet-api</artifactId>
- <version>2.5</version>
+ <groupId>javax.servlet</groupId>
+ <artifactId>javax.servlet-api</artifactId>
+ <version>3.0.1</version>
</dependency>
<dependency>
@@ -999,26 +1015,63 @@
<version>0.9.94</version>
</dependency>
+
+
+ <dependency>
+ <groupId>org.apache.tika</groupId>
+ <artifactId>tika-core</artifactId>
+ <version>${tika.version}</version>
+ </dependency>
+
+ <!-- Mock, Testing and Logging Dependencies -->
<dependency>
- <groupId>org.eclipse.jetty.aggregate</groupId>
- <artifactId>jetty-server</artifactId>
- <version>${jetty.version}</version>
+ <groupId>org.apache.tomcat.embed</groupId>
+ <artifactId>tomcat-embed-core</artifactId>
+ <version>${tomcat-version}</version>
</dependency>
<dependency>
- <groupId>org.eclipse.jetty.aggregate</groupId>
- <artifactId>jetty-webapp</artifactId>
- <version>${jetty.version}</version>
+ <groupId>org.apache.tomcat.embed</groupId>
+ <artifactId>tomcat-embed-logging-juli</artifactId>
+ <version>${tomcat-version}</version>
</dependency>
<dependency>
- <groupId>org.apache.tika</groupId>
- <artifactId>tika-core</artifactId>
- <version>${tika.version}</version>
+ <groupId>org.apache.tomcat.embed</groupId>
+ <artifactId>tomcat-embed-jasper</artifactId>
+ <version>${tomcat-version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tomcat</groupId>
+ <artifactId>tomcat-jasper</artifactId>
+ <version>${tomcat-version}</version>
</dependency>
+ <dependency>
+ <groupId>org.apache.tomcat</groupId>
+ <artifactId>tomcat-jasper-el</artifactId>
+ <version>${tomcat-version}</version>
+ </dependency>
- <!-- Mock, Testing and Logging Dependencies -->
+ <dependency>
+ <groupId>org.apache.tomcat</groupId>
+ <artifactId>tomcat-jsp-api</artifactId>
+ <version>${tomcat-version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tomcat</groupId>
+ <artifactId>tomcat-servlet-api</artifactId>
+ <version>${tomcat-version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tomcat</groupId>
+ <artifactId>tomcat-jsp-api</artifactId>
+ <scope>test</scope>
+ <version>${tomcat-version}</version>
+ </dependency>
<dependency>
<groupId>org.jvnet.mock-javamail</groupId>
@@ -1220,28 +1273,9 @@
<version>1.27</version>
</dependency>
- <dependency>
- <groupId>org.apache.tomcat</groupId>
- <artifactId>jasper</artifactId>
- <version>${tomcat-version}</version>
- <exclusions>
- <exclusion>
- <artifactId>servlet-api</artifactId>
- <groupId>org.apache.tomcat</groupId>
- </exclusion>
- <exclusion>
- <groupId>org.apache.tomcat</groupId>
- <artifactId>juli</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>javax.servlet</groupId>
- <artifactId>javax.servlet-api</artifactId>
- <version>3.0.1</version>
- </dependency>
+
<dependency>
<groupId>com.apple</groupId>
@@ -1779,4 +1813,4 @@
<url>https://usergrid-maven.s3.amazonaws.com/dependencies</url>
</repository>
</repositories>
-</project>
\ No newline at end of file
+</project>
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e2ee790d/stack/rest/pom.xml
----------------------------------------------------------------------
diff --git a/stack/rest/pom.xml b/stack/rest/pom.xml
index 6b13d4c..e23a5e3 100644
--- a/stack/rest/pom.xml
+++ b/stack/rest/pom.xml
@@ -395,10 +395,11 @@
<!-- SUN, Javax Package, and Other Com Dependencies -->
+
<dependency>
- <groupId>javax.servlet</groupId>
- <artifactId>servlet-api</artifactId>
- <scope>provided</scope>
+ <groupId>javax.servlet</groupId>
+ <artifactId>javax.servlet-api</artifactId>
+ <scope>provided</scope>
</dependency>
<dependency>
@@ -406,6 +407,7 @@
<artifactId>jstl</artifactId>
</dependency>
+
<dependency>
<groupId>com.sun.jersey.contribs</groupId>
<artifactId>jersey-multipart</artifactId>
@@ -510,8 +512,32 @@
</dependency>
<dependency>
+ <groupId>org.apache.tomcat.embed</groupId>
+ <artifactId>tomcat-embed-core</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tomcat.embed</groupId>
+ <artifactId>tomcat-embed-logging-juli</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tomcat.embed</groupId>
+ <artifactId>tomcat-embed-jasper</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tomcat</groupId>
+ <artifactId>tomcat-jasper-el</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
<groupId>org.apache.tomcat</groupId>
- <artifactId>jasper</artifactId>
+ <artifactId>tomcat-jsp-api</artifactId>
<scope>test</scope>
</dependency>
@@ -534,17 +560,7 @@
<scope>test</scope>
</dependency>
- <dependency>
- <groupId>org.eclipse.jetty.aggregate</groupId>
- <artifactId>jetty-server</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.eclipse.jetty.aggregate</groupId>
- <artifactId>jetty-webapp</artifactId>
- <scope>test</scope>
- </dependency>
<dependency>
<groupId>org.usergrid</groupId>
@@ -560,4 +576,4 @@
<classifier>tests</classifier>
</dependency>
</dependencies>
-</project>
\ No newline at end of file
+</project>
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e2ee790d/stack/rest/src/main/java/org/usergrid/rest/JacksonCustomMapperProvider.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/usergrid/rest/JacksonCustomMapperProvider.java b/stack/rest/src/main/java/org/usergrid/rest/JacksonCustomMapperProvider.java
index 313c71d..e25bf0b 100644
--- a/stack/rest/src/main/java/org/usergrid/rest/JacksonCustomMapperProvider.java
+++ b/stack/rest/src/main/java/org/usergrid/rest/JacksonCustomMapperProvider.java
@@ -34,7 +34,7 @@ import org.springframework.stereotype.Component;
@Provider
@Component
@Scope("singleton")
-@Produces({ MediaType.APPLICATION_JSON })
+@Produces({ MediaType.APPLICATION_JSON, MediaType.TEXT_HTML })
public class JacksonCustomMapperProvider implements ContextResolver<ObjectMapper> {
private static final Logger logger = LoggerFactory.getLogger( JacksonCustomMapperProvider.class );
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e2ee790d/stack/rest/src/main/java/org/usergrid/rest/TextToJsonSwapWriter.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/usergrid/rest/TextToJsonSwapWriter.java b/stack/rest/src/main/java/org/usergrid/rest/TextToJsonSwapWriter.java
new file mode 100644
index 0000000..d39ea45
--- /dev/null
+++ b/stack/rest/src/main/java/org/usergrid/rest/TextToJsonSwapWriter.java
@@ -0,0 +1,119 @@
+package org.usergrid.rest;
+
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Type;
+
+import javax.ws.rs.Produces;
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.GenericEntity;
+import javax.ws.rs.core.HttpHeaders;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.MultivaluedMap;
+import javax.ws.rs.ext.MessageBodyWriter;
+import javax.ws.rs.ext.Provider;
+import javax.xml.bind.annotation.XmlRootElement;
+
+import org.codehaus.jackson.map.JsonSerializable;
+import org.codehaus.jackson.map.JsonSerializableWithType;
+
+import com.sun.jersey.api.json.JSONWithPadding;
+import com.sun.jersey.spi.MessageBodyWorkers;
+
+
+/**
+ * A writer that will redirect requests for "text/html" to "application/json" if the value
+ * returned by the resource is an instance of JSONWithPadding
+ *
+ * @author tnine
+ *
+ */
+@Provider
+@Produces( MediaType.TEXT_HTML )
+public class TextToJsonSwapWriter implements MessageBodyWriter<JSONWithPadding> {
+
+
+ private static final MediaType JSON_MEDIA_TYPE = MediaType.APPLICATION_JSON_TYPE;
+
+ @Context
+ MessageBodyWorkers bodyWorker;
+
+
+ @Override
+ public boolean isWriteable( final Class<?> type, final Type genericType, final Annotation[] annotations,
+ final MediaType mediaType ) {
+
+ //this should only map no media type, or text/html requests with json responses
+
+ final boolean mediaTypeCorrect = mediaType == null || MediaType.TEXT_HTML_TYPE.equals( mediaType );
+
+ if(!mediaTypeCorrect){
+ return false;
+ }
+
+
+ final boolean serializableAnnotation = type.getAnnotation( XmlRootElement.class ) != null;
+
+
+ final boolean jsonSerializable = JsonSerializableWithType.class.isAssignableFrom( type );
+
+
+ return serializableAnnotation || jsonSerializable;
+ }
+
+
+ @Override
+ public long getSize( final JSONWithPadding jsonWithPadding, final Class<?> type, final Type genericType,
+ final Annotation[] annotations, final MediaType mediaType ) {
+ return -1;
+ }
+
+
+ @Override
+ public void writeTo( final JSONWithPadding jsonWithPadding, final Class<?> type, final Type genericType,
+ final Annotation[] annotations, final MediaType mediaType,
+ final MultivaluedMap<String, Object> httpHeaders, final OutputStream entityStream )
+ throws IOException, WebApplicationException {
+
+
+ Object jsonEntity = jsonWithPadding.getJsonSource();
+ Type entityGenericType = jsonEntity.getClass();
+ Class<?> entityType = jsonEntity.getClass();
+
+ final boolean genericEntityUsed = jsonEntity instanceof GenericEntity;
+
+ if ( genericEntityUsed ) {
+ GenericEntity ge = ( GenericEntity ) jsonEntity;
+ jsonEntity = ge.getEntity();
+ entityGenericType = ge.getType();
+ entityType = ge.getRawType();
+ }
+
+
+ //replace the text/html content type with application Json
+ httpHeaders.remove( HttpHeaders.CONTENT_TYPE);
+
+ httpHeaders.putSingle( HttpHeaders.CONTENT_TYPE, JSON_MEDIA_TYPE);
+
+
+
+
+ MessageBodyWriter bw = bodyWorker.getMessageBodyWriter( entityType, entityGenericType, annotations, JSON_MEDIA_TYPE );
+
+ if ( bw == null ) {
+
+ throw new RuntimeException( "Couldn't find the serailziation writer for json type");
+ }
+
+
+
+
+ bw.writeTo( jsonEntity, entityType, entityGenericType, annotations, JSON_MEDIA_TYPE, httpHeaders,
+ entityStream );
+
+
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e2ee790d/stack/rest/src/main/java/org/usergrid/rest/applications/ServiceResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/usergrid/rest/applications/ServiceResource.java b/stack/rest/src/main/java/org/usergrid/rest/applications/ServiceResource.java
index 8cb92d5..eeb5704 100644
--- a/stack/rest/src/main/java/org/usergrid/rest/applications/ServiceResource.java
+++ b/stack/rest/src/main/java/org/usergrid/rest/applications/ServiceResource.java
@@ -280,6 +280,7 @@ public class ServiceResource extends AbstractContextResource {
@GET
+ @Produces({MediaType.APPLICATION_JSON, MediaType.TEXT_HTML})
@RequireApplicationAccess
public JSONWithPadding executeGet( @Context UriInfo ui,
@QueryParam("callback") @DefaultValue("callback") String callback )
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e2ee790d/stack/rest/src/main/java/org/usergrid/rest/exceptions/QueryParseExceptionMapper.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/usergrid/rest/exceptions/QueryParseExceptionMapper.java b/stack/rest/src/main/java/org/usergrid/rest/exceptions/QueryParseExceptionMapper.java
new file mode 100644
index 0000000..7a4b5f9
--- /dev/null
+++ b/stack/rest/src/main/java/org/usergrid/rest/exceptions/QueryParseExceptionMapper.java
@@ -0,0 +1,34 @@
+/*******************************************************************************
+ * 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.exceptions;
+
+
+import javax.ws.rs.core.Response;
+import javax.ws.rs.ext.Provider;
+
+
+import org.usergrid.persistence.exceptions.QueryParseException;
+
+import static javax.ws.rs.core.Response.Status.BAD_REQUEST;
+
+
+@Provider
+public class QueryParseExceptionMapper extends AbstractExceptionMapper<QueryParseException> {
+ @Override
+ public Response toResponse( final QueryParseException e ) {
+ return toResponse( BAD_REQUEST, e );
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e2ee790d/stack/rest/src/main/java/org/usergrid/rest/exceptions/QueryTokenExceptionMapper.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/usergrid/rest/exceptions/QueryTokenExceptionMapper.java b/stack/rest/src/main/java/org/usergrid/rest/exceptions/QueryTokenExceptionMapper.java
new file mode 100644
index 0000000..510a5d5
--- /dev/null
+++ b/stack/rest/src/main/java/org/usergrid/rest/exceptions/QueryTokenExceptionMapper.java
@@ -0,0 +1,36 @@
+/*******************************************************************************
+ * 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.exceptions;
+
+
+import javax.ws.rs.core.Response;
+import javax.ws.rs.ext.Provider;
+
+import org.usergrid.persistence.exceptions.QueryParseException;
+import org.usergrid.persistence.exceptions.QueryTokenException;
+
+import antlr.NoViableAltException;
+
+import static javax.ws.rs.core.Response.Status.BAD_REQUEST;
+
+
+@Provider
+public class QueryTokenExceptionMapper extends AbstractExceptionMapper<QueryTokenException> {
+ @Override
+ public Response toResponse( final QueryTokenException e ) {
+ return toResponse( BAD_REQUEST, e );
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e2ee790d/stack/rest/src/main/webapp/WEB-INF/c.tld
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/webapp/WEB-INF/c.tld b/stack/rest/src/main/webapp/WEB-INF/c.tld
new file mode 100644
index 0000000..8c447f5
--- /dev/null
+++ b/stack/rest/src/main/webapp/WEB-INF/c.tld
@@ -0,0 +1,572 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<taglib 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-jsptaglibrary_2_1.xsd"
+ version="2.1">
+
+ <description>JSTL 1.1 core library</description>
+ <display-name>JSTL core</display-name>
+ <tlib-version>1.1</tlib-version>
+ <short-name>c</short-name>
+ <uri>http://java.sun.com/jsp/jstl/core</uri>
+
+ <validator>
+ <description>
+ Provides core validation features for JSTL tags.
+ </description>
+ <validator-class>
+ org.apache.taglibs.standard.tlv.JstlCoreTLV
+ </validator-class>
+ </validator>
+
+ <tag>
+ <description>
+ Catches any Throwable that occurs in its body and optionally
+ exposes it.
+ </description>
+ <name>catch</name>
+ <tag-class>org.apache.taglibs.standard.tag.common.core.CatchTag</tag-class>
+ <body-content>JSP</body-content>
+ <attribute>
+ <description>
+Name of the exported scoped variable for the
+exception thrown from a nested action. The type of the
+scoped variable is the type of the exception thrown.
+ </description>
+ <name>var</name>
+ <required>false</required>
+ <rtexprvalue>false</rtexprvalue>
+ </attribute>
+ </tag>
+
+ <tag>
+ <description>
+ Simple conditional tag that establishes a context for
+ mutually exclusive conditional operations, marked by
+ <when> and <otherwise>
+ </description>
+ <name>choose</name>
+ <tag-class>org.apache.taglibs.standard.tag.common.core.ChooseTag</tag-class>
+ <body-content>JSP</body-content>
+ </tag>
+
+ <tag>
+ <description>
+ Simple conditional tag, which evalutes its body if the
+ supplied condition is true and optionally exposes a Boolean
+ scripting variable representing the evaluation of this condition
+ </description>
+ <name>if</name>
+ <tag-class>org.apache.taglibs.standard.tag.rt.core.IfTag</tag-class>
+ <body-content>JSP</body-content>
+ <attribute>
+ <description>
+The test condition that determines whether or
+not the body content should be processed.
+ </description>
+ <name>test</name>
+ <required>true</required>
+ <rtexprvalue>true</rtexprvalue>
+ <type>boolean</type>
+ </attribute>
+ <attribute>
+ <description>
+Name of the exported scoped variable for the
+resulting value of the test condition. The type
+of the scoped variable is Boolean.
+ </description>
+ <name>var</name>
+ <required>false</required>
+ <rtexprvalue>false</rtexprvalue>
+ </attribute>
+ <attribute>
+ <description>
+Scope for var.
+ </description>
+ <name>scope</name>
+ <required>false</required>
+ <rtexprvalue>false</rtexprvalue>
+ </attribute>
+ </tag>
+
+ <tag>
+ <description>
+ Retrieves an absolute or relative URL and exposes its contents
+ to either the page, a String in 'var', or a Reader in 'varReader'.
+ </description>
+ <name>import</name>
+ <tag-class>org.apache.taglibs.standard.tag.rt.core.ImportTag</tag-class>
+ <tei-class>org.apache.taglibs.standard.tei.ImportTEI</tei-class>
+ <body-content>JSP</body-content>
+ <attribute>
+ <description>
+The URL of the resource to import.
+ </description>
+ <name>url</name>
+ <required>true</required>
+ <rtexprvalue>true</rtexprvalue>
+ </attribute>
+ <attribute>
+ <description>
+Name of the exported scoped variable for the
+resource's content. The type of the scoped
+variable is String.
+ </description>
+ <name>var</name>
+ <required>false</required>
+ <rtexprvalue>false</rtexprvalue>
+ </attribute>
+ <attribute>
+ <description>
+Scope for var.
+ </description>
+ <name>scope</name>
+ <required>false</required>
+ <rtexprvalue>false</rtexprvalue>
+ </attribute>
+ <attribute>
+ <description>
+Name of the exported scoped variable for the
+resource's content. The type of the scoped
+variable is Reader.
+ </description>
+ <name>varReader</name>
+ <required>false</required>
+ <rtexprvalue>false</rtexprvalue>
+ </attribute>
+ <attribute>
+ <description>
+Name of the context when accessing a relative
+URL resource that belongs to a foreign
+context.
+ </description>
+ <name>context</name>
+ <required>false</required>
+ <rtexprvalue>true</rtexprvalue>
+ </attribute>
+ <attribute>
+ <description>
+Character encoding of the content at the input
+resource.
+ </description>
+ <name>charEncoding</name>
+ <required>false</required>
+ <rtexprvalue>true</rtexprvalue>
+ </attribute>
+ </tag>
+
+ <tag>
+ <description>
+ The basic iteration tag, accepting many different
+ collection types and supporting subsetting and other
+ functionality
+ </description>
+ <name>forEach</name>
+ <tag-class>org.apache.taglibs.standard.tag.rt.core.ForEachTag</tag-class>
+ <tei-class>org.apache.taglibs.standard.tei.ForEachTEI</tei-class>
+ <body-content>JSP</body-content>
+ <attribute>
+ <description>
+Collection of items to iterate over.
+ </description>
+ <name>items</name>
+ <required>false</required>
+ <rtexprvalue>true</rtexprvalue>
+ <type>java.lang.Object</type>
+ <deferred-value>
+ <type>java.lang.Object</type>
+ </deferred-value>
+ </attribute>
+ <attribute>
+ <description>
+If items specified:
+Iteration begins at the item located at the
+specified index. First item of the collection has
+index 0.
+If items not specified:
+Iteration begins with index set at the value
+specified.
+ </description>
+ <name>begin</name>
+ <required>false</required>
+ <rtexprvalue>true</rtexprvalue>
+ <type>int</type>
+ </attribute>
+ <attribute>
+ <description>
+If items specified:
+Iteration ends at the item located at the
+specified index (inclusive).
+If items not specified:
+Iteration ends when index reaches the value
+specified.
+ </description>
+ <name>end</name>
+ <required>false</required>
+ <rtexprvalue>true</rtexprvalue>
+ <type>int</type>
+ </attribute>
+ <attribute>
+ <description>
+Iteration will only process every step items of
+the collection, starting with the first one.
+ </description>
+ <name>step</name>
+ <required>false</required>
+ <rtexprvalue>true</rtexprvalue>
+ <type>int</type>
+ </attribute>
+ <attribute>
+ <description>
+Name of the exported scoped variable for the
+current item of the iteration. This scoped
+variable has nested visibility. Its type depends
+on the object of the underlying collection.
+ </description>
+ <name>var</name>
+ <required>false</required>
+ <rtexprvalue>false</rtexprvalue>
+ </attribute>
+ <attribute>
+ <description>
+Name of the exported scoped variable for the
+status of the iteration. Object exported is of type
+javax.servlet.jsp.jstl.core.LoopTagStatus. This scoped variable has nested
+visibility.
+ </description>
+ <name>varStatus</name>
+ <required>false</required>
+ <rtexprvalue>false</rtexprvalue>
+ </attribute>
+ </tag>
+
+ <tag>
+ <description>
+ Iterates over tokens, separated by the supplied delimeters
+ </description>
+ <name>forTokens</name>
+ <tag-class>org.apache.taglibs.standard.tag.rt.core.ForTokensTag</tag-class>
+ <body-content>JSP</body-content>
+ <attribute>
+ <description>
+String of tokens to iterate over.
+ </description>
+ <name>items</name>
+ <required>true</required>
+ <rtexprvalue>true</rtexprvalue>
+ <type>java.lang.String</type>
+ <deferred-value>
+ <type>java.lang.String</type>
+ </deferred-value>
+ </attribute>
+ <attribute>
+ <description>
+The set of delimiters (the characters that
+separate the tokens in the string).
+ </description>
+ <name>delims</name>
+ <required>true</required>
+ <rtexprvalue>true</rtexprvalue>
+ <type>java.lang.String</type>
+ </attribute>
+ <attribute>
+ <description>
+Iteration begins at the token located at the
+specified index. First token has index 0.
+ </description>
+ <name>begin</name>
+ <required>false</required>
+ <rtexprvalue>true</rtexprvalue>
+ <type>int</type>
+ </attribute>
+ <attribute>
+ <description>
+Iteration ends at the token located at the
+specified index (inclusive).
+ </description>
+ <name>end</name>
+ <required>false</required>
+ <rtexprvalue>true</rtexprvalue>
+ <type>int</type>
+ </attribute>
+ <attribute>
+ <description>
+Iteration will only process every step tokens
+of the string, starting with the first one.
+ </description>
+ <name>step</name>
+ <required>false</required>
+ <rtexprvalue>true</rtexprvalue>
+ <type>int</type>
+ </attribute>
+ <attribute>
+ <description>
+Name of the exported scoped variable for the
+current item of the iteration. This scoped
+variable has nested visibility.
+ </description>
+ <name>var</name>
+ <required>false</required>
+ <rtexprvalue>false</rtexprvalue>
+ </attribute>
+ <attribute>
+ <description>
+Name of the exported scoped variable for the
+status of the iteration. Object exported is of
+type
+javax.servlet.jsp.jstl.core.LoopTag
+Status. This scoped variable has nested
+visibility.
+ </description>
+ <name>varStatus</name>
+ <required>false</required>
+ <rtexprvalue>false</rtexprvalue>
+ </attribute>
+ </tag>
+
+ <tag>
+ <description>
+ Like <%= ... >, but for expressions.
+ </description>
+ <name>out</name>
+ <tag-class>org.apache.taglibs.standard.tag.rt.core.OutTag</tag-class>
+ <body-content>JSP</body-content>
+ <attribute>
+ <description>
+Expression to be evaluated.
+ </description>
+ <name>value</name>
+ <required>true</required>
+ <rtexprvalue>true</rtexprvalue>
+ </attribute>
+ <attribute>
+ <description>
+Default value if the resulting value is null.
+ </description>
+ <name>default</name>
+ <required>false</required>
+ <rtexprvalue>true</rtexprvalue>
+ </attribute>
+ <attribute>
+ <description>
+Determines whether characters <,>,&,'," in the
+resulting string should be converted to their
+corresponding character entity codes. Default value is
+true.
+ </description>
+ <name>escapeXml</name>
+ <required>false</required>
+ <rtexprvalue>true</rtexprvalue>
+ </attribute>
+ </tag>
+
+
+ <tag>
+ <description>
+ Subtag of <choose> that follows <when> tags
+ and runs only if all of the prior conditions evaluated to
+ 'false'
+ </description>
+ <name>otherwise</name>
+ <tag-class>org.apache.taglibs.standard.tag.common.core.OtherwiseTag</tag-class>
+ <body-content>JSP</body-content>
+ </tag>
+
+ <tag>
+ <description>
+ Adds a parameter to a containing 'import' tag's URL.
+ </description>
+ <name>param</name>
+ <tag-class>org.apache.taglibs.standard.tag.rt.core.ParamTag</tag-class>
+ <body-content>JSP</body-content>
+ <attribute>
+ <description>
+Name of the query string parameter.
+ </description>
+ <name>name</name>
+ <required>true</required>
+ <rtexprvalue>true</rtexprvalue>
+ </attribute>
+ <attribute>
+ <description>
+Value of the parameter.
+ </description>
+ <name>value</name>
+ <required>false</required>
+ <rtexprvalue>true</rtexprvalue>
+ </attribute>
+ </tag>
+
+ <tag>
+ <description>
+ Redirects to a new URL.
+ </description>
+ <name>redirect</name>
+ <tag-class>org.apache.taglibs.standard.tag.rt.core.RedirectTag</tag-class>
+ <body-content>JSP</body-content>
+ <attribute>
+ <description>
+The URL of the resource to redirect to.
+ </description>
+ <name>url</name>
+ <required>false</required>
+ <rtexprvalue>true</rtexprvalue>
+ </attribute>
+ <attribute>
+ <description>
+Name of the context when redirecting to a relative URL
+resource that belongs to a foreign context.
+ </description>
+ <name>context</name>
+ <required>false</required>
+ <rtexprvalue>true</rtexprvalue>
+ </attribute>
+ </tag>
+
+ <tag>
+ <description>
+ Removes a scoped variable (from a particular scope, if specified).
+ </description>
+ <name>remove</name>
+ <tag-class>org.apache.taglibs.standard.tag.common.core.RemoveTag</tag-class>
+ <body-content>empty</body-content>
+ <attribute>
+ <description>
+Name of the scoped variable to be removed.
+ </description>
+ <name>var</name>
+ <required>true</required>
+ <rtexprvalue>false</rtexprvalue>
+ </attribute>
+ <attribute>
+ <description>
+Scope for var.
+ </description>
+ <name>scope</name>
+ <required>false</required>
+ <rtexprvalue>false</rtexprvalue>
+ </attribute>
+ </tag>
+
+ <tag>
+ <description>
+ Sets the result of an expression evaluation in a 'scope'
+ </description>
+ <name>set</name>
+ <tag-class>org.apache.taglibs.standard.tag.rt.core.SetTag</tag-class>
+ <body-content>JSP</body-content>
+ <attribute>
+ <description>
+Name of the exported scoped variable to hold the value
+specified in the action. The type of the scoped variable is
+whatever type the value expression evaluates to.
+ </description>
+ <name>var</name>
+ <required>false</required>
+ <rtexprvalue>false</rtexprvalue>
+ </attribute>
+ <attribute>
+ <description>
+Expression to be evaluated.
+ </description>
+ <name>value</name>
+ <required>false</required>
+ <rtexprvalue>true</rtexprvalue>
+ <deferred-value>
+ <type>java.lang.Object</type>
+ </deferred-value>
+ </attribute>
+ <attribute>
+ <description>
+Target object whose property will be set. Must evaluate to
+a JavaBeans object with setter property property, or to a
+java.util.Map object.
+ </description>
+ <name>target</name>
+ <required>false</required>
+ <rtexprvalue>true</rtexprvalue>
+ </attribute>
+ <attribute>
+ <description>
+Name of the property to be set in the target object.
+ </description>
+ <name>property</name>
+ <required>false</required>
+ <rtexprvalue>true</rtexprvalue>
+ </attribute>
+ <attribute>
+ <description>
+Scope for var.
+ </description>
+ <name>scope</name>
+ <required>false</required>
+ <rtexprvalue>false</rtexprvalue>
+ </attribute>
+ </tag>
+
+ <tag>
+ <description>
+ Creates a URL with optional query parameters.
+ </description>
+ <name>url</name>
+ <tag-class>org.apache.taglibs.standard.tag.rt.core.UrlTag</tag-class>
+ <body-content>JSP</body-content>
+ <attribute>
+ <description>
+Name of the exported scoped variable for the
+processed url. The type of the scoped variable is
+String.
+ </description>
+ <name>var</name>
+ <required>false</required>
+ <rtexprvalue>false</rtexprvalue>
+ </attribute>
+ <attribute>
+ <description>
+Scope for var.
+ </description>
+ <name>scope</name>
+ <required>false</required>
+ <rtexprvalue>false</rtexprvalue>
+ </attribute>
+ <attribute>
+ <description>
+URL to be processed.
+ </description>
+ <name>value</name>
+ <required>false</required>
+ <rtexprvalue>true</rtexprvalue>
+ </attribute>
+ <attribute>
+ <description>
+Name of the context when specifying a relative URL
+resource that belongs to a foreign context.
+ </description>
+ <name>context</name>
+ <required>false</required>
+ <rtexprvalue>true</rtexprvalue>
+ </attribute>
+ </tag>
+
+ <tag>
+ <description>
+ Subtag of <choose> that includes its body if its
+ condition evalutes to 'true'
+ </description>
+ <name>when</name>
+ <tag-class>org.apache.taglibs.standard.tag.rt.core.WhenTag</tag-class>
+ <body-content>JSP</body-content>
+ <attribute>
+ <description>
+The test condition that determines whether or not the
+body content should be processed.
+ </description>
+ <name>test</name>
+ <required>true</required>
+ <rtexprvalue>true</rtexprvalue>
+ <type>boolean</type>
+ </attribute>
+ </tag>
+
+</taglib>
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e2ee790d/stack/rest/src/main/webapp/WEB-INF/jsp/org/usergrid/rest/management/users/UserResource/resetpw_email_form.jsp
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/webapp/WEB-INF/jsp/org/usergrid/rest/management/users/UserResource/resetpw_email_form.jsp b/stack/rest/src/main/webapp/WEB-INF/jsp/org/usergrid/rest/management/users/UserResource/resetpw_email_form.jsp
index 61f7292..711c23a 100644
--- a/stack/rest/src/main/webapp/WEB-INF/jsp/org/usergrid/rest/management/users/UserResource/resetpw_email_form.jsp
+++ b/stack/rest/src/main/webapp/WEB-INF/jsp/org/usergrid/rest/management/users/UserResource/resetpw_email_form.jsp
@@ -9,7 +9,7 @@
<link rel="stylesheet" type="text/css" href="/css/styles.css" />
</head>
<body>
- <div class="dialog-area">
+ <div class="dialog-area password-reset-form">
<c:if test="${!empty it.errorMsg}">
<div class="dialog-form-message">${it.errorMsg}</div>
</c:if>
@@ -28,4 +28,4 @@
</form>
</div>
</body>
-</html>
\ No newline at end of file
+</html>
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e2ee790d/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 ee2c60f..7e6dc8b 100644
--- a/stack/rest/src/main/webapp/WEB-INF/web.xml
+++ b/stack/rest/src/main/webapp/WEB-INF/web.xml
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
- xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
- version="2.5">
+ xmlns="http://java.sun.com/xml/ns/javaee"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
+ version="3.0">
<display-name>Usergrid REST API Server</display-name>
@@ -106,4 +106,14 @@
<url-pattern>/*</url-pattern>
</filter-mapping>
-</web-app>
\ No newline at end of file
+ <jsp-config>
+ <taglib>
+ <taglib-uri>http://java.sun.com/jsp/jstl/core</taglib-uri>
+ <taglib-location>c.tld</taglib-location>
+ </taglib>
+ </jsp-config>
+
+
+
+
+</web-app>
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e2ee790d/stack/rest/src/main/webapp/css/styles.css
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/webapp/css/styles.css b/stack/rest/src/main/webapp/css/styles.css
index 212cb70..ad4ccdf 100644
--- a/stack/rest/src/main/webapp/css/styles.css
+++ b/stack/rest/src/main/webapp/css/styles.css
@@ -21,7 +21,10 @@ body {
margin-top: -20em; /*set to a negative number 1/2 of your height*/
margin-left: -15em; /*set to a negative number 1/2 of your width*/
}
-
+.dialog-area.password-reset-form {
+ width:600px;
+ height:350px;
+}
.dialog-form {
margin-left: 8px;
padding: 16px 16px 16px 16px;
@@ -123,4 +126,4 @@ button.positive, .buttons a.positive{
background-color:#d12f19;
border:1px solid #d12f19;
color:#fff;
-}
\ 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/AbstractRestIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/usergrid/rest/AbstractRestIT.java b/stack/rest/src/test/java/org/usergrid/rest/AbstractRestIT.java
index b0f2a09..f5cde00 100644
--- a/stack/rest/src/test/java/org/usergrid/rest/AbstractRestIT.java
+++ b/stack/rest/src/test/java/org/usergrid/rest/AbstractRestIT.java
@@ -152,7 +152,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.getJettyPort() ).build().toString() );
+ UriBuilder.fromUri( "http://localhost/" ).port( setup.getTomcatPort() ).build().toString() );
org.usergrid.java.client.response.ApiResponse response = client.authorizeAppUser( "ed@anuff.com", "sesame" );
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e2ee790d/stack/rest/src/test/java/org/usergrid/rest/ITSetup.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/usergrid/rest/ITSetup.java b/stack/rest/src/test/java/org/usergrid/rest/ITSetup.java
index d9b1515..2701202 100644
--- a/stack/rest/src/test/java/org/usergrid/rest/ITSetup.java
+++ b/stack/rest/src/test/java/org/usergrid/rest/ITSetup.java
@@ -20,12 +20,9 @@ import java.util.Properties;
import javax.ws.rs.core.UriBuilder;
-import org.eclipse.jetty.server.Server;
-import org.eclipse.jetty.webapp.WebAppContext;
import org.junit.rules.ExternalResource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.usergrid.cassandra.AvailablePortFinder;
import org.usergrid.cassandra.CassandraResource;
import org.usergrid.management.ApplicationCreator;
import org.usergrid.management.ManagementService;
@@ -34,15 +31,15 @@ import org.usergrid.security.providers.SignInProviderFactory;
import org.usergrid.security.tokens.TokenService;
import org.usergrid.services.ServiceManagerFactory;
-import org.apache.commons.lang.math.RandomUtils;
-
/** A {@link org.junit.rules.TestRule} that sets up services. */
public class ITSetup extends ExternalResource {
- private static final int DEFAULT_JETTY_PORT = 9998;
+
+
private static final Logger LOG = LoggerFactory.getLogger( ITSetup.class );
private final CassandraResource cassandraResource;
+ private final TomcatResource tomcatResource;
private ServiceManagerFactory smf;
private ManagementService managementService;
@@ -51,12 +48,13 @@ public class ITSetup extends ExternalResource {
private TokenService tokenService;
private SignInProviderFactory providerFactory;
private Properties properties;
- private Server jetty;
- private int jettyPort = DEFAULT_JETTY_PORT;
public ITSetup( CassandraResource cassandraResource ) {
this.cassandraResource = cassandraResource;
+ tomcatResource = TomcatResource.instance;
+
+
}
@@ -84,12 +82,10 @@ public class ITSetup extends ExternalResource {
properties = cassandraResource.getBean( "properties", Properties.class );
smf = cassandraResource.getBean( ServiceManagerFactory.class );
- while ( jetty == null ) {
- startJetty();
- }
+ tomcatResource.before();
// Initialize Jersey Client
- uri = UriBuilder.fromUri( "http://localhost/" ).port( jettyPort ).build();
+ uri = UriBuilder.fromUri( "http://localhost/" ).port( tomcatResource.getPort() ).build();
ready = true;
LOG.info( "Test setup complete..." );
@@ -97,20 +93,7 @@ public class ITSetup extends ExternalResource {
}
- private void startJetty() {
- LOG.info( "Starting the Jetty Server on port {}", jettyPort );
- jettyPort = AvailablePortFinder.getNextAvailable( DEFAULT_JETTY_PORT + RandomUtils.nextInt( 1000 ) );
- jetty = new Server( jettyPort );
- jetty.setHandler( new WebAppContext( "src/main/webapp", "/" ) );
-
- try {
- jetty.start();
- }
- catch ( Exception e ) {
- jetty = null;
- }
- }
public void protect() {
@@ -128,9 +111,9 @@ public class ITSetup extends ExternalResource {
}
- public int getJettyPort() {
+ public int getTomcatPort() {
protect();
- return jettyPort;
+ return tomcatResource.getPort();
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e2ee790d/stack/rest/src/test/java/org/usergrid/rest/TomcatResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/usergrid/rest/TomcatResource.java b/stack/rest/src/test/java/org/usergrid/rest/TomcatResource.java
new file mode 100644
index 0000000..8ba697f
--- /dev/null
+++ b/stack/rest/src/test/java/org/usergrid/rest/TomcatResource.java
@@ -0,0 +1,74 @@
+package org.usergrid.rest;
+
+
+import java.io.File;
+
+import org.junit.rules.ExternalResource;
+import org.usergrid.cassandra.AvailablePortFinder;
+
+import org.apache.catalina.startup.Tomcat;
+import org.apache.commons.lang.math.RandomUtils;
+
+import com.google.common.io.Files;
+
+
+/** @author tnine */
+public class TomcatResource extends ExternalResource {
+
+ private static Object mutex = new Object();
+
+ private static final String CONTEXT = "/";
+
+ private int port;
+
+
+
+
+ private Tomcat tomcat;
+
+ protected TomcatResource(){
+
+
+ }
+
+ @Override
+ protected void before() throws Throwable {
+ if ( tomcat != null ) {
+ return;
+ }
+
+ synchronized ( mutex ) {
+ //second into mutex
+ if ( tomcat != null ) {
+ return;
+ }
+
+ File dataDir = Files.createTempDir();
+ dataDir.deleteOnExit();
+
+ port = AvailablePortFinder.getNextAvailable( 9998 + RandomUtils.nextInt(10) );
+
+ tomcat = new Tomcat();
+ tomcat.setBaseDir( dataDir.getAbsolutePath() );
+ tomcat.setPort( port );
+ tomcat.addWebapp( CONTEXT, new File( "src/main/webapp" ).getAbsolutePath() );
+
+
+ tomcat.start();
+ }
+ }
+
+
+ /**
+ * Get the port tomcat runs on
+ * @return
+ */
+ public int getPort(){
+ return port;
+ }
+
+
+ public static final TomcatResource instance = new TomcatResource();
+
+
+}