protected CloudStoreObject[ ] fetchDirectoryContents(
CloudStoreDirectory dir )
throws NirvanixException, SDKException, IOException
{
ArrayList<CloudStoreObject> output = new ArrayList<CloudStoreObject>( );
Folder folder;
int numProcessed = 0;
do
{
folder = _session.getFolder(
dir.getPath( ).getAbsolutePath( ),
1,
MAX_PAGE_SIZE,
FolderSortCode.Name,
true );
for ( Folder childFolder : folder.getFolders( ) )
{
CloudStoreDirectory outputDir =
getDirectory(
getPathNormalizer( )
.normalizeToCloudStorePath( childFolder.getPath( ),
true ).getAbsolutePath( )
);
CloudStoreObjectMetadata metadata = new CloudStoreObjectMetadata( );
metadata.setLastModifiedDate( childFolder.getCreatedDate( ) );
outputDir.setMetadata( metadata );
output.add( outputDir );
numProcessed++;
}
for ( File childFile : folder.getFiles( ) )
{
CloudStoreFile outputFile =
getFile(
getPathNormalizer( )
.normalizeToCloudStorePath( childFile.getPath( ), false )
.getAbsolutePath( )
);
CloudStoreObjectMetadata metadata = new CloudStoreObjectMetadata( );
MetadataInfo[ ] nirvanixMetadata = childFile.getMetadata( );
for ( MetadataInfo info : nirvanixMetadata )
{
metadata.setCustomTag( info.getType( ), info.getValue( ) );
if ( info.getType( ).equals( "MD5" ) )
{
metadata.setETag( info.getValue( ) );
}
}
metadata.setContentLengthInBytes( childFile.getSizeBytes( ) );
metadata.setLastModifiedDate( childFile.getCreatedDate( ) );
metadata.isComplete( );
outputFile.setMetadata( metadata );
output.add( outputFile );
numProcessed++;
}
}
while ( folder.getTotalFileCount( ) + folder.getTotalFolderCount( ) < numProcessed );
return output.toArray( new CloudStoreObject[ output.size( ) ] );
}