Example usage for org.apache.commons.vfs2.provider GenericFileName getURI

List of usage examples for org.apache.commons.vfs2.provider GenericFileName getURI

Introduction

In this page you can find the example usage for org.apache.commons.vfs2.provider GenericFileName getURI.

Prototype

public String getURI() 

Source Link

Document

Returns the absolute URI of the file.

Usage

From source file:org.pentaho.reporting.libraries.pensol.PentahoSolutionFileProvider.java

private FileSystem createJCRFileSystem(final LayeredFileName genericRootName,
        final FileSystemOptions fileSystemOptions) {
    UserAuthenticationData authData = null;
    try {// w  w w  .j  ava 2s .  c om
        authData = UserAuthenticatorUtils.authenticate(fileSystemOptions, AUTHENTICATOR_TYPES);
        final GenericFileName outerName = (GenericFileName) genericRootName.getOuterName();

        final String username = UserAuthenticatorUtils.toString(UserAuthenticatorUtils.getData(authData,
                UserAuthenticationData.USERNAME, UserAuthenticatorUtils.toChar(outerName.getUserName())));

        final String password = UserAuthenticatorUtils.toString(UserAuthenticatorUtils.getData(authData,
                UserAuthenticationData.PASSWORD, UserAuthenticatorUtils.toChar(outerName.getPassword())));
        final PentahoSolutionsFileSystemConfigBuilder configBuilder = new PentahoSolutionsFileSystemConfigBuilder();
        final int timeOut = configBuilder.getTimeOut(fileSystemOptions);

        final JCRSolutionFileModel model = new JCRSolutionFileModel(outerName.getURI(), username, password,
                timeOut);
        return new JCRSolutionFileSystem(genericRootName, fileSystemOptions, model);
    } finally {
        UserAuthenticatorUtils.cleanup(authData);
    }
}

From source file:org.pentaho.reporting.libraries.pensol.PentahoSolutionFileProvider.java

private FileSystem createWebFileSystem(final LayeredFileName genericRootName,
        final FileSystemOptions fileSystemOptions) throws FileSystemException {
    final GenericFileName outerName = (GenericFileName) genericRootName.getOuterName();
    String scheme = outerName.getScheme();
    String hostName = outerName.getHostName();
    int port = outerName.getPort();
    String userName = outerName.getUserName();
    String password = outerName.getPassword();

    HttpClientManager.HttpClientBuilderFacade clientBuilder = HttpClientManager.getInstance().createBuilder();
    if (!StringUtil.isEmpty(hostName)) {
        clientBuilder.setProxy(hostName, port, scheme);
    }//from   w w  w. j a v  a 2s  .  c  om
    if (!StringUtil.isEmpty(userName)) {
        clientBuilder.setCredentials(userName, password);
    }
    final PentahoSolutionsFileSystemConfigBuilder configBuilder = new PentahoSolutionsFileSystemConfigBuilder();
    final int timeOut = configBuilder.getTimeOut(fileSystemOptions);
    clientBuilder.setSocketTimeout(Math.max(0, timeOut));

    return new WebSolutionFileSystem(genericRootName, fileSystemOptions,
            new LocalFileModel(outerName.getURI(), clientBuilder, userName, password, hostName, port));
}