Example usage for java.net URI getSchemeSpecificPart

List of usage examples for java.net URI getSchemeSpecificPart

Introduction

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

Prototype

public String getSchemeSpecificPart() 

Source Link

Document

Returns the decoded scheme-specific part of this URI.

Usage

From source file:com.bluexml.xforms.actions.AbstractAction.java

/**
 * Sets useful properties./* w  w w  . j  a  v  a  2 s . c om*/
 * 
 * @param controller
 *            the controller
 * @param uri
 *            the uri
 */
public void setProperties(AlfrescoController controller, String uri) {
    URI realUri;
    try {
        realUri = new URI(uri);
    } catch (URISyntaxException e) {
        throw new RuntimeException(e);
    }
    String[] fragments = realUri.getSchemeSpecificPart().split("/");
    getRequestParameters(fragments, realUri);
    this.controller = controller;
    this.uri = uri;
    this.transaction = new AlfrescoTransaction(controller, transactionLogin);

    this.transaction.setPage(navigationPath.peekCurrentPage());
    if (StringUtils.trimToNull(transactionLogin) == null) { // no CAS receipt was available
        Map<String, String> initParams = transaction.getPage().getInitParams();
        transaction.setLogin(controller.getParamUserName(initParams));
    }
}

From source file:com.esri.geoportal.commons.agp.client.AgpClient.java

private URI generateTokenUri() throws URISyntaxException {
    URI uri = rootUrl.toURI().resolve("sharing/rest/generateToken");
    return new URI("https", uri.getSchemeSpecificPart(), uri.getFragment());
}

From source file:org.pepstock.jem.node.StartUpSystem.java

/**
 * /*from w  w  w .jav a  2  s . com*/
 * @param conf
 * @throws Exception
 */
private static void loadDatabaseManagers() throws ConfigurationException {
    Database database = JEM_ENV_CONFIG.getDatabase();
    if (database == null) {
        LogAppl.getInstance().emit(NodeMessage.JEMC009E, ConfigKeys.DATABASE_ELEMENT);
        throw new ConfigurationException(
                NodeMessage.JEMC009E.toMessage().getFormattedMessage(ConfigKeys.DATABASE_ELEMENT));
    }
    // try to substitute vars in URL
    String url = substituteVariable(database.getUrl());
    database.setUrl(url);
    LogAppl.getInstance().emit(NodeMessage.JEMC193I, url);

    // try to substitute vars in user
    String user = substituteVariable(database.getUser());
    database.setUser(user);

    String dbType = null;
    try {
        URI url1 = new URI(database.getUrl());
        URI myURL = new URI(url1.getSchemeSpecificPart());
        dbType = myURL.getScheme();
    } catch (URISyntaxException e2) {
        LogAppl.getInstance().emit(NodeMessage.JEMC166E, e2, database.getUrl());
        throw new ConfigurationException(
                NodeMessage.JEMC166E.toMessage().getFormattedMessage(database.getUrl()));
    }

    SQLContainerFactory engine = null;
    if (dbType.equals(MySqlSQLContainerFactory.DATABASE_TYPE)) {
        engine = new MySqlSQLContainerFactory();
    } else if (dbType.equals(OracleSQLContainerFactory.DATABASE_TYPE)) {
        engine = new OracleSQLContainerFactory();
    } else if (dbType.equals(DB2SQLContainerFactory.DATABASE_TYPE)) {
        engine = new DB2SQLContainerFactory();
    } else {
        engine = new DefaultSQLContainerFactory();
    }

    // load JobManager for input, output, routing

    try {
        DBPoolManager.getInstance().setDriver(database.getDriver());
        DBPoolManager.getInstance().setUrl(database.getUrl());
        DBPoolManager.getInstance().setUser(database.getUser());
        DBPoolManager.getInstance().setPassword(database.getPassword());
        DBPoolManager.getInstance().setProperties(database.getProperties());
        DBPoolManager.getInstance().setKeepAliveConnectionSQL(engine.getKeepAliveConnectionSQL());

        DBPoolManager.getInstance().init();

        InputDBManager.getInstance().setSqlContainer(engine.getSQLContainerForInputQueue());
        RunningDBManager.getInstance().setSqlContainer(engine.getSQLContainerForRunningQueue());
        OutputDBManager.getInstance().setSqlContainer(engine.getSQLContainerForOutputQueue());
        RoutingDBManager.getInstance().setSqlContainer(engine.getSQLContainerForRoutingQueue());

        PreJobDBManager.getInstance().setSqlContainer(engine.getSQLContainerForCheckingQueue());

        RolesDBManager.getInstance().setSqlContainer(engine.getSQLContainerForRolesMap());

        CommonResourcesDBManager.getInstance().setSqlContainer(engine.getSQLContainerForCommonResourcesMap());

        RoutingConfigDBManager.getInstance().setSqlContainer(engine.getSQLContainerForRoutingConfigMap());

        UserPreferencesDBManager.getInstance().setSqlContainer(engine.getSQLContainerForUserPreferencesMap());

        NodesDBManager.getInstance().setSqlContainer(engine.getSQLContainerForNodesMap());

        // creates all necessary tables
        createTables();

    } catch (SQLException e) {
        throw new ConfigurationException(
                NodeMessage.JEMC165E.toMessage().getFormattedMessage(JobDBManager.class.getName()), e);
    }
}

From source file:org.codice.ddf.catalog.content.impl.FileSystemStorageProvider.java

private Path getContentItemDir(URI contentUri) {
    List<String> pathParts = getContentFilePathParts(contentUri.getSchemeSpecificPart(),
            contentUri.getFragment());//from w ww .  j  av  a  2s . com

    return Paths.get(baseContentDirectory.toAbsolutePath().toString(),
            pathParts.toArray(new String[pathParts.size()]));
}

From source file:org.apache.camel.component.http.HttpComponent.java

@Override
protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters)
        throws Exception {
    String addressUri = "http://" + remaining;
    if (uri.startsWith("https:")) {
        addressUri = "https://" + remaining;
    }//from   ww w .  j a va2  s. co  m
    Map<String, Object> httpClientParameters = new HashMap<String, Object>(parameters);
    // must extract well known parameters before we create the endpoint
    // TODO cmueller: remove the "httpBindingRef" look up in Camel 3.0
    HttpBinding binding = resolveAndRemoveReferenceParameter(parameters, "httpBindingRef", HttpBinding.class);
    if (binding == null) {
        // try without ref
        binding = resolveAndRemoveReferenceParameter(parameters, "httpBinding", HttpBinding.class);
    }
    String proxyHost = getAndRemoveParameter(parameters, "proxyHost", String.class);
    Integer proxyPort = getAndRemoveParameter(parameters, "proxyPort", Integer.class);
    String authMethodPriority = getAndRemoveParameter(parameters, "authMethodPriority", String.class);
    HeaderFilterStrategy headerFilterStrategy = resolveAndRemoveReferenceParameter(parameters,
            "headerFilterStrategy", HeaderFilterStrategy.class);
    UrlRewrite urlRewrite = resolveAndRemoveReferenceParameter(parameters, "urlRewrite", UrlRewrite.class);
    // http client can be configured from URI options
    HttpClientParams clientParams = new HttpClientParams();
    IntrospectionSupport.setProperties(clientParams, parameters, "httpClient.");
    // validate that we could resolve all httpClient. parameters as this component is lenient
    validateParameters(uri, parameters, "httpClient.");
    // http client can be configured from URI options
    HttpConnectionManagerParams connectionManagerParams = new HttpConnectionManagerParams();
    // setup the httpConnectionManagerParams
    IntrospectionSupport.setProperties(connectionManagerParams, parameters, "httpConnectionManager.");
    validateParameters(uri, parameters, "httpConnectionManager.");
    // make sure the component httpConnectionManager is take effect
    HttpConnectionManager thisHttpConnectionManager = httpConnectionManager;
    if (thisHttpConnectionManager == null) {
        // only set the params on the new created http connection manager
        thisHttpConnectionManager = new MultiThreadedHttpConnectionManager();
        thisHttpConnectionManager.setParams(connectionManagerParams);
    }
    // create the configurer to use for this endpoint (authMethods contains the used methods created by the configurer)
    final Set<AuthMethod> authMethods = new LinkedHashSet<AuthMethod>();
    HttpClientConfigurer configurer = createHttpClientConfigurer(parameters, authMethods);
    addressUri = UnsafeUriCharactersEncoder.encodeHttpURI(addressUri);
    URI endpointUri = URISupport.createRemainingURI(new URI(addressUri), httpClientParameters);

    // create the endpoint and connectionManagerParams already be set
    HttpEndpoint endpoint = new HttpEndpoint(endpointUri.toString(), this, clientParams,
            thisHttpConnectionManager, configurer);

    if (headerFilterStrategy != null) {
        endpoint.setHeaderFilterStrategy(headerFilterStrategy);
    } else {
        setEndpointHeaderFilterStrategy(endpoint);
    }
    if (urlRewrite != null) {
        // let CamelContext deal with the lifecycle of the url rewrite
        // this ensures its being shutdown when Camel shutdown etc.
        getCamelContext().addService(urlRewrite);
        endpoint.setUrlRewrite(urlRewrite);
    }

    // prefer to use endpoint configured over component configured
    if (binding == null) {
        // fallback to component configured
        binding = getHttpBinding();
    }
    if (binding != null) {
        endpoint.setBinding(binding);
    }
    if (proxyHost != null) {
        endpoint.setProxyHost(proxyHost);
        endpoint.setProxyPort(proxyPort);
    } else if (httpConfiguration != null) {
        endpoint.setProxyHost(httpConfiguration.getProxyHost());
        endpoint.setProxyPort(httpConfiguration.getProxyPort());
    }
    if (authMethodPriority != null) {
        endpoint.setAuthMethodPriority(authMethodPriority);
    } else if (httpConfiguration != null && httpConfiguration.getAuthMethodPriority() != null) {
        endpoint.setAuthMethodPriority(httpConfiguration.getAuthMethodPriority());
    } else {
        // no explicit auth method priority configured, so use convention over configuration
        // and set priority based on auth method
        if (!authMethods.isEmpty()) {
            authMethodPriority = CollectionHelper.collectionAsCommaDelimitedString(authMethods);
            endpoint.setAuthMethodPriority(authMethodPriority);
        }
    }
    setProperties(endpoint, parameters);
    // restructure uri to be based on the parameters left as we dont want to include the Camel internal options
    URI httpUri = URISupport.createRemainingURI(new URI(addressUri), parameters);

    // validate http uri that end-user did not duplicate the http part that can be a common error
    String part = httpUri.getSchemeSpecificPart();
    if (part != null) {
        part = part.toLowerCase();
        if (part.startsWith("//http//") || part.startsWith("//https//") || part.startsWith("//http://")
                || part.startsWith("//https://")) {
            throw new ResolveEndpointFailedException(uri,
                    "The uri part is not configured correctly. You have duplicated the http(s) protocol.");
        }
    }
    endpoint.setHttpUri(httpUri);
    return endpoint;
}

From source file:org.apache.camel.component.http4.HttpComponent.java

@Override
protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters)
        throws Exception {
    String addressUri = uri;/*from   w  w w  .  j a v a2 s .com*/
    if (!uri.startsWith("http4:") && !uri.startsWith("https4:")) {
        addressUri = remaining;
    }
    Map<String, Object> httpClientParameters = new HashMap<String, Object>(parameters);
    // http client can be configured from URI options
    HttpParams clientParams = configureHttpParams(parameters);

    // must extract well known parameters before we create the endpoint
    HttpBinding binding = resolveAndRemoveReferenceParameter(parameters, "httpBindingRef", HttpBinding.class);
    if (binding == null) {
        // try without ref
        binding = resolveAndRemoveReferenceParameter(parameters, "httpBinding", HttpBinding.class);
    }
    Boolean throwExceptionOnFailure = getAndRemoveParameter(parameters, "throwExceptionOnFailure",
            Boolean.class);
    Boolean transferException = getAndRemoveParameter(parameters, "transferException", Boolean.class);
    Boolean bridgeEndpoint = getAndRemoveParameter(parameters, "bridgeEndpoint", Boolean.class);
    Boolean matchOnUriPrefix = getAndRemoveParameter(parameters, "matchOnUriPrefix", Boolean.class);
    Boolean disableStreamCache = getAndRemoveParameter(parameters, "disableStreamCache", Boolean.class);

    // validate that we could resolve all httpClient. parameters as this component is lenient
    validateParameters(uri, parameters, "httpClient.");
    // create the configurer to use for this endpoint
    HttpClientConfigurer configurer = createHttpClientConfigurer(parameters);
    URI endpointUri = URISupport.createRemainingURI(new URI(addressUri), CastUtils.cast(httpClientParameters));
    // restructure uri to be based on the parameters left as we dont want to include the Camel internal options
    URI httpUri = URISupport.createRemainingURI(new URI(addressUri), CastUtils.cast(parameters));

    // validate http uri that end-user did not duplicate the http part that can be a common error
    String part = httpUri.getSchemeSpecificPart();
    if (part != null) {
        part = part.toLowerCase();
        if (part.startsWith("//http//") || part.startsWith("//https//")) {
            throw new ResolveEndpointFailedException(uri,
                    "The uri part is not configured correctly. You have duplicated the http(s) protocol.");
        }
    }

    // register port on schema registry
    boolean secure = isSecureConnection(uri);
    int port = getPort(httpUri);
    registerPort(secure, port);

    // create the endpoint
    HttpEndpoint endpoint = new HttpEndpoint(endpointUri.toString(), this, httpUri, clientParams,
            clientConnectionManager, configurer);
    setEndpointHeaderFilterStrategy(endpoint);

    // prefer to use endpoint configured over component configured
    if (binding == null) {
        // fallback to component configured
        binding = getHttpBinding();
    }
    if (binding != null) {
        endpoint.setBinding(binding);
    }
    // should we use an exception for failed error codes?
    if (throwExceptionOnFailure != null) {
        endpoint.setThrowExceptionOnFailure(throwExceptionOnFailure);
    }
    // should we transfer exception as serialized object
    if (transferException != null) {
        endpoint.setTransferException(transferException);
    }
    if (bridgeEndpoint != null) {
        endpoint.setBridgeEndpoint(bridgeEndpoint);
    }
    if (matchOnUriPrefix != null) {
        endpoint.setMatchOnUriPrefix(matchOnUriPrefix);
    }
    if (disableStreamCache != null) {
        endpoint.setDisableStreamCache(disableStreamCache);
    }

    setProperties(endpoint, parameters);
    return endpoint;
}

From source file:gov.nih.nci.caarray.dataStorage.database.DatabaseMultipartBlobDataStorage.java

/**
 * {@inheritDoc}//  w w w.  java  2 s.c  o  m
 */
public StorageMetadata addChunk(URI handle, InputStream stream) throws DataStoreException {
    try {
        MultiPartBlob multiPartBlob;
        if (handle == null) {
            multiPartBlob = new MultiPartBlob();
            multiPartBlob.setCreationTimestamp(new Date());
        } else {
            multiPartBlob = searchDao.retrieve(MultiPartBlob.class,
                    Long.valueOf(handle.getSchemeSpecificPart()));
        }
        multiPartBlob.writeData(stream, false, blobPartSize);
        blobDao.save(multiPartBlob);

        final StorageMetadata metadata = new StorageMetadata();
        metadata.setHandle(makeHandle(multiPartBlob.getId()));
        metadata.setPartialSize(multiPartBlob.getUncompressedSize());
        return metadata;
    } catch (final IOException e) {
        throw new DataStoreException("Could not add data", e);
    }
}

From source file:org.apache.cxf.maven_plugin.wadlto.AbstractCodeGeneratorMojo.java

private void addPluginArtifact(Set<URI> artifactsPath) {
    //for Maven 2.x, the actual artifact isn't in the list....  need to try and find it
    URL url = getClass().getResource(getClass().getSimpleName() + ".class");

    try {//from  w w  w .  ja va 2  s  . co  m
        if ("jar".equals(url.getProtocol())) {
            String s = url.getPath();
            if (s.contains("!")) {
                s = s.substring(0, s.indexOf('!'));
                url = new URL(s);
            }
        }
        URI uri = new URI(url.getProtocol(), null, url.getPath(), null, null);
        if (uri.getSchemeSpecificPart().endsWith(".class")) {
            String s = uri.toString();
            s = s.substring(0, s.length() - 6 - getClass().getName().length());
            uri = new URI(s);
        }
        File file = new File(uri);
        if (file.exists()) {
            artifactsPath.add(file.toURI());
        }
    } catch (Exception ex) {
        //ex.printStackTrace();
    }

}

From source file:org.codice.ddf.catalog.content.impl.FileSystemStorageProvider.java

private Path getTempContentItemDir(String requestId, URI contentUri) {
    List<String> pathParts = new ArrayList<>();
    pathParts.add(requestId);/*w ww  .ja v  a2 s .  c o  m*/
    pathParts.addAll(getContentFilePathParts(contentUri.getSchemeSpecificPart(), contentUri.getFragment()));

    return Paths.get(baseContentTmpDirectory.toAbsolutePath().toString(),
            pathParts.toArray(new String[pathParts.size()]));
}

From source file:com.tesora.dve.common.PEUrl.java

private PEUrl parseURL(String urlString) throws PEException {

    try {//from  w w  w.j av a 2 s  . c  o  m
        URI parser = new URI(urlString.trim());
        final String protocol = parser.getScheme();

        parser = URI.create(parser.getSchemeSpecificPart());
        final String subProtocol = parser.getScheme();
        final String authority = parser.getAuthority();

        if ((protocol == null) || (subProtocol == null)) {
            throw new PEException("Malformed URL '" + urlString + "' - incomplete protocol");
        } else if (authority == null) {
            throw new PEException("Malformed URL '" + urlString + "' - invalid authority");
        }

        this.setProtocol(protocol);
        this.setSubProtocol(subProtocol);

        final String host = parser.getHost();
        if (host != null) {
            this.setHost(host);
        }

        final int port = parser.getPort();
        if (port != -1) {
            this.setPort(port);
        }

        final String query = parser.getQuery();
        if (query != null) {
            this.setQuery(query);
        }

        final String path = parser.getPath();
        if ((path != null) && !path.isEmpty()) {
            this.setPath(path.startsWith("/") ? path.substring(1) : path);
        }

        return this;
    } catch (final URISyntaxException | IllegalArgumentException e) {
        throw new PEException("Malformed URL '" + urlString + "'", e);
    }
}