Package org.apache.commons.vfs2

Examples of org.apache.commons.vfs2.FileSystemOptions


     *             if the new size exceeds the limit
     */
    synchronized void resize(final long newSize) throws IOException
    {
        final RamFileSystem afs = getAbstractFileSystem();
        final FileSystemOptions afsOptions = afs.getFileSystemOptions();
        if (afsOptions != null)
        {
            final long maxSize = RamFileSystemConfigBuilder.getInstance().getLongMaxSize(afsOptions);
            if (afs.size() + newSize - this.size() > maxSize)
            {
View Full Code Here


  private File root;

  public CommonsVfsConnection(final ConnectionDescription desc, final FileSystem fs) throws net.sourceforge.fullsync.FileSystemException {
    try {
      this.desc = desc;
      FileSystemOptions options = new FileSystemOptions();
      if (null != fs) {
        fs.authSetup(desc, options);
      }
      base = VFS.getManager().resolveFile(desc.getUri().toString(), options);
      root = new AbstractFile(this, ".", null, true, base.exists());
View Full Code Here

        assertFalse(isEmpty(config.getProperty(ACCESS_KEY)), NO_CREDENTIALS_MESSAGE);
        assertFalse(isEmpty(config.getProperty(SECRET_KEY)), NO_CREDENTIALS_MESSAGE);

        // Configure VFS
        StaticUserAuthenticator auth = new StaticUserAuthenticator(null, config.getProperty(ACCESS_KEY), config.getProperty(SECRET_KEY));
        FileSystemOptions opts = S3FileProvider.getDefaultFileSystemOptions();
        DefaultFileSystemConfigBuilder.getInstance().setUserAuthenticator(opts, auth);
    }
View Full Code Here

    }
    userConfig.load(propertyResource);
    // create authenticator
    final StaticUserAuthenticator userAuthenticator = new StaticUserAuthenticator(null, userConfig.getProperty("aws.key-id", ""),
        userConfig.getProperty("aws.key", ""));
    final FileSystemOptions options = S3FileProvider.getDefaultFileSystemOptions();
    DefaultFileSystemConfigBuilder.getInstance().setUserAuthenticator(options, userAuthenticator);
    log.info("s3 provider initialized");
  }
View Full Code Here

   */
    @Deprecated
  public static void initS3Provider(final String awsKeyId, final String awsKey) throws FileSystemException {
    // create authenticator
    final StaticUserAuthenticator userAuthenticator = new StaticUserAuthenticator(null, awsKeyId, awsKey);
    final FileSystemOptions options = S3FileProvider.getDefaultFileSystemOptions();
    DefaultFileSystemConfigBuilder.getInstance().setUserAuthenticator(options, userAuthenticator);
    log.info("s3 provider initialized");
  }
View Full Code Here

     */
    @Override
    public FileSystemManager getObject() throws Exception {
        // Configure VFS
        StaticUserAuthenticator auth = new StaticUserAuthenticator(null, awsAccessKey, awsSecretKey);
        FileSystemOptions opts = S3FileProvider.getDefaultFileSystemOptions();
        DefaultFileSystemConfigBuilder.getInstance().setUserAuthenticator(opts, auth);

        return VFS.getManager();
    }
View Full Code Here

     */
    public void testDeleteAllFiles() throws Exception
    {
        final FileObject scratchFolder = createScratchFolder();

        assertEquals(scratchFolder.delete(new FileTypeSelector(FileType.FILE)), 2);
    }
View Full Code Here

    {
        FileObject file = null;
        try
        {
            file = getReadFolder().resolveFile("file1.txt");
            RandomAccessContent ra = file.getContent().getRandomAccessContent(RandomAccessMode.READ);

            // read first byte
            byte c = ra.readByte();
            assertEquals(c, TEST_DATA.charAt(0));
            assertEquals("fp", ra.getFilePointer(), 1);

            // start at pos 4
            ra.seek(3);
            c = ra.readByte();
            assertEquals(c, TEST_DATA.charAt(3));
            assertEquals("fp", ra.getFilePointer(), 4);

            c = ra.readByte();
            assertEquals(c, TEST_DATA.charAt(4));
            assertEquals("fp", ra.getFilePointer(), 5);

            // restart at pos 4
            ra.seek(3);
            c = ra.readByte();
            assertEquals(c, TEST_DATA.charAt(3));
            assertEquals("fp", ra.getFilePointer(), 4);

            c = ra.readByte();
            assertEquals(c, TEST_DATA.charAt(4));
            assertEquals("fp", ra.getFilePointer(), 5);

            // advance to pos 11
            ra.seek(10);
            c = ra.readByte();
            assertEquals(c, TEST_DATA.charAt(10));
            assertEquals("fp", ra.getFilePointer(), 11);

            c = ra.readByte();
            assertEquals(c, TEST_DATA.charAt(11));
            assertEquals("fp", ra.getFilePointer(), 12);
        }
        finally
        {
            if (file != null)
            {
View Full Code Here

    public FilesCache getFilesCache()
    {
        if (cache == null)
        {
            // cache = new DefaultFilesCache();
            cache = new SoftRefFilesCache();
        }

        return cache;
    }
View Full Code Here

    @Override
    protected void setUp() throws Exception
    {
        super.setUp();

        manager = new DefaultFileSystemManager();
        manager.addProvider("ram", new RamFileProvider());
        manager.init();

        // File Systems Options
        RamFileSystemConfigBuilder.getInstance().setMaxSize(zeroSized, 0);
View Full Code Here

TOP

Related Classes of org.apache.commons.vfs2.FileSystemOptions

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.