StorageRequest<C,P,R> Class

  • java.lang.Object
    • com.microsoft.azure.storage.core.StorageRequest<C,P,R>

Type Parameters

C

The service client type

P

The type of the parent object, i.e. CloudBlobContainer for downloadAttributes etc.

R

The type of the expected result

public class StorageRequest<C,P,R>

RESERVED FOR INTERNAL USE. A class which encapsulate the execution of a given storage operation.

Constructor Summary

Constructor Description
StorageRequest()

Default Ctor.

StorageRequest(final RequestOptions options, StorageUri storageUri)

Initializes a new instance of the StorageRequest class.

Method Summary

Modifier and Type Method and Description
void applyLocationModeToRequest()
abstract HttpURLConnection buildRequest(C client, P parentObject, OperationContext context)

Function to construct the request.

boolean getArePropertiesPopulated()
final HttpURLConnection getConnection()
final String getContentMD5()
StreamMd5AndLength getCurrentDescriptor()
StorageLocation getCurrentLocation()
long getCurrentRequestByteCount()
AccessCondition getETagLockCondition()
final StorageException getException()
Long getLength()
LocationMode getLocationMode()
final String getLockedETag()
Long getOffset()
RequestLocationMode getRequestLocationMode()
final RequestOptions getRequestOptions()
final RequestResult getResult()
final InputStream getSendStream()
StorageUri getStorageUri()
final void initialize(OperationContext opContext)

Resets the operation status flags between operations.

void initializeLocation()
final boolean isNonExceptionedRetryableFailure()
boolean isSent()
final StorageException materializeException(final OperationContext opContext)

Returns either the held exception from the operation if it is set, otherwise the translated exception.

StorageExtendedErrorInformation parseErrorDetails()

Returns extended error information for this request.

R postProcessResponse(HttpURLConnection connection, P parentObject, C client, OperationContext context, R storageObject)

Post-Stream Retrieval function.

abstract R preProcessResponse(P parentObject, C client, OperationContext context)

Pre-Stream Retrieval function.

void recoveryAction(OperationContext context)

Recovery action for retries.

void setArePropertiesPopulated(boolean arePropertiesPopulated)
final void setConnection(final HttpURLConnection connection)
void setContentMD5(String contentMD5)
void setCurrentDescriptor(StreamMd5AndLength currentDescriptor)
void setCurrentLocation(StorageLocation currentLocation)
void setCurrentRequestByteCount(long currentRequestByteCount)
void setETagLockCondition(AccessCondition etagLockCondition)
final void setException(final StorageException exceptionReference)
void setHeaders(HttpURLConnection connection, P parentObject, OperationContext context)

Function to set custom headers.

void setIsSent(boolean isSent)
void setLength(Long length)
void setLocationMode(LocationMode locationMode)
void setLockedETag(String lockedETag)
final void setNonExceptionedRetryableFailure(final boolean nonExceptionedRetryableFailure)
void setOffset(Long offset)
void setRequestLocationMode()

Function to apply the location mode to the request.

void setRequestLocationMode(RequestLocationMode requestLocationMode)
final void setRequestOptions(final RequestOptions requestOptions)
final void setResult(final RequestResult result)
void setSendStream(InputStream sendStream)
void setStorageUri(StorageUri storageUri)
final String signBlobQueueAndFileRequest(HttpURLConnection request, ServiceClient client, long contentLength, OperationContext context)
abstract void signRequest(HttpURLConnection connection, C client, OperationContext context)

Function to Sign headers.

final void signTableRequest(HttpURLConnection request, ServiceClient client, long contentLength, OperationContext context)
void validateLocation()
void validateStreamWrite(StreamMd5AndLength descriptor)

Validate the written stream length when length is provided.

Constructor Details

StorageRequest

protected StorageRequest()

Default Ctor.

StorageRequest

public StorageRequest(final RequestOptions options, StorageUri storageUri)

Initializes a new instance of the StorageRequest class.

Parameters:

options - the RequestOptions to use
storageUri

Method Details

applyLocationModeToRequest

public void applyLocationModeToRequest()

buildRequest

public abstract HttpURLConnection buildRequest(C client, P parentObject, OperationContext context)

Function to construct the request.

Parameters:

client
parentObject - Parent object, i.e. CloudBlobContainer for downloadAttributes etc.
context - An OperationContext object that represents the context for the current operation. This object is used to track requests to the storage service, and to provide additional runtime information about the operation.

Returns:

a HttpURLConnection configured for the operation.

Throws:

Exception

getArePropertiesPopulated

public boolean getArePropertiesPopulated()

Returns:

the arePropertiesPopulated value

getConnection

public final HttpURLConnection getConnection()

Returns:

the URL connection

getContentMD5

public final String getContentMD5()

Returns:

the ContentMD5

getCurrentDescriptor

protected StreamMd5AndLength getCurrentDescriptor()

Returns:

the current descriptor which contains the stream length and MD5 hash.

getCurrentLocation

public StorageLocation getCurrentLocation()

Returns:

the current location to which the request will be sent.

getCurrentRequestByteCount

public long getCurrentRequestByteCount()

Returns:

the currentRequestByteCount

getETagLockCondition

public AccessCondition getETagLockCondition()

Returns:

the locked ETag condition

getException

public final StorageException getException()

Returns:

the exception

getLength

public Long getLength()

Returns:

the length, in bytes, of the stream

getLocationMode

public LocationMode getLocationMode()

Returns:

the location mode used to decide which location the request should be sent to.

getLockedETag

public final String getLockedETag()

Returns:

the locked ETag

getOffset

public Long getOffset()

Returns:

the offset to start reading from

getRequestLocationMode

public RequestLocationMode getRequestLocationMode()

Returns:

the location mode used to decide which location the request should be sent to.

getRequestOptions

public final RequestOptions getRequestOptions()

Returns:

the requestOptions

getResult

public final RequestResult getResult()

Returns:

the result

getSendStream

public final InputStream getSendStream()

Returns:

the stream to send to server

getStorageUri

public StorageUri getStorageUri()

Returns:

the URI to which the request will be sent.

initialize

protected final void initialize(OperationContext opContext)

Resets the operation status flags between operations.

Parameters:

opContext

initializeLocation

public void initializeLocation()

isNonExceptionedRetryableFailure

public final boolean isNonExceptionedRetryableFailure()

Returns:

the nonExceptionedRetryableFailure

isSent

protected boolean isSent()

Returns:

the isSent value

materializeException

protected final StorageException materializeException(final OperationContext opContext)

Returns either the held exception from the operation if it is set, otherwise the translated exception.

Parameters:

opContext - an object used to track the execution of the operation

Returns:

the exception to throw.

parseErrorDetails

public StorageExtendedErrorInformation parseErrorDetails()

Returns extended error information for this request.

Returns:

A StorageExtendedErrorInformation object that represents the error details for the specified request.

postProcessResponse

public R postProcessResponse(HttpURLConnection connection, P parentObject, C client, OperationContext context, R storageObject)

Post-Stream Retrieval function.

Parameters:

connection - HttpURLConnection configured for the operation.
parentObject
client
context
storageObject - An object of the expected result's type.

Returns:

the expected result of the operation.

Throws:

Exception

preProcessResponse

public abstract R preProcessResponse(P parentObject, C client, OperationContext context)

Pre-Stream Retrieval function.

Parameters:

parentObject - Parent object, i.e. CloudBlobContainer for downloadAttributes etc.
client - The service client.
context - An OperationContext object that represents the context for the current operation. This object is used to track requests to the storage service, and to provide additional runtime information about the operation.

Returns:

an Object of the expected result's type.

Throws:

Exception

recoveryAction

public void recoveryAction(OperationContext context)

Recovery action for retries.

Parameters:

context

Throws:

IOException

setArePropertiesPopulated

public void setArePropertiesPopulated(boolean arePropertiesPopulated)

Parameters:

arePropertiesPopulated - the arePropertiesPopulated value

setConnection

public final void setConnection(final HttpURLConnection connection)

Parameters:

connection - the connection to set

setContentMD5

public void setContentMD5(String contentMD5)

Parameters:

contentMD5 - the contentMD5

setCurrentDescriptor

protected void setCurrentDescriptor(StreamMd5AndLength currentDescriptor)

Parameters:

currentDescriptor - the descriptor value

setCurrentLocation

public void setCurrentLocation(StorageLocation currentLocation)

Parameters:

currentLocation - the currentLocation value

setCurrentRequestByteCount

public void setCurrentRequestByteCount(long currentRequestByteCount)

Parameters:

currentRequestByteCount - the currentRequestByteCount to set

setETagLockCondition

public void setETagLockCondition(AccessCondition etagLockCondition)

Parameters:

etagLockCondition - the locked ETag condition

setException

protected final void setException(final StorageException exceptionReference)

Parameters:

exceptionReference - the exception to set

setHeaders

public void setHeaders(HttpURLConnection connection, P parentObject, OperationContext context)

Function to set custom headers.

Parameters:

connection - HttpURLConnection configured for the operation.
parentObject - Parent object, i.e. CloudBlobContainer for downloadAttributes etc.
context - An OperationContext object that represents the context for the current operation. This object is used to track requests to the storage service, and to provide additional runtime information about the operation.

setIsSent

protected void setIsSent(boolean isSent)

Parameters:

isSent - the isSent value

setLength

public void setLength(Long length)

Parameters:

length - the length, in bytes, of the stream

setLocationMode

public void setLocationMode(LocationMode locationMode)

Parameters:

locationMode - the locationMode value

setLockedETag

public void setLockedETag(String lockedETag)

Parameters:

lockedETag - the locked ETag

setNonExceptionedRetryableFailure

public final void setNonExceptionedRetryableFailure(final boolean nonExceptionedRetryableFailure)

Parameters:

nonExceptionedRetryableFailure - the nonExceptionedRetryableFailure to set

setOffset

public void setOffset(Long offset)

Parameters:

offset - the stream offset to start copying from

setRequestLocationMode

public void setRequestLocationMode()

Function to apply the location mode to the request.

setRequestLocationMode

public void setRequestLocationMode(RequestLocationMode requestLocationMode)

Parameters:

requestLocationMode - the requestLocationMode value

setRequestOptions

protected final void setRequestOptions(final RequestOptions requestOptions)

Parameters:

requestOptions - the requestOptions to set

setResult

public final void setResult(final RequestResult result)

Parameters:

result - the result to set

setSendStream

public void setSendStream(InputStream sendStream)

Parameters:

sendStream - the stream to send to the server

setStorageUri

public void setStorageUri(StorageUri storageUri)

Parameters:

storageUri - the storageUri value

signBlobQueueAndFileRequest

public static final String signBlobQueueAndFileRequest(HttpURLConnection request, ServiceClient client, long contentLength, OperationContext context)

Parameters:

request
client
contentLength
context

signRequest

public abstract void signRequest(HttpURLConnection connection, C client, OperationContext context)

Function to Sign headers.

Parameters:

connection - HttpURLConnection configured for the operation.
client - The service client.
context - An OperationContext object that represents the context for the current operation. This object is used to track requests to the storage service, and to provide additional runtime information about the operation.

Throws:

Exception

signTableRequest

public static final void signTableRequest(HttpURLConnection request, ServiceClient client, long contentLength, OperationContext context)

Parameters:

request
client
contentLength
context

validateLocation

public void validateLocation()

validateStreamWrite

public void validateStreamWrite(StreamMd5AndLength descriptor)

Validate the written stream length when length is provided.

Parameters:

descriptor

Throws:

StorageException

Applies to