public class EsuRestApiApache extends AbstractEsuRestApi
context, host, port, proto, readChecksum, secret, uid, unicodeEnabled
Constructor and Description |
---|
EsuRestApiApache(java.lang.String host,
int port,
java.lang.String uid,
java.lang.String sharedSecret)
Creates a new EsuRestApiApache object.
|
Modifier and Type | Method and Description |
---|---|
long |
calculateServerOffset()
Makes a request to the server to get the value of the response Date
header.
|
ObjectId |
createObjectFromSegment(Acl acl,
MetadataList metadata,
BufferSegment data,
java.lang.String mimeType,
Checksum checksum)
Creates a new object in the cloud using a BufferSegment.
|
ObjectId |
createObjectFromSegmentOnPath(ObjectPath path,
Acl acl,
MetadataList metadata,
BufferSegment data,
java.lang.String mimeType,
Checksum checksum)
Creates a new object in the cloud using a BufferSegment on the given
path.
|
ObjectId |
createObjectFromStream(Acl acl,
MetadataList metadata,
java.io.InputStream data,
long length,
java.lang.String mimeType)
Creates a new object in the cloud.
|
ObjectId |
createObjectFromStreamOnPath(ObjectPath path,
Acl acl,
MetadataList metadata,
java.io.InputStream data,
long length,
java.lang.String mimeType)
Creates a new object in the cloud.
|
ObjectId |
createObjectWithKeyFromSegment(java.lang.String keyPool,
java.lang.String key,
Acl acl,
MetadataList metadata,
BufferSegment data,
java.lang.String mimeType,
Checksum checksum)
Creates a new object in the cloud using a BufferSegment.
|
ObjectId |
createObjectWithKeyFromStream(java.lang.String keyPool,
java.lang.String key,
Acl acl,
MetadataList metadata,
java.io.InputStream data,
long length,
java.lang.String mimeType)
Creates a new object in the cloud.
|
void |
deleteObject(Identifier id)
Deletes an object from the cloud.
|
void |
deleteObjectWithKey(java.lang.String keyPool,
java.lang.String key)
Deletes an object from the cloud.
|
void |
deleteUserMetadata(Identifier id,
MetadataTags tags)
Deletes metadata items from an object.
|
void |
deleteVersion(ObjectId id)
Deletes a version of an object from the cloud.
|
Acl |
getAcl(Identifier id)
Returns an object's ACL
|
ObjectMetadata |
getAllMetadata(Identifier id)
Returns all of an object's metadata and its ACL in
one call.
|
ObjectMetadata |
getAllMetadata(java.lang.String keyPool,
java.lang.String key)
Returns all of an object's metadata and its ACL in
one call.
|
MetadataTags |
getListableTags(MetadataTag tag)
Returns a list of the tags that are listable the current user's tennant.
|
MetadataTags |
getListableTags(java.lang.String tag)
Returns a list of the tags that are listable the current user's tennant.
|
ObjectInfo |
getObjectInfo(Identifier id)
Get information about an object's state including
replicas, expiration, and retention.
|
ServiceInformation |
getServiceInformation()
Gets the current Atmos server information.
|
MetadataList |
getSystemMetadata(Identifier id,
MetadataTags tags)
Fetches the system metadata for the object.
|
MetadataList |
getSystemMetadata(java.lang.String keyPool,
java.lang.String key,
MetadataTags tags)
Fetches the system metadata for the object.
|
MetadataList |
getUserMetadata(Identifier id,
MetadataTags tags)
Fetches the user metadata for the object.
|
void |
hardLink(ObjectPath source,
ObjectPath target)
Unsupported.
|
java.util.List<DirectoryEntry> |
listDirectory(ObjectPath path,
ListOptions options)
Lists the contents of a directory.
|
java.util.List<ObjectResult> |
listObjects(java.lang.String tag,
ListOptions options)
Lists all objects with the given tag.
|
MetadataTags |
listUserMetadataTags(Identifier id)
Returns the list of user metadata tags assigned to the object.
|
java.util.List<Identifier> |
listVersions(Identifier id)
Lists the versions of an object.
|
java.util.List<Version> |
listVersions(ObjectId id,
ListOptions options)
Lists the versions of an object.
|
java.util.List<ObjectId> |
queryObjects(java.lang.String xquery)
Executes a query for objects matching the specified XQuery string.
|
byte[] |
readObject(Identifier id,
Extent extent,
byte[] buffer,
Checksum checksum)
Reads an object's content.
|
java.io.InputStream |
readObjectStream(Identifier id,
Extent extent)
Reads an object's content and returns an InputStream to read the content.
|
java.io.InputStream |
readObjectStreamWithKey(java.lang.String keyPool,
java.lang.String key,
Extent extent)
Reads an object's content and returns an InputStream to read the content.
|
byte[] |
readObjectWithKey(java.lang.String keyPool,
java.lang.String key,
Extent extent,
byte[] buffer,
Checksum checksum)
Reads an object's content.
|
void |
rename(ObjectPath source,
ObjectPath destination,
boolean force)
Renames a file or directory within the namespace.
|
void |
restoreVersion(ObjectId id,
ObjectId vId)
Restores a version of an object to the base version (i.e.
|
void |
setAcl(Identifier id,
Acl acl)
Sets (overwrites) the ACL on the object.
|
void |
setProxy(java.lang.String host,
int port,
boolean https) |
void |
setProxy(java.lang.String host,
int port,
boolean https,
java.lang.String username,
java.lang.String password) |
void |
setUserMetadata(Identifier id,
MetadataList metadata)
Writes the metadata into the object.
|
void |
updateObjectFromSegment(Identifier id,
Acl acl,
MetadataList metadata,
Extent extent,
BufferSegment data,
java.lang.String mimeType,
Checksum checksum)
Updates an object in the cloud and optionally its metadata and ACL.
|
void |
updateObjectFromStream(Identifier id,
Acl acl,
MetadataList metadata,
Extent extent,
java.io.InputStream data,
long length,
java.lang.String mimeType)
Updates an object in the cloud.
|
void |
updateObjectWithKeyFromSegment(java.lang.String keyPool,
java.lang.String key,
Acl acl,
MetadataList metadata,
Extent extent,
BufferSegment data,
java.lang.String mimeType,
Checksum checksum)
Updates an object in the cloud using a portion of a buffer.
|
void |
updateObjectWithKeyFromStream(java.lang.String keyPool,
java.lang.String key,
Acl acl,
MetadataList metadata,
Extent extent,
java.io.InputStream data,
long length,
java.lang.String mimeType)
Updates an object in the cloud.
|
ObjectId |
versionObject(Identifier id)
Creates a new immutable version of an object.
|
buildUrl, createObject, createObject, createObjectFromSegment, createObjectFromSegmentOnPath, createObjectOnPath, createObjectOnPath, createObjectWithKey, createObjectWithKey, createObjectWithKeyFromSegment, decodeUtf8, encodeUtf8, formatTag, getContext, getDateHeader, getObjectId, getProtocol, getResourcePath, getServerOffset, getShareableUrl, getShareableUrl, isReadChecksum, isUnicodeEnabled, join, listDirectory, listObjects, listObjects, listObjects, listObjectsWithMetadata, listObjectsWithMetadata, normalizeSpace, parseDirectoryListing, parseObjectList, parseObjectListWithMetadata, parseServiceInformation, parseVersionList, parseVersionListLong, processAcl, processMetadata, processTags, readAcl, readMetadata, readObject, readObjectWithKey, readStream, readTags, setContext, setProtocol, setReadChecksum, setServerOffset, setUnicodeEnabled, sign, sign, silentClose, updateObject, updateObject, updateObjectFromSegment, updateObjectWithKey, updateObjectWithKey, updateObjectWithKeyFromSegment
public EsuRestApiApache(java.lang.String host, int port, java.lang.String uid, java.lang.String sharedSecret)
host
- the hostname or IP address of the ESU serverport
- the port on the server to communicate with. Generally this is
80 for HTTP and 443 for HTTPS.uid
- the username to use when connecting to the serversharedSecret
- the Base64 encoded shared secret to use to sign
requests to the server.public void setProxy(java.lang.String host, int port, boolean https)
public void setProxy(java.lang.String host, int port, boolean https, java.lang.String username, java.lang.String password)
public ObjectId createObjectFromStreamOnPath(ObjectPath path, Acl acl, MetadataList metadata, java.io.InputStream data, long length, java.lang.String mimeType)
path
- The path to create the object on.acl
- Access control list for the new object. May be null
to use a default ACLmetadata
- Metadata for the new object. May be null for
no metadata.data
- The initial contents of the object. May be appended
to later. The stream will NOT be closed at the end of the request.length
- The length of the stream in bytes. If the stream
is longer than the length, only length bytes will be written. If
the stream is shorter than the length, an error will occur.mimeType
- the MIME type of the content. Optional,
may be null. If data is non-null and mimeType is null, the MIME
type will default to application/octet-stream.EsuException
- if the request fails.public ObjectId createObjectFromStream(Acl acl, MetadataList metadata, java.io.InputStream data, long length, java.lang.String mimeType)
acl
- Access control list for the new object. May be null to use a
default ACLmetadata
- Metadata for the new object. May be null for no metadata.data
- The initial contents of the object. May be appended to later.
The stream will NOT be closed at the end of the request.length
- The length of the stream in bytes. If the stream is longer
than the length, only length bytes will be written. If the
stream is shorter than the length, an error will occur.mimeType
- the MIME type of the content. Optional, may be null. If
data is non-null and mimeType is null, the MIME type will
default to application/octet-stream.EsuException
- if the request fails.public ObjectId createObjectFromSegment(Acl acl, MetadataList metadata, BufferSegment data, java.lang.String mimeType, Checksum checksum)
acl
- Access control list for the new object. May be null to use a
default ACLmetadata
- Metadata for the new object. May be null for no metadata.data
- The initial contents of the object. May be appended to later.
May be null to create an object with no content.mimeType
- the MIME type of the content. Optional, may be null. If
data is non-null and mimeType is null, the MIME type will
default to application/octet-stream.checksum
- if not null, use the Checksum object to compute
the checksum for the create object request. If appending
to the object with subsequent requests, use the same
checksum object for each request.EsuException
- if the request fails.public ObjectId createObjectFromSegmentOnPath(ObjectPath path, Acl acl, MetadataList metadata, BufferSegment data, java.lang.String mimeType, Checksum checksum)
path
- the path to create the object on.acl
- Access control list for the new object. May be null to use a
default ACLmetadata
- Metadata for the new object. May be null for no metadata.data
- The initial contents of the object. May be appended to later.
May be null to create an object with no content.mimeType
- the MIME type of the content. Optional, may be null. If
data is non-null and mimeType is null, the MIME type will
default to application/octet-stream.checksum
- if not null, use the Checksum object to compute
the checksum for the create object request. If appending
to the object with subsequent requests, use the same
checksum object for each request.EsuException
- if the request fails.public void deleteObject(Identifier id)
id
- the identifier of the object to delete.public void deleteVersion(ObjectId id)
id
- the identifier of the object to delete.public void deleteUserMetadata(Identifier id, MetadataTags tags)
id
- the identifier of the object whose metadata to delete.tags
- the list of metadata tags to delete.public Acl getAcl(Identifier id)
id
- the identifier of the object whose ACL to readpublic MetadataTags getListableTags(MetadataTag tag)
tag
- optional. If specified, the list will be limited to the tags
under the specified tag. If null, only top level tags will be
returned.public MetadataTags getListableTags(java.lang.String tag)
tag
- optional. If specified, the list will be limited to the tags
under the specified tag. If null, only top level tags will be
returned.public MetadataList getSystemMetadata(Identifier id, MetadataTags tags)
id
- the identifier of the object whose system metadata to fetch.tags
- A list of system metadata tags to fetch. Optional. Default
value is null to fetch all system metadata.public MetadataList getUserMetadata(Identifier id, MetadataTags tags)
id
- the identifier of the object whose user metadata to fetch.tags
- A list of user metadata tags to fetch. Optional. If null, all
user metadata will be fetched.public java.util.List<ObjectResult> listObjects(java.lang.String tag, ListOptions options)
tag
- the tag to search foroptions
- options for returning the listpublic MetadataTags listUserMetadataTags(Identifier id)
id
- the object whose metadata tags to listpublic java.util.List<Identifier> listVersions(Identifier id)
id
- the object whose versions to list.public java.util.List<Version> listVersions(ObjectId id, ListOptions options)
EsuApi
id
- the object whose versions to list.public java.util.List<ObjectId> queryObjects(java.lang.String xquery)
xquery
- the XQuery string to execute against the cloud.public byte[] readObject(Identifier id, Extent extent, byte[] buffer, Checksum checksum)
id
- the identifier of the object whose content to read.extent
- the portion of the object data to read. Optional. Default
is null to read the entire object.buffer
- the buffer to use to read the extent. Must be large enough
to read the response or an error will be thrown. If null, a
buffer will be allocated to hold the response data. If you
pass a buffer that is larger than the extent, only
extent.getSize() bytes will be valid.checksum
- if not null, the given checksum object will be used
to verify checksums during the read operation. Note that only erasure
coded objects will return checksums *and* if you're reading the object
in chunks, you'll have to read the data back sequentially to keep
the checksum consistent. If the read operation does not return
a checksum from the server, the checksum operation will be skipped.public java.io.InputStream readObjectStream(Identifier id, Extent extent)
id
- the identifier of the object whose content to read.extent
- the portion of the object data to read. Optional. Default
is null to read the entire object.public void updateObjectFromSegment(Identifier id, Acl acl, MetadataList metadata, Extent extent, BufferSegment data, java.lang.String mimeType, Checksum checksum)
id
- The ID of the object to updateacl
- Access control list for the new object. Optional, default is
NULL to leave the ACL unchanged.metadata
- Metadata list for the new object. Optional, default is
NULL for no changes to the metadata.data
- The new contents of the object. May be appended to later.
Optional, default is NULL (no content changes).extent
- portion of the object to update. May be null to indicate
the whole object is to be replaced. If not null, the extent
size must match the data size.mimeType
- the MIME type of the content. Optional, may be null. If
data is non-null and mimeType is null, the MIME type will
default to application/octet-stream.checksum
- if not null, use the Checksum object to compute
the checksum for the update object request. If appending
to the object with subsequent requests, use the same
checksum object for each request.EsuException
- if the request fails.public void updateObjectFromStream(Identifier id, Acl acl, MetadataList metadata, Extent extent, java.io.InputStream data, long length, java.lang.String mimeType)
id
- The ID of the object to updateacl
- Access control list for the new object. Optional, default is
NULL to leave the ACL unchanged.metadata
- Metadata list for the new object. Optional, default is
NULL for no changes to the metadata.data
- The updated data to apply to the object. Requred. Note that
the input stream is NOT closed at the end of the request.extent
- portion of the object to update. May be null to indicate
the whole object is to be replaced. If not null, the extent
size must match the data size.length
- The length of the stream in bytes. If the stream is longer
than the length, only length bytes will be written. If the
stream is shorter than the length, an error will occur.mimeType
- the MIME type of the content. Optional, may be null. If
data is non-null and mimeType is null, the MIME type will
default to application/octet-stream.EsuException
- if the request fails.public void setUserMetadata(Identifier id, MetadataList metadata)
id
- the identifier of the object to updatemetadata
- metadata to write to the object.public void setAcl(Identifier id, Acl acl)
id
- the identifier of the object to change the ACL on.acl
- the new ACL for the object.public ObjectId versionObject(Identifier id)
id
- the object to versionpublic java.util.List<DirectoryEntry> listDirectory(ObjectPath path, ListOptions options)
path
- the path to list. Must be a directory.options
- options for returning the list.public ObjectMetadata getAllMetadata(Identifier id)
EsuApi
id
- the object's identifier.public ServiceInformation getServiceInformation()
EsuApi
public void rename(ObjectPath source, ObjectPath destination, boolean force)
source
- The file or directory to renamedestination
- The new path for the file or directoryforce
- If true, the desination file or
directory will be overwritten. Directories must be empty to be
overwritten. Also note that overwrite operations on files are
not synchronous; a delay may be required before the object is
available at its destination.public void restoreVersion(ObjectId id, ObjectId vId)
id
- Base object ID (target of the restore)vId
- Version object ID to restorepublic ObjectInfo getObjectInfo(Identifier id)
id
- the object identifierpublic long calculateServerOffset()
AbstractEsuRestApi
calculateServerOffset
in class AbstractEsuRestApi
public ObjectId createObjectWithKeyFromSegment(java.lang.String keyPool, java.lang.String key, Acl acl, MetadataList metadata, BufferSegment data, java.lang.String mimeType, Checksum checksum)
EsuApi
keyPool
- A name which represents the keyspace for this key. A pool is analogous
to an S3 bucket and two objects with the same name can exist in different pools.key
- The key that uniquely identifies this object within its keyPool.acl
- Access control list for the new object. May be null
to use a default ACLmetadata
- Metadata for the new object. May be null for
no metadata.data
- The initial contents of the object. May be appended
to later. May be null to create an object with no content.mimeType
- the MIME type of the content. Optional,
may be null. If data is non-null and mimeType is null, the MIME
type will default to application/octet-stream.checksum
- if not null, use the Checksum object to compute
the checksum for the create object request. If appending
to the object with subsequent requests, use the same
checksum object for each request.public void hardLink(ObjectPath source, ObjectPath target)
EsuApi
public ObjectId createObjectWithKeyFromStream(java.lang.String keyPool, java.lang.String key, Acl acl, MetadataList metadata, java.io.InputStream data, long length, java.lang.String mimeType)
EsuApi
keyPool
- A name which represents the keyspace for this key. A pool is analogous
to an S3 bucket and two objects with the same name can exist in different pools.key
- The key that uniquely identifies this object within its keyPool.acl
- Access control list for the new object. May be null
to use a default ACLmetadata
- Metadata for the new object. May be null for
no metadata.data
- The initial contents of the object. May be appended
to later. The stream will NOT be closed at the end of the request.length
- The length of the stream in bytes. If the stream
is longer than the length, only length bytes will be written. If
the stream is shorter than the length, an error will occur.mimeType
- the MIME type of the content. Optional,
may be null. If data is non-null and mimeType is null, the MIME
type will default to application/octet-stream.public void deleteObjectWithKey(java.lang.String keyPool, java.lang.String key)
EsuApi
keyPool
- A name which represents the keyspace for this key. A pool is analogous
to an S3 bucket and two objects with the same name can exist in different pools.key
- The key that uniquely identifies this object within its keyPool.public ObjectMetadata getAllMetadata(java.lang.String keyPool, java.lang.String key)
EsuApi
keyPool
- A name which represents the keyspace for this key. A pool is analogous
to an S3 bucket and two objects with the same name can exist in different pools.key
- The key that uniquely identifies this object within its keyPool.public MetadataList getSystemMetadata(java.lang.String keyPool, java.lang.String key, MetadataTags tags)
EsuApi
keyPool
- A name which represents the keyspace for this key. A pool is analogous
to an S3 bucket and two objects with the same name can exist in different pools.key
- The key that uniquely identifies this object within its keyPool.tags
- A list of system metadata tags to fetch. Optional.
Default value is null to fetch all system metadata.public byte[] readObjectWithKey(java.lang.String keyPool, java.lang.String key, Extent extent, byte[] buffer, Checksum checksum)
EsuApi
keyPool
- A name which represents the keyspace for this key. A pool is analogous
to an S3 bucket and two objects with the same name can exist in different pools.key
- The key that uniquely identifies this object within its keyPool.extent
- the portion of the object data to read. Optional.
Default is null to read the entire object.buffer
- the buffer to use to read the extent. Must be large
enough to read the response or an error will be thrown. If null,
a buffer will be allocated to hold the response data. If you pass
a buffer that is larger than the extent, only extent.getSize() bytes
will be valid.checksum
- if not null, the given checksum object will be used
to verify checksums during the read operation. Note that only erasure
coded objects will return checksums *and* if you're reading the object
in chunks, you'll have to read the data back sequentially to keep
the checksum consistent. If the read operation does not return
a checksum from the server, the checksum operation will be skipped.public java.io.InputStream readObjectStreamWithKey(java.lang.String keyPool, java.lang.String key, Extent extent)
EsuApi
keyPool
- A name which represents the keyspace for this key. A pool is analogous
to an S3 bucket and two objects with the same name can exist in different pools.key
- The key that uniquely identifies this object within its keyPool.extent
- the portion of the object data to read. Optional.
Default is null to read the entire object.public void updateObjectWithKeyFromStream(java.lang.String keyPool, java.lang.String key, Acl acl, MetadataList metadata, Extent extent, java.io.InputStream data, long length, java.lang.String mimeType)
EsuApi
keyPool
- A name which represents the keyspace for this key. A pool is analogous
to an S3 bucket and two objects with the same name can exist in different pools.key
- The key that uniquely identifies this object within its keyPool.acl
- Access control list for the new object. Optional, default
is NULL to leave the ACL unchanged.metadata
- Metadata list for the new object. Optional,
default is NULL for no changes to the metadata.extent
- portion of the object to update. May be null to indicate
the whole object is to be replaced. If not null, the extent size must
match the data size.data
- The new contents of the object. May be appended
to later. Optional, default is NULL (no content changes).length
- The length of the stream in bytes. If the stream
is longer than the length, only length bytes will be written. If
the stream is shorter than the length, an error will occur.mimeType
- the MIME type of the content. Optional,
may be null. If data is non-null and mimeType is null, the MIME
type will default to application/octet-stream.public void updateObjectWithKeyFromSegment(java.lang.String keyPool, java.lang.String key, Acl acl, MetadataList metadata, Extent extent, BufferSegment data, java.lang.String mimeType, Checksum checksum)
EsuApi
keyPool
- A name which represents the keyspace for this key. A pool is analogous
to an S3 bucket and two objects with the same name can exist in different pools.key
- The key that uniquely identifies this object within its keyPool.acl
- Access control list for the new object. Optional, default
is NULL to leave the ACL unchanged.metadata
- Metadata list for the new object. Optional,
default is NULL for no changes to the metadata.extent
- portion of the object to update. May be null to indicate
the whole object is to be replaced. If not null, the extent size must
match the data size.data
- The new contents of the object. May be appended
to later. Optional, default is NULL (no content changes).mimeType
- the MIME type of the content. Optional,
may be null. If data is non-null and mimeType is null, the MIME
type will default to application/octet-stream.checksum
- if not null, use the Checksum object to compute
the checksum for the update object request. If appending
to the object with subsequent requests, use the same
checksum object for each request.