org.apache.commons.vfs2.FileName Java Examples

The following examples show how to use org.apache.commons.vfs2.FileName. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: WebdavFileProvider.java    From commons-vfs with Apache License 2.0 6 votes vote down vote up
/**
 * Creates a {@link FileSystem}.
 * <p>
 * If you're looking at this method and wondering how to get a FileSystemOptions object bearing the proxy host and
 * credentials configuration through to this method so it's used for resolving a
 * {@link org.apache.commons.vfs2.FileObject FileObject} in the FileSystem, then be sure to use correct signature of
 * the {@link org.apache.commons.vfs2.FileSystemManager FileSystemManager} resolveFile method.
 * </p>
 *
 * @see org.apache.commons.vfs2.impl.DefaultFileSystemManager#resolveFile(FileObject, String, FileSystemOptions)
 */
@Override
protected FileSystem doCreateFileSystem(final FileName name, final FileSystemOptions fileSystemOptions)
        throws FileSystemException {
    // Create the file system
    final GenericFileName rootName = (GenericFileName) name;
    final FileSystemOptions fsOpts = fileSystemOptions == null ? new FileSystemOptions() : fileSystemOptions;

    UserAuthenticationData authData = null;
    HttpClient httpClient;
    try {
        authData = UserAuthenticatorUtils.authenticate(fsOpts, AUTHENTICATOR_TYPES);

        httpClient = HttpClientFactory.createConnection(WebdavFileSystemConfigBuilder.getInstance(), "http",
                rootName.getHostName(), rootName.getPort(),
                UserAuthenticatorUtils.toString(UserAuthenticatorUtils.getData(authData,
                        UserAuthenticationData.USERNAME, UserAuthenticatorUtils.toChar(rootName.getUserName()))),
                UserAuthenticatorUtils.toString(UserAuthenticatorUtils.getData(authData,
                        UserAuthenticationData.PASSWORD, UserAuthenticatorUtils.toChar(rootName.getPassword()))),
                fsOpts);
    } finally {
        UserAuthenticatorUtils.cleanup(authData);
    }

    return new WebdavFileSystem(rootName, httpClient, fsOpts);
}
 
Example #2
Source File: AbstractLayeredFileProvider.java    From commons-vfs with Apache License 2.0 6 votes vote down vote up
/**
 * Locates a file object, by absolute URI.
 *
 * @param baseFile The base FileObject.
 * @param uri The name of the file to locate.
 * @param fileSystemOptions The FileSystemOptions.
 * @return The FileObject if it is located, null otherwise.
 * @throws FileSystemException if an error occurs.
 */
@Override
public FileObject findFile(final FileObject baseFile, final String uri, final FileSystemOptions fileSystemOptions)
        throws FileSystemException {
    // Split the URI up into its parts
    final LayeredFileName name = (LayeredFileName) parseUri(baseFile != null ? baseFile.getName() : null, uri);

    // Make the URI canonical

    // Resolve the outer file name
    final FileName fileName = name.getOuterName();
    final FileObject file = getContext().resolveFile(baseFile, fileName.getURI(), fileSystemOptions);

    // Create the file system
    final FileObject rootFile = createFileSystem(name.getScheme(), file, fileSystemOptions);

    // Resolve the file
    return rootFile.resolveFile(name.getPath());
}
 
Example #3
Source File: Webdav4FileProvider.java    From commons-vfs with Apache License 2.0 6 votes vote down vote up
/**
 * Creates a {@link FileSystem}.
 * <p>
 * If you're looking at this method and wondering how to get a FileSystemOptions object bearing the proxy host and
 * credentials configuration through to this method so it's used for resolving a
 * {@link org.apache.commons.vfs2.FileObject FileObject} in the FileSystem, then be sure to use correct signature of
 * the {@link org.apache.commons.vfs2.FileSystemManager FileSystemManager} resolveFile method.
 *
 * @see org.apache.commons.vfs2.impl.DefaultFileSystemManager#resolveFile(FileObject, String, FileSystemOptions)
 */
@Override
protected FileSystem doCreateFileSystem(final FileName name, final FileSystemOptions fileSystemOptions)
        throws FileSystemException {
    // Create the file system
    final GenericFileName rootName = (GenericFileName) name;
    // TODO: need to check null to create a non-null here???
    final FileSystemOptions fsOpts = fileSystemOptions == null ? new FileSystemOptions() : fileSystemOptions;

    UserAuthenticationData authData = null;
    HttpClient httpClient = null;
    HttpClientContext httpClientContext = null;

    try {
        final Webdav4FileSystemConfigBuilder builder = Webdav4FileSystemConfigBuilder.getInstance();
        authData = UserAuthenticatorUtils.authenticate(fsOpts, AUTHENTICATOR_TYPES);
        httpClientContext = createHttpClientContext(builder, rootName, fsOpts, authData);
        httpClient = createHttpClient(builder, rootName, fsOpts);
    } finally {
        UserAuthenticatorUtils.cleanup(authData);
    }

    return new Webdav4FileSystem(rootName, fsOpts, httpClient, httpClientContext);
}
 
Example #4
Source File: JobEntryUnZipTest.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
@Test
public void unzipPostProcessingTest() throws Exception {

  JobEntryUnZip jobEntryUnZip = new JobEntryUnZip();

  Method unzipPostprocessingMethod = jobEntryUnZip.getClass().getDeclaredMethod( "doUnzipPostProcessing", FileObject.class, FileObject.class, String.class );
  unzipPostprocessingMethod.setAccessible( true );
  FileObject sourceFileObject = Mockito.mock( FileObject.class );
  Mockito.doReturn( Mockito.mock( FileName.class ) ).when( sourceFileObject ).getName();

  //delete
  jobEntryUnZip.afterunzip = 1;
  unzipPostprocessingMethod.invoke( jobEntryUnZip, sourceFileObject, Mockito.mock( FileObject.class ), "" );
  Mockito.verify( sourceFileObject, Mockito.times( 1 ) ).delete();

  //move
  jobEntryUnZip.afterunzip = 2;
  unzipPostprocessingMethod.invoke( jobEntryUnZip, sourceFileObject, Mockito.mock( FileObject.class ), "" );
  Mockito.verify( sourceFileObject, Mockito.times( 1 ) ).moveTo( Mockito.anyObject() );
}
 
Example #5
Source File: S3FileNameParser.java    From hop with Apache License 2.0 6 votes vote down vote up
public FileName parseUri( VfsComponentContext context, FileName base, String uri ) throws FileSystemException {
  StringBuilder name = new StringBuilder();

  String scheme = UriParser.extractScheme( uri, name );
  UriParser.canonicalizePath( name, 0, name.length(), this );

  // Normalize separators in the path
  UriParser.fixSeparators( name );

  // Normalise the path
  FileType fileType = UriParser.normalisePath( name );

  String fullPath = name.toString();
  // Extract bucket name
  final String bucketName = UriParser.extractFirstElement( name );

  return new S3FileName( scheme, bucketName, fullPath, fileType );
}
 
Example #6
Source File: AbstractFileObject.java    From commons-vfs with Apache License 2.0 6 votes vote down vote up
/**
 * Returns the parent of the file.
 *
 * @return the parent FileObject.
 * @throws FileSystemException if an error occurs.
 */
@Override
public FileObject getParent() throws FileSystemException {
    if (this.compareTo(fileSystem.getRoot()) == 0) // equals is not implemented :-/
    {
        if (fileSystem.getParentLayer() == null) {
            // Root file has no parent
            return null;
        }
        // Return the parent of the parent layer
        return fileSystem.getParentLayer().getParent();
    }

    synchronized (fileSystem) {
        // Locate the parent of this file
        if (parent == null) {
            final FileName name = fileName.getParent();
            if (name == null) {
                return null;
            }
            parent = fileSystem.resolveFile(name);
        }
        return parent;
    }
}
 
Example #7
Source File: S3AFileNameParser.java    From hop with Apache License 2.0 6 votes vote down vote up
public FileName parseUri( VfsComponentContext context, FileName base, String uri ) throws FileSystemException {
  StringBuilder name = new StringBuilder();

  String scheme = UriParser.extractScheme( uri, name );
  UriParser.canonicalizePath( name, 0, name.length(), this );

  // Normalize separators in the path
  UriParser.fixSeparators( name );

  // Normalise the path
  FileType fileType = UriParser.normalisePath( name );

  // Extract bucket name
  final String bucketName = UriParser.extractFirstElement( name );

  return new S3AFileName( scheme, bucketName, name.toString(), fileType );
}
 
Example #8
Source File: NamingTests.java    From commons-vfs with Apache License 2.0 6 votes vote down vote up
/**
 * Tests resolution of absolute names.
 */
private void checkAbsoluteNames(final FileName name) throws Exception {
    // Root
    assertSameName("/", name, "/");
    assertSameName("/", name, "//");
    assertSameName("/", name, "/.");
    assertSameName("/", name, "/some file/..");

    // Some absolute names
    assertSameName("/a", name, "/a");
    assertSameName("/a", name, "/./a");
    assertSameName("/a", name, "/a/.");
    assertSameName("/a/b", name, "/a/b");

    // Some bad names
    assertBadName(name, "/..", NameScope.FILE_SYSTEM);
    assertBadName(name, "/a/../..", NameScope.FILE_SYSTEM);
}
 
Example #9
Source File: WorkflowActionUnZipTest.java    From hop with Apache License 2.0 6 votes vote down vote up
@Test
public void unzipPostProcessingTest() throws Exception {

  ActionUnZip jobEntryUnZip = new ActionUnZip();

  Method unzipPostprocessingMethod = jobEntryUnZip.getClass().getDeclaredMethod( "doUnzipPostProcessing", FileObject.class, FileObject.class, String.class );
  unzipPostprocessingMethod.setAccessible( true );
  FileObject sourceFileObject = Mockito.mock( FileObject.class );
  Mockito.doReturn( Mockito.mock( FileName.class ) ).when( sourceFileObject ).getName();

  //delete
  jobEntryUnZip.afterunzip = 1;
  unzipPostprocessingMethod.invoke( jobEntryUnZip, sourceFileObject, Mockito.mock( FileObject.class ), "" );
  Mockito.verify( sourceFileObject, Mockito.times( 1 ) ).delete();

  //move
  jobEntryUnZip.afterunzip = 2;
  unzipPostprocessingMethod.invoke( jobEntryUnZip, sourceFileObject, Mockito.mock( FileObject.class ), "" );
  Mockito.verify( sourceFileObject, Mockito.times( 1 ) ).moveTo( Mockito.anyObject() );
}
 
Example #10
Source File: LayeredFileNameParser.java    From commons-vfs with Apache License 2.0 6 votes vote down vote up
/**
 * Parses the base and name into a FileName.
 *
 * @param context The component context.
 * @param baseFileName The base FileName.
 * @param fileName name The target file name.
 * @return The constructed FileName.
 * @throws FileSystemException if an error occurs.
 */
@Override
public FileName parseUri(final VfsComponentContext context, final FileName baseFileName, final String fileName)
        throws FileSystemException {
    final StringBuilder name = new StringBuilder();

    // Extract the scheme
    final String scheme = UriParser.extractScheme(context.getFileSystemManager().getSchemes(), fileName, name);

    // Extract the Layered file URI
    final String rootUriName = extractRootName(name);
    FileName rootUri = null;
    if (rootUriName != null) {
        rootUri = context.parseURI(rootUriName);
    }

    // Decode and normalise the path
    UriParser.canonicalizePath(name, 0, name.length(), this);
    UriParser.fixSeparators(name);
    final FileType fileType = UriParser.normalisePath(name);
    final String path = name.toString();

    return new LayeredFileName(scheme, rootUri, path, fileType);
}
 
Example #11
Source File: Http5FileSystem.java    From commons-vfs with Apache License 2.0 6 votes vote down vote up
/**
 * Construct {@code Http4FileSystem}.
 *
 * @param rootName root base name
 * @param fileSystemOptions file system options
 * @param httpClient {@link HttpClient} instance
 * @param httpClientContext {@link HttpClientContext} instance
 */
protected Http5FileSystem(final FileName rootName, final FileSystemOptions fileSystemOptions, final HttpClient httpClient,
        final HttpClientContext httpClientContext) {
    super(rootName, null, fileSystemOptions);

    final String rootURI = getRootURI();
    final int offset = rootURI.indexOf(':');
    final char lastCharOfScheme = (offset > 0) ? rootURI.charAt(offset - 1) : 0;

    // if scheme is 'http*s' or 'HTTP*S', then the internal base URI should be 'https'. 'http' otherwise.
    if (lastCharOfScheme == 's' || lastCharOfScheme == 'S') {
        this.internalBaseURI = URI.create("https" + rootURI.substring(offset));
    } else {
        this.internalBaseURI = URI.create("http" + rootURI.substring(offset));
    }

    this.httpClient = httpClient;
    this.httpClientContext = httpClientContext;
}
 
Example #12
Source File: VFSFileSystem.java    From commons-configuration with Apache License 2.0 6 votes vote down vote up
@Override
public String getBasePath(final String path)
{
    if (UriParser.extractScheme(path) == null)
    {
        return super.getBasePath(path);
    }
    try
    {
        final FileSystemManager fsManager = VFS.getManager();
        final FileName name = fsManager.resolveURI(path);
        return name.getParent().getURI();
    }
    catch (final FileSystemException fse)
    {
        fse.printStackTrace();
        return null;
    }
}
 
Example #13
Source File: LRUFilesCache.java    From commons-vfs with Apache License 2.0 6 votes vote down vote up
@Override
public boolean putFileIfAbsent(final FileObject file) {
    final Map<FileName, FileObject> files = getOrCreateFilesystemCache(file.getFileSystem());

    writeLock.lock();
    try {
        final FileName name = file.getName();

        if (files.containsKey(name)) {
            return false;
        }

        files.put(name, file);
        return true;
    } finally {
        writeLock.unlock();
    }
}
 
Example #14
Source File: Http4FileSystem.java    From commons-vfs with Apache License 2.0 6 votes vote down vote up
/**
 * Construct {@code Http4FileSystem}.
 *
 * @param rootName root base name
 * @param fileSystemOptions file system options
 * @param httpClient {@link HttpClient} instance
 * @param httpClientContext {@link HttpClientContext} instance
 */
protected Http4FileSystem(final FileName rootName, final FileSystemOptions fileSystemOptions, final HttpClient httpClient,
        final HttpClientContext httpClientContext) {
    super(rootName, null, fileSystemOptions);

    final String rootURI = getRootURI();
    final int offset = rootURI.indexOf(':');
    final char lastCharOfScheme = (offset > 0) ? rootURI.charAt(offset - 1) : 0;

    // if scheme is 'http*s' or 'HTTP*S', then the internal base URI should be 'https'. 'http' otherwise.
    if (lastCharOfScheme == 's' || lastCharOfScheme == 'S') {
        this.internalBaseURI = URI.create("https" + rootURI.substring(offset));
    } else {
        this.internalBaseURI = URI.create("http" + rootURI.substring(offset));
    }

    this.httpClient = httpClient;
    this.httpClientContext = httpClientContext;
}
 
Example #15
Source File: NamingTests.java    From commons-vfs with Apache License 2.0 6 votes vote down vote up
/**
 * Checks that a relative name resolves to the expected absolute path. Tests both forward and back slashes.
 */
private void assertSameName(final String expectedPath, final FileName baseName, final String relName,
        final NameScope scope) throws Exception {
    // Try the supplied name
    FileName name = getManager().resolveName(baseName, relName, scope);
    assertEquals(expectedPath, name.getPath());

    String temp;

    // Replace the separators
    temp = relName.replace('\\', '/');
    name = getManager().resolveName(baseName, temp, scope);
    assertEquals(expectedPath, name.getPath());

    // And again
    temp = relName.replace('/', '\\');
    name = getManager().resolveName(baseName, temp, scope);
    assertEquals(expectedPath, name.getPath());
}
 
Example #16
Source File: S3NFileNameParserTest.java    From hop with Apache License 2.0 6 votes vote down vote up
@Test
public void testParseUri() throws Exception {
  VfsComponentContext context = mock( VfsComponentContext.class );
  FileName fileName = mock( FileName.class );
  String uri = "s3n://bucket/file";
  FileName noBaseFile = parser.parseUri( context, null, uri );
  assertNotNull( noBaseFile );
  assertEquals( "bucket", ( (S3NFileName) noBaseFile ).getBucketId() );
  FileName withBaseFile = parser.parseUri( context, fileName, uri );
  assertNotNull( withBaseFile );
  assertEquals( "bucket", ( (S3NFileName) withBaseFile ).getBucketId() );

  // assumption is that the whole URL is valid until it comes time to resolve to S3 objects
  uri = "s3n://s3n/bucket/file";
  withBaseFile = parser.parseUri( context, fileName, uri );
  assertEquals( "s3n", ( (S3NFileName)withBaseFile ).getBucketId() );
}
 
Example #17
Source File: TestFTPRemoteFile.java    From datacollector with Apache License 2.0 5 votes vote down vote up
@Test
public void testCreateAndCommitOutputStream() throws Exception {
  String name = "file.txt";
  String filePath = "/some/path/";
  FileObject fileObject = Mockito.mock(FileObject.class);
  FileName fileName = Mockito.mock(FileName.class);
  Mockito.when(fileObject.getName()).thenReturn(fileName);
  Mockito.when(fileName.getBaseName()).thenReturn(name);
  FileObject parentFileObject = Mockito.mock(FileObject.class);
  FileObject tempFileObject = Mockito.mock(FileObject.class);
  Mockito.when(fileObject.getParent()).thenReturn(parentFileObject);
  Mockito.when(parentFileObject.resolveFile(Mockito.any())).thenReturn(tempFileObject);
  FileContent tempFileContent = Mockito.mock(FileContent.class);
  Mockito.when(tempFileObject.getContent()).thenReturn(tempFileContent);

  FTPRemoteFile file = new FTPRemoteFile(filePath + name, 0L, fileObject);

  try {
    file.commitOutputStream();
    Assert.fail("Expected IOException because called commitOutputStream before createOutputStream");
  } catch (IOException ioe) {
    Assert.assertEquals("Cannot commit " + filePath + name + " - it must be written first", ioe.getMessage());
  }

  file.createOutputStream();
  Mockito.verify(parentFileObject).resolveFile("_tmp_" + name);
  Mockito.verify(tempFileContent).getOutputStream();

  file.commitOutputStream();
  Mockito.verify(tempFileObject).moveTo(fileObject);
}
 
Example #18
Source File: SimpleProjectService.java    From spoofax with Apache License 2.0 5 votes vote down vote up
@Override public @Nullable IProject get(FileObject resource) {
    final FileName name = resource.getName();
    for(Entry<FileName, IProject> entry : projects.entrySet()) {
        final FileName projectName = entry.getKey();
        if(name.equals(projectName) || name.isAncestor(projectName)) {
            return entry.getValue();
        }
    }
    return null;
}
 
Example #19
Source File: MimeFileProvider.java    From commons-vfs with Apache License 2.0 5 votes vote down vote up
/**
 * Creates the file system.
 */
@Override
protected FileSystem doCreateFileSystem(final String scheme, final FileObject file,
        final FileSystemOptions fileSystemOptions) throws FileSystemException {
    final FileName name = new LayeredFileName(scheme, file.getName(), FileName.ROOT_PATH, FileType.FOLDER);
    return new MimeFileSystem(name, file, fileSystemOptions);
}
 
Example #20
Source File: GoogleDriveFileSystemTest.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
@Test public void testFileSystem() {
  FileName fileName = mock( FileName.class );
  FileSystemOptions options = new FileSystemOptions();
  GoogleDriveFileSystem fileSystem = new GoogleDriveFileSystem( fileName, new FileSystemOptions() );
  Collection<Capability> fileSystemCapabilities = new ArrayList<>();
  fileSystem.addCapabilities( fileSystemCapabilities );
  assertTrue( capabilities.containsAll( fileSystemCapabilities ) );
}
 
Example #21
Source File: ConfigBasedProjectService.java    From spoofax with Apache License 2.0 5 votes vote down vote up
private IProject getProject(FileObject resource) {
    for(Map.Entry<FileName,IProject> entry : projects.entrySet()) {
        if(resource.getName().isAncestor(entry.getKey())) {
            return entry.getValue();
        }
    }
    return null;
}
 
Example #22
Source File: XmlSolutionFileModel.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
public String getUrl( final FileName file ) throws FileSystemException {
  final String[] fileName = computeFileNames( file );
  final FileInfo fileInfo = lookupNode( fileName );
  if ( fileInfo == null ) {
    throw new FileSystemException( "File is not valid." );
  }
  return fileInfo.getUrl();
}
 
Example #23
Source File: RepositoryTreeModelTest.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Before
public void setUp() throws Exception {
  repositoryRoot = mock( FileObject.class );
  childFile1 = mock( FileObject.class );
  childFile2 = mock( FileObject.class );
  childFile3 = mock( FileObject.class );
  childFile4 = mock( FileObject.class );
  childFileName1 = mock( FileName.class );
  childFileName2 = mock( FileName.class );
  childFileName3 = mock( FileName.class );
}
 
Example #24
Source File: AbstractLayeredFileProvider.java    From commons-vfs with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a layered file system.
 *
 * @param scheme The protocol to use.
 * @param file a FileObject.
 * @param fileSystemOptions Options to access the FileSystem.
 * @return A FileObject associated with the new FileSystem.
 * @throws FileSystemException if an error occurs.
 */
@Override
public synchronized FileObject createFileSystem(final String scheme, final FileObject file,
        final FileSystemOptions fileSystemOptions) throws FileSystemException {
    // Check if cached
    final FileName rootName = file.getName();
    FileSystem fs = findFileSystem(rootName, fileSystemOptions);
    if (fs == null) {
        // Create the file system
        fs = doCreateFileSystem(scheme, file, fileSystemOptions);
        addFileSystem(rootName, fs);
    }
    return fs.getRoot();
}
 
Example #25
Source File: RepositoryTableModelTest.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Before
public void setUp() throws Exception {
  fileObject = mock( FileObject.class );
  childFile1 = mock( FileObject.class );
  childFile2 = mock( FileObject.class );
  childFile3 = mock( FileObject.class );
  childFileName1 = mock( FileName.class );
  childFileName2 = mock( FileName.class );
  childFileName3 = mock( FileName.class );
  childFileContent1 = mock( FileContent.class );
  childFileContent2 = mock( FileContent.class );
  childFileContent3 = mock( FileContent.class );
}
 
Example #26
Source File: HttpFileProvider.java    From commons-vfs with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a {@link FileSystem}.
 */
@Override
protected FileSystem doCreateFileSystem(final FileName name, final FileSystemOptions fileSystemOptions)
        throws FileSystemException {
    // Create the file system
    final GenericFileName rootName = (GenericFileName) name;

    UserAuthenticationData authData = null;
    HttpClient httpClient;
    try {
        authData = UserAuthenticatorUtils.authenticate(fileSystemOptions, AUTHENTICATOR_TYPES);

        final String fileScheme = rootName.getScheme();
        final char lastChar = fileScheme.charAt(fileScheme.length() - 1);
        final String internalScheme = (lastChar == 's' || lastChar == 'S') ? "https" : "http";

        httpClient = HttpClientFactory.createConnection(internalScheme, rootName.getHostName(),
                rootName.getPort(),
                UserAuthenticatorUtils.toString(UserAuthenticatorUtils.getData(authData,
                        UserAuthenticationData.USERNAME, UserAuthenticatorUtils.toChar(rootName.getUserName()))),
                UserAuthenticatorUtils.toString(UserAuthenticatorUtils.getData(authData,
                        UserAuthenticationData.PASSWORD, UserAuthenticatorUtils.toChar(rootName.getPassword()))),
                fileSystemOptions);
    } finally {
        UserAuthenticatorUtils.cleanup(authData);
    }

    return new HttpFileSystem(rootName, httpClient, fileSystemOptions);
}
 
Example #27
Source File: XmlSolutionFileModel.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
public void setDescription( final FileName file, final String description ) throws FileSystemException {
  final String[] fileName = computeFileNames( file );
  final FileInfo fileInfo = lookupNode( fileName );
  if ( fileInfo == null ) {
    throw new FileSystemException( "File is not valid." );
  }
  fileInfo.setDescription( description );
}
 
Example #28
Source File: AbstractFileSystem.java    From commons-vfs with Apache License 2.0 5 votes vote down vote up
protected AbstractFileSystem(final FileName rootName, final FileObject parentLayer,
        final FileSystemOptions fileSystemOptions) {
    this.parentLayer = parentLayer;
    this.rootName = rootName;
    this.fileSystemOptions = fileSystemOptions;
    final FileSystemConfigBuilder builder = DefaultFileSystemConfigBuilder.getInstance();
    String uri = builder.getRootURI(fileSystemOptions);
    if (uri == null) {
        uri = rootName.getURI();
    }
    this.rootURI = uri;
}
 
Example #29
Source File: FtpFileObject.java    From commons-vfs with Apache License 2.0 5 votes vote down vote up
private FileObject getLinkDestination() throws FileSystemException {
    if (linkDestination == null) {
        final String path;
        synchronized (getFileSystem()) {
            path = this.fileInfo == null ? null : this.fileInfo.getLink();
        }
        final FileName parent = getName().getParent();
        final FileName relativeTo = parent == null ? getName() : parent;
        final FileName linkDestinationName = getFileSystem().getFileSystemManager().resolveName(relativeTo, path);
        linkDestination = getFileSystem().resolveFile(linkDestinationName);
    }
    return linkDestination;
}
 
Example #30
Source File: FileObjectToImport.java    From otroslogviewer with Apache License 2.0 5 votes vote down vote up
FileObjectToImport(FileObject fileObject, FileName fileName, FileSize fileSize, Level level, OpenMode openMode, CanParse canParse,PossibleLogImporters possibleLogImporters) {
  this.fileObject = fileObject;
  this.fileName = fileName;
  this.fileSize = fileSize;
  this.level = level;
  this.openMode = openMode;
  this.canParse = canParse;
  this.possibleLogImporters = possibleLogImporters;
}