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.opengamma.web.analytics.rest.WebUiResource.java

@POST
public Response createView(@Context SecurityContext securityContext, @Context UriInfo uriInfo,
        @FormParam("requestId") String requestId, @FormParam("viewDefinitionId") String viewDefinitionId,
        @FormParam("aggregators") List<String> aggregators,
        @FormParam("marketDataProviders") String marketDataProviders,
        @FormParam("valuationTime") String valuationTime,
        @FormParam("portfolioVersionTime") String portfolioVersionTime,
        @FormParam("portfolioCorrectionTime") String portfolioCorrectionTime,
        @FormParam("clientId") String clientId, @FormParam("blotter") Boolean blotter) {
    ArgumentChecker.notEmpty(requestId, "requestId");
    ArgumentChecker.notEmpty(viewDefinitionId, "viewDefinitionId");
    ArgumentChecker.notNull(aggregators, "aggregators");
    ArgumentChecker.notEmpty(marketDataProviders, "marketDataProviders");
    ArgumentChecker.notEmpty(clientId, "clientId");
    boolean blotterColumns = blotter == null ? false : blotter;
    List<MarketDataSpecification> marketDataSpecs = MarketDataSpecificationJsonReader
            .buildSpecifications(marketDataProviders);
    VersionCorrection versionCorrection = VersionCorrection.of(parseInstant(portfolioVersionTime),
            parseInstant(portfolioCorrectionTime));
    ViewRequest viewRequest = new ViewRequest(UniqueId.parse(viewDefinitionId), aggregators, marketDataSpecs,
            parseInstant(valuationTime), versionCorrection, blotterColumns);
    String viewId = Long.toString(s_nextViewId.getAndIncrement());
    URI portfolioGridUri = uriInfo.getAbsolutePathBuilder().path(viewId).path("portfolio").build();
    URI primitivesGridUri = uriInfo.getAbsolutePathBuilder().path(viewId).path("primitives").build();
    Principal userPrincipal = securityContext.getUserPrincipal();
    String userName = userPrincipal != null ? userPrincipal.getName() : null;
    ClientConnection connection = _connectionManager.getConnectionByClientId(userName, clientId);
    URI uri = uriInfo.getAbsolutePathBuilder().path(viewId).build();
    ImmutableMap<String, Object> callbackMap = ImmutableMap.<String, Object>of("id", requestId, "message",
            uri.getPath());
    URI errorUri = uriInfo.getAbsolutePathBuilder().path(viewId).path("errors").build();
    UserPrincipal ogUserPrincipal = userName != null ? UserPrincipal.getLocalUser(userName)
            : UserPrincipal.getTestUser();
    _viewManager.createView(viewRequest, clientId, ogUserPrincipal, connection, viewId, callbackMap,
            portfolioGridUri.getPath(), primitivesGridUri.getPath(), errorUri.getPath());
    return Response.status(Response.Status.CREATED).build();
}

From source file:io.jmnarloch.spring.cloud.discovery.DiscoveryClientPropertySource.java

/**
 * Expands the service URI.//from w w w .  j  a  v a  2  s  . c om
 *
 * @param uri the input uri
 * @return the result uri
 */
private URI expandUri(String uri) {
    try {
        final URI inputUri = URI.create(uri);
        final ServiceInstance serviceInstance = findOneService(inputUri.getHost());
        if (serviceInstance == null) {
            return null;
        }
        return new URI((serviceInstance.isSecure() ? "https" : "http"), inputUri.getUserInfo(),
                serviceInstance.getHost(), serviceInstance.getPort(), inputUri.getPath(), inputUri.getQuery(),
                inputUri.getFragment());
    } catch (URISyntaxException e) {
        logger.error("Unexpected error occurred when expanding the property URI", e);
        throw new RuntimeException("Could not parse URI value: " + uri, e);
    }
}

From source file:eionet.gdem.utils.InputFile.java

/**
 * Extracts filename from URI's path [scheme:][//authority][path][?query][#fragment].
 *
 * @param uri URI of input file.// w w w  .  j a va  2s.  com
 */
private void parseUri(URI uri) {

    this.strHostName = uri.getScheme() + "://" + uri.getAuthority();
    findFileName(uri.getPath());
}

From source file:info.magnolia.ui.admincentral.shellapp.favorites.FavoritesPresenter.java

String getWebAppRootURI() {
    final URI currentUri = UI.getCurrent().getPage().getLocation();
    String instancePrefix = currentUri.getScheme() + "://" + currentUri.getHost();
    if (currentUri.getPort() > -1) {
        instancePrefix += ":" + currentUri.getPort();
    }/*  www  .  java2  s  .  com*/
    instancePrefix += currentUri.getPath(); // Path contains the ctx
    if (StringUtils.isNotBlank(currentUri.getQuery())) {
        instancePrefix += "?" + currentUri.getQuery();
    }
    return instancePrefix;
}

From source file:com.chigix.bio.proxy.buffer.FixedBufferTest.java

License:asdf

@Test
public void testURI() {
    try {/*from w w  w.  j  a  v  a2s  . c om*/
        URI uri = new URI(
                "http://www.baidu.com/awefawgwage/awefwfa/wefafwef/awdfa?safwefawf=awefaf&afwef=fafwef");
        System.out.println(uri.getScheme());
        System.out.println(uri.getHost());
        System.out.println(uri.getPort());
        System.out.println(uri.getQuery());
        System.out.println(uri.getPath());
    } catch (URISyntaxException ex) {
        Logger.getLogger(FixedBufferTest.class.getName()).log(Level.SEVERE, null, ex);
    }
    String illegalQuery = "http://sclick.baidu.com/w.gif?q=a&fm=se&T=1423492890&y=55DFFF7F&rsv_cache=0&rsv_pre=0&rsv_reh=109_130_149_109_85_195_85_85_85_85|540&rsv_scr=1899_1720_0_0_1080_1920&rsv_sid=10383_1469_12498_10902_11101_11399_11277_11241_11401_12550_11243_11403_12470&cid=0&qid=fd67eec000006821&t=1423492880700&rsv_iorr=1&rsv_tn=baidu&path=http%3A%2F%2Fwww.baidu.com%2Fs%3Fie%3Dutf-8%26f%3D8%26rsv_bp%3D1%26rsv_idx%3D1%26ch%3D%26tn%3Dbaidu%26bar%3D%26wd%3Da%26rn%3D%26rsv_pq%3Dda7dc5fb00004904%26rsv_t%3D55188AMIFp8JX4Jb3hJkfCZHYxQdZOBK%252FhV0kLFfAPijGGrceXBoFpnHzmI%26rsv_enter%3D1%26inputT%3D111";
    URI uri;
    while (true) {
        try {
            uri = new URI(illegalQuery);
        } catch (URISyntaxException ex) {
            System.out.println(illegalQuery);
            System.out.println(illegalQuery.charAt(ex.getIndex()));
            System.out.println(illegalQuery.substring(0, ex.getIndex()));
            System.out.println(illegalQuery.substring(ex.getIndex() + 1));
            try {
                illegalQuery = illegalQuery.substring(0, ex.getIndex())
                        + URLEncoder.encode(String.valueOf(illegalQuery.charAt(ex.getIndex())), "utf-8")
                        + illegalQuery.substring(ex.getIndex() + 1);
            } catch (UnsupportedEncodingException ex1) {
            }
            System.out.println(illegalQuery);
            continue;
        }
        break;
    }
    System.out.println("SCHEME: " + uri.getScheme());
    System.out.println("HOST: " + uri.getHost());
    System.out.println("path: " + uri.getRawPath());
    System.out.println("query: " + uri.getRawQuery());
    System.out.println("PORT: " + uri.getPort());
}

From source file:org.apache.hadoop.yarn.server.resourcemanager.webapp.RMWebAppFilter.java

private String appendOrReplaceParamter(String uri, String newQuery) {
    if (uri.contains(YarnWebParams.NEXT_REFRESH_INTERVAL + "=")) {
        return uri.replaceAll(YarnWebParams.NEXT_REFRESH_INTERVAL + "=[^&]+", newQuery);
    }//from  w  w w.  ja v  a  2  s . co  m
    try {
        URI oldUri = new URI(uri);
        String appendQuery = oldUri.getQuery();
        if (appendQuery == null) {
            appendQuery = newQuery;
        } else {
            appendQuery += "&" + newQuery;
        }

        URI newUri = new URI(oldUri.getScheme(), oldUri.getAuthority(), oldUri.getPath(), appendQuery,
                oldUri.getFragment());

        return newUri.toString();
    } catch (URISyntaxException e) {
        return null;
    }
}

From source file:n3phele.storage.swift.CloudStorageImpl.java

@Override
public UploadSignature getUploadSignature(Repository repo, String name) {
    Credential credential = repo.getCredential().decrypt();
    Access access = getAccess(repo.getTarget(), credential.getAccount(), credential.getSecret());

    String endpoint = SwiftClient.findEndpointURL(access.getServiceCatalog(), "object-store", getRegion(repo),
            "public");
    URI canonicalName = UriBuilder.fromUri(endpoint).path(repo.getRoot()).path(name).build();
    int last = canonicalName.getPath().lastIndexOf('/');
    String path = canonicalName.getPath().substring(0, last + 1);
    int discard = canonicalName.getPath().length() - path.length();
    String canonicalNameWithFile = canonicalName.toString();
    URI target = URI.create(canonicalNameWithFile.substring(0, canonicalNameWithFile.length() - discard));

    log.info("Target=<" + target + "> path=<" + path + ">");

    String expires = Long.toString((Calendar.getInstance().getTimeInMillis() / 1000) + 60 * 60);
    // hmac_body = '%s\n%s\n%s\n%s\n%s' % (path, redirect, max_file_size, max_file_count, expires) 
    String stringToSign = path.replace(" ", "%20") + "\n" + "\n" + "1073741824" + "\n" + "1" + "\n" + expires;
    String signature = access.getToken().getTenant().getId() + ":" + credential.getAccount().split(":")[1] + ":"
            + signSwiftQueryString(stringToSign, repo.getCredential());

    String acl = "swift";

    String contentType = Mimetypes.getInstance().getMimetype(name);

    UploadSignature uploadSignature = new UploadSignature(name, acl, target, repo.getRoot(), expires, signature,
            "none", contentType);
    return uploadSignature;

}

From source file:io.cloudslang.lang.cli.utils.CompilerHelperTest.java

@Test
public void testLoadSystemPropertiesInvalidExtension() throws Exception {
    URI systemPropertyURI = getClass().getResource("/flow.sl").toURI();

    expectedException.expect(RuntimeException.class);
    expectedException.expectMessage("flow.sl");
    expectedException.expectMessage("extension");
    expectedException.expectMessage("prop.sl");

    compilerHelper.loadSystemProperties(Collections.singletonList(systemPropertyURI.getPath()));
}

From source file:org.carrot2.workbench.vis.FlashViewPage.java

/**
 * Construct a HTTP GET. /*  www. j  a  v a2  s.c om*/
 */
private String createGetURI(String uriString, Map<String, Object> customParams) {
    try {
        List<NameValuePair> pairs = Lists.newArrayList();
        for (Map.Entry<String, Object> e : customParams.entrySet()) {
            pairs.add(new BasicNameValuePair(e.getKey(), e.getValue().toString()));
        }

        URI uri = new URI(uriString);
        uri = URIUtils.createURI(uri.getScheme(), uri.getHost(), uri.getPort(), uri.getPath(),
                URLEncodedUtils.format(pairs, "UTF-8"), null);

        return uri.toString();
    } catch (URISyntaxException e) {
        throw new RuntimeException(e);
    }
}

From source file:uk.ac.ebi.eva.pipeline.configuration.JobOptions.java

private void loadDbConnectionOptions() throws IOException {
    URI configUri = URI.create(Config.getOpenCGAHome() + "/").resolve("conf/")
            .resolve("storage-mongodb.properties");
    Properties properties = new Properties();
    properties.load(new InputStreamReader(new FileInputStream(configUri.getPath())));

    if (dbHosts == null) {
        dbHosts = properties.getProperty("OPENCGA.STORAGE.MONGODB.VARIANT.DB.HOSTS");
    }// ww  w.  j  a  v a2s  .c o  m
    if (dbAuthenticationDb == null) {
        dbAuthenticationDb = properties.getProperty("OPENCGA.STORAGE.MONGODB.VARIANT.DB.AUTHENTICATION.DB", "");
    }
    if (dbUser == null) {
        dbUser = properties.getProperty("OPENCGA.STORAGE.MONGODB.VARIANT.DB.USER", "");
    }
    if (dbPassword == null) {
        dbPassword = properties.getProperty("OPENCGA.STORAGE.MONGODB.VARIANT.DB.PASS", "");
    }
    if (dbName == null) {
        dbName = properties.getProperty("OPENCGA.STORAGE.MONGODB.VARIANT.DB.NAME");
    }
    if (dbCollectionVariantsName == null) {
        dbCollectionVariantsName = properties
                .getProperty("OPENCGA.STORAGE.MONGODB.VARIANT.DB.COLLECTION.VARIANTS", "variants");
    }
    if (dbCollectionFilesName == null) {
        dbCollectionFilesName = properties.getProperty("OPENCGA.STORAGE.MONGODB.VARIANT.DB.COLLECTION.FILES",
                "files");
    }

    if (dbHosts == null || dbHosts.isEmpty()) {
        throw new IllegalArgumentException("Please provide a database hostname");
    }
    if (dbName == null || dbName.isEmpty()) {
        throw new IllegalArgumentException("Please provide a database name");
    }
    if (dbCollectionVariantsName == null || dbCollectionVariantsName.isEmpty()) {
        throw new IllegalArgumentException(
                "Please provide a name for the collection to store the variant information into");
    }
    if (dbCollectionFilesName == null || dbCollectionFilesName.isEmpty()) {
        throw new IllegalArgumentException(
                "Please provide a name for the collection to store the file information into");
    }
}