Example usage for java.net URI getRawAuthority

List of usage examples for java.net URI getRawAuthority

Introduction

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

Prototype

public String getRawAuthority() 

Source Link

Document

Returns the raw authority component of this URI.

Usage

From source file:com.box.restclientv2.httpclientsupport.HttpClientURIBuilder.java

private void digestURI(final URI uri) throws URISyntaxException {
    this.scheme = uri.getScheme();
    this.encodedSchemeSpecificPart = uri.getRawSchemeSpecificPart();
    this.encodedAuthority = uri.getRawAuthority();
    this.host = uri.getHost();
    this.port = uri.getPort();
    this.encodedUserInfo = uri.getRawUserInfo();
    this.userInfo = uri.getUserInfo();
    this.encodedPath = uri.getRawPath();
    this.path = uri.getPath();
    this.encodedQuery = uri.getRawQuery();
    this.queryParams = parseQuery(uri.getRawQuery(), HttpClientConsts.UTF_8);
    this.encodedFragment = uri.getRawFragment();
    this.fragment = uri.getFragment();
}

From source file:org.mcxiaoke.commons.http.util.URIBuilderEx.java

private void digestURI(final URI uri) {
    this.scheme = uri.getScheme();
    this.encodedSchemeSpecificPart = uri.getRawSchemeSpecificPart();
    this.encodedAuthority = uri.getRawAuthority();
    this.host = uri.getHost();
    this.port = uri.getPort();
    this.encodedUserInfo = uri.getRawUserInfo();
    this.userInfo = uri.getUserInfo();
    this.encodedPath = uri.getRawPath();
    this.path = uri.getPath();
    this.encodedQuery = uri.getRawQuery();
    this.queryParams = parseQuery(uri.getRawQuery(), URIUtilsEx.UTF_8);
    this.encodedFragment = uri.getRawFragment();
    this.fragment = uri.getFragment();
}

From source file:com.mcxiaoke.next.http.util.URIBuilder.java

private void digestURI(final URI uri) {
    this.scheme = uri.getScheme();
    this.encodedSchemeSpecificPart = uri.getRawSchemeSpecificPart();
    this.encodedAuthority = uri.getRawAuthority();
    this.host = uri.getHost();
    this.port = uri.getPort();
    this.encodedUserInfo = uri.getRawUserInfo();
    this.userInfo = uri.getUserInfo();
    this.encodedPath = uri.getRawPath();
    this.path = uri.getPath();
    this.encodedQuery = uri.getRawQuery();
    this.queryParams = parseQuery(uri.getRawQuery(), Charsets.UTF_8);
    this.encodedFragment = uri.getRawFragment();
    this.fragment = uri.getFragment();
}

From source file:org.wso2.carbon.ml.core.impl.BAMInputAdapter.java

/**
 * Checks whether the data source uri refers to a valid table in BAM
 * /*w  w  w.ja  va  2 s.c  o m*/
 * @param uri   Data Source URI to be validated.
 * @return      Boolean indicating validity
 * @throws      MLInputAdapterException
 * @throws      ClientProtocolException
 * @throws      IOException
 */
private boolean isValidTable(URI uri) throws MLInputAdapterException, ClientProtocolException, IOException {
    httpClient = HttpClients.createDefault();
    uriResourceParameters = uri.normalize().getPath().replaceFirst("/analytics/tables", "").replaceAll("^/", "")
            .replaceAll("/$", "").split("/");
    // if BAM table name is not empty, return false.
    if (uriResourceParameters[0].isEmpty()) {
        return false;
    }
    // check whether the BAM table exists.
    try {
        URI tableCheckUri = new URI(uri.getScheme() + "://" + uri.getRawAuthority()
                + "/analytics/table_exists?tableName=" + uriResourceParameters[0]);
        HttpGet get = new HttpGet(tableCheckUri);
        CloseableHttpResponse response = httpClient.execute(get);
        BufferedReader br = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
        JSONObject outputJson = new JSONObject(br.readLine());
        return "success".equalsIgnoreCase(outputJson.get("status").toString());
    } catch (URISyntaxException e) {
        throw new MLInputAdapterException("Invalid Uri Syntax:" + e.getMessage(), e);
    }
}

From source file:org.cryptomator.frontend.webdav.mount.MacOsXShellScriptWebDavMounter.java

@Override
public WebDavMount mount(URI uri, Map<MountParam, Optional<String>> mountParams) throws CommandFailedException {
    final String mountName = mountParams.getOrDefault(MountParam.MOUNT_NAME, Optional.empty())
            .orElseThrow(() -> {/* w  w w .j  av a  2  s. c  o  m*/
                return new IllegalArgumentException("Missing mount parameter MOUNT_NAME.");
            });

    // we don't use the uri to derive a path, as it *could* be longer than 255 chars.
    final String path = "/Volumes/Cryptomator_" + UUID.randomUUID().toString();
    final Script mountScript = Script
            .fromLines("mkdir \"$MOUNT_PATH\"",
                    "mount_webdav -S -v $MOUNT_NAME \"$DAV_AUTHORITY$DAV_PATH\" \"$MOUNT_PATH\"")
            .addEnv("DAV_AUTHORITY", uri.getRawAuthority()).addEnv("DAV_PATH", uri.getRawPath())
            .addEnv("MOUNT_PATH", path).addEnv("MOUNT_NAME", mountName);
    mountScript.execute();
    return new MacWebDavMount(path);
}

From source file:com.cloudbees.jenkins.plugins.bitbucket.server.client.BitbucketServerAPIClient.java

/**
 * {@inheritDoc}//w  ww  .  ja  v  a 2  s  .co m
 */
@NonNull
@Override
public String getRepositoryUri(@NonNull BitbucketRepositoryType type,
        @NonNull BitbucketRepositoryProtocol protocol, @CheckForNull String cloneLink, @NonNull String owner,
        @NonNull String repository) {
    switch (type) {
    case GIT:
        URI baseUri;
        try {
            baseUri = new URI(baseURL);
        } catch (URISyntaxException e) {
            throw new IllegalStateException("Server URL is not a valid URI", e);
        }

        UriTemplate template = UriTemplate
                .fromTemplate("{scheme}://{+authority}{+path}{/owner,repository}.git");
        template.set("owner", owner);
        template.set("repository", repository);

        switch (protocol) {
        case HTTP:
            template.set("scheme", baseUri.getScheme());
            template.set("authority", baseUri.getRawAuthority());
            template.set("path", Objects.toString(baseUri.getRawPath(), "") + "/scm");
            break;
        case SSH:
            template.set("scheme", BitbucketRepositoryProtocol.SSH.getType());
            template.set("authority", "git@" + baseUri.getHost());
            if (cloneLink != null) {
                try {
                    URI cloneLinkUri = new URI(cloneLink);
                    if (cloneLinkUri.getScheme() != null) {
                        template.set("scheme", cloneLinkUri.getScheme());
                    }
                    if (cloneLinkUri.getRawAuthority() != null) {
                        template.set("authority", cloneLinkUri.getRawAuthority());
                    }
                } catch (@SuppressWarnings("unused") URISyntaxException ignored) {
                    // fall through
                }
            }
            break;
        default:
            throw new IllegalArgumentException("Unsupported repository protocol: " + protocol);
        }
        return template.expand();
    default:
        throw new IllegalArgumentException("Unsupported repository type: " + type);
    }
}

From source file:org.apache.hadoop.fs.azure.AzureNativeFileSystemStore.java

/**
 * Method to extract the container name from an Azure URI.
 * //from   w  w w  .  j a v a  2s  .co  m
 * @param uri
 *          -- WASB blob URI
 * @returns containerName -- the container name for the URI. May be null.
 * @throws URISyntaxException
 *           if the uri does not have an authority it is badly formed.
 */
private String getContainerFromAuthority(URI uri) throws URISyntaxException {

    // Check to make sure that the authority is valid for the URI.
    //
    String authority = uri.getRawAuthority();
    if (null == authority) {
        // Badly formed or illegal URI.
        //
        throw new URISyntaxException(uri.toString(), "Expected URI with a valid authority");
    }

    // The URI has a valid authority. Extract the container name. It is the
    // second component of the WASB URI authority.
    if (!authority.contains(WASB_AUTHORITY_DELIMITER)) {
        // The authority does not have a container name. Use the default container by
        // setting the container name to the default Azure root container.
        //
        return AZURE_ROOT_CONTAINER;
    }

    // Split off the container name and the authority.
    String[] authorityParts = authority.split(WASB_AUTHORITY_DELIMITER, 2);

    // Because the string contains an '@' delimiter, a container must be
    // specified.
    if (authorityParts.length < 2 || "".equals(authorityParts[0])) {
        // Badly formed WASB authority since there is no container.
        final String errMsg = String.format("URI '%s' has a malformed WASB authority, expected container name."
                + "Authority takes the form wasb://[<container name>@]<account name>", uri.toString());
        throw new IllegalArgumentException(errMsg);
    }

    // Set the container name from the first entry for the split parts of the
    // authority.
    return authorityParts[0];
}

From source file:org.apache.hadoop.fs.azure.AzureNativeFileSystemStore.java

/**
 * Method to extract the account name from an Azure URI.
 * /*from   w ww  .  j  a  va  2  s  . c  o m*/
 * @param uri
 *          -- WASB blob URI
 * @returns accountName -- the account name for the URI.
 * @throws URISyntaxException
 *           if the URI does not have an authority it is badly formed.
 */
private String getAccountFromAuthority(URI uri) throws URISyntaxException {

    // Check to make sure that the authority is valid for the URI.
    //
    String authority = uri.getRawAuthority();
    if (null == authority) {
        // Badly formed or illegal URI.
        //
        throw new URISyntaxException(uri.toString(), "Expected URI with a valid authority");
    }

    // Check if authority container the delimiter separating the account name from the
    // the container.
    //
    if (!authority.contains(WASB_AUTHORITY_DELIMITER)) {
        return authority;
    }

    // Split off the container name and the authority.
    //
    String[] authorityParts = authority.split(WASB_AUTHORITY_DELIMITER, 2);

    // Because the string contains an '@' delimiter, a container must be
    // specified.
    //
    if (authorityParts.length < 2 || "".equals(authorityParts[0])) {
        // Badly formed WASB authority since there is no container.
        //
        final String errMsg = String.format("URI '%s' has a malformed WASB authority, expected container name. "
                + "Authority takes the form wasb://[<container name>@]<account name>", uri.toString());
        throw new IllegalArgumentException(errMsg);
    }

    // Return with the account name. It is possible that this name is NULL.
    //
    return authorityParts[1];
}