Example usage for java.net URI getPath

List of usage examples for java.net URI getPath

Introduction

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

Prototype

public String getPath() 

Source Link

Document

Returns the decoded path component of this URI.

Usage

From source file:com.collective.celos.ci.deploy.JScpWorker.java

URI getURIRespectingUsername(URI uri) throws URISyntaxException {

    if (userName != null && uri.getUserInfo() == null) {
        uri = new URI(uri.getScheme(), userName, uri.getHost(), uri.getPort(), uri.getPath(), uri.getQuery(),
                uri.getFragment());// ww w  .  j a v  a 2  s .c o  m
    }
    return uri;
}

From source file:com.anrisoftware.simplerest.owncloudocs.OwncloudOcsStatus.java

private URI getRequestURI0() throws URISyntaxException {
    URI baseUri = account.getBaseUri();
    String extraPath = baseUri.getPath();
    URIBuilder builder = new URIBuilder(baseUri);
    builder.setUserInfo(account.getUser(), account.getPassword());
    String statusPath = String.format("%s%s", extraPath, propertiesProvider.getOwncloudStatusPath());
    builder.setPath(statusPath);/*from  w w w. j  av a2 s.  com*/
    return builder.build();
}

From source file:com.splunk.shuttl.archiver.archive.ArchiveConfigurationTest.java

public void getArchivingRoot_givenUriInMBean_childToTheUri() {
    String uriString = "valid:/uri";
    when(mBean.getArchiverRootURI()).thenReturn(uriString);
    URI actualUri = createConfiguration().getArchivingRoot();
    String childName = FilenameUtils.getName(actualUri.getPath());
    URI expectedUri = URI.create(uriString + "/" + childName);
    assertEquals(expectedUri, actualUri);
}

From source file:com.adaptris.security.TestKeystoreLocation.java

@Test
public void testRemoteKeystore() throws Exception {
    if (Boolean.parseBoolean(cfg.getProperty(Config.REMOTE_TESTS_ENABLED, "false"))) {
        String ks = cfg.getProperty(Config.KEYSTORE_TEST_URL);
        ks = ks.replaceAll("\\\\", "/");
        URI uri = new URI(ks);
        File keystore = new File(uri.getPath());
        String filename = keystore.getName();
        File newFile = new File(cfg.getProperty(Config.KEYSTORE_REMOTE_REALPATH) + "/" + filename);
        FileUtils.copyFile(keystore, newFile);
        Thread.sleep(10000);/*w  w w . jav a  2  s . com*/
        logR.debug("newFile " + newFile.getCanonicalPath());
        String keystoreType = uri.getQuery();
        String url = cfg.getProperty(Config.KEYSTORE_REMOTE_ROOT) + filename + "?" + keystoreType;
        KeystoreLocation k = KeystoreFactory.getDefault().create(url,
                cfg.getProperty(Config.KEYSTORE_COMMON_KEYSTORE_PW).toCharArray());
        assertTrue("Remote Keystore exists", k.exists());
        InputStream in = k.openInput();
        in.close();
        assertTrue(!k.isWriteable());
        boolean openOutputSuccess = false;
        try {
            OutputStream o = k.openOutput();
            openOutputSuccess = true;
            o.close();
        } catch (Exception e) {
            // Expected as it's non-writeable
        }
        newFile.delete();
        if (openOutputSuccess) {
            fail("Successfully opened output to a remote keystore!");
        }
    }
}

From source file:de.betterform.connector.xmlrpc.XMLRPCURIResolver.java

/**
 * Parses the URI into three elements./*from  w w w .  j a va  2  s.co m*/
 * The xmlrpc URL, the function and the params
 *
 * @return a Vector
 */
private Vector parseURI(URI uri) {
    String host = uri.getHost();
    int port = uri.getPort();
    String path = uri.getPath();
    String query = uri.getQuery();

    /* Split the path up into basePath and function */
    int finalSlash = path.lastIndexOf('/');
    String basePath = "";
    if (finalSlash > 0) {
        basePath = path.substring(1, finalSlash);
    }
    String function = path.substring(finalSlash + 1, path.length());

    String rpcURL = "http://" + host + ":" + port + "/" + basePath;

    log.debug("New URL  = " + rpcURL);
    log.debug("Function = " + function);

    Hashtable paramHash = new Hashtable();

    if (query != null) {
        String[] params = query.split("&");

        for (int i = 0; i < params.length; i++) {
            log.debug("params[" + i + "] = " + params[i]);
            String[] keyval = params[i].split("=");
            log.debug("\t" + keyval[0] + " -> " + keyval[1]);
            paramHash.put(keyval[0], keyval[1]);
        }
    }

    Vector ret = new Vector();
    ret.add(rpcURL);
    ret.add(function);
    ret.add(paramHash);
    return ret;
}

From source file:com.anrisoftware.simplerest.owncloudocs.OwncloudOcsUploadFile.java

private URI getRequestURI0() throws URISyntaxException {
    URI baseUri = account.getBaseUri();
    String extraPath = baseUri.getPath();
    URIBuilder builder = new URIBuilder(baseUri);
    builder.setUserInfo(account.getUser(), account.getPassword());
    String statusPath = String.format("%s%s%s", extraPath, propertiesProvider.getOwncloudWebdavPath(),
            remotePath);//from w  ww.  j  av  a  2 s  . c  om
    builder.setPath(statusPath);
    return builder.build();
}

From source file:org.iipg.hurricane.jmx.client.JMXRequestHandler.java

protected String prepareBaseUrl(URI pUri) {
    String base = pUri.getPath();
    if (base == null) {
        return "/";
    } else if (!base.endsWith("/")) {
        return base + "/";
    } else {/*from   w w w.j a  va  2  s.  c om*/
        return base;
    }
}

From source file:com.mgmtp.perfload.perfalyzer.normalization.MeasuringNormalizingStrategy.java

@Override
public List<ChannelData> normalizeLine(final String line) {
    tokenizer.reset(line);/*from   ww w  .  j a  v a2s . c o  m*/
    String[] tokens = tokenizer.getTokenArray();

    List<ChannelData> channelDataList = newArrayListWithExpectedSize(3);
    ZonedDateTime timestamp;
    try {
        timestamp = ZonedDateTime.parse(tokens[3]);
    } catch (IllegalArgumentException ex) {
        log.error("Invalid data line: {}", line);
        return channelDataList;
    }

    if (!timestampNormalizer.isInRange(timestamp)) {
        log.trace("Skipping measuring entry. Timestamp not in time range of test: " + timestamp);
        return channelDataList;
    }
    StrBuilder sb = new StrBuilder(200);

    long normalizedTimestamp = timestampNormalizer.normalizeTimestamp(timestamp, 0L);

    String responseTimeFirstByte = tokens[MEASURING_RAW_COL_RESPONSE_TIME_FIRST_BYTE];
    String responseTime = tokens[MEASURING_RAW_COL_RESPONSE_TIME];
    String operation = tokens[MEASURING_RAW_COL_OPERATION];
    if (operation == null || operation.isEmpty()) {
        return channelDataList;
    }

    String result = tokens[MEASURING_RAW_COL_RESULT];
    String errorMsg = tokens[MEASURING_RAW_COL_ERROR_MSG];
    String type = tokens[MEASURING_RAW_COL_REQUEST_TYPE];
    String uriString = tokens[MEASURING_RAW_COL_URI];
    String uriAlias = tokens[MEASURING_RAW_COL_URI_ALIAS];

    String uriPath;
    try {
        URI uri = new URI(uriString);
        uriPath = uri.getPath();
        String query = uri.getQuery();
        if (query != null) {
            uriPath += '?' + query;
        }
    } catch (URISyntaxException ex) {
        // this can happen for agent measurings and custom request types
        uriPath = uriString;
    }

    if (uriString.equals(uriAlias)) {
        uriAlias = uriPath;
    }

    String executionId = tokens[MEASURING_RAW_COL_EXECUTION_ID];
    String requestId = tokens[MEASURING_RAW_COL_REQUEST_ID];

    appendEscapedAndQuoted(sb, DELIMITER, normalizedTimestamp);
    appendEscapedAndQuoted(sb, DELIMITER, responseTimeFirstByte);
    appendEscapedAndQuoted(sb, DELIMITER, responseTime);
    appendEscapedAndQuoted(sb, DELIMITER, operation);
    appendEscapedAndQuoted(sb, DELIMITER, type);
    appendEscapedAndQuoted(sb, DELIMITER, uriPath);
    appendEscapedAndQuoted(sb, DELIMITER, uriAlias);
    appendEscapedAndQuoted(sb, DELIMITER, result);
    appendEscapedAndQuoted(sb, DELIMITER, errorMsg);
    appendEscapedAndQuoted(sb, DELIMITER, executionId);
    appendEscapedAndQuoted(sb, DELIMITER, requestId);

    String resultLine = sb.toString();
    channelDataList.add(new ChannelData(CHANNEL_BASE_NAME, operation, resultLine));
    return channelDataList;
}

From source file:org.jolokia.client.request.J4pRequestHandler.java

private String prepareBaseUrl(URI pUri) {
    String base = pUri.getPath();
    if (base == null) {
        return "/";
    } else if (!base.endsWith("/")) {
        return base + "/";
    } else {//from  w  ww  . ja  v  a  2  s.  co m
        return base;
    }
}

From source file:de.catma.document.source.contenthandler.DefaultProtocolHandler.java

private void handle(URI sourceDocURI) throws IOException {

    final String sourceDocURL = sourceDocURI.toURL().toString();
    final String sourceURIPath = sourceDocURI.getPath();

    SourceDocumentHandler sourceDocumentHandler = new SourceDocumentHandler();

    URLConnection urlConnection = new URL(sourceDocURL).openConnection();

    InputStream is = urlConnection.getInputStream();
    try {//w  w  w .j ava 2 s.  c  o  m
        this.byteContent = IOUtils.toByteArray(is);
        if (this.mimeType == null) {
            this.mimeType = sourceDocumentHandler.getMimeType(sourceURIPath, urlConnection,
                    FileType.TEXT.getMimeType());
        }

        this.encoding = Charset.defaultCharset().name();

        if (this.mimeType.equals(FileType.TEXT.getMimeType())
                || (this.mimeType.equals(FileType.HTML.getMimeType()))) {
            this.encoding = sourceDocumentHandler.getEncoding(urlConnection, byteContent,
                    Charset.defaultCharset().name());
        }
    } finally {
        is.close();
    }

}