usergrid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ry...@apache.org
Subject incubator-usergrid git commit: [USERGRID-515] catch exception in ApplicationResource.executePut if application restore fails
Date Fri, 10 Apr 2015 15:18:21 GMT
Repository: incubator-usergrid
Updated Branches:
  refs/heads/USERGRID-515 [created] 853be0583


[USERGRID-515] catch exception in ApplicationResource.executePut if application restore fails


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

Branch: refs/heads/USERGRID-515
Commit: 853be05835eb3f67eac064dea653d69cbfa06f5b
Parents: f67c0eb
Author: ryan bridges <ryanb@apache.org>
Authored: Fri Apr 10 11:08:28 2015 -0400
Committer: ryan bridges <ryanb@apache.org>
Committed: Fri Apr 10 11:17:58 2015 -0400

----------------------------------------------------------------------
 .../usergrid/rest/applications/ApplicationResource.java | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/853be058/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 a35532d..f5562b5 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
@@ -31,6 +31,7 @@ import javax.ws.rs.core.Response;
 import javax.ws.rs.core.UriInfo;
 
 import org.apache.commons.lang.StringUtils;
+import org.apache.usergrid.persistence.exceptions.EntityNotFoundException;
 import org.apache.usergrid.rest.ApiResponse;
 import org.apache.usergrid.rest.security.annotations.RequireOrganizationAccess;
 import org.slf4j.Logger;
@@ -501,7 +502,16 @@ public class ApplicationResource extends ServiceResource {
             throw new IllegalArgumentException("Application ID not specified in request");
         }
 
-        management.restoreApplication( applicationId );
+        ApplicationInfo app = management.getApplicationInfo( applicationId );
+        if ( app == null ) {
+            throw new EntityNotFoundException("Application ID " + applicationId + " not found");
+        }
+
+        try {
+            emf.restoreApplication(applicationId);
+        } catch (EntityNotFoundException enfe){
+            logger.warn("Attempt to restore %s failed: %s", applicationId, enfe.getMessage());
+        }
 
         ApiResponse response = createApiResponse();
         response.setAction( "restore" );


Mime
View raw message