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.springrest.controller.EmployeeController.java

@RequestMapping(value = "/rest/emp/delete/{id}", method = RequestMethod.PUT)
public @ResponseBody Employee deleteEmployee(@PathVariable("id") int empId) {
    logger.info("Start deleteEmployee.");
    return employeeService.delete(empId);
}

From source file:infowall.web.controller.ItemValueController.java

@RequestMapping(value = "/item/{dashboardId}/{itemName}", method = RequestMethod.PUT)
@ResponseBody//from   w  w w .  j av  a 2  s.  co  m
public ReturnStatus storeValueWithBody(@PathVariable String dashboardId, @PathVariable String itemName,
        @RequestBody String value) {

    return status(itemValueProcess.storeItemValue(dashboardId, itemName, value));
}

From source file:com.turn.griffin.GriffinService.java

@RequestMapping(value = { "/localrepo", "/globalrepo" }, method = { RequestMethod.POST, RequestMethod.PUT })
public @ResponseBody String pushToRepo(@RequestParam(value = "blobname", required = true) String blobname,
        @RequestParam(value = "dest", required = true) String dest,
        @RequestParam(value = "file", required = true) MultipartFile file) {

    if (!StringUtils.isNotBlank(blobname)) {
        return "Blobname cannot be empty\n";
    }/*from ww  w. j a  va2 s  .  c o m*/

    if (!StringUtils.isNotBlank(dest)) {
        return "Dest cannot be empty\n";
    }

    try {
        File tempFile = File.createTempFile("gfn", null, null);
        byte[] bytes = file.getBytes();
        BufferedOutputStream stream = new BufferedOutputStream(new FileOutputStream(tempFile));
        stream.write(bytes);
        stream.close();
        module.get().syncBlob(blobname, dest, tempFile.getAbsolutePath());
        return String.format("Pushed file as blob %s to destination %s%n", blobname, dest);
    } catch (Exception e) {
        logger.error(String.format("POST request failed%n%s%n", ExceptionUtils.getStackTrace(e)));
        return String.format("Unable to push file as blob %s to destination %s%n", blobname, dest);
    } // TODO: Delete tempFile
}

From source file:net.bluemix.questions.web.controllers.QuestionController.java

@RequestMapping(value = "{id}", method = RequestMethod.PUT)
public Question update(@RequestBody Question domain, @PathVariable Long id) {
    Question question = repo.findOne(id);
    question.setAnswered(domain.isAnswered());
    question.setContent(domain.getContent());
    question.setEmail(domain.getEmail());
    question.setNumber(domain.getNumber());
    return repo.save(question);
}

From source file:de.sainth.recipe.backend.rest.controller.FoodController.java

@Secured("ROLE_ADMIN")
@RequestMapping(value = "{id}", method = RequestMethod.PUT)
HttpEntity<Food> update(@PathVariable("id") Long id, @Valid @RequestBody Food food) {
    if (id.equals(food.getId())) {
        if (repository.findOne(food.getId()) != null) {
            repository.save(food);/*from   w  w w.j ava 2  s  .c  om*/
            return new ResponseEntity<>(food, HttpStatus.OK);
        }
    }
    return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
}

From source file:com.tsg.cms.CategoryController.java

@RequestMapping(value = "/category/{id}", method = RequestMethod.PUT)
@ResponseStatus(HttpStatus.NO_CONTENT)//  w  ww . j a  v a 2 s .  c om
@ResponseBody
public CategoryContainer updateCategory(@PathVariable("id") int id, @Valid @RequestBody Category category) {

    category.setCategoryId(id);
    CategoryContainer categoryContainer = new CategoryContainer();

    categoryContainer.setCategory(dao.updateCategory(category));

    return categoryContainer;
}

From source file:com.example.controller.admin.AdminRestaurantController.java

@RequestMapping(value = "/restaurants/{id}", method = RequestMethod.PUT)
public String update(@PathVariable Long id, @RequestBody String body) {
    Restaurant restaurant = restaurantRepository.findOne(id);
    if (restaurant != null) {
        RestaurantDTO dto = gson.fromJson(body, RestaurantDTO.class);
        if (dto.getName() != null && !dto.getName().isEmpty())
            restaurant.setName(dto.getName());
        if (dto.getDescriptions() != null && !dto.getDescriptions().isEmpty())
            restaurant.setDescription(dto.getDescriptions());
        restaurantRepository.save(restaurant);
        return "ok";
    } else/* w ww  . j  a va  2 s  .c  om*/
        throw new IllegalArgumentException("Restaurant not found");
}

From source file:net.triptech.metahive.web.CategoryController.java

@RequestMapping(method = RequestMethod.PUT)
@PreAuthorize("hasRole('ROLE_ADMIN')")
public String update(@Valid Category category, BindingResult bindingResult, Model uiModel,
        HttpServletRequest request) {//from  w w  w .  ja v  a 2 s.c  o  m

    if (bindingResult.hasErrors()) {
        uiModel.addAttribute("category", category);

        FlashScope.appendMessage(getMessage("metahive_object_validation", Category.class), request);
        return "categories/update";
    }
    uiModel.asMap().clear();
    category.merge();

    FlashScope.appendMessage(getMessage("metahive_edit_complete", Category.class), request);

    return "redirect:/lists";
}

From source file:com.cloud.ops.resource.ResourcePackageController.java

@RequestMapping(method = RequestMethod.PUT)
public ResourcePackage update(@RequestBody ResourcePackage version) {
    return service.update(version);
}

From source file:com.sentinel.web.controllers.LoginController.java

/**
 * api to set session timeout for current HttpSession. timeoutInSeconds is
 * optional parameter. If not set, will be defaulted to 24 hours (86400s)
 * /*from w  w  w  .j ava2 s. c o m*/
 * @param timeoutInSeconds
 * @param httpSession
 * @return
 */
@RequestMapping(method = RequestMethod.PUT, value = "/loginsession/timeout")
public @ResponseBody String setSessionTimeout(
        @RequestParam(value = "timeoutInSeconds", defaultValue = "86400") int timeoutInSeconds,
        HttpSession httpSession) {
    httpSession.setMaxInactiveInterval(timeoutInSeconds);
    return "httpSession timeout set to:" + httpSession.getMaxInactiveInterval();
}