Search in sources :

Example 46 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 47 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 48 with ResponseStatus

use of org.springframework.web.bind.annotation.ResponseStatus in project ORCID-Source by ORCID.

the class PasswordResetController method sendReactivation.

@RequestMapping(value = "/sendReactivation.json", method = RequestMethod.POST)
@ResponseStatus(value = HttpStatus.OK)
public void sendReactivation(@RequestParam("email") String email) {
    OrcidProfile orcidProfile = orcidProfileCacheManager.retrieve(emailManager.findOrcidIdByEmail(email));
    notificationManager.sendReactivationEmail(email, orcidProfile);
}
Also used : OrcidProfile(org.orcid.jaxb.model.message.OrcidProfile) ResponseStatus(org.springframework.web.bind.annotation.ResponseStatus) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 49 with ResponseStatus

use of org.springframework.web.bind.annotation.ResponseStatus in project Activiti by Activiti.

the class ModelSaveRestResource method saveModel.

@RequestMapping(value = "/model/{modelId}/save", method = RequestMethod.PUT)
@ResponseStatus(value = HttpStatus.OK)
public void saveModel(@PathVariable String modelId, @RequestBody MultiValueMap<String, String> values) {
    try {
        Model model = repositoryService.getModel(modelId);
        ObjectNode modelJson = (ObjectNode) objectMapper.readTree(model.getMetaInfo());
        modelJson.put(MODEL_NAME, values.getFirst("name"));
        modelJson.put(MODEL_DESCRIPTION, values.getFirst("description"));
        model.setMetaInfo(modelJson.toString());
        model.setName(values.getFirst("name"));
        repositoryService.saveModel(model);
        repositoryService.addModelEditorSource(model.getId(), values.getFirst("json_xml").getBytes("utf-8"));
        InputStream svgStream = new ByteArrayInputStream(values.getFirst("svg_xml").getBytes("utf-8"));
        TranscoderInput input = new TranscoderInput(svgStream);
        PNGTranscoder transcoder = new PNGTranscoder();
        // Setup output
        ByteArrayOutputStream outStream = new ByteArrayOutputStream();
        TranscoderOutput output = new TranscoderOutput(outStream);
        // Do the transformation
        transcoder.transcode(input, output);
        final byte[] result = outStream.toByteArray();
        repositoryService.addModelEditorSourceExtra(model.getId(), result);
        outStream.close();
    } catch (Exception e) {
        LOGGER.error("Error saving model", e);
        throw new ActivitiException("Error saving model", e);
    }
}
Also used : PNGTranscoder(org.apache.batik.transcoder.image.PNGTranscoder) ActivitiException(org.activiti.engine.ActivitiException) TranscoderOutput(org.apache.batik.transcoder.TranscoderOutput) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) ByteArrayInputStream(java.io.ByteArrayInputStream) TranscoderInput(org.apache.batik.transcoder.TranscoderInput) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) Model(org.activiti.engine.repository.Model) ByteArrayOutputStream(java.io.ByteArrayOutputStream) ActivitiException(org.activiti.engine.ActivitiException) ResponseStatus(org.springframework.web.bind.annotation.ResponseStatus) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 50 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)93 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)69 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)35 WebMessageException (org.hisp.dhis.dxf2.webmessage.WebMessageException)26 GetMapping (org.springframework.web.bind.annotation.GetMapping)17 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)16 User (org.hisp.dhis.user.User)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 ApiOperation (com.wordnik.swagger.annotations.ApiOperation)9 Calendar (java.util.Calendar)9 DataSet (org.hisp.dhis.dataset.DataSet)7 ISymmetricEngine (org.jumpmind.symmetric.ISymmetricEngine)7 ArrayList (java.util.ArrayList)6 DataApproval (org.hisp.dhis.dataapproval.DataApproval)6 DataApprovalLevel (org.hisp.dhis.dataapproval.DataApprovalLevel)6 NotFoundException (org.hisp.dhis.webapi.controller.exception.NotFoundException)6 Proveedor (sic.modelo.Proveedor)6