@ PUT @ Path ( "/{windowsID}" ) @ Consumes ( MediaType . APPLICATION_JSON ) @ Produces ( MediaType . APPLICATION_JSON ) public Response updateWindowsVariant ( @ PathParam ( "windowsID" ) String windowsID , WindowsVariant updatedWindowsVariant ) { WindowsVariant windowsVariant = ( WindowsVariant ) variantService . findByVariantID ( windowsID ) ; if ( windowsVariant != null ) { // some validation try { validateModelClass ( updatedWindowsVariant ) ; } catch ( ConstraintViolationException cve ) { logger . info ( "Unable to update Windows Variant '{}'" , windowsVariant . getVariantID ( ) ) ; logger . debug ( "Details: {}" , cve ) ; // Build and return the 400 (Bad Request) response Response . ResponseBuilder builder = createBadRequestResponse ( cve . getConstraintViolations ( ) ) ; return builder . build ( ) ; } // apply updated data: if ( windowsVariant instanceof WindowsWNSVariant ) { WindowsWNSVariant windowsWNSVariant = ( WindowsWNSVariant ) windowsVariant ; windowsWNSVariant . setClientSecret ( ( ( WindowsWNSVariant ) updatedWindowsVariant ) . getClientSecret ( ) ) ; windowsWNSVariant . setSid ( ( ( WindowsWNSVariant ) updatedWindowsVariant ) . getSid ( ) ) ; } windowsVariant . setName ( updatedWindowsVariant . getName ( ) ) ; windowsVariant . setDescription ( updatedWindowsVariant . getDescription ( ) ) ; logger . trace ( "Updating Windows Variant '{}'" , windowsVariant . getVariantID ( ) ) ; variantService . updateVariant ( windowsVariant ) ; return Response . ok ( windowsVariant ) . build ( ) ; } return Response . status ( Response . Status . NOT_FOUND ) . entity ( "Could not find requested Variant" ) . build ( ) ; }
Update Windows Variant