Search in sources :

Example 76 with ResponseStatus

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);
}
Also used : Configuration(org.hisp.dhis.configuration.Configuration) ResponseStatus(org.springframework.web.bind.annotation.ResponseStatus) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 77 with ResponseStatus

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);
}
Also used : Configuration(org.hisp.dhis.configuration.Configuration) ResponseStatus(org.springframework.web.bind.annotation.ResponseStatus) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 78 with ResponseStatus

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);
}
Also used : SampleReference(com.iggroup.oss.sample.domain.SampleReference) ResponseStatus(org.springframework.web.bind.annotation.ResponseStatus) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 79 with ResponseStatus

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);
}
Also used : InformationOrder(org.mifos.platform.questionnaire.service.InformationOrder) ArrayList(java.util.ArrayList) Map(java.util.Map) ResponseStatus(org.springframework.web.bind.annotation.ResponseStatus) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 80 with ResponseStatus

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;
}
Also used : StringWriter(java.io.StringWriter) ResponseStatus(org.springframework.web.bind.annotation.ResponseStatus) ErrorModelAndView(uk.ac.ebi.spot.goci.curation.model.errors.ErrorModelAndView) ModelAndView(org.springframework.web.servlet.ModelAndView) PrintWriter(java.io.PrintWriter) ExceptionHandler(org.springframework.web.bind.annotation.ExceptionHandler)

Aggregations

ResponseStatus (org.springframework.web.bind.annotation.ResponseStatus)149 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)118 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)36 ApiOperation (io.swagger.annotations.ApiOperation)31 WebMessageException (org.hisp.dhis.dxf2.webmessage.WebMessageException)26 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)19 GetMapping (org.springframework.web.bind.annotation.GetMapping)18 ApiResponses (io.swagger.annotations.ApiResponses)14 User (org.hisp.dhis.user.User)14 Transactional (org.springframework.transaction.annotation.Transactional)14 Date (java.util.Date)13 Configuration (org.hisp.dhis.configuration.Configuration)12 OrganisationUnit (org.hisp.dhis.organisationunit.OrganisationUnit)12 Period (org.hisp.dhis.period.Period)11 ArrayList (java.util.ArrayList)10 QualifiedName (com.netflix.metacat.common.QualifiedName)9 ApiOperation (com.wordnik.swagger.annotations.ApiOperation)9 ApiImplicitParam (io.swagger.annotations.ApiImplicitParam)9 Calendar (java.util.Calendar)9 Task (org.flowable.engine.task.Task)8