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:com.restfiddle.controller.rest.StarController.java

@RequestMapping(value = "/api/stars/{id}", method = RequestMethod.PUT, headers = "Accept=application/json")
public @ResponseBody Star update(@PathVariable("id") Long id, @RequestBody StarDTO updated) {
    logger.debug("Updating star with information: " + updated);

    Star star = starRepository.findOne(updated.getId());

    star.setName(updated.getName());//from   w  ww  .ja v  a  2 s.  c om
    star.setDescription(updated.getDescription());

    return star;
}

From source file:org.opentestsystem.authoring.testauth.rest.PublishingRecordController.java

@ResponseStatus(HttpStatus.OK)
@RequestMapping(value = "/publishingRecord/{publishingRecordId}", method = RequestMethod.PUT, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
@Secured({ "ROLE_Approval Modify" })
@PreAuthorize("hasPermission(#publishingRecord, 'ROLE_Test Modify')")
@ResponseBody// w  w w .j a  v a  2  s . c o  m
public PublishingRecord savePublishingRecord(@PathVariable final String publishingRecordId,
        @RequestBody @Valid final PublishingRecord publishingRecord,
        @RequestParam(required = false) final String incrementNextMajor, final HttpServletResponse response) {
    return this.publishingRecordService.savePublishingRecord(publishingRecord,
            Boolean.valueOf(incrementNextMajor));
}

From source file:ca.qhrtech.controllers.GameController.java

@ApiMethod(description = "Updates the Game at the specified location. Passed Game should contain the updated fields")
@RequestMapping(value = "/game/{id}", method = RequestMethod.PUT)
public ResponseEntity<Game> updateGame(@PathVariable("id") long id, @RequestBody Game game) {
    Game currentGame = gameService.findGameById(id);
    if (game == null) {
        return new ResponseEntity<>(HttpStatus.NOT_FOUND);
    }//  w  w w  . j a  va 2s  .  c o m
    currentGame.setBggId(game.getBggId());
    currentGame.setCategories(game.getCategories());
    currentGame.setImagePath(game.getImagePath());
    currentGame.setMaxPlayTimeMins(game.getMaxPlayTimeMins());
    currentGame.setMaxPlayers(game.getMaxPlayers());
    currentGame.setMinPlayTimeMins(game.getMinPlayTimeMins());
    currentGame.setMinPlayers(game.getMinPlayers());
    currentGame.setName(game.getName());
    gameService.updateGame(currentGame);
    return new ResponseEntity<>(currentGame, HttpStatus.OK);

}

From source file:at.ac.tuwien.dsg.cloud.utilities.gateway.registry.UserController.java

@RequestMapping(method = RequestMethod.PUT, value = REST_USER_PATH_VARIABLE)
public ResponseEntity<String> register(@PathVariable String user) {

    RequestEntity<KongUserCreateDto> request = RequestEntity
            .post(URI.create(this.kongUris.getKongConsumersUri())).contentType(MediaType.APPLICATION_JSON)
            .body(KongUserCreateDto.build(user));

    ResponseEntity<KongUser> resp = restUtilities.simpleRestExchange(request, KongUser.class);

    if (resp == null || resp.getStatusCode() != HttpStatus.CREATED) {
        return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
    }//from w  w w . ja v  a2 s . c om

    KongUser kongUser = resp.getBody();
    kongUser.setKey(kongService.createKeyForUser(kongUser.getUserName()));

    if (kongUser.getKey() == null) {
        return new ResponseEntity<>("User was created but key generation failed!",
                HttpStatus.FAILED_DEPENDENCY);
    }

    this.kongUsers.getUsers().add(kongUser);
    return new ResponseEntity(kongUser.getKey().getKey(), HttpStatus.OK);
}

From source file:com.jee.shiro.rest.TaskRestController.java

@RequestMapping(value = "/{id}", method = RequestMethod.PUT, consumes = "applaction/json")
// Restful204??, . ?200??.
@ResponseStatus(HttpStatus.NO_CONTENT)//from  ww w  . j  a  va 2  s .  c om
public void update(@RequestBody Task task) {
    // JSR303 Bean Validator, RestExceptionHandler?.
    BeanValidators.validateWithException(validator, task);

    // ?
    taskService.saveTask(task);
}

From source file:com.wordnik.springmvc.UserResource.java

@RequestMapping(value = "/{username}", method = { RequestMethod.PUT, RequestMethod.PATCH })
@ApiOperation(value = "Updated user", notes = "This can only be done by the logged in user.", position = 4)
@ApiResponses(value = { @ApiResponse(code = 400, message = "Invalid user supplied"),
        @ApiResponse(code = 404, message = "User not found") })
public ResponseEntity updateUser(
        @ApiParam(value = "name that need to be deleted", required = true) @PathVariable("username") String username,
        @ApiParam(value = "Updated user object", required = true) User user) {
    userData.addUser(user);//from  w ww.j a  v a 2 s  .c  o  m
    return new ResponseEntity(HttpStatus.OK);
}

From source file:com.todo.backend.web.rest.TodoApi.java

@RequestMapping(value = "/todo/{id}", method = RequestMethod.PUT, produces = MediaType.APPLICATION_JSON_VALUE)
@Timed// w w w .j av a 2s .co m
@Transactional
public ResponseEntity<UpdateTodoResponse> updateTodo(@PathVariable Long id,
        @Valid @RequestBody RestUpdateTodoRequest request) {
    log.debug("PUT /todo/{} {}", id, request);
    final Todo todo = convertToTodo(id, request);
    final Todo result = todoRepository.save(todo);
    return ResponseEntity.ok().body(convertToUpdateTodoResponse(result));
}

From source file:com.todo.backend.web.rest.UserApi.java

@RequestMapping(value = "/user/{id}", method = RequestMethod.PUT, produces = MediaType.APPLICATION_JSON_VALUE)
@Timed//from w  w  w.  j  a v  a2 s  . com
@Transactional
@PreAuthorize("hasAuthority('ADMIN')")
public ResponseEntity<UpdateUserResponse> updateUser(@PathVariable Long id,
        @Valid @RequestBody RestUpdateUserRequest request) {
    log.debug("PUT /user/{} {}", id, request);
    final User user = convertToUser(id, request);
    final User result = userRepository.save(user);
    return ResponseEntity.ok().body(convertToUpdateUserResponse(result));
}

From source file:ca.qhrtech.controllers.ResultController.java

@ApiMethod(description = "Updates the Game Result at the specified location")
@RequestMapping(value = "/result/{id}", method = RequestMethod.PUT)
public ResponseEntity<GameResult> updateResult(@PathVariable("id") long id, @RequestBody GameResult result) {
    GameResult currentResult = resultService.findResultById(id);
    if (currentResult == null) {
        return new ResponseEntity<>(HttpStatus.NOT_FOUND);
    }//from ww  w . j a  va2s .c om

    currentResult.setComments(result.getComments());
    currentResult.setTeam(result.getTeam());
    currentResult.setWinner(result.isWinner());
    resultService.updateResult(currentResult);
    return new ResponseEntity<>(currentResult, HttpStatus.OK);
}

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

@RequestMapping(method = RequestMethod.PUT, headers = "Accept=application/json")
public @ResponseBody WorkEntity update(@PathParam("id") int id, @RequestBody WorkEntity work) {
    System.out.println("ID " + id);
    System.out.println("Modify " + work);
    serviceWork.modifyEntity(work);/*www.  j ava 2s.  com*/
    return work;
}