Class FilesystemStorageStrategyImpl
- java.lang.Object
 - 
- org.jclouds.filesystem.strategy.internal.FilesystemStorageStrategyImpl
 
 
- 
- All Implemented Interfaces:
 LocalStorageStrategy
public class FilesystemStorageStrategyImpl extends Object implements LocalStorageStrategy
FilesystemStorageStrategyImpl implements a blob store that stores objects on the file system. Content metadata and user attributes are stored in extended attributes if the file system supports them. Directory blobs (blobs that end with a /) cannot have content, but otherwise appear in LIST like normal blobs. 
- 
- 
Field Summary
Fields Modifier and Type Field Description protected booleanautoDetectContentTypeprotected StringbaseDirectoryprotected javax.inject.Provider<BlobBuilder>blobBuildersprotected FilesystemBlobKeyValidatorfilesystemBlobKeyValidatorprotected FilesystemContainerNameValidatorfilesystemContainerNameValidatorprotected Loggerlogger 
- 
Constructor Summary
Constructors Modifier Constructor Description protectedFilesystemStorageStrategyImpl(javax.inject.Provider<BlobBuilder> blobBuilders, String baseDir, boolean autoDetectContentType, FilesystemContainerNameValidator filesystemContainerNameValidator, FilesystemBlobKeyValidator filesystemBlobKeyValidator, com.google.common.base.Supplier<Location> defaultLocation) 
- 
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanblobExists(String container, String key)Return true if a blob named by key existsprotected StringbuildPathStartingFromBaseDir(String... pathTokens)Facility method used to concatenate path tokens normalizing separatorsvoidclearContainer(String container)Empty the container of its content (files and subdirectories), but doesn't delete the container itselfvoidclearContainer(String container, ListContainerOptions options)LikeLocalStorageStrategy.clearContainer(String)except you can use options to do things like recursive deletes, or clear at a different path than root.booleancontainerExists(String container)Checks if a container existslongcountBlobs(String container, ListContainerOptions options)booleancreateContainer(String container)booleancreateContainerInLocation(String container, Location location, CreateContainerOptions options)Creates a new containervoidcreateDirectory(String container, String directory)protected booleancreateDirectoryWithResult(String container, String directory)Creates a directory and returns the resultvoiddeleteContainer(String container)Deletes a container and all its contentvoiddeleteDirectory(String container, String directory)booleandirectoryExists(String container, String directory)Collection<String>getAllContainerNames()Return an iterator that reports all the containers under base pathBlobgetBlob(String container, String key)Load the blob with the given key belonging to the container with the given name.BlobAccessgetBlobAccess(String containerName, String blobName)Iterable<String>getBlobKeysInsideContainer(String container, String prefix)Returns all the blobs key inside a containerContainerAccessgetContainerAccess(String container)StorageMetadatagetContainerMetadata(String container)FilegetFileForBlobKey(String container, String blobKey)Returns aFileobject that links to the blobLocationgetLocation(String containerName)StringgetSeparator()protected UserDefinedFileAttributeViewgetUserDefinedFileAttributeView(Path path)BlobnewBlob(String name)StringputBlob(String containerName, Blob blob)StringputBlob(String containerName, Blob blob, BlobAccess access)Write aBlobinto a filevoidremoveBlob(String container, String blobKey)Remove blob named by the given keyvoidsetBlobAccess(String container, String name, BlobAccess access)voidsetContainerAccess(String container, ContainerAccess access) 
 - 
 
- 
- 
Field Detail
- 
logger
protected Logger logger
 
- 
blobBuilders
protected final javax.inject.Provider<BlobBuilder> blobBuilders
 
- 
baseDirectory
protected final String baseDirectory
 
- 
autoDetectContentType
protected final boolean autoDetectContentType
 
- 
filesystemContainerNameValidator
protected final FilesystemContainerNameValidator filesystemContainerNameValidator
 
- 
filesystemBlobKeyValidator
protected final FilesystemBlobKeyValidator filesystemBlobKeyValidator
 
 - 
 
- 
Constructor Detail
- 
FilesystemStorageStrategyImpl
@Inject protected FilesystemStorageStrategyImpl(javax.inject.Provider<BlobBuilder> blobBuilders, @Named("jclouds.filesystem.basedir") String baseDir, @Named("jclouds.filesystem.auto-detect-content-type") boolean autoDetectContentType, FilesystemContainerNameValidator filesystemContainerNameValidator, FilesystemBlobKeyValidator filesystemBlobKeyValidator, com.google.common.base.Supplier<Location> defaultLocation)
 
 - 
 
- 
Method Detail
- 
containerExists
public boolean containerExists(String container)
Description copied from interface:LocalStorageStrategyChecks if a container exists- Specified by:
 containerExistsin interfaceLocalStorageStrategy- Returns:
 
 
- 
getAllContainerNames
public Collection<String> getAllContainerNames()
Description copied from interface:LocalStorageStrategyReturn an iterator that reports all the containers under base path- Specified by:
 getAllContainerNamesin interfaceLocalStorageStrategy- Returns:
 
 
- 
createContainerInLocation
public boolean createContainerInLocation(String container, Location location, CreateContainerOptions options)
Description copied from interface:LocalStorageStrategyCreates a new container- Specified by:
 createContainerInLocationin interfaceLocalStorageStrategy- Returns:
 
 
- 
getContainerAccess
public ContainerAccess getContainerAccess(String container)
- Specified by:
 getContainerAccessin interfaceLocalStorageStrategy
 
- 
setContainerAccess
public void setContainerAccess(String container, ContainerAccess access)
- Specified by:
 setContainerAccessin interfaceLocalStorageStrategy
 
- 
deleteContainer
public void deleteContainer(String container)
Description copied from interface:LocalStorageStrategyDeletes a container and all its content- Specified by:
 deleteContainerin interfaceLocalStorageStrategy
 
- 
clearContainer
public void clearContainer(String container)
Description copied from interface:LocalStorageStrategyEmpty the container of its content (files and subdirectories), but doesn't delete the container itself- Specified by:
 clearContainerin interfaceLocalStorageStrategy
 
- 
clearContainer
public void clearContainer(String container, ListContainerOptions options)
Description copied from interface:LocalStorageStrategyLikeLocalStorageStrategy.clearContainer(String)except you can use options to do things like recursive deletes, or clear at a different path than root.- Specified by:
 clearContainerin interfaceLocalStorageStrategy- Parameters:
 container- what to clearoptions- recursion and path to clear
 
- 
getContainerMetadata
public StorageMetadata getContainerMetadata(String container)
- Specified by:
 getContainerMetadatain interfaceLocalStorageStrategy- Returns:
 - StorageMetadata associated with a container name, e.g., creation date and location, or null if container does not exist
 
 
- 
blobExists
public boolean blobExists(String container, String key)
Description copied from interface:LocalStorageStrategyReturn true if a blob named by key exists- Specified by:
 blobExistsin interfaceLocalStorageStrategy- Returns:
 
 
- 
getBlobKeysInsideContainer
public Iterable<String> getBlobKeysInsideContainer(String container, String prefix) throws IOException
Returns all the blobs key inside a container- Specified by:
 getBlobKeysInsideContainerin interfaceLocalStorageStrategy- Parameters:
 container-- Returns:
 - Throws:
 IOException
 
- 
getBlob
public Blob getBlob(String container, String key)
Description copied from interface:LocalStorageStrategyLoad the blob with the given key belonging to the container with the given name. There must exist a resource on the file system whose complete name is given concatenating the container name and the key- Specified by:
 getBlobin interfaceLocalStorageStrategy- Returns:
 - the blob belonging to the given container with the given key
 
 
- 
putBlob
public String putBlob(String containerName, Blob blob) throws IOException
- Specified by:
 putBlobin interfaceLocalStorageStrategy- Throws:
 IOException
 
- 
putBlob
public String putBlob(String containerName, Blob blob, BlobAccess access) throws IOException
Description copied from interface:LocalStorageStrategyWrite aBlobinto a file- Specified by:
 putBlobin interfaceLocalStorageStrategy- Returns:
 - etag of blob
 - Throws:
 IOException
 
- 
removeBlob
public void removeBlob(String container, String blobKey)
Description copied from interface:LocalStorageStrategyRemove blob named by the given key- Specified by:
 removeBlobin interfaceLocalStorageStrategy
 
- 
getBlobAccess
public BlobAccess getBlobAccess(String containerName, String blobName)
- Specified by:
 getBlobAccessin interfaceLocalStorageStrategy
 
- 
setBlobAccess
public void setBlobAccess(String container, String name, BlobAccess access)
- Specified by:
 setBlobAccessin interfaceLocalStorageStrategy
 
- 
getLocation
public Location getLocation(String containerName)
- Specified by:
 getLocationin interfaceLocalStorageStrategy- Parameters:
 containerName- name of container- Returns:
 - Location of container or null
 
 
- 
getSeparator
public String getSeparator()
- Specified by:
 getSeparatorin interfaceLocalStorageStrategy- Returns:
 - path separator, either / or \
 
 
- 
createContainer
public boolean createContainer(String container)
 
- 
getFileForBlobKey
public File getFileForBlobKey(String container, String blobKey)
Returns aFileobject that links to the blob- Parameters:
 container-blobKey-- Returns:
 
 
- 
countBlobs
public long countBlobs(String container, ListContainerOptions options)
 
- 
getUserDefinedFileAttributeView
protected UserDefinedFileAttributeView getUserDefinedFileAttributeView(Path path) throws IOException
- Throws:
 IOException
 
- 
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
 
 
 - 
 
 -