add apm mobile config
Project: http://git-wip-us.apache.org/repos/asf/usergrid/repo Commit: http://git-wip-us.apache.org/repos/asf/usergrid/commit/cf6cf833 Tree: http://git-wip-us.apache.org/repos/asf/usergrid/tree/cf6cf833 Diff: http://git-wip-us.apache.org/repos/asf/usergrid/diff/cf6cf833 Branch: refs/heads/USERGRID-933 Commit: cf6cf83348819ead3ad58b1308832c06e1c9b412 Parents: a7ae791 Author: Shawn Feldman <sfeld...@apache.org> Authored: Fri Sep 11 10:44:38 2015 -0600 Committer: Shawn Feldman <sfeld...@apache.org> Committed: Fri Sep 11 10:44:38 2015 -0600 ---------------------------------------------------------------------- .../usergrid/rest/applications/ApplicationResource.java | 11 +++++++++-- .../rest/applications/ApplicationResourceIT.java | 12 ++++++++++++ 2 files changed, 21 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/usergrid/blob/cf6cf833/stack/rest/src/main/java/org/apache/usergrid/rest/applications/ApplicationResource.java ---------------------------------------------------------------------- diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/applications/ApplicationResource.java b/stack/rest/src/main/java/org/apache/usergrid/rest/applications/ApplicationResource.java index 52a0f99..c521d4f 100644 --- a/stack/rest/src/main/java/org/apache/usergrid/rest/applications/ApplicationResource.java +++ b/stack/rest/src/main/java/org/apache/usergrid/rest/applications/ApplicationResource.java @@ -35,6 +35,7 @@ import org.apache.usergrid.persistence.EntityManager; import org.apache.usergrid.persistence.SimpleEntityRef; import org.apache.usergrid.persistence.entities.Application; import org.apache.usergrid.persistence.entities.User; +import org.apache.usergrid.persistence.exceptions.EntityNotFoundException; import org.apache.usergrid.persistence.index.query.Identifier; import org.apache.usergrid.rest.AbstractContextResource; import org.apache.usergrid.rest.applications.assets.AssetsResource; @@ -42,6 +43,7 @@ import org.apache.usergrid.rest.applications.events.EventsResource; import org.apache.usergrid.rest.applications.queues.QueueResource; import org.apache.usergrid.rest.applications.users.UsersResource; import org.apache.usergrid.rest.exceptions.AuthErrorInfo; +import org.apache.usergrid.rest.exceptions.NotFoundExceptionMapper; import org.apache.usergrid.rest.exceptions.RedirectionException; import org.apache.usergrid.rest.security.annotations.RequireApplicationAccess; import org.apache.usergrid.rest.security.annotations.RequireOrganizationAccess; @@ -589,8 +591,13 @@ public class ApplicationResource extends ServiceResource { APIGEE_MOBILE_APM_CONFIG_JSON_KEY ); //If there is no apm configuration then try to create apm config on the fly if ( value == null ) { - value = management.registerAppWithAPM( management.getOrganizationForApplication( applicationId ), - management.getApplicationInfo( applicationId ) ); + value = management.registerAppWithAPM( + management.getOrganizationForApplication( applicationId ), + management.getApplicationInfo( applicationId ) + ); + } + if(value==null){ + throw new EntityNotFoundException("apigeeMobileConfig not found, it is possibly not enabled for your config."); } return new JSONWithPadding( value, callback ); } http://git-wip-us.apache.org/repos/asf/usergrid/blob/cf6cf833/stack/rest/src/test/java/org/apache/usergrid/rest/applications/ApplicationResourceIT.java ---------------------------------------------------------------------- diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/ApplicationResourceIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/ApplicationResourceIT.java index ec858f7..f7e8dc3 100644 --- a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/ApplicationResourceIT.java +++ b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/ApplicationResourceIT.java @@ -21,10 +21,12 @@ import com.sun.jersey.api.client.ClientResponse.Status; import com.sun.jersey.api.client.UniformInterfaceException; import com.sun.jersey.api.client.WebResource; import com.sun.jersey.api.representation.Form; +import junit.framework.Assert; import org.apache.commons.lang.RandomStringUtils; import org.apache.shiro.codec.Base64; import org.apache.usergrid.cassandra.SpringResource; import org.apache.usergrid.management.ManagementService; +import org.apache.usergrid.persistence.exceptions.EntityNotFoundException; import org.apache.usergrid.rest.test.resource.AbstractRestIT; import org.apache.usergrid.rest.test.resource.endpoints.mgmt.OrganizationResource; import org.apache.usergrid.rest.test.resource.model.*; @@ -845,6 +847,16 @@ public class ApplicationResourceIT extends AbstractRestIT { assertNull(response.getError()); } + @Test + public void getApmConfig(){ + try { + Collection collection = this.app().collection("apm/apigeeMobileConfig").get(); + fail(); + }catch (UniformInterfaceException e){ + Assert.assertEquals(404, e.getResponse().getStatus()); + } + } + /** * Get the client credentials for the current app * @return Credentials