public class S3FileSystemImpl extends Object implements org.refcodes.filesystem.FileSystem
Constructor and Description |
---|
S3FileSystemImpl(String aBucketName,
String aAccessKey,
String aSecretKey)
Instantiates a new s 3 file system impl.
|
S3FileSystemImpl(String aBucketName,
String aAccessKey,
String aSecretKey,
String aEndPoint)
Instantiates a new s 3 file system impl.
|
Modifier and Type | Method and Description |
---|---|
protected static void |
clearBucket(com.amazonaws.services.s3.AmazonS3 aAmazonS3,
String aBucketId)
Clears (removes all content from) an S3 bucket.
|
protected static com.amazonaws.services.s3.AmazonS3 |
createAmazonS3(String aAccessKey,
String aSecretKey)
Creates an
AmazonS3 "client". |
static void |
createBucket(com.amazonaws.services.s3.AmazonS3 aAmazonS3,
String aBucketId)
Creates an S3 bucket.
|
protected static void |
createBucket(com.amazonaws.services.s3.AmazonS3 aAmazonS3,
String aBucketId,
String aRegion)
Creates an S3 bucket.
|
org.refcodes.filesystem.FileHandle |
createFile(String aKey) |
org.refcodes.filesystem.FileHandle |
createFile(String aPath,
String aName) |
static void |
deleteBucket(com.amazonaws.services.s3.AmazonS3 aAmazonS3,
String aBucketId)
Deletes an S3 bucket.
|
void |
deleteFile(org.refcodes.filesystem.FileHandle aFileHandle) |
protected static void |
deleteS3Objects(com.amazonaws.services.s3.AmazonS3 aAmazonS3,
String aBucketId,
List<com.amazonaws.services.s3.model.S3ObjectSummary> aS3SummaryObjects)
Deletes the content described by the given
S3ObjectSummary list
from an S3 bucket. |
void |
destroy() |
InputStream |
fromFile(org.refcodes.filesystem.FileHandle aFromFileHandle) |
void |
fromFile(org.refcodes.filesystem.FileHandle aFileHandle,
File aToFile) |
void |
fromFile(org.refcodes.filesystem.FileHandle aFromFileHandle,
OutputStream aOutputStream) |
protected String |
getAmazonS3BucketName()
Retrieves the bucket name to be used.
|
protected com.amazonaws.services.s3.AmazonS3Client |
getAmazonS3Client()
Retrieves the amazon S3 client to be used.
|
protected static com.amazonaws.services.s3.AmazonS3Client |
getAmazonS3Client(File aConfigFile)
Retrieves an
AmazonS3Client from a configuration file containing
the access- and the secret key. |
org.refcodes.filesystem.FileHandle |
getFileHandle(String aKey) |
org.refcodes.filesystem.FileHandle |
getFileHandle(String aPath,
String aName) |
List<org.refcodes.filesystem.FileHandle> |
getFileHandles(String aPath,
boolean isRecursively) |
boolean |
hasFile(org.refcodes.filesystem.FileHandle aFileHandle) |
boolean |
hasFile(String aKey)
Checks for file.
|
boolean |
hasFile(String aPath,
String aName) |
boolean |
hasFiles(String aPath,
boolean isRecursively) |
org.refcodes.filesystem.FileHandle |
moveFile(org.refcodes.filesystem.FileHandle aFileHandle,
String aNewKey) |
org.refcodes.filesystem.FileHandle |
renameFile(org.refcodes.filesystem.FileHandle aFileHandle,
String aNewName) |
protected void |
setAmazonS3BucketName(String aAmazonS3BucketName)
Sets the bucket name to be used.
|
OutputStream |
toFile(org.refcodes.filesystem.FileHandle aToFileHandle) |
void |
toFile(org.refcodes.filesystem.FileHandle aFileHandle,
byte[] aBuffer) |
void |
toFile(org.refcodes.filesystem.FileHandle aFileHandle,
File aFile) |
void |
toFile(org.refcodes.filesystem.FileHandle aToFileHandle,
InputStream aInputStream) |
public S3FileSystemImpl(String aBucketName, String aAccessKey, String aSecretKey)
aBucketName
- the bucket nameaAccessKey
- the access keyaSecretKey
- the secret keypublic boolean hasFile(String aKey) throws org.refcodes.filesystem.IllegalKeyException, org.refcodes.filesystem.NoListAccessException, org.refcodes.filesystem.UnknownFileSystemException, IOException
hasFile
in interface org.refcodes.filesystem.FileSystem
aKey
- the keyorg.refcodes.filesystem.IllegalKeyException
- the illegal key exceptionorg.refcodes.filesystem.NoListAccessException
- the no list access exceptionorg.refcodes.filesystem.UnknownFileSystemException
- the unknown file system exceptionIOException
- Signals that an I/O exception has occurred.public boolean hasFile(String aPath, String aName) throws org.refcodes.filesystem.IllegalPathException, org.refcodes.filesystem.IllegalNameException, org.refcodes.filesystem.NoListAccessException, org.refcodes.filesystem.UnknownFileSystemException, IOException
hasFile
in interface org.refcodes.filesystem.FileSystem
org.refcodes.filesystem.IllegalPathException
org.refcodes.filesystem.IllegalNameException
org.refcodes.filesystem.NoListAccessException
org.refcodes.filesystem.UnknownFileSystemException
IOException
public boolean hasFile(org.refcodes.filesystem.FileHandle aFileHandle) throws org.refcodes.filesystem.NoListAccessException, org.refcodes.filesystem.UnknownFileSystemException, IOException, org.refcodes.filesystem.IllegalFileHandleException
hasFile
in interface org.refcodes.filesystem.FileSystem
org.refcodes.filesystem.NoListAccessException
org.refcodes.filesystem.UnknownFileSystemException
IOException
org.refcodes.filesystem.IllegalFileHandleException
public org.refcodes.filesystem.FileHandle createFile(String aKey) throws org.refcodes.filesystem.FileAlreadyExistsException, org.refcodes.filesystem.NoCreateAccessException, org.refcodes.filesystem.IllegalKeyException, org.refcodes.filesystem.UnknownFileSystemException, IOException, org.refcodes.filesystem.NoListAccessException
createFile
in interface org.refcodes.filesystem.FileSystem
org.refcodes.filesystem.FileAlreadyExistsException
org.refcodes.filesystem.NoCreateAccessException
org.refcodes.filesystem.IllegalKeyException
org.refcodes.filesystem.UnknownFileSystemException
IOException
org.refcodes.filesystem.NoListAccessException
public org.refcodes.filesystem.FileHandle createFile(String aPath, String aName) throws org.refcodes.filesystem.FileAlreadyExistsException, org.refcodes.filesystem.NoCreateAccessException, org.refcodes.filesystem.IllegalNameException, org.refcodes.filesystem.IllegalPathException, org.refcodes.filesystem.UnknownFileSystemException, IOException, org.refcodes.filesystem.NoListAccessException
createFile
in interface org.refcodes.filesystem.FileSystem
org.refcodes.filesystem.FileAlreadyExistsException
org.refcodes.filesystem.NoCreateAccessException
org.refcodes.filesystem.IllegalNameException
org.refcodes.filesystem.IllegalPathException
org.refcodes.filesystem.UnknownFileSystemException
IOException
org.refcodes.filesystem.NoListAccessException
public org.refcodes.filesystem.FileHandle getFileHandle(String aKey) throws org.refcodes.filesystem.NoListAccessException, org.refcodes.filesystem.IllegalKeyException, org.refcodes.filesystem.UnknownFileSystemException, IOException, org.refcodes.filesystem.UnknownKeyException
getFileHandle
in interface org.refcodes.filesystem.FileSystem
org.refcodes.filesystem.NoListAccessException
org.refcodes.filesystem.IllegalKeyException
org.refcodes.filesystem.UnknownFileSystemException
IOException
org.refcodes.filesystem.UnknownKeyException
public org.refcodes.filesystem.FileHandle getFileHandle(String aPath, String aName) throws org.refcodes.filesystem.NoListAccessException, org.refcodes.filesystem.IllegalNameException, org.refcodes.filesystem.IllegalPathException, org.refcodes.filesystem.UnknownFileSystemException, IOException, org.refcodes.filesystem.UnknownKeyException
getFileHandle
in interface org.refcodes.filesystem.FileSystem
org.refcodes.filesystem.NoListAccessException
org.refcodes.filesystem.IllegalNameException
org.refcodes.filesystem.IllegalPathException
org.refcodes.filesystem.UnknownFileSystemException
IOException
org.refcodes.filesystem.UnknownKeyException
public void fromFile(org.refcodes.filesystem.FileHandle aFromFileHandle, OutputStream aOutputStream) throws org.refcodes.filesystem.ConcurrentAccessException, org.refcodes.filesystem.UnknownFileException, org.refcodes.filesystem.NoReadAccessException, org.refcodes.filesystem.UnknownFileSystemException, IOException, org.refcodes.filesystem.NoListAccessException, org.refcodes.filesystem.IllegalFileHandleException
fromFile
in interface org.refcodes.filesystem.FileSystem
org.refcodes.filesystem.ConcurrentAccessException
org.refcodes.filesystem.UnknownFileException
org.refcodes.filesystem.NoReadAccessException
org.refcodes.filesystem.UnknownFileSystemException
IOException
org.refcodes.filesystem.NoListAccessException
org.refcodes.filesystem.IllegalFileHandleException
public void toFile(org.refcodes.filesystem.FileHandle aToFileHandle, InputStream aInputStream) throws org.refcodes.filesystem.ConcurrentAccessException, org.refcodes.filesystem.UnknownFileException, org.refcodes.filesystem.NoWriteAccessException, org.refcodes.filesystem.UnknownFileSystemException, IOException, org.refcodes.filesystem.NoListAccessException, org.refcodes.filesystem.IllegalFileHandleException
toFile
in interface org.refcodes.filesystem.FileSystem
org.refcodes.filesystem.ConcurrentAccessException
org.refcodes.filesystem.UnknownFileException
org.refcodes.filesystem.NoWriteAccessException
org.refcodes.filesystem.UnknownFileSystemException
IOException
org.refcodes.filesystem.NoListAccessException
org.refcodes.filesystem.IllegalFileHandleException
public InputStream fromFile(org.refcodes.filesystem.FileHandle aFromFileHandle) throws org.refcodes.filesystem.ConcurrentAccessException, org.refcodes.filesystem.UnknownFileException, org.refcodes.filesystem.UnknownFileException, org.refcodes.filesystem.NoReadAccessException, org.refcodes.filesystem.UnknownFileSystemException, IOException, org.refcodes.filesystem.NoListAccessException, org.refcodes.filesystem.IllegalFileHandleException
fromFile
in interface org.refcodes.filesystem.FileSystem
org.refcodes.filesystem.ConcurrentAccessException
org.refcodes.filesystem.UnknownFileException
org.refcodes.filesystem.NoReadAccessException
org.refcodes.filesystem.UnknownFileSystemException
IOException
org.refcodes.filesystem.NoListAccessException
org.refcodes.filesystem.IllegalFileHandleException
public OutputStream toFile(org.refcodes.filesystem.FileHandle aToFileHandle) throws org.refcodes.filesystem.ConcurrentAccessException, org.refcodes.filesystem.UnknownFileException, org.refcodes.filesystem.NoWriteAccessException, org.refcodes.filesystem.UnknownFileSystemException, IOException, org.refcodes.filesystem.IllegalFileHandleException
toFile
in interface org.refcodes.filesystem.FileSystem
org.refcodes.filesystem.ConcurrentAccessException
org.refcodes.filesystem.UnknownFileException
org.refcodes.filesystem.NoWriteAccessException
org.refcodes.filesystem.UnknownFileSystemException
IOException
org.refcodes.filesystem.IllegalFileHandleException
public void fromFile(org.refcodes.filesystem.FileHandle aFileHandle, File aToFile) throws org.refcodes.filesystem.ConcurrentAccessException, org.refcodes.filesystem.UnknownFileException, org.refcodes.filesystem.NoReadAccessException, org.refcodes.filesystem.UnknownFileSystemException, IOException, org.refcodes.filesystem.NoListAccessException, org.refcodes.filesystem.IllegalFileHandleException
fromFile
in interface org.refcodes.filesystem.FileSystem
org.refcodes.filesystem.ConcurrentAccessException
org.refcodes.filesystem.UnknownFileException
org.refcodes.filesystem.NoReadAccessException
org.refcodes.filesystem.UnknownFileSystemException
IOException
org.refcodes.filesystem.NoListAccessException
org.refcodes.filesystem.IllegalFileHandleException
public void toFile(org.refcodes.filesystem.FileHandle aFileHandle, File aFile) throws org.refcodes.filesystem.ConcurrentAccessException, org.refcodes.filesystem.UnknownFileException, org.refcodes.filesystem.NoWriteAccessException, org.refcodes.filesystem.UnknownFileSystemException, IOException, org.refcodes.filesystem.NoListAccessException, org.refcodes.filesystem.IllegalFileHandleException
toFile
in interface org.refcodes.filesystem.FileSystem
org.refcodes.filesystem.ConcurrentAccessException
org.refcodes.filesystem.UnknownFileException
org.refcodes.filesystem.NoWriteAccessException
org.refcodes.filesystem.UnknownFileSystemException
IOException
org.refcodes.filesystem.NoListAccessException
org.refcodes.filesystem.IllegalFileHandleException
public void toFile(org.refcodes.filesystem.FileHandle aFileHandle, byte[] aBuffer) throws org.refcodes.filesystem.ConcurrentAccessException, org.refcodes.filesystem.UnknownFileException, org.refcodes.filesystem.NoWriteAccessException, org.refcodes.filesystem.UnknownFileSystemException, IOException, org.refcodes.filesystem.NoListAccessException, org.refcodes.filesystem.IllegalFileHandleException
toFile
in interface org.refcodes.filesystem.FileSystem
org.refcodes.filesystem.ConcurrentAccessException
org.refcodes.filesystem.UnknownFileException
org.refcodes.filesystem.NoWriteAccessException
org.refcodes.filesystem.UnknownFileSystemException
IOException
org.refcodes.filesystem.NoListAccessException
org.refcodes.filesystem.IllegalFileHandleException
public org.refcodes.filesystem.FileHandle renameFile(org.refcodes.filesystem.FileHandle aFileHandle, String aNewName) throws org.refcodes.filesystem.UnknownFileException, org.refcodes.filesystem.ConcurrentAccessException, org.refcodes.filesystem.FileAlreadyExistsException, org.refcodes.filesystem.NoCreateAccessException, org.refcodes.filesystem.NoDeleteAccessException, org.refcodes.filesystem.IllegalNameException, org.refcodes.filesystem.UnknownFileSystemException, IOException, org.refcodes.filesystem.NoListAccessException, org.refcodes.filesystem.IllegalFileHandleException
renameFile
in interface org.refcodes.filesystem.FileSystem
org.refcodes.filesystem.UnknownFileException
org.refcodes.filesystem.ConcurrentAccessException
org.refcodes.filesystem.FileAlreadyExistsException
org.refcodes.filesystem.NoCreateAccessException
org.refcodes.filesystem.NoDeleteAccessException
org.refcodes.filesystem.IllegalNameException
org.refcodes.filesystem.UnknownFileSystemException
IOException
org.refcodes.filesystem.NoListAccessException
org.refcodes.filesystem.IllegalFileHandleException
public org.refcodes.filesystem.FileHandle moveFile(org.refcodes.filesystem.FileHandle aFileHandle, String aNewKey) throws org.refcodes.filesystem.UnknownFileException, org.refcodes.filesystem.ConcurrentAccessException, org.refcodes.filesystem.FileAlreadyExistsException, org.refcodes.filesystem.NoCreateAccessException, org.refcodes.filesystem.NoDeleteAccessException, org.refcodes.filesystem.IllegalKeyException, org.refcodes.filesystem.UnknownFileSystemException, IOException, org.refcodes.filesystem.NoListAccessException, org.refcodes.filesystem.IllegalFileHandleException
moveFile
in interface org.refcodes.filesystem.FileSystem
org.refcodes.filesystem.UnknownFileException
org.refcodes.filesystem.ConcurrentAccessException
org.refcodes.filesystem.FileAlreadyExistsException
org.refcodes.filesystem.NoCreateAccessException
org.refcodes.filesystem.NoDeleteAccessException
org.refcodes.filesystem.IllegalKeyException
org.refcodes.filesystem.UnknownFileSystemException
IOException
org.refcodes.filesystem.NoListAccessException
org.refcodes.filesystem.IllegalFileHandleException
public void deleteFile(org.refcodes.filesystem.FileHandle aFileHandle) throws org.refcodes.filesystem.ConcurrentAccessException, org.refcodes.filesystem.UnknownFileException, org.refcodes.filesystem.NoDeleteAccessException, org.refcodes.filesystem.UnknownFileSystemException, IOException, org.refcodes.filesystem.NoListAccessException, org.refcodes.filesystem.IllegalFileHandleException
deleteFile
in interface org.refcodes.filesystem.FileSystem
org.refcodes.filesystem.ConcurrentAccessException
org.refcodes.filesystem.UnknownFileException
org.refcodes.filesystem.NoDeleteAccessException
org.refcodes.filesystem.UnknownFileSystemException
IOException
org.refcodes.filesystem.NoListAccessException
org.refcodes.filesystem.IllegalFileHandleException
public boolean hasFiles(String aPath, boolean isRecursively) throws org.refcodes.filesystem.NoListAccessException, org.refcodes.filesystem.IllegalPathException, org.refcodes.filesystem.UnknownFileSystemException, IOException
hasFiles
in interface org.refcodes.filesystem.FileSystem
org.refcodes.filesystem.NoListAccessException
org.refcodes.filesystem.IllegalPathException
org.refcodes.filesystem.UnknownFileSystemException
IOException
public List<org.refcodes.filesystem.FileHandle> getFileHandles(String aPath, boolean isRecursively) throws org.refcodes.filesystem.NoListAccessException, org.refcodes.filesystem.UnknownPathException, org.refcodes.filesystem.IllegalPathException, org.refcodes.filesystem.UnknownFileSystemException, IOException
getFileHandles
in interface org.refcodes.filesystem.FileSystem
org.refcodes.filesystem.NoListAccessException
org.refcodes.filesystem.UnknownPathException
org.refcodes.filesystem.IllegalPathException
org.refcodes.filesystem.UnknownFileSystemException
IOException
public void destroy()
destroy
in interface org.refcodes.component.Destroyable
protected String getAmazonS3BucketName()
protected void setAmazonS3BucketName(String aAmazonS3BucketName)
aAmazonS3BucketName
- The bucket name to be used.protected com.amazonaws.services.s3.AmazonS3Client getAmazonS3Client()
public static void createBucket(com.amazonaws.services.s3.AmazonS3 aAmazonS3, String aBucketId)
aAmazonS3
- The AmazonS3
client.aBucketId
- The ID of the bucket to be created.protected static void createBucket(com.amazonaws.services.s3.AmazonS3 aAmazonS3, String aBucketId, String aRegion)
aAmazonS3
- The AmazonS3
client.aBucketId
- The ID of the bucket to be created.aRegion
- The region in the Amazon landscape where to create the
bucket.protected static void clearBucket(com.amazonaws.services.s3.AmazonS3 aAmazonS3, String aBucketId)
aAmazonS3
- The AmazonS3
client.aBucketId
- The ID of the bucket to be cleared.public static void deleteBucket(com.amazonaws.services.s3.AmazonS3 aAmazonS3, String aBucketId)
aAmazonS3
- The AmazonS3
client.aBucketId
- The ID of the bucket to be deleted.protected static com.amazonaws.services.s3.AmazonS3 createAmazonS3(String aAccessKey, String aSecretKey)
AmazonS3
"client".aAccessKey
- The according access key for accessing amazon AWS.aSecretKey
- The secret access key for accessing amazon AWS.AmazonS3
instance.protected static void deleteS3Objects(com.amazonaws.services.s3.AmazonS3 aAmazonS3, String aBucketId, List<com.amazonaws.services.s3.model.S3ObjectSummary> aS3SummaryObjects)
S3ObjectSummary
list
from an S3 bucket.aAmazonS3
- The AmazonS3
client.aBucketId
- The ID of the bucket from which the objects are to be
deleted.aS3SummaryObjects
- The S3ObjectSummary
list describing the
objects to be deleted.protected static com.amazonaws.services.s3.AmazonS3Client getAmazonS3Client(File aConfigFile) throws IOException
AmazonS3Client
from a configuration file containing
the access- and the secret key.aConfigFile
- The configuration file used to configure the
AmazonS3Client
.AmazonS3Client
.IOException
- In case there were problems reading the configuration
file.Copyright © 2018. All rights reserved.