Package com.cloudloop.storage

Examples of com.cloudloop.storage.CloudStoreFile


        if ( dir.existsInStore(  ) )
        {
            return CloudStoreObjectType.DIRECTORY;
        }

        CloudStoreFile file = ( ( CloudStore ) path.getCloudProvider(  ) ).getFile( path.getPath(  ) );

        if ( file.existsInStore(  ) )
        {
            return CloudStoreObjectType.FILE;
        }

        return CloudStoreObjectType.OBJECT;
View Full Code Here


    for (String arg : args.getArguments())
    {
      CloudPath filePath = new CloudPath( arg , currentDir, CliSession.getSession( ).getCloudloop( ) );
      CloudStore store = (CloudStore) filePath.getCloudProvider( );
      CloudStoreFile file = store.getFile( filePath.getPath( ) );
      if (!file.existsInStore( ))
      {
        err.println( "File '" + filePath.getPath( )
            + "' does not exist in store '"
            + store.getCloudloopToken( ) + "'." );
        return 1;
      }
      files.add( file );
    }

    for (CloudStoreFile file : files)
    {
      // TODO: Support UTF-16 and other formats?
      InputStream fileStream = file.read( null );
      BufferedReader buff = new BufferedReader( new InputStreamReader(
          fileStream ) );

      String line;
      try
      {
        while ( ( line = buff.readLine( ) ) != null)
        {
          out.println( line );
        }
        fileStream.close( );
      } catch (IOException e)
      {
        err.println( "Error reading file '"
            + file.getPath( ).getAbsolutePath( ) + "' from store '"
            + file.getParentStore( ).getCloudloopToken( ) + "'." );
        err.println( e.getMessage( ) );
        return 1;
      }
    }
View Full Code Here

   
    @Override
    public CloudStoreDirectory sendCreateDirectoryRequest(
                 CloudStoreDirectory directory )
    {
  CloudStoreFile placeholder = new FakeDirectoryPlaceholder( this,
    directory.getPath( ) );
  placeholder.write( null );
 
  return directory;
    }
View Full Code Here

        store.createDirectory( store.getDirectory( obj.Path ) );
        createDirectoryContents( store,
            (MockFileSystem.MockDirectory) obj );
      } else
      {
        CloudStoreFile file = store.getFile( obj.Path );
        file.setStreamToStore( ( (MockFileSystem.MockFile) obj )
            .getStream( ) );
        file.write( null );
      }
    }
  }
View Full Code Here

    public void testSendIntraStoreCopyRequest( )
    {
  CloudStoreAdapterBase store = getCloudStoreAdapter( );
  CloudStorePath dirPath = new CloudStorePath( "/foo/bar/" );
  store.createDirectory( store.getDirectory( "/foo/bar/" ) );
  CloudStoreFile fileToUpload = store.getFile( "/foo/bar/some_file.txt" );
  fileToUpload.setStreamToStore( new MockFileStream( 50 ) );
  fileToUpload.write( null );
  // HACK!! (AL) For some reason, Nirvanix needs time to process the file
  // before it can be copied. I'm not sure why this is, and I can't
  // find anything in the docs.
  // TODO: Perhaps put in a retry for the copy command?
  try
  {
      Thread.sleep( 1000 );
  }
  catch ( Throwable e )
  {
  }
  fileToUpload.copyTo( store
    .getFile( dirPath.getParent( )
    .combine(
        PathUtil.popLeaf( fileToUpload.getPath( ) ) )
    .getAbsolutePath( ) ), null );
  assertTrue( store.contains( store.getFile( "/foo/some_file.txt" ) ) );
    }
View Full Code Here

    @Test
    public void testSendUploadDownloadRequest( )
    {
  CloudStoreAdapterBase store = getCloudStoreAdapter( );
  store.createDirectory( store.getDirectory( "/foo/bar/" ) );
  CloudStoreFile fileToUpload = store.getFile( "/foo/bar/some_file.txt" );
  fileToUpload.setStreamToStore( new MockFileStream( 50 ) );
  fileToUpload.write( null );
  FileStreamComparer.areStreamsEqual( new MockFileStream( 50 ),
              fileToUpload.read( null ) );
    }
View Full Code Here

    @Test
    public void testSendRemoveFileRequest( )
    {
  CloudStoreAdapterBase store = getCloudStoreAdapter( );
  store.createDirectory( store.getDirectory( "/foo/bar/" ) );
  CloudStoreFile fileToUpload = store.getFile( "/foo/bar/some_file.txt" );
  fileToUpload.setStreamToStore( new MockFileStream( 50 ) );
  fileToUpload.write( null );
  fileToUpload.remove( );
  assertFalse( store.contains( fileToUpload ) );
    }
View Full Code Here

      {
    CloudStoreDirectory subDir = store.getDirectory( dirPath
      + "sub_dir_" + j + "/" );
    store.createDirectory( subDir );
   
    CloudStoreFile subFile = store.getFile( dirPath + "sub_file_"
      + j );
    subFile.setStreamToStore( new MockFileStream( 50 ) );
    subFile.write( null );
      }
  }
 
  for ( int i = 0; i < numFiles; i++ )
  {
      String filePath = baseDir + "file_" + i;
      CloudStoreFile file = store.getFile( filePath );
      file.setStreamToStore( new MockFileStream( 50 ) );
      file.write( null );
  }
    }
View Full Code Here

    @Test
    public void testSendWriteMetadataRequest( )
    {
  CloudStoreAdapterBase store = getCloudStoreAdapter( );
  store.createDirectory( store.getDirectory( "/foo/bar/" ) );
  CloudStoreFile fileToUpload = store.getFile( "/foo/bar/some_file.txt" );
  fileToUpload.setStreamToStore( new MockFileStream( 50 ) );
  fileToUpload.setCustomMetaTag( "foo", "bar" );
  fileToUpload.write( null );
 
  CloudStoreFile uploaded = store.getFile( fileToUpload.getPath( )
    .getAbsolutePath( ) );
  uploaded.refreshMetadata( );
  String tag = uploaded.getMetadata( ).getCustomTags( ).get( "foo" );
  if ( tag == null ) // Rackspace capitalizes the first letter of keys for
      // some reason...
      // TODO: Log defect!!
      tag = uploaded.getMetadata( ).getCustomTags( ).get( "Foo" );
  assertEquals( "bar", tag );
    }
View Full Code Here

      cloudStoreObjects.add( cloudStoreObject );
        }
    }
    if ( !isDir && typeFilter != CloudStoreObjectType.DIRECTORY )
    {
        cloudStoreObject = new CloudStoreFile( this,
          new CloudStorePath( filesObject.getName( ) ) );
        cloudStoreObject.setMetadata( objectMetadata );
        cloudStoreObjects.add( cloudStoreObject );
    }
      }
View Full Code Here

TOP

Related Classes of com.cloudloop.storage.CloudStoreFile

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.