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:ca.qhrtech.controllers.CategoryController.java

@ApiMethod(description = "Updates the Category at the specified location. Passed Category should contain updated fields")
@RequestMapping(value = "/category/{id}", method = RequestMethod.PUT)
public ResponseEntity<Category> updateCategory(@PathVariable("id") long id, @RequestBody Category category) {
    Category currentCategory = categoryService.findCategoryById(id);
    if (category == null) {
        return new ResponseEntity<>(HttpStatus.NOT_FOUND);
    }/*from  ww w  .  j a  va2s .co m*/

    currentCategory.setName(category.getName());
    categoryService.updateCategory(currentCategory);
    return new ResponseEntity<>(currentCategory, HttpStatus.OK);
}

From source file:com.consol.citrus.admin.web.TestController.java

@RequestMapping(value = "/source", method = { RequestMethod.PUT })
@ResponseBody/*from   w  w  w  .  j  av  a  2  s.  co  m*/
public void updateSourceCode(@RequestParam("relativePath") String relativePath,
        @RequestBody String newSourceCode) {
    testCaseService.updateSourceCode(projectService.getActiveProject(), relativePath, newSourceCode);
}

From source file:com.sg.dvdlibrary.controller.HomeController.java

@RequestMapping(value = "/dvd/{id}", method = RequestMethod.PUT)
@ResponseStatus(HttpStatus.NO_CONTENT)/*from ww  w  .j a  v a 2  s  . c o m*/
public void updateEntry(@PathVariable("id") int id, @Valid @RequestBody Dvd dvd) {
    dvd.setLibId(id);
    dao.updateEntry(dvd);
}

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

@RequestMapping(value = { "/assertionConsumerServiceURL" }, method = RequestMethod.PUT)
@ResponseStatus(HttpStatus.NO_CONTENT)/*from  ww w .  java  2s.co  m*/
@ResponseBody
public void setAssertionConsumerServiceURL(
        @RequestBody AssertionConsumerServiceURL assertionConsumerServiceURL) {
    log.debug("Request to set assertionConsumerServiceURL to {}", assertionConsumerServiceURL.getValue());
    configuration.setAssertionConsumerServiceURL(assertionConsumerServiceURL.getValue());
}

From source file:com.okta.scim.SingleUserController.java

/**
 * Update via Put {@link User} attributes
 *
 * @param payload Payload from HTTP request
 * @param id {@link User#id}/* ww w . j  a v a  2  s  . co  m*/
 * @return JSON {@link Map} of {@link User}
 */
@RequestMapping(method = RequestMethod.PUT)
public @ResponseBody Map singleUserPut(@RequestBody Map<String, Object> payload, @PathVariable String id) {
    User user = db.findById(id).get(0);
    user.update(payload);
    return user.toScimResource();
}

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

@Secured("ROLE_ADMIN")
@RequestMapping(value = "{shortname}", method = RequestMethod.PUT)
HttpEntity<BasicUnit> update(@PathVariable("shortname") String shortname,
        @Valid @RequestBody BasicUnit basicUnit) {
    if (shortname.equals(basicUnit.getShortname())) {
        if (repository.findOne(basicUnit.getShortname()) != null) {
            repository.save(basicUnit);/*from  w ww.  j a v a  2 s.  c  om*/
            return new ResponseEntity<>(basicUnit, HttpStatus.OK);
        }
    }
    return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
}

From source file:com.pos.web.ArInvController.java

@RequestMapping(value = "/ar-inv", method = RequestMethod.PUT)
public void update(@RequestBody ArInv x, HttpServletResponse response) {
    dao.save(x);
}

From source file:nu.yona.server.batch.quartz.JobController.java

@RequestMapping(value = "/{group}/", method = RequestMethod.PUT)
@ResponseBody/*from  ww  w .  j  a va  2s . c o  m*/
public HttpEntity<Resources<JobResource>> updateJobGroup(@PathVariable String group,
        @RequestBody Set<JobDto> jobs) {
    return createOkResponse(jobManagementService.updateJobGroup(group, jobs), createResourceAssembler(),
            getJobsInGroupLinkBuilder(group));
}

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

@RequestMapping(value = "/staticPage/{id}", method = RequestMethod.PUT)
@ResponseStatus(HttpStatus.CREATED)//from  w w w.j a v  a 2 s . c om
@ResponseBody
public StaticPage updateStaticPage(@PathVariable("id") int id, @RequestBody StaticPage staticPage) {

    if (staticPage.getCategoryIdFK() == -1) {
        staticPage.setCategoryIdFK(null);
    }
    if (staticPage.getStatus() == null) {
        staticPage.setStatus(Status.DRAFT);
    }
    staticPage.setPageId(id);
    staticPageDao.updateStaticPage(staticPage);
    return staticPage;
}

From source file:plbtw.klmpk.barang.hilang.controller.RoleController.java

@RequestMapping(method = RequestMethod.PUT, produces = "application/json")
public CustomResponseMessage updateRole(@RequestBody RoleRequest roleRequest) {
    try {//from  ww w.  ja va 2  s.  c o  m
        Role role = roleService.getRole(roleRequest.getId());
        System.out.println(role.toString());
        role.setRole(roleRequest.getRole());
        roleService.updateRole(role);
        return new CustomResponseMessage(HttpStatus.CREATED, "Update Role Succesfull");
    } catch (Exception ex) {
        return new CustomResponseMessage(HttpStatus.BAD_REQUEST, ex.toString());
    }
}