Example usage for org.springframework.web.bind.annotation RequestMethod PUT

List of usage examples for org.springframework.web.bind.annotation RequestMethod PUT

Introduction

In this page you can find the example usage for org.springframework.web.bind.annotation RequestMethod PUT.

Prototype

RequestMethod PUT

To view the source code for org.springframework.web.bind.annotation RequestMethod PUT.

Click Source Link

Usage

From source file:org.easy.scrum.service.SprintService.java

@RequestMapping(value = "/teams/{teamId}/sprints/{sprintId}", method = RequestMethod.PUT)
@ResponseBody/*  w w  w  . jav  a  2s  .c om*/
public SprintBE updateSprint(@PathVariable Long teamId, @PathVariable Long sprintId,
        @Valid @RequestBody SprintBE sprint) {
    sprint.setId(sprintId);
    return sprintDao.save(sprint);
}

From source file:com.ar.hotwiredautorepairshop.controller.CarController.java

@RequestMapping(value = "/cars/update", method = RequestMethod.PUT)
public Car updateCar(@RequestBody Car car) {
    Car carToBeUpdated = carRepository.findOne(car.getLicensePlate());
    carToBeUpdated.setBrand(car.getBrand());
    carToBeUpdated.setModel(car.getModel());
    carToBeUpdated.setProductionYear(car.getProductionYear());
    carToBeUpdated.setFuelType(car.getFuelType());
    carToBeUpdated.setMileage(car.getMileage());
    carRepository.save(carToBeUpdated);/*from   w  ww .  j av a  2 s. c o m*/
    return carToBeUpdated;
}

From source file:com.artivisi.salary.payroll.system.controller.KaryawanController.java

@RequestMapping(value = "/karyawan/{id}", method = RequestMethod.PUT)
public void editKaryawan(@PathVariable String id, @RequestBody Karyawan k) throws Exception {
    Karyawan karyawan = karyawanService.findOne(id);
    if (karyawan == null) {
        throw new Exception("Data tidak ditemukan");
    }/*from  w  w  w  .  j  a  v a  2s  .  c o  m*/
    k.setId(karyawan.getId());
    karyawanService.save(k);
}

From source file:org.lamop.riche.webservices.WorkAuthorRESTWs.java

@RequestMapping(method = RequestMethod.PUT, headers = "Accept=application/json")
public @ResponseBody WorkAuthor update(@PathParam("id") int id, @RequestBody WorkAuthor work) {
    System.out.println("ID " + id);
    System.out.println("Modify " + work);
    workAuthorService.modifyEntity(work);
    return work;//  w ww. ja  v  a 2  s  .  co m
}

From source file:nl.surfnet.mujina.controllers.IdentityProviderAPI.java

@RequestMapping(value = { "/attributes/{name:.+}" }, method = RequestMethod.PUT)
@ResponseStatus(HttpStatus.NO_CONTENT)//from www .j  a va2 s .co m
@ResponseBody
public void setAttribute(@PathVariable String name, @RequestBody Attribute attribute) {
    log.debug("Request to set attribute {} to {}", attribute.getValue(), name);
    configuration.getAttributes().put(name, attribute.getValue());
}

From source file:com.mum.controller.CardRestController.java

@RequestMapping(value = "/add/{productId}", method = RequestMethod.PUT)
@ResponseStatus(value = HttpStatus.NO_CONTENT)
public void addItem(@PathVariable String productId, HttpServletRequest request) {
    System.out.println("AddItem");
    String sessionId = request.getSession(true).getId();
    Card card = cardServiceImpl.read(productId);
    if (card == null) {
        card = cardServiceImpl.create(new Card(sessionId));
    }/*from   www. j  a v  a 2  s  .  c  o m*/
    // Product product = productServiceImpl.getProductById(productId,);
    Product product = productServiceImpl.getProductById(productId);
    if (product == null) {
        //
        throw new IllegalArgumentException("some exception");
    }
    card.addCartItem(new CardItem(product));
    cardServiceImpl.update(sessionId, card);
}

From source file:app.api.swagger.SwaggerConfig.java

@Bean
public Docket swaggerSpringMvcPlugin() {
    final Docket docket = new Docket(DocumentationType.SWAGGER_2).select().build();
    docket.apiInfo(apiInfo()).pathProvider(pathProvider());
    docket.consumes(defaultMediaType()).produces(defaultMediaType());
    docket.securitySchemes(securitySchemes()).securityContexts(securityContexts());
    docket.globalResponseMessage(RequestMethod.GET, defaultGetResponses());
    docket.globalResponseMessage(RequestMethod.PUT, defaultHttpResponses());
    docket.globalResponseMessage(RequestMethod.POST, defaultHttpResponses());
    docket.globalResponseMessage(RequestMethod.DELETE, defaultHttpResponses());
    return docket;
}

From source file:no.ndla.taxonomy.service.SwaggerConfiguration.java

@Bean
public Docket api() {
    return new Docket(DocumentationType.SWAGGER_2).select()
            .apis(RequestHandlerSelectors.basePackage("no.ndla.taxonomy.service.rest.v1"))
            .paths(PathSelectors.regex("/v1/.*")).build().pathMapping("/").apiInfo(apiInfo())
            .securitySchemes(newArrayList(oauth())).securityContexts(newArrayList(securityContext()))
            .directModelSubstitute(URI.class, String.class).useDefaultResponseMessages(false)
            .produces(newHashSet(APPLICATION_JSON_UTF8.toString()))
            .consumes(newHashSet(APPLICATION_JSON_UTF8.toString()))
            .globalResponseMessage(RequestMethod.GET,
                    newArrayList(new ResponseMessageBuilder().code(HttpStatus.OK.value())
                            .message(HttpStatus.OK.getReasonPhrase()).build()))
            .globalResponseMessage(RequestMethod.PUT,
                    newArrayList(/*from ww  w  .j a va2  s . c om*/
                            new ResponseMessageBuilder().code(NO_CONTENT.value())
                                    .message(NO_CONTENT.getReasonPhrase()).build(),
                            new ResponseMessageBuilder().code(NOT_FOUND.value())
                                    .message(NOT_FOUND.getReasonPhrase()).build()))
            .globalResponseMessage(DELETE,
                    newArrayList(
                            new ResponseMessageBuilder().code(NO_CONTENT.value())
                                    .message(NO_CONTENT.getReasonPhrase()).build(),
                            new ResponseMessageBuilder().code(NOT_FOUND.value())
                                    .message(NOT_FOUND.getReasonPhrase()).build()))
            .globalResponseMessage(RequestMethod.POST,
                    newArrayList(
                            new ResponseMessageBuilder().code(HttpStatus.CREATED.value())
                                    .message(CREATED.getReasonPhrase())
                                    .headersWithDescription(singletonMap(LOCATION.toString(),
                                            new Header("Location", "Path to created resource",
                                                    new ModelRef("URI"))))
                                    .build(),
                            new ResponseMessageBuilder().code(HttpStatus.CONFLICT.value())
                                    .message(CONFLICT.getReasonPhrase()).build()));
}

From source file:com.volho.example.todo.web.controller.TodoController.java

@RequestMapping(value = "/todos/{id}/edit", method = RequestMethod.PUT, produces = "application/json", consumes = "application/json")
@ResponseBody//from   w w w.j av a2s  .  co m
public ApiResponse editById(@PathVariable Long id, @RequestBody Todo todo) throws Exception {

    ApiResponse response = new ApiResponse();
    try {
        todo.setId(id);
        Todo item = todoService.editTodo(todo);
        response.setData(item);
        response.setSuccess(true);
        response.setMessage("Edit item successfully");

    } catch (Exception e) {
        response.setSuccess(false);
        response.setMessage("Error occur, cannot edit an item id = " + id);
    }

    return response;
}

From source file:fi.helsinki.opintoni.web.rest.adminapi.FeedbackResource.java

@RequestMapping(method = RequestMethod.PUT, value = "/{feedbackId}")
public ResponseEntity<List<FeedbackDto>> updateFeedback(@PathVariable("feedbackId") long feedbackId,
        @RequestBody FeedbackDto feedback) {
    return response(feedbackService.updateFeedback(feedbackId, feedback));
}