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:org.springframework.social.box.api.impl.FolderTemplate.java

@Override
public BoxFolder updateFolder(String folderId, String newName, String newDescription, List<String> newTags,
        List<BoxFolderFields> fields) {
    try {/* ww  w.  j a va  2  s . c o  m*/
        return boxOperation(HttpMethod.PUT, FOLDER_OPERATION + folderId, fields,
                mapper.writeValueAsString(new BoxFolderUpdate(newName, newDescription, newTags)),
                BoxFolder.class);
    } catch (JsonProcessingException e) {
        throw new UncategorizedApiException(BOX_PROVIDER_NAME, "spring-social-bx internal error", e);
    }
}

From source file:org.springframework.web.client.RestTemplate.java

public void put(String url, Object request, Object... urlVariables) throws RestClientException {
    HttpEntityRequestCallback requestCallback = new HttpEntityRequestCallback(request);
    execute(url, HttpMethod.PUT, requestCallback, null, urlVariables);
}

From source file:org.springframework.web.client.RestTemplate.java

public void put(String url, Object request, Map<String, ?> urlVariables) throws RestClientException {
    HttpEntityRequestCallback requestCallback = new HttpEntityRequestCallback(request);
    execute(url, HttpMethod.PUT, requestCallback, null, urlVariables);
}

From source file:org.springframework.web.client.RestTemplate.java

public void put(URI url, Object request) throws RestClientException {
    HttpEntityRequestCallback requestCallback = new HttpEntityRequestCallback(request);
    execute(url, HttpMethod.PUT, requestCallback, null);
}

From source file:org.springframework.web.reactive.function.server.RequestPredicates.java

/**
 * Return a {@code RequestPredicate} that matches if request's HTTP method is {@code PUT}
 * and the given {@code pattern} matches against the request path.
 * @param pattern the path pattern to match against
 * @return a predicate that matches if the request method is PUT and if the given pattern
 * matches against the request path//from  w ww.  ja v  a 2 s.c  o m
 */
public static RequestPredicate PUT(String pattern) {
    return method(HttpMethod.PUT).and(path(pattern));
}

From source file:org.tinygroup.springmvc.coc.impl.RestfulConventionHandlerMethodResolver.java

private String[] doResolveInner(String uri, Method method) {
    String hmn = method.getName();
    String[] urls = null;/*  w ww.  j a  v  a 2s .co  m*/
    if ("doIndex".equals(hmn)) {
        return this.registerUrls(HttpMethod.GET, method, uri);
    }
    if ("doNew".equals(hmn)) {
        String url = new StringBuilder(uri).append("/new").toString();
        return this.registerUrls(HttpMethod.GET, method, url);

    }
    if ("doCreate".equals(hmn)) {
        return this.registerUrls(HttpMethod.POST, method, uri);
    }
    if ("doShow".equals(hmn)) {
        String url = new StringBuilder(uri).append("/{id}").toString();
        return this.registerUrls(HttpMethod.GET, method, url);
    }
    if ("doEdit".equals(hmn)) {
        String url = new StringBuilder(uri).append("/{id}/edit").toString();
        return this.registerUrls(HttpMethod.GET, method, url);
    }
    if ("doUpdate".equals(hmn)) {
        String url = new StringBuilder(uri).append("/{id}").toString();
        return this.registerUrls(HttpMethod.PUT, method, url);
    }
    if ("doDestroy".equals(hmn)) {
        String url = new StringBuilder(uri).append("/{id}").toString();
        return this.registerUrls(HttpMethod.DELETE, method, url);
    }
    return urls;
}

From source file:philharmonic.utilities.MessageSender.java

public ResponseEntity<String> sendMessage(Message message, String body) {
    String target = message.getTargetComponentName();
    String URI;//from   www.  ja v  a2 s  .c  o m
    URI = parser.getAddressForComponent(target) + "/" + target + "/" + message.getResourceName();

    HttpEntity entity = new HttpEntity(body, createHeaders(target));
    if (message.getAction().equals(namePOSTAction)) {
        return rt.exchange(URI, HttpMethod.POST, entity, String.class);
    }
    if (message.getAction().equals(namePUTAction)) {
        return rt.exchange(URI, HttpMethod.PUT, entity, String.class);
    }

    return null;
}

From source file:sg.ncl.DataController.java

@RequestMapping("{did}/requests/{rid}/approve")
public String approveRequest(@PathVariable String did, @PathVariable String rid,
        RedirectAttributes redirectAttributes) throws WebServiceRuntimeException {
    HttpEntity<String> request = createHttpEntityHeaderOnly();
    restTemplate.setErrorHandler(new MyResponseErrorHandler());
    ResponseEntity response = restTemplate.exchange(properties.getRequest(did, rid), HttpMethod.PUT, request,
            String.class);
    String dataResponseBody = response.getBody().toString();

    try {//from   w  ww  . j  a v  a 2  s. c  o  m
        if (RestUtil.isError(response.getStatusCode())) {
            MyErrorResource error = objectMapper.readValue(dataResponseBody, MyErrorResource.class);
            ExceptionState exceptionState = ExceptionState.parseExceptionState(error.getError());

            if (exceptionState == FORBIDDEN_EXCEPTION) {
                log.warn("Approving of dataset access request forbidden.");
                redirectAttributes.addFlashAttribute(MESSAGE_ATTRIBUTE, error.getMessage());
            } else if (exceptionState == DATA_ACCESS_REQUEST_NOT_FOUND_EXCEPTION) {
                log.warn("Dataset access request not found.");
                redirectAttributes.addFlashAttribute(MESSAGE_ATTRIBUTE, error.getMessage());
            } else if (exceptionState == DATA_NOT_MATCH_EXCEPTION) {
                log.warn("Dataset access request does not have matching parent.");
                redirectAttributes.addFlashAttribute(MESSAGE_ATTRIBUTE, error.getMessage());
            } else if (exceptionState == DATA_NOT_FOUND_EXCEPTION) {
                log.warn("Dataset not found for approving request.");
                redirectAttributes.addFlashAttribute(MESSAGE_ATTRIBUTE, error.getMessage());
            } else {
                log.warn("Unknown error for approving dataset access request.");
            }
        } else {
            log.info("Dataset access request approved: {}", dataResponseBody);
            redirectAttributes.addFlashAttribute("approved_message", "Request Approved");
        }
    } catch (IOException e) {
        log.error("approveRequest: {}", e.toString());
        throw new WebServiceRuntimeException(e.getMessage());
    }

    return "redirect:/data/" + did + "/requests/" + rid;
}

From source file:sg.ncl.DataController.java

private ResponseEntity getResponseEntity(@PathVariable Optional<String> id, HttpEntity<String> request) {
    ResponseEntity response;//  www .j  av a2s. c  o  m
    if (!id.isPresent()) {
        response = restTemplate.exchange(properties.getSioDataUrl(), HttpMethod.POST, request, String.class);
    } else {
        response = restTemplate.exchange(properties.getDataset(id.get()), HttpMethod.PUT, request,
                String.class);
    }
    return response;
}

From source file:sg.ncl.MainController.java

@RequestMapping(value = "/emailVerification", params = { ID, EMAIL, "key" })
public String verifyEmail(@NotNull @RequestParam(ID) final String id,
        @NotNull @RequestParam(EMAIL) final String emailBase64,
        @NotNull @RequestParam("key") final String key) {
    HttpHeaders headers = new HttpHeaders();
    headers.setContentType(MediaType.APPLICATION_JSON);

    ObjectNode keyObject = objectMapper.createObjectNode();
    keyObject.put("key", key);

    HttpEntity<String> request = new HttpEntity<>(keyObject.toString(), headers);
    restTemplate.setErrorHandler(new MyResponseErrorHandler());

    final String link = properties.getSioRegUrl() + "/users/" + id + "/emails/" + emailBase64;
    // log.info("Activation link: {}, verification key {}", link, key);
    ResponseEntity response = restTemplate.exchange(link, HttpMethod.PUT, request, String.class);

    if (RestUtil.isError(response.getStatusCode())) {
        log.error("Activation of user {} failed.", id);
        return "email_validation_failed";
    } else {/*  w  ww . j  a v a  2 s  .com*/
        log.info("Activation of user {} completed.", id);
        return "email_validation_ok";
    }
}