@RequireOrganizationAccess @GET @JSONP @Produces({MediaType.APPLICATION_JSON, "application/javascript"}) public ApiResponse getApplication( @Context UriInfo ui, @QueryParam("callback") @DefaultValue("callback") String callback) throws Exception { ApiResponse response = createApiResponse(); ServiceManager sm = smf.getServiceManager(applicationId); response.setAction("get"); response.setApplication(sm.getApplication()); response.setParams(ui.getQueryParameters()); response.setResults(management.getApplicationMetadata(applicationId)); return response; }
@DELETE @RequireOrganizationAccess @JSONP @Produces({MediaType.APPLICATION_JSON, "application/javascript"}) public ApiResponse executeDelete( @Context UriInfo ui, @QueryParam("callback") @DefaultValue("callback") String callback, @QueryParam("app_delete_confirm") String confirmDelete) throws Exception { if (!"confirm_delete_of_application_and_data".equals(confirmDelete)) { throw new IllegalArgumentException( "Cannot delete application without app_delete_confirm parameter"); } Properties props = management.getProperties(); // for now, only works in test mode String testProp = (String) props.get("usergrid.test"); if (testProp == null || !Boolean.parseBoolean(testProp)) { throw new UnsupportedOperationException(); } if (applicationId == null) { throw new IllegalArgumentException("Application ID not specified in request"); } management.deleteApplication(applicationId); if (logger.isDebugEnabled()) { logger.debug("ApplicationResource.delete() deleted appId = {}", applicationId); } ApiResponse response = createApiResponse(); response.setAction("delete"); response.setApplication(emf.getEntityManager(applicationId).getApplication()); response.setParams(ui.getQueryParameters()); if (logger.isDebugEnabled()) { logger.debug("ApplicationResource.delete() sending response "); } return response; }
/** Put on application URL will restore application if it was deleted. */ @PUT @RequireOrganizationAccess @JSONP @Produces({MediaType.APPLICATION_JSON, "application/javascript"}) public ApiResponse executePut( @Context UriInfo ui, String body, @QueryParam("callback") @DefaultValue("callback") String callback) throws Exception { if (applicationId == null) { throw new IllegalArgumentException("Application ID not specified in request"); } management.restoreApplication(applicationId); ApiResponse response = createApiResponse(); response.setAction("restore"); response.setApplication(emf.getEntityManager(applicationId).getApplication()); response.setParams(ui.getQueryParameters()); return response; }