Example usage for org.springframework.http HttpMethod PUT

List of usage examples for org.springframework.http HttpMethod PUT

Introduction

In this page you can find the example usage for org.springframework.http HttpMethod PUT.

Prototype

HttpMethod PUT

To view the source code for org.springframework.http HttpMethod PUT.

Click Source Link

Usage

From source file:com.citrix.g2w.webdriver.dependencies.AccountServiceQAIImpl.java

/**
 * Method to enable or disable isRecordingv2Enabled flag for an account.
 * /* w w w  . j a  v  a  2 s . com*/
 * @param accountKey
 *            (user account key)
 * @param enable
 *            (enable or disable isRecordingv2Enabled flag)
 */
@Override
public void setRecordingv2AttributeForAccount(final Long accountKey, final boolean enable) {
    HttpEntity httpEntity = new HttpEntity("{\"isRecordingv2Enabled\":" + enable + "}", this.accountSvcHeaders);
    this.restTemplate.exchange(this.accountSvcUrl + "/accounts/" + accountKey + "/products/g2w", HttpMethod.PUT,
            httpEntity, null);
}

From source file:org.zalando.boot.etcd.EtcdClient.java

/**
 * Creates a directory node in etcd./*from  w w w.j a  v  a 2 s . com*/
 * 
 * @param key
 *            the key
 * @return the response from etcd with the node
 * @throws EtcdException
 *             in case etcd returned an error
 */
public EtcdResponse putDir(final String key) throws EtcdException {
    UriComponentsBuilder builder = UriComponentsBuilder.fromUriString(KEYSPACE);
    builder.pathSegment(key);

    MultiValueMap<String, String> payload = new LinkedMultiValueMap<>(1);
    payload.set("dir", "true");

    return execute(builder, HttpMethod.PUT, payload, EtcdResponse.class);
}

From source file:com.citrix.g2w.webdriver.dependencies.AccountServiceQAIImpl.java

/**
 * Method to suspend user./*from   w  w  w. j a  v a  2s . c  om*/
 * 
 * @param userKey
 *            (user key)
 */
@Override
public void suspendUser(final Long userKey) {
    HttpEntity httpEntity = new HttpEntity("{\"status\":\"suspended\"}", this.accountSvcHeaders);
    this.restTemplate.exchange(this.accountSvcUrl + "/users/" + userKey, HttpMethod.PUT, httpEntity, null);
}

From source file:com.brightcove.zencoder.client.ZencoderClient.java

/**
 * Finishes the input on a Live streaming job. Has no effect on non-Live jobs.
 *
 * @see https://app.zencoder.com/docs/api/jobs/finish
 * @param id/*from  w  w  w .  j a  va2s . c om*/
 * @throws ZencoderClientException
 */
public void finishLiveJob(String id) throws ZencoderClientException {
    String url = api_url + "/jobs/" + id + "/finish";

    HttpHeaders headers = getHeaders();
    @SuppressWarnings("rawtypes")
    HttpEntity entity = new HttpEntity<String>("", headers);

    try {
        rt.exchange(url, HttpMethod.PUT, entity, String.class, new HashMap<String, Object>());

    } catch (HttpClientErrorException hcee) {
        throw new ZencoderClientException(hcee.getResponseBodyAsString(), hcee);
    }
}

From source file:eu.freme.broker.eservices.FremeNER.java

@RequestMapping(value = "/e-entity/freme-ner/datasets/{name}", method = { RequestMethod.PUT })
public ResponseEntity<String> updateDataset(
        @RequestHeader(value = "Content-Type", required = false) String contentTypeHeader,
        @PathVariable(value = "name") String name, @RequestParam(value = "language") String language,
        //@RequestParam(value = "informat", required = false) String informat,
        //@RequestParam(value = "f", required = false) String f,
        @RequestParam Map<String, String> allParams, @RequestBody(required = false) String postBody) {

    try {//w  ww .  j  a v  a  2  s. c  om

        if (!SUPPORTED_LANGUAGES.contains(language)) {
            // The language specified with the langauge parameter is not supported.
            throw new eu.freme.broker.exception.BadRequestException("Unsupported language.");
        }

        NIFParameterSet nifParameters = this.normalizeNif(postBody, null, contentTypeHeader, allParams, false);

        String format = null;
        switch (nifParameters.getInformat()) {
        case TURTLE:
            format = "TTL";
            break;
        case JSON_LD:
            format = "JSON-LD";
            break;
        case RDF_XML:
            format = "RDF/XML";
            break;
        case N_TRIPLES:
            format = "N-TRIPLES";
            break;
        case N3:
            format = "N3";
            break;
        }

        return callBackend(
                fremeNerEndpoint + "/datasets/" + name + "?format=" + format + "&language=" + language,
                HttpMethod.PUT, nifParameters.getInput());
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
        throw new eu.freme.broker.exception.BadRequestException(e.getMessage());
    }
}

From source file:org.zalando.boot.etcd.EtcdClient.java

/**
 * Creates a directory node in etcd.// ww w. ja  va 2s. c o m
 * 
 * @param key
 *            the key
 * @param ttl
 *            the time-to-live
 * @return the response from etcd with the node
 * @throws EtcdException
 *             in case etcd returned an error
 */
public EtcdResponse putDir(String key, int ttl) throws EtcdException {
    UriComponentsBuilder builder = UriComponentsBuilder.fromUriString(KEYSPACE);
    builder.pathSegment(key);

    MultiValueMap<String, String> payload = new LinkedMultiValueMap<>(1);
    payload.set("dir", "true");
    payload.set("ttl", ttl == -1 ? "" : String.valueOf(ttl));

    return execute(builder, HttpMethod.PUT, payload, EtcdResponse.class);
}

From source file:com.citrix.g2w.webdriver.dependencies.AccountServiceQAIImpl.java

/**
 * Method to un suspend user./*  www. ja v a  2  s  .c o  m*/
 * 
 * @param userKey
 *            (user key)
 */
@Override
public void unSuspendUser(final Long userKey) {
    HttpEntity httpEntity = new HttpEntity("{\"status\":null}", this.accountSvcHeaders);
    this.restTemplate.exchange(this.accountSvcUrl + "/users/" + userKey, HttpMethod.PUT, httpEntity, null);
}

From source file:com.orange.ngsi.client.NgsiRestClientTest.java

@Test
public void testUpdateContextSubscription_JSON() throws Exception {
    String responseBody = json(jsonConverter, createUpdateContextSubscriptionResponseTemperature());

    mockServer.expect(requestTo(baseUrl + "/ngsi10/contextSubscriptions/12345678"))
            .andExpect(method(HttpMethod.PUT))
            .andRespond(withSuccess(responseBody, MediaType.APPLICATION_JSON));

    UpdateContextSubscriptionResponse response = ngsiRestClient
            .updateContextSubscription(baseUrl, null, "12345678", createUpdateContextSubscriptionTemperature())
            .get();//ww  w  .ja va2s  .  co  m

    this.mockServer.verify();

    assertNotNull(response);
    assertNull(response.getSubscribeError());
    assertNotNull(response.getSubscribeResponse());
    assertEquals("12345678", response.getSubscribeResponse().getSubscriptionId());
    assertEquals("P1M", response.getSubscribeResponse().getDuration());
}

From source file:com.brightcove.zencoder.client.ZencoderClient.java

/**
 * Sets whether or not your account should be in the limited integration mode.
 * Use 'true' to make your account limited to integration mode.
 * Use 'false' to make your account a regular account.
 *
 * @see https://app.zencoder.com/docs/api/accounts/integration
 * @param integration_mode Integration Mode setting.
 * @throws ZencoderClientException //  ww w .  j a  v  a 2 s.co  m
 */
public void setAccountIntegrationMode(boolean integration_mode) throws ZencoderClientException {
    String url = null;
    if (integration_mode) {
        url = api_url + "/account/integration";
    } else {
        url = api_url + "/account/live";
    }

    HttpHeaders headers = getHeaders();
    @SuppressWarnings("rawtypes")
    HttpEntity entity = new HttpEntity<String>("", headers);

    try {
        rt.exchange(url, HttpMethod.PUT, entity, String.class, new HashMap<String, Object>());

    } catch (HttpClientErrorException hcee) {
        throw new ZencoderClientException(hcee.getResponseBodyAsString(), hcee);
    }
}

From source file:com.gooddata.dataload.processes.ProcessService.java

private DataloadProcess postProcess(DataloadProcess process, File processData, URI postUri) {
    File tempFile = createTempFile("process", ".zip");

    try (FileOutputStream output = new FileOutputStream(tempFile)) {
        ZipHelper.zip(processData, output);
    } catch (IOException e) {
        throw new GoodDataException("Unable to zip process data", e);
    }/*from  w ww.j  av a2 s. co  m*/

    Object processToSend;
    HttpMethod method = HttpMethod.POST;
    if (tempFile.length() > MAX_MULTIPART_SIZE) {
        try {
            process.setPath(dataStoreService.getUri(tempFile.getName()).getPath());
            dataStoreService.upload(tempFile.getName(), new FileInputStream(tempFile));
            processToSend = process;
            if (DataloadProcess.TEMPLATE.matches(postUri.toString())) {
                method = HttpMethod.PUT;
            }
        } catch (FileNotFoundException e) {
            throw new GoodDataException("Unable to access zipped process data at " + tempFile.getAbsolutePath(),
                    e);
        }
    } else {
        final MultiValueMap<String, Object> parts = new LinkedMultiValueMap<>(2);
        parts.add("process", process);
        final HttpHeaders headers = new HttpHeaders();
        headers.setContentType(MEDIA_TYPE_ZIP);
        parts.add("data", new HttpEntity<>(new FileSystemResource(tempFile), headers));
        processToSend = parts;
    }

    try {
        final ResponseEntity<DataloadProcess> response = restTemplate.exchange(postUri, method,
                new HttpEntity<>(processToSend), DataloadProcess.class);
        if (response == null) {
            throw new GoodDataException("Unable to post dataload process. No response returned from API.");
        }
        return response.getBody();
    } catch (GoodDataException | RestClientException e) {
        throw new GoodDataException("Unable to post dataload process.", e);
    } finally {
        deleteTempFile(tempFile);
    }
}