Skip to content

Instantly share code, notes, and snippets.

@chathurawidanage
Created September 3, 2016 08:23
Show Gist options
  • Save chathurawidanage/404f824230143d79d97fb626d11a4b7b to your computer and use it in GitHub Desktop.
Save chathurawidanage/404f824230143d79d97fb626d11a4b7b to your computer and use it in GitHub Desktop.
@RequestMapping( value = "/{uid}", method = RequestMethod.DELETE )
@PreAuthorize( "hasRole('ALL') or hasRole('F_TRACKED_ENTITY_DATAVALUE_DELETE')" )
public void deleteEvent( HttpServletResponse response, HttpServletRequest request,
@PathVariable( "uid" ) String uid ) throws WebMessageException
{
if ( !programStageInstanceService.programStageInstanceExists( uid ) )
{
throw new WebMessageException( WebMessageUtils.notFound( "Event not found for ID " + uid ) );
}
response.setStatus( HttpServletResponse.SC_OK );
try
{
ImportSummary importSummary = eventService.deleteEvent( uid );
webMessageService.send( WebMessageUtils.importSummary( importSummary ), response, request );
}
catch ( Exception ex )
{
webMessageService.send( WebMessageUtils.conflict( "Unable to delete event " + uid, ex.getMessage() ), response, request );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment