org.jclouds.filesystem.strategy.internal
Class FilesystemStorageStrategyImpl

java.lang.Object
  extended by org.jclouds.filesystem.strategy.internal.FilesystemStorageStrategyImpl
All Implemented Interfaces:
FilesystemStorageStrategy

public class FilesystemStorageStrategyImpl
extends Object
implements FilesystemStorageStrategy

Author:
Alfredo "Rainbowbreeze" Morresi

Field Summary
protected  String baseDirectory
           
protected  javax.inject.Provider<BlobBuilder> blobBuilders
           
protected  FilesystemBlobKeyValidator filesystemBlobKeyValidator
           
protected  FilesystemContainerNameValidator filesystemContainerNameValidator
           
protected  Logger logger
           
 
Constructor Summary
protected FilesystemStorageStrategyImpl(javax.inject.Provider<BlobBuilder> blobBuilders, String baseDir, FilesystemContainerNameValidator filesystemContainerNameValidator, FilesystemBlobKeyValidator filesystemBlobKeyValidator)
           
 
Method Summary
 boolean blobExists(String container, String key)
           
protected  String buildPathStartingFromBaseDir(String... pathTokens)
          Facility method used to concatenate path tokens normalizing separators
 void clearContainer(String container)
          Empty the directory of its content (files and subdirectories)
 void clearContainer(String container, ListContainerOptions options)
          Like FilesystemStorageStrategy.clearContainer(String) except you can use options to do things like recursive deletes, or clear at a different path than root.
 boolean containerExists(String container)
          Checks if a container exists
 long countBlobs(String container, ListContainerOptions options)
          Counts number of blobs inside a container
 boolean createContainer(String container)
          Creates a new container
 void createDirectory(String container, String directory)
          Creates a folder or a directory marker depending on the service
protected  boolean createDirectoryWithResult(String container, String directory)
          Creates a directory and returns the result
 void deleteContainer(String container)
          Deletes a container and all its content
 void deleteDirectory(String container, String directory)
          Deletes a folder or a directory marker depending on the service
 boolean directoryExists(String container, String directory)
          Determines if a directory exists
 Iterable<String> getAllContainerNames()
          Return an iterator that reports all the containers under base path
 Iterable<String> getBlobKeysInsideContainer(String container)
          Returns all the blobs key inside a container
 File getFileForBlobKey(String container, String blobKey)
          Returns a File object that links to the blob
 Blob newBlob(String name)
          Creates a new blob
 void removeBlob(String container, String blobKey)
           
 void writePayloadOnFile(String container, String blobKey, Payload payload)
          Write a Blob Payload into a file
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

protected Logger logger

blobBuilders

protected final javax.inject.Provider<BlobBuilder> blobBuilders

baseDirectory

protected final String baseDirectory

filesystemContainerNameValidator

protected final FilesystemContainerNameValidator filesystemContainerNameValidator

filesystemBlobKeyValidator

protected final FilesystemBlobKeyValidator filesystemBlobKeyValidator
Constructor Detail

FilesystemStorageStrategyImpl

@Inject
protected FilesystemStorageStrategyImpl(javax.inject.Provider<BlobBuilder> blobBuilders,
                                               @Named(value="jclouds.filesystem.basedir")
                                               String baseDir,
                                               FilesystemContainerNameValidator filesystemContainerNameValidator,
                                               FilesystemBlobKeyValidator filesystemBlobKeyValidator)
Method Detail

containerExists

public boolean containerExists(String container)
Description copied from interface: FilesystemStorageStrategy
Checks if a container exists

Specified by:
containerExists in interface FilesystemStorageStrategy
Returns:

blobExists

public boolean blobExists(String container,
                          String key)
Specified by:
blobExists in interface FilesystemStorageStrategy
Returns:

createContainer

public boolean createContainer(String container)
Description copied from interface: FilesystemStorageStrategy
Creates a new container

Specified by:
createContainer in interface FilesystemStorageStrategy
Returns:

deleteContainer

public void deleteContainer(String container)
Description copied from interface: FilesystemStorageStrategy
Deletes a container and all its content

Specified by:
deleteContainer in interface FilesystemStorageStrategy

clearContainer

public void clearContainer(String container)
Empty the directory of its content (files and subdirectories)

Specified by:
clearContainer in interface FilesystemStorageStrategy
Parameters:
container -

clearContainer

public void clearContainer(String container,
                           ListContainerOptions options)
Description copied from interface: FilesystemStorageStrategy
Like FilesystemStorageStrategy.clearContainer(String) except you can use options to do things like recursive deletes, or clear at a different path than root.

Specified by:
clearContainer in interface FilesystemStorageStrategy
Parameters:
container - what to clear
options - recursion and path to clear

newBlob

public Blob newBlob(String name)
Description copied from interface: FilesystemStorageStrategy
Creates a new blob

Specified by:
newBlob in interface FilesystemStorageStrategy
Returns:

removeBlob

public void removeBlob(String container,
                       String blobKey)
Specified by:
removeBlob in interface FilesystemStorageStrategy

getAllContainerNames

public Iterable<String> getAllContainerNames()
Return an iterator that reports all the containers under base path

Specified by:
getAllContainerNames in interface FilesystemStorageStrategy
Returns:

getFileForBlobKey

public File getFileForBlobKey(String container,
                              String blobKey)
Returns a File object that links to the blob

Specified by:
getFileForBlobKey in interface FilesystemStorageStrategy
Parameters:
container -
blobKey -
Returns:

writePayloadOnFile

public void writePayloadOnFile(String container,
                               String blobKey,
                               Payload payload)
                        throws IOException
Write a Blob Payload into a file

Specified by:
writePayloadOnFile in interface FilesystemStorageStrategy
Parameters:
container -
blobKey -
payload -
Throws:
IOException

getBlobKeysInsideContainer

public Iterable<String> getBlobKeysInsideContainer(String container)
                                            throws IOException
Returns all the blobs key inside a container

Specified by:
getBlobKeysInsideContainer in interface FilesystemStorageStrategy
Parameters:
container -
Returns:
Throws:
IOException

directoryExists

public boolean directoryExists(String container,
                               String directory)
Description copied from interface: FilesystemStorageStrategy
Determines if a directory exists

Specified by:
directoryExists in interface FilesystemStorageStrategy
Parameters:
container - container where the directory resides
directory - full path to the directory

createDirectory

public void createDirectory(String container,
                            String directory)
Description copied from interface: FilesystemStorageStrategy
Creates a folder or a directory marker depending on the service

Specified by:
createDirectory in interface FilesystemStorageStrategy
Parameters:
container - container to create the directory in
directory - full path to the directory

deleteDirectory

public void deleteDirectory(String container,
                            String directory)
Description copied from interface: FilesystemStorageStrategy
Deletes a folder or a directory marker depending on the service

Specified by:
deleteDirectory in interface FilesystemStorageStrategy
Parameters:
container - container to delete the directory from
directory - full path to the directory to delete

countBlobs

public long countBlobs(String container,
                       ListContainerOptions options)
Description copied from interface: FilesystemStorageStrategy
Counts number of blobs inside a container

Specified by:
countBlobs in interface FilesystemStorageStrategy
Returns:

buildPathStartingFromBaseDir

protected String buildPathStartingFromBaseDir(String... pathTokens)
Facility method used to concatenate path tokens normalizing separators

Parameters:
pathTokens - all the string in the proper order that must be concatenated in order to obtain the filename
Returns:
the resulting string

createDirectoryWithResult

protected boolean createDirectoryWithResult(String container,
                                            String directory)
Creates a directory and returns the result

Parameters:
container -
directory -
Returns:
true if the directory was created, otherwise false


Copyright © 2009-2011 jclouds. All Rights Reserved.