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.pf9.pangu.app.act.rest.editor.model.ModelSaveRestResource.java

@RequiresPermissions("act:model:edit")
@RequestMapping(value = "/act/service/model/{modelId}/save", method = RequestMethod.PUT)
@ResponseStatus(value = HttpStatus.OK)//from   ww  w .java  2 s  .  c o m
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);
    }
}

From source file:co.agileventure.cloud.product.rest.ProductController.java

@RequestMapping(value = "{id}", method = RequestMethod.PUT)
public Product update(@RequestBody @Valid Product product) {
    return productService.update(product);
}

From source file:com.snv.todo.TodoController.java

/**
 * {@inheritDoc}//from   w w w  .j av  a 2 s  . c o m
 */
@RequestMapping(method = RequestMethod.PUT, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@Override
public Todo put(@Valid @RequestBody final Todo todo) {
    return todoService.put(todo);
}

From source file:cz.fi.muni.pa036.airticketbooking.rest.UserRest.java

@RequestMapping(method = RequestMethod.PUT)
public UserDto updateUser(@RequestBody @Valid UserDto user) {
    Long currentUserId = securityService.getCurrentlyLoggedUser().getId();
    if (!securityService.hasPermissionToModifyEntity(user.getId())) {
        throw new AccessDeniedException(
                "Access denied: User " + currentUserId + " cannot update user " + user.getId());
    }//w w w.  j  a  va 2s  .  com
    String hashedPassword = HashCode.getHashPassword(user.getPassword());
    user.setPassword(hashedPassword);
    return userService.update(user);
}

From source file:es.fdi.reservas.reserva.web.EdificioRestController.java

@RequestMapping(value = "/admin/administrar/edificios/editar/{idEdificio}", method = RequestMethod.PUT)
public void editarEdificio(@PathVariable("idEdificio") long idEdificio,
        @RequestBody EdificioDTO edificioActualizado) {

    edificio_service.editarEdificio(edificioActualizado);

}

From source file:com.dolphine.customer.controller.CustomerController.java

@RequestMapping(method = { RequestMethod.PUT }, value = "/{id}")
public CustomerResource put(@PathVariable("id") String id, @RequestBody CustomerResource resource) {
    return null;/*from   w w w . j  av a  2 s. c om*/
}

From source file:com.br.helpdesk.controller.UserController.java

@RequestMapping(value = { "/password" }, method = RequestMethod.PUT)
@ResponseBody//from   w  ww.ja  v a  2  s  .  c  om
public String updatePassword(@RequestBody String req) {
    JSONObject profile = new JSONObject(req);
    User user = userService.findOne(Long.parseLong((String) profile.get("id")));
    user.setPassword(String.valueOf(profile.get("newpassword")));
    userService.save(user);
    return req;

}

From source file:cz.fi.muni.pa036.airticketbooking.rest.SeatReservationRest.java

@RequestMapping(method = RequestMethod.PUT)
public void updateSeatReservation(@RequestBody @Valid SeatReservationDto seatReservation) {
    seatReservationService.update(seatReservation);
}

From source file:com.brunomcustodio.dojo.springboot.BookServiceController.java

@RequestMapping(value = "/{id}", method = RequestMethod.PUT)
public Book updateBook(@PathVariable("id") int id, @RequestBody @Valid Book book) {
    Book target = repository.findOne(id);

    if (target != null) {
        book.setId(id);/*from   ww  w. j  a  v a2s.c o  m*/
        return repository.save(book);
    } else {
        throw new BookNotFoundException();
    }
}

From source file:com.thesoftwareguild.addressbook.controller.HomeController.java

@RequestMapping(value = "/address/{id}", method = RequestMethod.PUT)
@ResponseStatus(HttpStatus.NO_CONTENT)/*from   w  ww .ja  v  a  2s . c  om*/
public void putAddress(@PathVariable("id") int id, @Valid @RequestBody Address address) {
    address.setAddressId(id);
    dao.updateAddress(address);
}