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.github.brandtg.pantopod.crawler.FileBasedCrawlingEventHandler.java

@Override
protected boolean hasError(URI url) {
    File outputRoot = new File(outputDir, url.getHost() + File.separator + url.getPath());
    File errFile = new File(outputRoot, ERR_FILE);
    return errFile.exists();
}

From source file:org.jboss.aerogear.unifiedpush.admin.ui.utils.UpsOpenshiftStatusCheck.java

@Override
public void target(URI uri) {
    Validate.notNull(uri, "target URI to check status of can not be a null object");
    this.uri = uri.getPath().contains("extension") ? uri.resolve(uri.getPath() + "/status") : uri;
}

From source file:com.cognifide.qa.bb.proxy.analyzer.predicate.RequestPredicateImpl.java

@Override
public boolean accepts(HttpRequest request) {
    boolean result = false;
    URI uri = URI.create(request.getUri());
    String path = uri.getPath();
    if (path != null && path.startsWith(urlPrefix)) {
        String query = uri.getQuery();
        if (expectedParams.isEmpty() && StringUtils.isEmpty(query)) {
            result = true;/*from  www  .  j  a  v  a2s  .  c  o m*/
        } else if (StringUtils.isNotEmpty(query)) {
            List<NameValuePair> params = URLEncodedUtils.parse(query, Charsets.UTF_8);
            result = hasAllExpectedParams(expectedParams, params);
        }
    }
    return result;
}

From source file:io.druid.storage.google.GoogleDataSegmentPuller.java

@Override
public InputStream getInputStream(URI uri) throws IOException {
    String path = uri.getPath();
    if (path.startsWith("/")) {
        path = path.substring(1);/*  w  w  w  .  j  a v a 2 s .  co m*/
    }
    return storage.get(uri.getHost(), path);
}

From source file:io.druid.storage.google.GoogleDataSegmentPuller.java

@Override
public String getVersion(URI uri) throws IOException {
    String path = uri.getPath();
    if (path.startsWith("/")) {
        path = path.substring(1);//from  w ww .  j  av a  2  s  .c  o m
    }
    return storage.version(uri.getHost(), path);
}

From source file:com.cloudbees.jenkins.plugins.bitbucket.endpoints.BitbucketEndpointConfiguration.java

/**
 * Fix a serverUrl./*from  w  w w .j  a v  a 2 s  .  c om*/
 *
 * @param serverUrl the server URL.
 * @return the normalized server URL.
 */
@NonNull
public static String normalizeServerUrl(@CheckForNull String serverUrl) {
    serverUrl = StringUtils.defaultIfBlank(serverUrl, BitbucketCloudEndpoint.SERVER_URL);
    try {
        URI uri = new URI(serverUrl).normalize();
        String scheme = uri.getScheme();
        if ("http".equals(scheme) || "https".equals(scheme)) {
            // we only expect http / https, but also these are the only ones where we know the authority
            // is server based, i.e. [userinfo@]server[:port]
            // DNS names must be US-ASCII and are case insensitive, so we force all to lowercase

            String host = uri.getHost() == null ? null : uri.getHost().toLowerCase(Locale.ENGLISH);
            int port = uri.getPort();
            if ("http".equals(scheme) && port == 80) {
                port = -1;
            } else if ("https".equals(scheme) && port == 443) {
                port = -1;
            }
            serverUrl = new URI(scheme, uri.getUserInfo(), host, port, uri.getPath(), uri.getQuery(),
                    uri.getFragment()).toASCIIString();
        }
    } catch (URISyntaxException e) {
        // ignore, this was a best effort tidy-up
    }
    return serverUrl.replaceAll("/$", "");
}

From source file:com.vmware.photon.controller.api.frontend.filter.NetworkToSubnetRedirectionFilter.java

/**
 * Filter to detect API calls that contain /networks in them and redirect to /subnets instead.
 * <p>//from w w  w . j ava2s. c  om
 * Calls to /networks... get redirected to /subnets...
 * Calls to /projects/{id}/networks get redirected to /projects/{id}/subnets
 * Calls to /vms/{id}/networks get redirected to /vms/{id}/subnets
 *
 * @param requestContext
 */
@Override
public void filter(ContainerRequestContext requestContext) {
    final UriInfo uriInfo = requestContext.getUriInfo();
    final URI oldRequestURI = uriInfo.getRequestUri();
    final String oldPath = oldRequestURI.getPath().toLowerCase();

    // String.startsWith should be more efficient than String.contains.
    // Using startsWith first should short circuit this filter quickly for most requests
    // that do not have "/networks" in them.

    if (oldPath.startsWith("/networks")) {
        redirectNetworkToSubnet(requestContext, uriInfo, oldRequestURI, oldPath);
        return;
    }

    if (oldPath.startsWith("/projects") || oldPath.startsWith("/vms")) {
        if (oldPath.contains("/networks")) {
            redirectNetworkToSubnet(requestContext, uriInfo, oldRequestURI, oldPath);
        }
    }
}

From source file:nu.yona.server.DOSProtectionService.java

private String getKey(URI uri, HttpServletRequest request) {
    String key = request.getRemoteAddr() + "@" + uri.getPath();
    String query = uri.getQuery();
    if (query != null) {
        key += query;//w  ww  . j a  v  a 2s  . c o  m
    }
    return key;
}

From source file:de.openknowledge.cdi.common.property.source.ClassPathPropertySourceLoader.java

public Properties load(URI resource) {
    Properties properties = new Properties();

    try {//from  w ww. j a v  a 2 s  .com
        String resourceName = resource.getPath().substring(1);
        InputStream stream = Thread.currentThread().getContextClassLoader().getResourceAsStream(resourceName);
        if (stream == null) {
            LOG.warn("Property file " + resource + " not found in classpath.");
        } else {
            LOG.debug("Loading properties from classpath " + resource);
            loadFromStream(properties, stream);
        }
    } catch (IOException e) {
        LOG.warn("Error loading properties from classpath resource " + resource + ": " + e.getMessage());
    }
    return properties;
}

From source file:io.druid.segment.realtime.firehose.HttpFirehoseFactory.java

@Override
protected InputStream wrapObjectStream(URI object, InputStream stream) throws IOException {
    return object.getPath().endsWith(".gz") ? CompressionUtils.gzipInputStream(stream) : stream;
}