Repository: incubator-usergrid Updated Branches: refs/heads/USERGRID-515 853be0583 -> 266a111fb refs/heads/two-dot-o 472ccaf25 -> cb44722cc refs/heads/two-dot-o-dev b28aeee05 -> 53563e83b
[USERGRID-515] Mapping request body and passing to service Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/88b36b68 Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/88b36b68 Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/88b36b68 Branch: refs/heads/USERGRID-515 Commit: 88b36b6826c74cbbf21e57d22d9e143e2666ee1d Parents: 853be05 Author: ryan bridges <[email protected]> Authored: Fri Apr 10 16:36:50 2015 -0400 Committer: ryan bridges <[email protected]> Committed: Fri Apr 10 16:36:50 2015 -0400 ---------------------------------------------------------------------- .../rest/applications/ApplicationResource.java | 38 +++++++++++++------- 1 file changed, 25 insertions(+), 13 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/88b36b68/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 f5562b5..a47bae6 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 @@ -30,10 +30,15 @@ import javax.ws.rs.core.PathSegment; import javax.ws.rs.core.Response; import javax.ws.rs.core.UriInfo; +import com.fasterxml.jackson.databind.ObjectMapper; 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.apache.usergrid.services.ServiceAction; +import org.apache.usergrid.services.ServicePayload; +import org.apache.usergrid.utils.JsonUtils; +import org.jclouds.json.Json; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.context.annotation.Scope; @@ -502,21 +507,28 @@ public class ApplicationResource extends ServiceResource { throw new IllegalArgumentException("Application ID not specified in request"); } - ApplicationInfo app = management.getApplicationInfo( 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()); +// + app=management.getDeletedApplicationInfo(applicationId); + if(app==null) { + throw new EntityNotFoundException("Application ID " + applicationId + " not found"); + }else{ + emf.restoreApplication(applicationId); + } } ApiResponse response = createApiResponse(); - response.setAction( "restore" ); - response.setApplication( services.getApplication() ); - response.setParams( ui.getQueryParameters() ); + response.setAction("restore"); + response.setApplication(services.getApplication()); + response.setParams(ui.getQueryParameters()); + + ObjectMapper mapper = new ObjectMapper(); + Map<String, Object> json = mapper.readValue(body, mapTypeReference); + + ServicePayload payload = getPayload(json); + + executeServiceRequest( ui, response, ServiceAction.PUT, payload ); return new JSONWithPadding( response, callback ); } @@ -548,14 +560,14 @@ public class ApplicationResource extends ServiceResource { management.deleteApplication( applicationId ); - LOG.debug( "ApplicationResource.delete() deleted appId = {}", applicationId); + LOG.debug("ApplicationResource.delete() deleted appId = {}", applicationId); ApiResponse response = createApiResponse(); response.setAction( "delete" ); response.setApplication(services.getApplication()); response.setParams(ui.getQueryParameters()); - LOG.debug( "ApplicationResource.delete() sending response "); + LOG.debug("ApplicationResource.delete() sending response "); return new JSONWithPadding( response, callback ); }
