use of org.springframework.web.bind.annotation.ResponseStatus in project dhis2-core by dhis2.
the class ConfigurationController method setSystemId.
@PreAuthorize("hasRole('ALL')")
@ResponseStatus(value = HttpStatus.OK)
@RequestMapping(value = "/systemId", method = RequestMethod.POST)
public void setSystemId(@RequestBody(required = false) String systemId) {
systemId = ObjectUtils.firstNonNull(systemId, UUID.randomUUID().toString());
Configuration config = configurationService.getConfiguration();
config.setSystemId(systemId);
configurationService.setConfiguration(config);
}
use of org.springframework.web.bind.annotation.ResponseStatus in project dhis2-core by dhis2.
the class ConfigurationController method removeFeedbackRecipients.
@PreAuthorize("hasRole('ALL') or hasRole('F_SYSTEM_SETTING')")
@RequestMapping(value = "/feedbackRecipients", method = RequestMethod.DELETE)
@ResponseStatus(HttpStatus.NO_CONTENT)
public void removeFeedbackRecipients() {
Configuration config = configurationService.getConfiguration();
config.setFeedbackRecipients(null);
configurationService.setConfiguration(config);
}
use of org.springframework.web.bind.annotation.ResponseStatus in project RESTdoclet by IG-Group.
the class SampleController method deleteSample.
/**
* Delete the sample indicated by the reference
*
* @param reference the sample's reference, a 5 digit text field
*/
@RequestMapping(value = "/samples/{reference}", method = { RequestMethod.DELETE })
@ResponseStatus(value = HttpStatus.NO_CONTENT)
public void deleteSample(@PathVariable String reference) {
LOGGER.info("deleteSample " + reference);
validate(new SampleReference(reference));
service.deleteSample(reference);
}
use of org.springframework.web.bind.annotation.ResponseStatus in project head by mifos.
the class InformationOrderController method saveInformationOrder.
@RequestMapping(value = "/saveInformationOrder", method = RequestMethod.POST)
@ResponseStatus(HttpStatus.NO_CONTENT)
public void saveInformationOrder(@RequestBody Map<String, Integer> order, HttpServletRequest request, HttpServletResponse response) {
List<InformationOrder> informationOrderList = new ArrayList<InformationOrder>();
InformationOrder informationOrder;
for (Map.Entry<String, Integer> entry : order.entrySet()) {
informationOrder = new InformationOrder(Integer.valueOf(entry.getKey()), null, null, null, entry.getValue());
informationOrderList.add(informationOrder);
}
informationOrderServiceFacade.updateInformationOrder(informationOrderList);
}
use of org.springframework.web.bind.annotation.ResponseStatus in project goci by EBISPOT.
the class GlobalExceptionHandlingControllerAdvice method defaultErrorHandler.
// //xintodo more
// @ResponseStatus(value=HttpStatus.CONFLICT, reason=“Data integrity violation”) // 409
// @ExceptionHandler(DataIntegrityViolationException.class)
// public void conflict() {
// // Nothing to do
// }
/**
* Created by xinhe on 11/04/2017.
* This method is the dedault place for un-handled exceptions raised from controllers.
*/
@ExceptionHandler(value = Exception.class)
public ModelAndView defaultErrorHandler(HttpServletRequest req, Exception e) throws Exception {
// AnnotationUtils is a Spring Framework utility class.
if (AnnotationUtils.findAnnotation(e.getClass(), ResponseStatus.class) != null) {
throw e;
}
getLog().warn("Unhandled exception caught GlobalExceptionHandlingControllerAdvice when User <" + req.getRemoteUser().toString() + "> requesting " + req.getRequestURL().toString() + " with HTTP- " + req.getMethod());
getLog().warn("Exception: " + e);
getLog().warn("Cause: " + e.getCause().getCause().toString());
//print all request header/parameters
// getLog().warn(“Request Details:“);
// Enumeration<String> headerNames = req.getHeaderNames();
// while(headerNames.hasMoreElements()) {
// String headerName = (String)headerNames.nextElement();
// getLog().warn(“Header Name - ” + headerName + “, Value - ” + req.getHeader(headerName));
// }
//
//
// Enumeration<String> params = req.getParameterNames();
// while(params.hasMoreElements()){
// String paramName = (String)params.nextElement();
// getLog().warn(“Parameter Name - “+paramName+“, Value - “+req.getParameter(paramName));
// }
//print stacktrace
getLog().warn("StackTrace: ");
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
e.printStackTrace(pw);
getLog().warn(sw.toString());
// Otherwise setup and send the user to a default error-view.
ModelAndView mav = new ModelAndView();
mav.addObject("exception", e);
mav.addObject("message", e.getCause().getCause().toString());
mav.addObject("url", req.getRequestURL());
mav.addObject("trace", sw.toString());
mav.addObject("path", req.getRequestURL());
mav.setViewName(DEFAULT_ERROR_VIEW);
return mav;
}
Aggregations