usergrid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From g...@apache.org
Subject usergrid git commit: Changed how the use of UnsupportedException to be only in core and added a new UnsupportedRestException error that is to be used in the rest tier. Confirmed it is now thrown in the correct cases
Date Mon, 25 Jan 2016 20:48:32 GMT
Repository: usergrid
Updated Branches:
  refs/heads/USERGRID-767 783c58403 -> f563a8d05


Changed how the use of UnsupportedException to be only in core and added a new UnsupportedRestException
error that is to be used in the rest tier. Confirmed it is now thrown in the correct cases


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

Branch: refs/heads/USERGRID-767
Commit: f563a8d0540578228ad559e5b7a0ed4beac901e4
Parents: 783c584
Author: George Reyes <grey@apache.org>
Authored: Mon Jan 25 12:48:28 2016 -0800
Committer: George Reyes <grey@apache.org>
Committed: Mon Jan 25 12:48:28 2016 -0800

----------------------------------------------------------------------
 .../org/apache/usergrid/rest/ApiResponse.java   |  2 +-
 .../rest/applications/ApplicationResource.java  |  3 +-
 .../exceptions/AbstractExceptionMapper.java     |  3 --
 .../UnsupportedOperationExceptionMapper.java    |  7 ++--
 .../UnsupportedRestOperationException.java      | 25 ++++++++++++++
 ...UnsupportedRestOperationExceptionMapper.java | 34 ++++++++++++++++++++
 ...upportedServiceOperationExceptionMapper.java |  3 --
 .../applications/ApplicationResource.java       |  3 +-
 .../usergrid/rest/test/PropertiesResource.java  |  3 +-
 .../rest/test/RefreshIndexResource.java         |  3 +-
 .../usergrid/rest/ExceptionResourceIT.java      |  3 --
 .../endpoints/OrganizationResource.java         |  3 +-
 .../rest/test/resource/model/Collection.java    |  4 ++-
 13 files changed, 76 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/usergrid/blob/f563a8d0/stack/rest/src/main/java/org/apache/usergrid/rest/ApiResponse.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/ApiResponse.java b/stack/rest/src/main/java/org/apache/usergrid/rest/ApiResponse.java
index 314f9aa..5d61c39 100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/ApiResponse.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/ApiResponse.java
@@ -184,7 +184,7 @@ public class ApiResponse {
         error = code;
         if ( e instanceof UncaughtException ) {
             errorId = ((UncaughtException) e).getTimeUUID();
-            errorDescription = "Internal Server Error: "+e.getMessage();
+            errorDescription = "Error: " + e.getMessage();
             exception = UncaughtException.class.getName();
         } else {
             errorDescription = description;

http://git-wip-us.apache.org/repos/asf/usergrid/blob/f563a8d0/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 a598c4f..8feee2c 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
@@ -46,6 +46,7 @@ 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.exceptions.UnsupportedRestOperationException;
 import org.apache.usergrid.rest.security.annotations.RequireApplicationAccess;
 import org.apache.usergrid.rest.security.annotations.RequireOrganizationAccess;
 import org.apache.usergrid.rest.security.annotations.RequireSystemAccess;
@@ -487,7 +488,7 @@ public class ApplicationResource extends ServiceResource {
     @RequireOrganizationAccess
     public ApiResponse executeDelete( @Context final UriInfo ui, @DefaultValue( "callback"
) final String callback,
                                           final String confirmAppDelete ) throws Exception
{
-        throw new UnsupportedOperationException( "Delete must be done from the management
endpoint" );
+        throw new UnsupportedRestOperationException( "Delete must be done from the management
endpoint" );
     }
 
 

http://git-wip-us.apache.org/repos/asf/usergrid/blob/f563a8d0/stack/rest/src/main/java/org/apache/usergrid/rest/exceptions/AbstractExceptionMapper.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/exceptions/AbstractExceptionMapper.java
b/stack/rest/src/main/java/org/apache/usergrid/rest/exceptions/AbstractExceptionMapper.java
index 5c42224..765e9fb 100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/exceptions/AbstractExceptionMapper.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/exceptions/AbstractExceptionMapper.java
@@ -24,7 +24,6 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import javax.servlet.http.HttpServletRequest;
-import javax.ws.rs.NotAllowedException;
 import javax.ws.rs.core.Context;
 import javax.ws.rs.core.HttpHeaders;
 import javax.ws.rs.core.Response;
@@ -33,8 +32,6 @@ import javax.ws.rs.ext.ExceptionMapper;
 
 import static javax.ws.rs.core.MediaType.APPLICATION_JSON_TYPE;
 import static javax.ws.rs.core.Response.Status.INTERNAL_SERVER_ERROR;
-import static javax.ws.rs.core.Response.Status.METHOD_NOT_ALLOWED;
-import static javax.ws.rs.core.Response.Status.NOT_IMPLEMENTED;
 import static javax.ws.rs.core.Response.Status.OK;
 import static org.apache.commons.lang.StringUtils.isNotBlank;
 import static org.apache.usergrid.rest.utils.JSONPUtils.isJavascript;

http://git-wip-us.apache.org/repos/asf/usergrid/blob/f563a8d0/stack/rest/src/main/java/org/apache/usergrid/rest/exceptions/UnsupportedOperationExceptionMapper.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/exceptions/UnsupportedOperationExceptionMapper.java
b/stack/rest/src/main/java/org/apache/usergrid/rest/exceptions/UnsupportedOperationExceptionMapper.java
index f38d152..5310b4a 100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/exceptions/UnsupportedOperationExceptionMapper.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/exceptions/UnsupportedOperationExceptionMapper.java
@@ -4,17 +4,16 @@ package org.apache.usergrid.rest.exceptions;
 import javax.ws.rs.core.Response;
 import javax.ws.rs.ext.Provider;
 
+import static javax.ws.rs.core.Response.Status.INTERNAL_SERVER_ERROR;
 import static javax.ws.rs.core.Response.Status.METHOD_NOT_ALLOWED;
 
 
-/**
- * Created by ApigeeCorporation on 1/8/16.
- */
+
 @Provider
 public class UnsupportedOperationExceptionMapper extends AbstractExceptionMapper<UnsupportedOperationException>
{
 
     @Override
     public Response toResponse( UnsupportedOperationException e ) {
-        return toResponse( METHOD_NOT_ALLOWED, e );
+        return toResponse( INTERNAL_SERVER_ERROR, e );
     }
 }

http://git-wip-us.apache.org/repos/asf/usergrid/blob/f563a8d0/stack/rest/src/main/java/org/apache/usergrid/rest/exceptions/UnsupportedRestOperationException.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/exceptions/UnsupportedRestOperationException.java
b/stack/rest/src/main/java/org/apache/usergrid/rest/exceptions/UnsupportedRestOperationException.java
new file mode 100644
index 0000000..04d48b9
--- /dev/null
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/exceptions/UnsupportedRestOperationException.java
@@ -0,0 +1,25 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.usergrid.rest.exceptions;
+
+public class UnsupportedRestOperationException extends RuntimeException{
+
+    public UnsupportedRestOperationException(String message ) {
+        super(message);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/usergrid/blob/f563a8d0/stack/rest/src/main/java/org/apache/usergrid/rest/exceptions/UnsupportedRestOperationExceptionMapper.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/exceptions/UnsupportedRestOperationExceptionMapper.java
b/stack/rest/src/main/java/org/apache/usergrid/rest/exceptions/UnsupportedRestOperationExceptionMapper.java
new file mode 100644
index 0000000..267afab
--- /dev/null
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/exceptions/UnsupportedRestOperationExceptionMapper.java
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.usergrid.rest.exceptions;
+
+
+import javax.ws.rs.core.Response;
+import javax.ws.rs.ext.Provider;
+
+import static javax.ws.rs.core.Response.Status.METHOD_NOT_ALLOWED;
+
+
+@Provider
+public class UnsupportedRestOperationExceptionMapper extends AbstractExceptionMapper<UnsupportedRestOperationException>
{
+
+    @Override
+    public Response toResponse( UnsupportedRestOperationException e ) {
+        return toResponse( METHOD_NOT_ALLOWED, e );
+    }
+}
+

http://git-wip-us.apache.org/repos/asf/usergrid/blob/f563a8d0/stack/rest/src/main/java/org/apache/usergrid/rest/exceptions/UnsupportedServiceOperationExceptionMapper.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/exceptions/UnsupportedServiceOperationExceptionMapper.java
b/stack/rest/src/main/java/org/apache/usergrid/rest/exceptions/UnsupportedServiceOperationExceptionMapper.java
index 0b68793..c5a2b65 100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/exceptions/UnsupportedServiceOperationExceptionMapper.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/exceptions/UnsupportedServiceOperationExceptionMapper.java
@@ -8,9 +8,6 @@ import org.apache.usergrid.services.exceptions.UnsupportedServiceOperationExcept
 import static javax.ws.rs.core.Response.Status.METHOD_NOT_ALLOWED;
 
 
-/**
- * Created by ApigeeCorporation on 1/8/16.
- */
 @Provider
 public class UnsupportedServiceOperationExceptionMapper extends AbstractExceptionMapper<UnsupportedServiceOperationException>
{
 

http://git-wip-us.apache.org/repos/asf/usergrid/blob/f563a8d0/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/applications/ApplicationResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/applications/ApplicationResource.java
b/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/applications/ApplicationResource.java
index cf575a5..5a60088 100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/applications/ApplicationResource.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/applications/ApplicationResource.java
@@ -32,6 +32,7 @@ import org.apache.usergrid.persistence.queue.impl.UsergridAwsCredentials;
 import org.apache.usergrid.rest.AbstractContextResource;
 import org.apache.usergrid.rest.ApiResponse;
 import org.apache.usergrid.rest.applications.ServiceResource;
+import org.apache.usergrid.rest.exceptions.UnsupportedRestOperationException;
 import org.apache.usergrid.rest.management.organizations.applications.imports.ImportsResource;
 import org.apache.usergrid.rest.security.annotations.RequireOrganizationAccess;
 import org.apache.usergrid.rest.utils.JSONPUtils;
@@ -493,7 +494,7 @@ public class ApplicationResource extends AbstractContextResource {
         // for now, only works in test mode
         String testProp = ( String ) props.get( "usergrid.test" );
         if ( testProp == null || !Boolean.parseBoolean( testProp ) ) {
-            throw new UnsupportedOperationException();
+            throw new UnsupportedRestOperationException("Test props not not functioning correctly.");
         }
 
         if ( applicationId == null ) {

http://git-wip-us.apache.org/repos/asf/usergrid/blob/f563a8d0/stack/rest/src/main/java/org/apache/usergrid/rest/test/PropertiesResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/test/PropertiesResource.java
b/stack/rest/src/main/java/org/apache/usergrid/rest/test/PropertiesResource.java
index c414b5f..c6819d7 100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/test/PropertiesResource.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/test/PropertiesResource.java
@@ -35,6 +35,7 @@ import org.slf4j.LoggerFactory;
 import org.springframework.context.annotation.Scope;
 import org.springframework.stereotype.Component;
 import org.apache.usergrid.rest.AbstractContextResource;
+import org.apache.usergrid.rest.exceptions.UnsupportedRestOperationException;
 
 
 /**
@@ -80,7 +81,7 @@ public class PropertiesResource extends AbstractContextResource {
         // only works in test mode
         String testProp = ( String ) props.get( "usergrid.test" );
         if ( testProp == null || !Boolean.parseBoolean( testProp ) ) {
-            throw new UnsupportedOperationException();
+            throw new UnsupportedRestOperationException( "Test properties were null or could
not parse usergrid.test properties" );
         }
 
         ObjectMapper mapper = new ObjectMapper();

http://git-wip-us.apache.org/repos/asf/usergrid/blob/f563a8d0/stack/rest/src/main/java/org/apache/usergrid/rest/test/RefreshIndexResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/test/RefreshIndexResource.java
b/stack/rest/src/main/java/org/apache/usergrid/rest/test/RefreshIndexResource.java
index 1fdcee0..8f1da23 100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/test/RefreshIndexResource.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/test/RefreshIndexResource.java
@@ -37,6 +37,7 @@ import org.slf4j.LoggerFactory;
 import org.springframework.context.annotation.Scope;
 import org.springframework.stereotype.Component;
 import org.apache.usergrid.rest.AbstractContextResource;
+import org.apache.usergrid.rest.exceptions.UnsupportedRestOperationException;
 
 
 /**
@@ -63,7 +64,7 @@ public class RefreshIndexResource extends AbstractContextResource {
             Properties props = management.getProperties();
             String testProp = ( String ) props.get( "usergrid.test" );
             if ( testProp == null || !Boolean.parseBoolean( testProp ) ) {
-                throw new UnsupportedOperationException();
+                throw new UnsupportedRestOperationException("Properties");
             }
 
             UUID appid = UUIDUtils.tryExtractUUID(appIdString);

http://git-wip-us.apache.org/repos/asf/usergrid/blob/f563a8d0/stack/rest/src/test/java/org/apache/usergrid/rest/ExceptionResourceIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/ExceptionResourceIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/ExceptionResourceIT.java
index c2f1728..fb32546 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/ExceptionResourceIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/ExceptionResourceIT.java
@@ -21,9 +21,6 @@ import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
 
-/**
- * Created by ApigeeCorporation on 1/5/16.
- */
 public class ExceptionResourceIT extends AbstractRestIT{
 
     @Test

http://git-wip-us.apache.org/repos/asf/usergrid/blob/f563a8d0/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/OrganizationResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/OrganizationResource.java
b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/OrganizationResource.java
index 4338677..1389148 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/OrganizationResource.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/endpoints/OrganizationResource.java
@@ -22,6 +22,7 @@ import java.util.UUID;
 
 import javax.ws.rs.core.MediaType;
 
+import org.apache.usergrid.rest.exceptions.UnsupportedRestOperationException;
 import org.apache.usergrid.rest.test.resource.model.ApiResponse;
 import org.apache.usergrid.rest.test.resource.model.Organization;
 import org.apache.usergrid.rest.test.resource.model.Token;
@@ -44,6 +45,6 @@ public class OrganizationResource extends NamedResource {
     }
 
     public Organization get(){
-        throw new UnsupportedOperationException("service doesn't exist");
+        throw new UnsupportedRestOperationException("service doesn't exist");
     }
 }

http://git-wip-us.apache.org/repos/asf/usergrid/blob/f563a8d0/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/model/Collection.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/model/Collection.java
b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/model/Collection.java
index aba05a1..5bbc0dc 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/model/Collection.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/model/Collection.java
@@ -23,6 +23,8 @@ package org.apache.usergrid.rest.test.resource.model;
 import java.util.Iterator;
 import java.util.Map;
 
+import org.apache.usergrid.rest.exceptions.UnsupportedRestOperationException;
+
 
 /**
  * A stateful iterable collection response. Used to dole out entities in iterable form
@@ -85,7 +87,7 @@ public class Collection implements Iterable<Entity>, Iterator<Entity>
{
 
     @Override
     public void remove() {
-        throw new UnsupportedOperationException( "Remove is unsupported" );
+        throw new UnsupportedRestOperationException( "Remove is unsupported" );
     }
 
     public int getNumOfEntities(){


Mime
View raw message