/** * Reset MasterSecret for Push Application * * @param pushApplicationID id of {@link PushApplication} * @return updated {@link PushApplication} * @statuscode 204 The MasterSecret for Push Application reset successfully * @statuscode 404 The requested PushApplication resource does not exist */ @PUT @Path("/{pushAppID}/reset") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) @ReturnType("org.jboss.aerogear.unifiedpush.api.PushApplication") public Response resetMasterSecret(@PathParam("pushAppID") String pushApplicationID) { // PushApplication pushApp = // pushAppService.findByPushApplicationIDForDeveloper(pushApplicationID, // extractUsername(request)); PushApplication pushApp = getSearch().findByPushApplicationIDForDeveloper(pushApplicationID); if (pushApp != null) { // generate the new 'masterSecret' and apply it: String newMasterSecret = UUID.randomUUID().toString(); pushApp.setMasterSecret(newMasterSecret); pushAppService.updatePushApplication(pushApp); return Response.ok(pushApp).build(); } return Response.status(Status.NOT_FOUND) .entity("Could not find requested PushApplicationEntity") .build(); }
/** * Update Push Application * * @param pushApplicationID id of {@link PushApplication} * @param updatedPushApp new info of {@link PushApplication} * @statuscode 204 The PushApplication updated successfully * @statuscode 400 The format of the client request was incorrect * @statuscode 404 The requested PushApplication resource does not exist */ @PUT @Path("/{pushAppID}") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) @ReturnType("java.lang.Void") public Response updatePushApplication( @PathParam("pushAppID") String pushApplicationID, PushApplication updatedPushApp) { PushApplication pushApp = getSearch().findByPushApplicationIDForDeveloper(pushApplicationID); if (pushApp != null) { // some validation try { validateModelClass(updatedPushApp); } catch (ConstraintViolationException cve) { // Build and return the 400 (Bad Request) response ResponseBuilder builder = createBadRequestResponse(cve.getConstraintViolations()); return builder.build(); } // update name/desc: pushApp.setDescription(updatedPushApp.getDescription()); pushApp.setName(updatedPushApp.getName()); pushAppService.updatePushApplication(pushApp); return Response.noContent().build(); } return Response.status(Status.NOT_FOUND) .entity("Could not find requested PushApplicationEntity") .build(); }