Example usage for java.net URI getAuthority

List of usage examples for java.net URI getAuthority

Introduction

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

Prototype

public String getAuthority() 

Source Link

Document

Returns the decoded authority component of this URI.

Usage

From source file:org.ovirt.engine.sdk4.internal.SsoUtils.java

/**
 * Construct SSO URL to revoke SSO token
 *
 * @param url oVirt engine URL/*from  ww  w . jav a2 s .  co  m*/
 * @return URI to be used to revoke token
 */
public static URI buildSsoRevokeUrl(String url) {
    try {
        URI uri = new URI(url);
        URIBuilder uriBuilder = new URIBuilder(String.format("%1$s://%2$s/ovirt-engine/services/sso-logout",
                uri.getScheme(), uri.getAuthority()));
        return uriBuilder.build();
    } catch (URISyntaxException ex) {
        throw new Error("Failed to build SSO revoke URL", ex);
    }
}

From source file:org.apache.bookkeeper.meta.zk.ZKMetadataDriverBase.java

public static String getZKServersFromServiceUri(URI uri) {
    return uri.getAuthority().replace(";", ",");
}

From source file:org.apache.drill.exec.store.dfs.FileSelection.java

private static String commonPath(FileStatus... paths) {
    String commonPath = "";
    String[][] folders = new String[paths.length][];
    for (int i = 0; i < paths.length; i++) {
        folders[i] = Path.getPathWithoutSchemeAndAuthority(paths[i].getPath()).toString().split("/");
    }/*  w  ww. java2 s . com*/
    for (int j = 0; j < folders[0].length; j++) {
        String thisFolder = folders[0][j];
        boolean allMatched = true;
        for (int i = 1; i < folders.length && allMatched; i++) {
            if (folders[i].length < j) {
                allMatched = false;
                break;
            }
            allMatched &= folders[i][j].equals(thisFolder);
        }
        if (allMatched) {
            commonPath += thisFolder + "/";
        } else {
            break;
        }
    }
    URI oneURI = paths[0].getPath().toUri();
    return new Path(oneURI.getScheme(), oneURI.getAuthority(), commonPath).toString();
}

From source file:org.apache.drill.exec.store.dfs.FileSelection.java

public static FileSelection create(DrillFileSystem fs, String parent, String path) throws IOException {
    Path p = new Path(parent, removeLeadingSlash(path));
    FileStatus[] status = fs.globStatus(p);
    if (status == null || status.length == 0) {
        return null;
    }/*w w  w .  j av a2s. c o m*/
    if (status.length == 1) {
        URI oneURI = status[0].getPath().toUri();
        String selectionRoot = new Path(oneURI.getScheme(), oneURI.getAuthority(), p.toUri().getPath())
                .toString();
        return new FileSelection(Collections.singletonList(status[0]), selectionRoot);
    }
    return new FileSelection(Lists.newArrayList(status), commonPath(status));
}

From source file:io.servicecomb.serviceregistry.RegistryUtils.java

/**
 * ?0.0.0.0??????//  ww w .  j ava  2s  .  c o  m
 */
public static String getPublishAddress(String schema, String address) {
    if (address == null) {
        return address;
    }

    try {
        URI originalURI = new URI(schema + "://" + address);
        IpPort ipPort = NetUtils.parseIpPort(originalURI.getAuthority());
        if (ipPort == null) {
            LOGGER.warn("address {} not valid.", address);
            return null;
        }

        IpPort publishIpPort = genPublishIpPort(schema, ipPort);
        URIBuilder builder = new URIBuilder(originalURI);
        return builder.setHost(publishIpPort.getHostOrIp()).setPort(publishIpPort.getPort()).build().toString();
    } catch (URISyntaxException e) {
        LOGGER.warn("address {} not valid.", address);
        return null;
    }
}

From source file:org.eurocarbdb.tranche.TrancheUtility.java

/** Download a file from the Tranche network 
 * @param inputURI      Input URI of the tranche file
 * @return              File at the URI, or null if it does not exist
 * @throws IOException/*from w  ww  .ja  v  a  2s.  c  o  m*/
 */
public static File downloadFile(URI inputURI) throws IOException {
    if (inputURI.getScheme().equals("tranche")) {
        return downloadFile(inputURI.getAuthority() + inputURI.getPath());
    } else {
        throw new FileNotFoundException("Supplied URI does not specify a tranche file");
    }
}

From source file:de.metas.procurement.webui.ui.view.PasswordResetView.java

public static final URI buildPasswordResetURI(final String passwordResetKey) {
    try {/*from w  w w.  ja v a2s . co  m*/
        final URI uri = Page.getCurrent().getLocation();
        final String query = null;
        final String fragment = MFNavigator.createURIFragment(NAME, passwordResetKey);
        final URI resetURI = new URI(uri.getScheme(), uri.getAuthority(), uri.getPath(), query, fragment);
        System.out.println(resetURI);
        return resetURI;
    } catch (Exception e) {
        throw Throwables.propagate(e);
    }
}

From source file:org.apache.gobblin.service.FlowConfigResourceLocalHandler.java

public static URI createFlowSpecUri(FlowId flowId) throws URISyntaxException {
    URI flowCatalogURI = new URI("gobblin-flow", null, "/", null, null);
    URI flowUri = new URI(flowCatalogURI.getScheme(), flowCatalogURI.getAuthority(),
            "/" + flowId.getFlowGroup() + "/" + flowId.getFlowName(), null, null);
    return flowUri;
}

From source file:org.apache.openmeetings.service.calendar.caldav.handler.EtagsHandler.java

/**
 * @param uri URI to provide the host and scheme
 * @param path Path to append to host/* w  w  w  .  j  av  a2s . c  o m*/
 * @return Returns the full path, based on the URI as host and the path provided
 */
private static String getFullPath(URI uri, String path) {
    return uri.getScheme() + "://" + uri.getAuthority() + path;
}

From source file:org.apache.hadoop.fs.s3native.S3xLoginHelper.java

/**
 * Extract the login details from a URI.
 * @param name URI of the filesystem//  w ww.  j a v a 2  s  . co  m
 * @return a login tuple, possibly empty.
 */
public static Login extractLoginDetails(URI name) {
    try {
        String authority = name.getAuthority();
        if (authority == null) {
            return Login.EMPTY;
        }
        int loginIndex = authority.indexOf('@');
        if (loginIndex < 0) {
            // no login
            return Login.EMPTY;
        }
        String login = authority.substring(0, loginIndex);
        int loginSplit = login.indexOf(':');
        if (loginSplit > 0) {
            String user = login.substring(0, loginSplit);
            String password = URLDecoder.decode(login.substring(loginSplit + 1), "UTF-8");
            return new Login(user, password);
        } else if (loginSplit == 0) {
            // there is no user, just a password. In this case, there's no login
            return Login.EMPTY;
        } else {
            return new Login(login, "");
        }
    } catch (UnsupportedEncodingException e) {
        // this should never happen; translate it if it does.
        throw new RuntimeException(e);
    }
}