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:fi.helsinki.opintoni.web.rest.privateapi.UsefulLinkResource.java

@RequestMapping(value = "/{usefulLinkId}", method = RequestMethod.PUT)
@Timed/*from  ww  w . j  a  v  a  2 s .c om*/
public ResponseEntity<UsefulLinkDto> update(@UserId Long userId,
        @PathVariable("usefulLinkId") Long usefulLinkId, @Valid @RequestBody UsefulLinkDto usefulLinkDto,
        Locale locale) {
    permissionChecker.verifyPermission(userId, usefulLinkId, UsefulLink.class);
    return response(usefulLinkService.update(usefulLinkId, usefulLinkDto, locale));
}

From source file:com.activiti.web.rest.ServerConfigsResource.java

@RequestMapping(value = "/rest/server-configs/{serverId}", method = RequestMethod.PUT, produces = "application/json")
@ResponseStatus(value = HttpStatus.OK)//from  w  w w . j a  v a 2s  . c o m
public void updateServer(@PathVariable Long serverId,
        @RequestBody ServerConfigRepresentation configRepresentation) {

    ServerConfig config = serverConfigService.findOne(serverId);

    if (config == null) {
        throw new BadRequestException("Server with id '" + serverId + "' does not exist");
    }

    boolean updatePassword = false;
    if (StringUtils.isNotEmpty(configRepresentation.getPassword())) {
        config.setPassword(configRepresentation.getPassword());
        updatePassword = true;
    } else {
        configRepresentation.setPassword(serverConfigService.getServerConfigDecryptedPassword(config));
    }

    config.setContextRoot(configRepresentation.getContextRoot());
    config.setDescription(configRepresentation.getDescription());
    config.setName(configRepresentation.getName());
    config.setPort(configRepresentation.getServerPort());
    config.setRestRoot(configRepresentation.getRestRoot());
    config.setServerAddress(configRepresentation.getServerAddress());
    config.setUserName(configRepresentation.getUserName());

    serverConfigService.save(config, updatePassword);
}

From source file:org.hekmatof.activiti.editor.ModelSaveRestResource.java

@RequestMapping(value = "/model/{modelId}/save", method = RequestMethod.PUT)
public void saveModel(@PathVariable String modelId, @RequestBody MultiValueMap<String, String> values) {
    try {//from w  w  w  .ja va  2 s  . c  om

        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:org.lamop.riche.webservices.AuthorRESTWS.java

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

From source file:com.netflix.spinnaker.halyard.controllers.v1.AdminController.java

@RequestMapping(value = "/publishVersion", method = RequestMethod.PUT)
DaemonTask<Halconfig, Void> publishVersion(@RequestBody Versions.Version version) {
    StaticRequestBuilder<Void> builder = new StaticRequestBuilder<>();
    builder.setBuildResponse(() -> {/*w w  w . j av  a2 s  .com*/
        artifactService.publishVersion(version);
        return null;
    });

    return DaemonTaskHandler.submitTask(builder::build, "Publish a new version " + version.getVersion());
}

From source file:com.cfitzarl.cfjwed.controller.AccountController.java

/**
 * This updates the current account's information.
 *
 * @param accountDTO the account DTO//from w  w w .jav a2  s .  c  o m
 */
@RequestMapping(value = "", method = RequestMethod.PUT)
public void updateAccount(@Valid @RequestBody AccountDTO accountDTO) {
    accountDTO.setId(SecurityContextWrapper.getId());
    accountService.save(modelMapper.map(accountDTO, Account.class));
}

From source file:fi.helsinki.opintoni.web.rest.privateapi.usersettings.UserSettingsResource.java

@RequestMapping(value = "/{id}/uploaduseravatar", method = RequestMethod.PUT)
@Timed/* w  w  w. j  a v  a2  s  .  c  o  m*/
@SkipLoggingAspect
public ResponseEntity<Boolean> uploadUserAvatar(@UserId Long userId, @PathVariable Long id,
        @RequestBody UploadImageBase64Request request) throws IOException {
    permissionChecker.verifyPermission(userId, id, UserSettings.class);
    userSettingsService.updateUserAvatar(id, request.imageBase64);
    return response(true);
}

From source file:rest.TorneoRestController.java

@RequestMapping(value = "/{torneo}/ronda/{ronda}", method = RequestMethod.PUT)
public ResponseEntity<?> modificarRondaEnTorneo(@PathVariable int torneo, @PathVariable int ronda,
        @RequestBody InfoRonda ir) {/*from  w w  w.j  av a 2s . c  om*/
    logicaTorneo.modificarRondaEnTorneo(ir, ronda, torneo);
    return new ResponseEntity<>(HttpStatus.CREATED);
}

From source file:edu.mayo.cts2.uriresolver.controller.ResolveURI.java

@RequestMapping(method = RequestMethod.PUT, value = "/ids/{type}/{identifier}")
public ResponseEntity<String> saveIdentifiers(@RequestBody UriResults uriResults, @PathVariable String type,
        @PathVariable String identifier) {
    logger.info("\n\nsaveIdentifiers\n\n");
    uriDAO.saveIdentifiers(uriResults);/*from   w  w w  .j  av  a  2s .  c o m*/
    logger.info("finshed saving");
    return new ResponseEntity<String>(new HttpHeaders(), HttpStatus.OK);
}

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

@RequestMapping(method = RequestMethod.PUT)
public ResponseEntity update(@RequestBody Project project) {
    projectService.update(project);
    return ResponseEntity.ok().build();
}