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.elomagic.vaadin.addon.speechrecognition.SpeechRecognition.java

/**
 * The serviceURI attribute specifies the location of the speech recognition service that the web application wishes to use. If this attribute is unset at the time of the start method call, then
 * the user agent must use the user agent default speech service. Note that the serviceURI is a generic URI and can thus point to local services either through use of a URN with meaning to the
 * user agent or by specifying a URL that the user agent recognizes as a local service. Additionally, the user agent default can be local or remote and can incorporate end user choices via
 * interfaces provided by the user agent such as browser configuration parameters. [Editor note: The group is currently discussing whether WebRTC might be used to specify selection of audio
 * sources and remote recognizers.]//from   w  w w.  j  a va 2 s  .  c  om
 *
 * @param uri
 */
public void setServiceURI(final URI uri) {
    getState().serviceURI = uri == null ? "" : uri.toString();
}

From source file:io.github.swagger2markup.extensions.SpringRestDocsExtension.java

public void snippetSection(Context context, String snippetName, String title) {
    ContentExtension content = new ContentExtension(globalContext, context);
    URI snippetUri = operationSnippetUri(context, context.getOperation().get(), snippetName);
    logger.info("Processing Spring REST Docs snippet: {}", snippetUri.toString());
    content.importContent(snippetUri, reader -> {
        context.getMarkupDocBuilder().sectionTitleLevel(1 + levelOffset(context), title);
        context.getMarkupDocBuilder().importMarkup(reader, extensionMarkupLanguage, levelOffset(context) + 1);
    });/*from  w w  w  . jav  a 2s . c o  m*/
}

From source file:eu.scape_project.up2ti.identifiers.DroidIdentification.java

/**
 * Run droid identification on file/*from   w w w.j a v a2  s  . c  o m*/
 *
 * @param filePath Absolute file path
 * @return Result list
 * @throws FileNotFoundException
 * @throws IOException
 */
@Override
public HashMap<String, String> identify(File file) throws FileNotFoundException {
    HashMap<String, String> droidIdRes = new HashMap<String, String>();
    InputStream in = null;
    IdentificationRequest request = null;

    try {
        URI resourceUri = file.toURI();
        in = new FileInputStream(file);
        LOG.debug("Identification of resource: " + resourceUri.toString());
        RequestMetaData metaData = new RequestMetaData(file.length(), file.lastModified(), file.getName());
        LOG.debug("File length: " + file.length());
        LOG.debug("File modified: " + file.lastModified());
        LOG.debug("File name: " + file.getName());
        RequestIdentifier identifier = new RequestIdentifier(resourceUri);
        request = new FileSystemIdentificationRequest(metaData, identifier);
        request.open(in);
        IdentificationResultCollection results = bsi.matchBinarySignatures(request);
        bsi.removeLowerPriorityHits(results);
        if (results == null || results.getResults() == null || results.getResults().isEmpty()) {
            LOG.debug("No identification result");
        } else {
            List<IdentificationResult> result = results.getResults();
            if (result != null && !result.isEmpty()) {
                for (IdentificationResult ir : result) {
                    String mime = ir.getMimeType();
                    if (mime != null && !mime.isEmpty()) {
                        // take first mime, ignore others
                        if (!droidIdRes.containsKey("mime")) {
                            droidIdRes.put("mime", mime);
                        }
                    }
                    String puid = ir.getPuid();
                    if (puid != null && !puid.isEmpty()) {
                        // take first puid, ignore others
                        if (!droidIdRes.containsKey("puid")) {
                            droidIdRes.put("puid", puid);
                        }
                    }
                }
            }
        }
        in.close();
        request.close();
    } catch (IOException ex) {
        LOG.error("I/O Exception", ex);
    } finally {
        try {
            in.close();
            request.close();
        } catch (IOException _) {
        }
    }
    if (!droidIdRes.containsKey("mime")) {
        droidIdRes.put("mime", MIME_UNKNOWN);
    }
    if (!droidIdRes.containsKey("puid")) {
        droidIdRes.put("puid", "fmt/0");
    }
    return droidIdRes;
}

From source file:com.github.ukase.toolkit.WrappedUserAgentCallback.java

@Override
public String resolveURI(String uri) {
    URI resolvingUri = transformUri(uri);
    if (resolvingUri == null) {
        return null;
    }/* ww  w. j  a v  a2s . c  om*/
    if (resolvingUri.isAbsolute()) {
        return resolvingUri.toString();
    }

    return resolveUri(resolvingUri);
}

From source file:org.gbif.registry.metasync.protocols.digir.DigirMetadataSynchroniser.java

/**
 * Iterates through the resource's map of namespace (conceptualSchemas) / schemaLocation key value pairs.
 * If a DIGIR_MANIS endpoint is found in the list, the EndpointType is equal to DiGIR_MANIS. A DiGIR_MANIS
 * endpoint is identified, by checking if the schemaLocation 1)contains the word "manis" or 2) is equal to
 * "http://bnhm.berkeley.edu/DwC/bnhm_dc2_schema.xsd".
 *
 * @param conceptualSchemas map with namespace (conceptualSchemas), schemaLocation key value pairs
 *
 * @return endpoint type, defaulting to (normal) DiGIR
 *//*from  w  w w . j a v  a2s  . c  o  m*/
EndpointType determineEndpointType(Map<String, URI> conceptualSchemas) {
    for (URI schemaLocation : conceptualSchemas.values()) {
        if (schemaLocation.toString().equalsIgnoreCase(MANIS_SCHEMA_LOCATION)
                || schemaLocation.toString().toLowerCase().contains(MANIS_KEYWORD)) {
            return EndpointType.DIGIR_MANIS;
        }
    }
    return EndpointType.DIGIR;
}

From source file:org.moserp.facility.rest.FacilityTest.java

@Test
public void createFacility() {
    URI facilityUri = restTemplate.postForLocation(testEnvironment.createRestUri("/facilities"),
            facilityUtil.createFacility());
    assertNotNull("facilityUri", facilityUri);
    assertNotNull(facilityRepository.findOne(facilityUtil.getFacilityIdFromUri(facilityUri.toString())));
}

From source file:com.github.sardine.AuthenticationTest.java

@Test
public void testDigestAuthWithBasicPreemptiveAuthenticationEnabled() throws Exception {
    Sardine sardine = SardineFactory.begin(properties.getProperty("username"),
            properties.getProperty("password"));
    try {//from  w w w.  j  a  v a2s .c  om
        URI url = URI.create("http://sudo.ch/dav/digest/");
        sardine.enablePreemptiveAuthentication(url.getHost());
        sardine.list(url.toString());
        fail("Expected authentication to fail becuase of preemptive credential cache");
    } catch (SardineException e) {
        // If preemptive basic authentication is enabled, we cannot login
        // with digest authentication. This is currently expected.
        assertEquals(401, e.getStatusCode());
    }
}

From source file:eu.esdihumboldt.hale.common.core.io.PathUpdate.java

private void analysePaths(URI oldLocation, URI newLocation) {
    String o = oldLocation.toString();
    String n = newLocation.toString();

    // cut off file name. only look at the path to the files.
    int oindex = o.lastIndexOf('/');
    o = (oindex >= 0) ? (o.substring(0, oindex)) : "";
    int nindex = n.lastIndexOf('/');
    n = (nindex >= 0) ? (n.substring(0, nindex)) : "";

    int commonEndLength = 0;
    while (commonEndLength < o.length() && commonEndLength < n.length()
            && o.charAt(o.length() - commonEndLength - 1) == n.charAt(n.length() - commonEndLength - 1)) {
        commonEndLength++;/*from w ww .  ja v  a  2  s .c  om*/
    }
    oldRaw = o.substring(0, o.length() - commonEndLength);
    newRaw = n.substring(0, n.length() - commonEndLength);
}

From source file:org.chtijbug.drools.platform.rules.config.RuntimeSiteTopology.java

public WebClient webClient(String envName, String resourcePath) {
    try {//from w  w w  .  ja v a2 s .  c  om
        URI uri = environments.get(envName).getUrl().toURI();
        URI baseUri = uri.resolve("/");
        JacksonJaxbJsonProvider jsonProvider = new JacksonJaxbJsonProvider();
        WebClient client = WebClient.create(baseUri.toString(), asList(jsonProvider))
                .path(uri.getPath().concat(resourcePath));
        //_____ Adding no timeout feature for long running process
        ClientConfiguration config = WebClient.getConfig(client);
        HTTPConduit http = (HTTPConduit) config.getConduit();
        HTTPClientPolicy httpClientPolicy = new HTTPClientPolicy();
        /* connection timeout for requesting the rule package binaries */
        httpClientPolicy.setConnectionTimeout(0L);
        /* Reception timeout */
        httpClientPolicy.setReceiveTimeout(0L);
        http.setClient(httpClientPolicy);
        return client;
    } catch (URISyntaxException e) {
        throw propagate(e);
    }
}

From source file:de.ii.ldproxy.rest.LdProxyServiceResourceFactory.java

@Override
public Response getResponseForParams(Collection<Service> services, UriInfo uriInfo) {
    if (uriInfo.getQueryParameters().containsKey(PARAM_WFS_URL)) {
        try {/*from   w ww  .ja  va  2s .  c om*/
            URI wfsUri = WFSAdapter.parseAndCleanWfsUrl(uriInfo.getQueryParameters().getFirst(PARAM_WFS_URL));
            for (Service service : services) {
                URI serviceWfsUri = ((LdProxyService) service).getWfsAdapter().getUrls().get("default")
                        .get(WFS.METHOD.GET);
                if (wfsUri.equals(serviceWfsUri)) {
                    URI serviceUri = new URIBuilder().setPath(getPath(uriInfo) + service.getId() + "/").build();
                    return Response.status(Response.Status.TEMPORARY_REDIRECT)
                            .header("Location", serviceUri.toString()).build();
                }
            }
        } catch (URISyntaxException e) {
            //ignore
        }
        return Response.status(Response.Status.NOT_FOUND).build();
    }
    return null;
}