Search in sources :

Example 56 with UriComponentsBuilder

use of org.springframework.web.util.UriComponentsBuilder in project mirrorgate-jira-stories-collector by BBVA.

the class SprintService method deleteIssue.

public void deleteIssue(final Long issueId) {
    final MultiValueMap<String, String> params = new LinkedMultiValueMap<>();
    params.set("collectorId", appName);
    final UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(mirrorGateUrl + MIRRORGATE_DELETE_ISSUE_ENDPOINT).queryParams(params);
    try {
        restTemplate.delete(builder.build().toUriString(), issueId);
    } catch (final HttpClientErrorException e) {
        if (e.getStatusCode() == HttpStatus.NOT_FOUND) {
            LOGGER.warn("Issue {} already deleted", issueId);
        } else {
            LOGGER.error("Error trying to delete issue {}", issueId, e);
            throw e;
        }
    }
}
Also used : HttpClientErrorException(org.springframework.web.client.HttpClientErrorException) LinkedMultiValueMap(org.springframework.util.LinkedMultiValueMap) UriComponentsBuilder(org.springframework.web.util.UriComponentsBuilder)

Example 57 with UriComponentsBuilder

use of org.springframework.web.util.UriComponentsBuilder in project mirrorgate-jira-stories-collector by BBVA.

the class SprintService method sendIssues.

public ResponseEntity<List> sendIssues(final List<IssueDTO> issues) {
    final MultiValueMap<String, String> params = new LinkedMultiValueMap<>();
    params.set("collectorId", appName);
    final UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(mirrorGateUrl + MIRRORGATE_SEND_ISSUES_ENDPOINT).queryParams(params);
    return restTemplate.postForEntity(builder.build().toUriString(), issues, List.class);
}
Also used : LinkedMultiValueMap(org.springframework.util.LinkedMultiValueMap) UriComponentsBuilder(org.springframework.web.util.UriComponentsBuilder)

Example 58 with UriComponentsBuilder

use of org.springframework.web.util.UriComponentsBuilder in project mirrorgate-jira-stories-collector by BBVA.

the class CollectorService method update.

public void update(final Date date) {
    final MultiValueMap<String, String> params = new LinkedMultiValueMap<>();
    params.set("collectorId", appName);
    final UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(mirrorGateUrl + MIRRORGATE_COLLECTOR_ENDPOINT).queryParams(params);
    restTemplate.put(builder.build().toUriString(), date, appName);
}
Also used : LinkedMultiValueMap(org.springframework.util.LinkedMultiValueMap) UriComponentsBuilder(org.springframework.web.util.UriComponentsBuilder)

Example 59 with UriComponentsBuilder

use of org.springframework.web.util.UriComponentsBuilder in project cloudstack by apache.

the class Force10BaremetalSwitchBackend method buildLink.

private String buildLink(String switchIp, String path) {
    UriComponentsBuilder builder = UriComponentsBuilder.newInstance();
    builder.scheme("http");
    builder.host(switchIp);
    builder.port(8008);
    builder.path(path);
    return builder.build().toUriString();
}
Also used : UriComponentsBuilder(org.springframework.web.util.UriComponentsBuilder)

Example 60 with UriComponentsBuilder

use of org.springframework.web.util.UriComponentsBuilder in project dhis2-core by dhis2.

the class SimplisticHttpGetGateWay method send.

@Override
public OutboundMessageResponse send(String subject, String text, Set<String> recipients, SmsGatewayConfig config) {
    GenericHttpGatewayConfig genericConfig = (GenericHttpGatewayConfig) config;
    UriComponentsBuilder uriBuilder;
    ResponseEntity<String> responseEntity = null;
    HttpEntity<String> requestEntity;
    URI uri;
    try {
        requestEntity = getRequestEntity(genericConfig, text, recipients);
        if (genericConfig.isSendUrlParameters()) {
            uriBuilder = UriComponentsBuilder.fromHttpUrl(config.getUrlTemplate() + "?" + requestEntity.getBody());
        } else {
            uriBuilder = UriComponentsBuilder.fromHttpUrl(config.getUrlTemplate());
        }
        uri = uriBuilder.build().encode().toUri();
        responseEntity = restTemplate.exchange(uri, genericConfig.isUseGet() ? HttpMethod.GET : HttpMethod.POST, requestEntity, String.class);
    } catch (HttpClientErrorException ex) {
        log.error("Client error " + ex.getMessage());
    } catch (HttpServerErrorException ex) {
        log.error("Server error " + ex.getMessage());
    } catch (Exception ex) {
        log.error("Error " + ex.getMessage());
    }
    return getResponse(responseEntity);
}
Also used : HttpClientErrorException(org.springframework.web.client.HttpClientErrorException) UriComponentsBuilder(org.springframework.web.util.UriComponentsBuilder) URI(java.net.URI) HttpServerErrorException(org.springframework.web.client.HttpServerErrorException) HttpServerErrorException(org.springframework.web.client.HttpServerErrorException) HttpClientErrorException(org.springframework.web.client.HttpClientErrorException)

Aggregations

UriComponentsBuilder (org.springframework.web.util.UriComponentsBuilder)131 Test (org.junit.Test)34 UriComponents (org.springframework.web.util.UriComponents)23 ServletUriComponentsBuilder (org.springframework.web.servlet.support.ServletUriComponentsBuilder)12 URI (java.net.URI)9 Test (org.junit.jupiter.api.Test)9 SearchRequest (org.nzbhydra.searching.searchrequests.SearchRequest)8 MvcUriComponentsBuilder (org.springframework.web.servlet.mvc.method.annotation.MvcUriComponentsBuilder)8 ArrayList (java.util.ArrayList)7 LinkedMultiValueMap (org.springframework.util.LinkedMultiValueMap)7 List (java.util.List)6 User (com.serotonin.m2m2.vo.User)5 RestProcessResult (com.serotonin.m2m2.web.mvc.rest.v1.message.RestProcessResult)5 ApiOperation (com.wordnik.swagger.annotations.ApiOperation)5 HashMap (java.util.HashMap)5 HttpEntity (org.springframework.http.HttpEntity)5 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)5 HttpClientErrorException (org.springframework.web.client.HttpClientErrorException)5 IOException (java.io.IOException)4 Map (java.util.Map)4