Example usage for java.net URI toString

List of usage examples for java.net URI toString

Introduction

In this page you can find the example usage for java.net URI toString.

Prototype

public String toString() 

Source Link

Document

Returns the content of this URI as a string.

Usage

From source file:de.codecentric.boot.admin.discovery.DefaultServiceInstanceConverter.java

@Override
public Application convert(ServiceInstance instance) {
    LOGGER.debug("Converting service '{}' running at '{}' with metadata {}", instance.getServiceId(),
            instance.getUri(), instance.getMetadata());

    Application.Builder builder = Application.create(instance.getServiceId());
    URI healthUrl = getHealthUrl(instance);
    if (healthUrl != null) {
        builder.withHealthUrl(healthUrl.toString());
    }/*from ww w .  ja  v  a  2s  .c om*/

    URI managementUrl = getManagementUrl(instance);
    if (managementUrl != null) {
        builder.withManagementUrl(managementUrl.toString());
    }

    URI serviceUrl = getServiceUrl(instance);
    if (serviceUrl != null) {
        builder.withServiceUrl(serviceUrl.toString());
    }

    Map<String, String> metadata = getMetadata(instance);
    if (metadata != null) {
        builder.withMetadata(metadata);
    }

    return builder.build();
}

From source file:com.subgraph.vega.internal.analysis.urls.HtmlUrlExtractor.java

List<URI> findHtmlUrls(HttpEntity entity, URI basePath) throws IOException {
    final String htmlString = inputStreamToString(entity.getContent());
    final Document document = Jsoup.parse(htmlString, basePath.toString());
    return extractUrlsFromDocument(document);
}

From source file:com.nesscomputing.velocity.VelocityGuiceModule.java

public VelocityGuiceModule bindTemplateDirectory(final String prefix, final URI... templateDirUris) {
    bindingActions.add(new Runnable() {
        @Override/*from w  w  w  .j  av a 2s  . c o  m*/
        public void run() {
            try {
                Set<String> foundTemplates = Sets.newHashSet();
                for (URI dir : templateDirUris) {
                    FileObject root = VFS.getManager().resolveFile(dir.toString());
                    walk(foundTemplates, prefix, root);
                }
                bind(TemplateGroup.class).annotatedWith(Names.named(prefix))
                        .toProvider(new TemplateGroupProvider(prefix));
            } catch (FileSystemException e) {
                throw Throwables.propagate(e);
            } catch (URISyntaxException e) {
                throw Throwables.propagate(e);
            }
        }
    });
    return this;
}

From source file:com.vmware.identity.openidconnect.protocol.LogoutSuccessResponse.java

@Override
public HttpResponse toHttpResponse() {
    URI postLogoutRedirectUriWithState = URIUtils.appendQueryParameter(super.getPostLogoutRedirectURI(),
            "state", super.getState().getValue());

    StringBuilder logoutUriLinks = new StringBuilder();
    for (URI logoutUri : this.logoutUris) {
        URI logoutUriWithSid = URIUtils.appendQueryParameter(logoutUri, "sid", this.sessionId.getValue());
        logoutUriLinks.append(String.format("<iframe src=\"%s\">", logoutUriWithSid.toString()));
    }/*from  www  . j a v a2  s.  c o m*/

    String content = String.format(HTML_RESPONSE, postLogoutRedirectUriWithState, logoutUriLinks.toString());
    return HttpResponse.createHtmlResponse(StatusCode.OK, content);
}

From source file:org.openlmis.fulfillment.service.ObjReferenceExpanderTest.java

@Test
public void shouldHandleNestedExpand() {
    Map<String, Object> responseMap = new HashMap<>();
    responseMap.put("expandedStringProperty", EXPANDED_STRING_VALUE);
    responseMap.put("expandedListProperty", EXPANDED_LIST_VALUE);
    responseMap.put("expandedUuidProperty", EXPANDED_UUID_VALUE);
    responseMap.put("expandedNestedProperty", EXPANDED_NESTED_PROPERTY);

    ArgumentCaptor<URI> uriCaptor = ArgumentCaptor.forClass(URI.class);

    when(restTemplate.exchange(any(URI.class), eq(HttpMethod.GET), any(RequestEntity.class), eq(Map.class)))
            .thenReturn(ResponseEntity.ok(responseMap));

    objReferenceExpander.expandDto(testDto, singleton(EXPANDED_NESTED_FIELD));

    verify(restTemplate).exchange(uriCaptor.capture(), eq(HttpMethod.GET), any(RequestEntity.class),
            eq(Map.class));

    URI value = uriCaptor.getValue();
    assertThat(value.toString(), endsWith("?expand=" + EXPANDED_NESTED_PROPERTY_FIELD));
}

From source file:ca.uhn.fhir.model.primitive.UriDt.java

private String normalize(String theValue) {
    if (theValue == null) {
        return null;
    }/*  w w w . j  av a 2s.  co  m*/
    URI retVal;
    try {
        retVal = new URI(theValue).normalize();
        String urlString = retVal.toString();
        if (urlString.endsWith("/") && urlString.length() > 1) {
            retVal = new URI(urlString.substring(0, urlString.length() - 1));
        }
    } catch (URISyntaxException e) {
        ourLog.debug("Failed to normalize URL '{}', message was: {}", theValue, e.toString());
        return theValue;
    }

    return retVal.toASCIIString();
}

From source file:org.nuclos.common.activemq.NuclosHttpsTransportFactory.java

@Override
protected Transport createTransport(URI location, WireFormat wf) throws MalformedURLException {
    if (location.getScheme().equals("myhttps")) {
        try {/*ww w.  j  a  v a2  s . c  om*/
            location = new URI(location.toString().substring(2));
        } catch (URISyntaxException e) {
            throw new MalformedURLException(e.toString());
        }
    }
    final HttpsClientTransport result = (HttpsClientTransport) super.createTransport(location, wf);
    final HttpClient httpClient = getHttpClient();
    result.setReceiveHttpClient(httpClient);
    result.setSendHttpClient(httpClient);
    return result;
}

From source file:com.marklogic.contentpump.ContentWithFileNameWritable.java

protected String getEncodedURI(String val) {
    try {/*from ww w . ja v  a 2  s  .com*/
        URI uri = new URI(null, null, null, 0, val, null, null);
        return uri.toString();
    } catch (URISyntaxException e) {
        LOG.error("Error parsing value as URI, skipping " + val, e);
        return null;
    }
}

From source file:main.java.miro.validator.fetcher.RsyncFetcher.java

public void writePrefetchURIsToFile() {
    try {/* w  ww.  j a va 2s .c om*/
        FileWriter writer = new FileWriter(prefetchURIstorage, false);
        for (URI uri : prefetchURIs) {
            writer.write(uri.toString());
            writer.write('\n');
        }
        writer.close();
    } catch (IOException e) {
        e.printStackTrace();
        throw new RuntimeException();
    }
}

From source file:org.openlmis.fulfillment.service.referencedata.BaseReferenceDataServiceTest.java

@Test
public void shouldReturnNullIfEntityCannotBeFoundById() throws Exception {
    // given//from w  w  w .  ja va  2 s . c  om
    BaseReferenceDataService<T> service = prepareService();
    UUID id = UUID.randomUUID();

    // when
    when(restTemplate.exchange(any(URI.class), eq(HttpMethod.GET), any(HttpEntity.class),
            eq(service.getResultClass()))).thenThrow(new HttpClientErrorException(HttpStatus.NOT_FOUND));

    T found = service.findOne(id);

    // then
    verify(restTemplate).exchange(uriCaptor.capture(), eq(HttpMethod.GET), entityCaptor.capture(),
            eq(service.getResultClass()));

    URI uri = uriCaptor.getValue();
    String url = service.getServiceUrl() + service.getUrl() + id;

    assertThat(uri.toString(), is(equalTo(url)));
    assertThat(found, is(nullValue()));

    assertAuthHeader(entityCaptor.getValue());
    assertThat(entityCaptor.getValue().getBody(), is(nullValue()));
}