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:io.cloudslang.lang.cli.utils.CompilerHelperTest.java

@Test
public void testLoadInputsFromCommentedFile() throws Exception {
    expectedException.expect(RuntimeException.class);
    expectedException.expectMessage("Inputs file");

    URI inputsFromFile = getClass().getResource("/inputs/commented_inputs.yaml").toURI();
    compilerHelper.loadInputsFromFile(Collections.singletonList(inputsFromFile.getPath()));
}

From source file:be.fedict.eid.idp.model.bean.AccountingServiceBean.java

private String normalize(String domain) {
    URI uri;
    try {//  ww w  . j ava 2s . co  m
        uri = new URI(domain);
    } catch (URISyntaxException e) {
        return domain;
    }
    String scheme = uri.getScheme();
    if ("http".equals(scheme) || "https".equals(scheme)) {
        return uri.getScheme() + "://" + uri.getHost() + uri.getPath();
    }
    return domain;
}

From source file:jp.primecloud.auto.api.ApiFilter.java

/**
 *
 * URI(Signature????)?// w  w  w  .j  a va 2  s  . co m
 *
 * @param decodeParamMap base64??
 * @param uri URI()
 * @return ???URL(Signature????)
 */
private String createUriQueryParams(LinkedHashMap<String, String> decodeParamMap, URI uri) {
    String baseUriText = uri.getScheme() + "://" + uri.getAuthority() + uri.getPath() + "?";
    StringBuffer uriText = new StringBuffer(baseUriText);
    String splitChar = "";
    for (String key : decodeParamMap.keySet()) {
        if (PARAM_NAME_SIGNATURE.equals(key) == false) {
            uriText.append(splitChar + key + "=" + decodeParamMap.get(key));
            splitChar = "&";
        }
    }
    return uriText.toString();
}

From source file:com.microsoft.alm.plugin.idea.common.actions.OpenFileInBrowserAction.java

@Override
public void doActionPerformed(final AnActionEvent anActionEvent) {
    final Project project = anActionEvent.getRequiredData(CommonDataKeys.PROJECT);
    final VirtualFile virtualFile = anActionEvent.getRequiredData(CommonDataKeys.VIRTUAL_FILE);

    final GitRepositoryManager manager = GitUtil.getRepositoryManager(project);
    final GitRepository gitRepository = manager.getRepositoryForFile(virtualFile);
    final GitRemote gitRemote = TfGitHelper.getTfGitRemote(gitRepository);

    // guard for null so findbugs doesn't complain
    if (gitRemote == null || gitRepository == null || gitRepository.getRoot() == null) {
        return;// w  ww .  j a  va  2  s. co m
    }

    final String rootPath = gitRepository.getRoot().getPath();
    final String path = virtualFile.getPath();
    final String relativePath = path.substring(rootPath.length());

    String gitRemoteBranchName = StringUtils.EMPTY;
    final GitLocalBranch gitLocalBranch = gitRepository.getCurrentBranch();
    if (gitLocalBranch != null) {
        final GitRemoteBranch gitRemoteBranch = gitLocalBranch.findTrackedBranch(gitRepository);
        if (gitRemoteBranch != null) {
            gitRemoteBranchName = gitRemoteBranch.getNameForRemoteOperations();
        }
    }

    final URI urlToBrowseTo = UrlHelper.getFileURI(gitRemote.getFirstUrl(), encodeVirtualFilePath(relativePath),
            gitRemoteBranchName);
    logger.info("Browsing to url " + urlToBrowseTo.getPath());
    BrowserUtil.browse(urlToBrowseTo);
}

From source file:com.subgraph.vega.impl.scanner.urls.UriParser.java

public IPathState processUri(URI uri) {
    final HttpHost host = new HttpHost(uri.getHost(), uri.getPort(), uri.getScheme());
    final IWebHost webHost = getWebHost(host);
    IWebPath path = webHost.getRootPath();
    final boolean hasTrailingSlash = uri.getPath().endsWith("/");

    String[] parts = uri.getPath().split("/");
    IWebPath childPath;//from   w w  w  .ja  v a 2s. c o  m
    for (int i = 1; i < parts.length; i++) {
        synchronized (path) {
            childPath = path.getChildPath(parts[i]);
            if (childPath == null) {
                childPath = path.addChildPath(parts[i]);
            }
            processPath(childPath, uri, (i == (parts.length - 1)), hasTrailingSlash);
        }
        path = childPath;
    }
    return pathStateManager.getStateForPath(path);
}

From source file:org.soyatec.windowsazure.authenticate.SharedKeyCredentialsWrapper.java

/**
 * Replace the uri container name./*  w w w  . j a v a 2s . com*/
 * 
 * @param uri
 * @param containerName
 * @return The uri after be replaced the container name with the input
 *         containerName.
 */
private URI replaceContainerName(URI uri, String containerName) {
    if (containerName == null) {
        return uri;
    }
    try {
        String host = uri.getPath();
        String[] temp = host.split("/");
        temp[0] = containerName;
        return URIUtils.createURI(uri.getScheme(), uri.getHost(), uri.getPort(), join("/", temp),
                (uri.getQuery() == null ? Utilities.emptyString() : uri.getQuery()), uri.getFragment());
    } catch (URISyntaxException e) {
        Logger.error("", e);
    }
    return uri;
}

From source file:com.ge.predix.acs.privilege.management.ResourcePrivilegeManagementController.java

private ResponseEntity<BaseResource> doPutResource(final BaseResource resource,
        final String resourceIdentifier) {
    try {//w  ww.j a  v a2 s .c om
        boolean createdResource = this.service.upsertResource(resource);

        URI resourceUri = UriTemplateUtils.expand(MANAGED_RESOURCE_URL,
                "resourceIdentifier:" + resourceIdentifier);

        if (createdResource) {
            return created(resourceUri.getPath(), false);
        }

        // CHECK if path returns the right info
        return created(resourceUri.getPath(), true);
    } catch (Exception e) {
        throw new RestApiException(HttpStatus.UNPROCESSABLE_ENTITY, e);
    }
}

From source file:org.coffeebreaks.validators.nu.NuValidator.java

ValidationResult validateUri(URL url, ValidationRequest request) throws IOException {
    String parser = request.getValue("parser", null);
    HttpRequestBase method;/*from  w w w .  j  a  va 2 s  .  c o  m*/
    List<NameValuePair> qParams = new ArrayList<NameValuePair>();
    qParams.add(new BasicNameValuePair("out", "json"));
    if (parser != null) {
        qParams.add(new BasicNameValuePair("parser", parser));
    }
    qParams.add(new BasicNameValuePair("doc", url.toString()));

    try {
        URI uri = new URI(baseUrl);
        URI uri2 = URIUtils.createURI(uri.getScheme(), uri.getHost(), uri.getPort(), uri.getPath(),
                URLEncodedUtils.format(qParams, "UTF-8"), null);
        method = new HttpGet(uri2);
        return validate(method);
    } catch (URISyntaxException e) {
        throw new IllegalArgumentException("invalid uri. Check your baseUrl " + baseUrl, e);
    }
}

From source file:com.machinepublishers.jbrowserdriver.CookieStore.java

/**
 * {@inheritDoc}/*from w w w .j  a va  2s. co  m*/
 */
@Override
public Map<String, List<String>> get(URI uri, Map<String, List<String>> requestHeaders) throws IOException {
    final String reqHost = canonicalHost(uri.getHost());
    final String reqPath = canonicalPath(uri.getPath());
    final boolean reqSecure = isSecure(uri.getScheme());
    final boolean reqJavascript = isJavascript(uri.getScheme());
    StringBuilder builder = new StringBuilder();
    if (reqJavascript) {
        List<Cookie> list;
        synchronized (store) {
            store.clearExpired(new Date());
            list = store.getCookies();
        }
        for (Cookie cookie : list) {
            if ((!cookie.isSecure() || reqSecure) && reqHost.endsWith(canonicalHost(cookie.getDomain()))
                    && reqPath.startsWith(canonicalPath(cookie.getPath()))) {
                if (builder.length() > 0) {
                    builder.append(';');
                }
                builder.append(cookie.getName());
                builder.append('=');
                builder.append(cookie.getValue());
            }
        }
    }
    String cookies = builder.length() == 0 ? null : builder.toString();
    Map<String, List<String>> map;
    if (cookies != null) {
        map = new HashMap<String, List<String>>();
        map.put("Cookie", Arrays.asList(cookies));
    } else {
        map = Collections.emptyMap();
    }
    return map;
}