本文整理汇总了Java中com.microsoft.azure.storage.AccessCondition.applyConditionToRequest方法的典型用法代码示例。如果您正苦于以下问题:Java AccessCondition.applyConditionToRequest方法的具体用法?Java AccessCondition.applyConditionToRequest怎么用?Java AccessCondition.applyConditionToRequest使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.microsoft.azure.storage.AccessCondition
的用法示例。
在下文中一共展示了AccessCondition.applyConditionToRequest方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: abortCopy
import com.microsoft.azure.storage.AccessCondition; //导入方法依赖的package包/类
/**
* Generates a web request to abort a copy operation.
*
* @param uri
* A <code>java.net.URI</code> object that specifies the absolute URI.
* @param fileOptions
* A {@link FileRequestOptions} object that specifies execution options such as retry policy and timeout
* settings for the operation. Specify <code>null</code> to use the request options specified on the
* {@link CloudFileClient}.
* @param opContext
* An {@link 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.
* @param accessCondition
* The access condition to apply to the request. Only lease conditions are supported for this operation.
* @param copyId
* A <code>String</code> object that identifying the copy operation.
* @return a <code>HttpURLConnection</code> configured for the operation.
* @throws StorageException
* An exception representing any error which occurred during the operation.
* @throws IllegalArgumentException
* @throws IOException
* @throws URISyntaxException
*/
public static HttpURLConnection abortCopy(final URI uri, final FileRequestOptions fileOptions,
final OperationContext opContext, final AccessCondition accessCondition, final String copyId)
throws StorageException, IOException, URISyntaxException {
final UriQueryBuilder builder = new UriQueryBuilder();
builder.add(Constants.QueryConstants.COMPONENT, Constants.QueryConstants.COPY);
builder.add(Constants.QueryConstants.COPY_ID, copyId);
final HttpURLConnection request = BaseRequest.createURLConnection(uri, fileOptions, builder, opContext);
request.setFixedLengthStreamingMode(0);
request.setDoOutput(true);
request.setRequestMethod(Constants.HTTP_PUT);
request.setRequestProperty(Constants.HeaderConstants.COPY_ACTION_HEADER,
Constants.HeaderConstants.COPY_ACTION_ABORT);
if (accessCondition != null) {
accessCondition.applyConditionToRequest(request);
}
return request;
}
示例2: deleteBlob
import com.microsoft.azure.storage.AccessCondition; //导入方法依赖的package包/类
/**
* Constructs a HttpURLConnection to delete the blob, Sign with no length specified.
*
* @param uri
* A <code>java.net.URI</code> object that specifies the absolute URI.
* @param blobOptions
* A {@link BlobRequestOptions} object that specifies execution options such as retry policy and timeout
* settings for the operation. Specify <code>null</code> to use the request options specified on the
* {@link CloudBlobClient}.
* @param opContext
* An {@link 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.
* @param accessCondition
* An {@link AccessCondition} object that represents the access conditions for the blob.
* @param snapshotVersion
* The snapshot version, if the blob is a snapshot.
* @param deleteSnapshotsOption
* A set of options indicating whether to delete only blobs, only snapshots, or both.
* @return a HttpURLConnection to use to perform the operation.
* @throws IOException
* if there is an error opening the connection
* @throws URISyntaxException
* if the resource URI is invalid
* @throws StorageException
* an exception representing any error which occurred during the operation.
* @throws IllegalArgumentException
*/
public static HttpURLConnection deleteBlob(final URI uri, final BlobRequestOptions blobOptions,
final OperationContext opContext, final AccessCondition accessCondition, final String snapshotVersion,
final DeleteSnapshotsOption deleteSnapshotsOption) throws IOException, URISyntaxException, StorageException {
if (snapshotVersion != null && deleteSnapshotsOption != DeleteSnapshotsOption.NONE) {
throw new IllegalArgumentException(String.format(SR.DELETE_SNAPSHOT_NOT_VALID_ERROR,
"deleteSnapshotsOption", "snapshot"));
}
final UriQueryBuilder builder = new UriQueryBuilder();
BlobRequest.addSnapshot(builder, snapshotVersion);
final HttpURLConnection request = BaseRequest.delete(uri, blobOptions, builder, opContext);
if (accessCondition != null) {
accessCondition.applyConditionToRequest(request);
}
switch (deleteSnapshotsOption) {
case NONE:
// nop
break;
case INCLUDE_SNAPSHOTS:
request.setRequestProperty(Constants.HeaderConstants.DELETE_SNAPSHOT_HEADER,
BlobConstants.INCLUDE_SNAPSHOTS_VALUE);
break;
case DELETE_SNAPSHOTS_ONLY:
request.setRequestProperty(Constants.HeaderConstants.DELETE_SNAPSHOT_HEADER,
BlobConstants.SNAPSHOTS_ONLY_VALUE);
break;
default:
break;
}
return request;
}
示例3: putBlob
import com.microsoft.azure.storage.AccessCondition; //导入方法依赖的package包/类
/**
* Constructs a HttpURLConnection to upload a blob. Sign with blob length, or -1 for pageblob create.
*
* @param uri
* A <code>java.net.URI</code> object that specifies the absolute URI.
* @param blobOptions
* A {@link BlobRequestOptions} object that specifies execution options such as retry policy and timeout
* settings for the operation. Specify <code>null</code> to use the request options specified on the
* {@link CloudBlobClient}.
* @param opContext
* An {@link 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.
* @param accessCondition
* An {@link AccessCondition} object that represents the access conditions for the blob.
* @param properties
* The properties to set for the blob.
* @param blobType
* The type of the blob.
* @param pageBlobSize
* For a page blob, the size of the blob. This parameter is ignored for block blobs.
* @return a HttpURLConnection to use to perform the operation.
* @throws IOException
* if there is an error opening the connection
* @throws URISyntaxException
* if the resource URI is invalid
* @throws StorageException
* an exception representing any error which occurred during the operation.
* @throws IllegalArgumentException
*/
public static HttpURLConnection putBlob(final URI uri, final BlobRequestOptions blobOptions,
final OperationContext opContext, final AccessCondition accessCondition, final BlobProperties properties,
final BlobType blobType, final long pageBlobSize) throws IOException, URISyntaxException, StorageException {
if (blobType == BlobType.UNSPECIFIED) {
throw new IllegalArgumentException(SR.BLOB_TYPE_NOT_DEFINED);
}
final HttpURLConnection request = createURLConnection(uri, null, blobOptions, opContext);
request.setDoOutput(true);
request.setRequestMethod(Constants.HTTP_PUT);
addProperties(request, properties);
if (blobType == BlobType.PAGE_BLOB) {
request.setFixedLengthStreamingMode(0);
request.setRequestProperty(Constants.HeaderConstants.CONTENT_LENGTH, "0");
request.setRequestProperty(BlobConstants.BLOB_TYPE_HEADER, BlobConstants.PAGE_BLOB);
request.setRequestProperty(BlobConstants.SIZE, String.valueOf(pageBlobSize));
properties.setLength(pageBlobSize);
}
else {
request.setRequestProperty(BlobConstants.BLOB_TYPE_HEADER, BlobConstants.BLOCK_BLOB);
}
if (accessCondition != null) {
accessCondition.applyConditionToRequest(request);
}
return request;
}
示例4: lease
import com.microsoft.azure.storage.AccessCondition; //导入方法依赖的package包/类
/**
* Constructs a HttpURLConnection to Acquire,Release,Break, or Renew a blob/container lease. Sign with 0 length.
*
* @param uri
* A <code>java.net.URI</code> object that specifies the absolute URI.
* @param blobOptions
* A {@link BlobRequestOptions} object that specifies execution options such as retry policy and timeout
* settings for the operation. Specify <code>null</code> to use the request options specified on the
* {@link CloudBlobClient}.
* @param opContext
* An {@link 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.
* @param accessCondition
* An {@link AccessCondition} object that represents the access conditions for the blob.
* @param action
* the LeaseAction to perform
* @param proposedLeaseId
* A <code>String</code> that represents the proposed lease ID for the new lease,
* or null if no lease ID is proposed.
* @param breakPeriodInSeconds
* Specifies the amount of time to allow the lease to remain, in seconds.
* If null, the break period is the remainder of the current lease, or zero for infinite leases.
* @param visibilityTimeoutInSeconds
* Specifies the the span of time for which to acquire the lease, in seconds.
* If null, an infinite lease will be acquired. If not null, this must be greater than zero.
* @return a HttpURLConnection to use to perform the operation.
* @throws IOException
* if there is an error opening the connection
* @throws URISyntaxException
* if the resource URI is invalid
* @throws StorageException
* an exception representing any error which occurred during the operation.
* @throws IllegalArgumentException
*/
private static HttpURLConnection lease(final URI uri, final BlobRequestOptions blobOptions,
final OperationContext opContext, final AccessCondition accessCondition, final LeaseAction action,
final Integer leaseTimeInSeconds, final String proposedLeaseId, final Integer breakPeriodInSeconds,
final UriQueryBuilder builder) throws IOException, URISyntaxException, StorageException {
final HttpURLConnection request = createURLConnection(uri, builder, blobOptions, opContext);
request.setDoOutput(true);
request.setRequestMethod(Constants.HTTP_PUT);
request.setFixedLengthStreamingMode(0);
request.setRequestProperty(HeaderConstants.LEASE_ACTION_HEADER, action.toString());
// Lease duration should only be sent for acquire.
if (action == LeaseAction.ACQUIRE) {
// Assert lease duration is in bounds
if (leaseTimeInSeconds != null && leaseTimeInSeconds != -1) {
Utility.assertInBounds("leaseTimeInSeconds", leaseTimeInSeconds, Constants.LEASE_DURATION_MIN,
Constants.LEASE_DURATION_MAX);
}
request.setRequestProperty(HeaderConstants.LEASE_DURATION, leaseTimeInSeconds == null ? "-1"
: leaseTimeInSeconds.toString());
}
if (proposedLeaseId != null) {
request.setRequestProperty(HeaderConstants.PROPOSED_LEASE_ID_HEADER, proposedLeaseId);
}
if (breakPeriodInSeconds != null) {
// Assert lease break period is in bounds
Utility.assertInBounds("breakPeriodInSeconds", breakPeriodInSeconds, Constants.LEASE_BREAK_PERIOD_MIN,
Constants.LEASE_BREAK_PERIOD_MAX);
request.setRequestProperty(HeaderConstants.LEASE_BREAK_PERIOD_HEADER, breakPeriodInSeconds.toString());
}
if (accessCondition != null) {
accessCondition.applyConditionToRequest(request);
}
return request;
}
示例5: setBlobProperties
import com.microsoft.azure.storage.AccessCondition; //导入方法依赖的package包/类
/**
* Constructs a HttpURLConnection to set the blob's properties, Sign with zero length specified.
*
* @param uri
* A <code>java.net.URI</code> object that specifies the absolute URI.
* @param blobOptions
* A {@link BlobRequestOptions} object that specifies execution options such as retry policy and timeout
* settings for the operation. Specify <code>null</code> to use the request options specified on the
* {@link CloudBlobClient}.
* @param opContext
* An {@link 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.
* @param accessCondition
* An {@link AccessCondition} object that represents the access conditions for the blob.
* @param properties
* The properties to upload.
* @return a HttpURLConnection to use to perform the operation.
* @throws IOException
* if there is an error opening the connection
* @throws URISyntaxException
* if the resource URI is invalid
* @throws StorageException
* an exception representing any error which occurred during the operation.
* @throws IllegalArgumentException
*/
public static HttpURLConnection setBlobProperties(final URI uri, final BlobRequestOptions blobOptions,
final OperationContext opContext, final AccessCondition accessCondition, final BlobProperties properties)
throws IOException, URISyntaxException, StorageException {
final UriQueryBuilder builder = new UriQueryBuilder();
builder.add(Constants.QueryConstants.COMPONENT, Constants.QueryConstants.PROPERTIES);
final HttpURLConnection request = createURLConnection(uri, builder, blobOptions, opContext);
request.setFixedLengthStreamingMode(0);
request.setDoOutput(true);
request.setRequestMethod(Constants.HTTP_PUT);
if (accessCondition != null) {
accessCondition.applyConditionToRequest(request);
}
if (properties != null) {
addProperties(request, properties);
}
return request;
}
示例6: setShareProperties
import com.microsoft.azure.storage.AccessCondition; //导入方法依赖的package包/类
/**
* Constructs a HttpURLConnection to set the share's properties, signed with zero length specified.
*
* @param uri
* A <code>java.net.URI</code> object that specifies the absolute URI.
* @param options
* A {@link FileRequestOptions} object that specifies execution options such as retry policy and timeout
* settings for the operation. Specify <code>null</code> to use the request options specified on the
* {@link CloudFileClient}.
* @param opContext
* An {@link 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.
* @param accessCondition
* An {@link AccessCondition} object that represents the access conditions for the file.
* @param properties
* The properties to upload.
* @return a HttpURLConnection to use to perform the operation.
* @throws IOException
* if there is an error opening the connection
* @throws URISyntaxException
* if the resource URI is invalid
* @throws StorageException
* an exception representing any error which occurred during the operation.
* @throws IllegalArgumentException
*/
public static HttpURLConnection setShareProperties(final URI uri, final FileRequestOptions options,
final OperationContext opContext, final AccessCondition accessCondition, final FileShareProperties properties)
throws IOException, URISyntaxException, StorageException {
final UriQueryBuilder builder = getShareUriQueryBuilder();
builder.add(Constants.QueryConstants.COMPONENT, Constants.QueryConstants.PROPERTIES);
final HttpURLConnection request = BaseRequest.createURLConnection(uri, options, builder, opContext);
request.setFixedLengthStreamingMode(0);
request.setDoOutput(true);
request.setRequestMethod(Constants.HTTP_PUT);
if (accessCondition != null) {
accessCondition.applyConditionToRequest(request);
}
if (properties != null) {
addProperties(request, properties);
}
return request;
}
示例7: snapshot
import com.microsoft.azure.storage.AccessCondition; //导入方法依赖的package包/类
/**
* Constructs a HttpURLConnection to create a snapshot of the blob. Sign with 0 length.
*
* @param uri
* A <code>java.net.URI</code> object that specifies the absolute URI.
* @param blobOptions
* A {@link BlobRequestOptions} object that specifies execution options such as retry policy and timeout
* settings for the operation. Specify <code>null</code> to use the request options specified on the
* {@link CloudBlobClient}.
* @param opContext
* An {@link 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.
* @param accessCondition
* An {@link AccessCondition} object that represents the access conditions for the blob.
* @return a HttpURLConnection to use to perform the operation.
* @throws IOException
* if there is an error opening the connection
* @throws URISyntaxException
* if the resource URI is invalid
* @throws StorageException
* an exception representing any error which occurred during the operation.
* @throws IllegalArgumentException
*/
public static HttpURLConnection snapshot(final URI uri, final BlobRequestOptions blobOptions,
final OperationContext opContext, final AccessCondition accessCondition) throws IOException,
URISyntaxException, StorageException {
final UriQueryBuilder builder = new UriQueryBuilder();
builder.add(Constants.QueryConstants.COMPONENT, BlobConstants.SNAPSHOT);
final HttpURLConnection request = createURLConnection(uri, builder, blobOptions, opContext);
request.setFixedLengthStreamingMode(0);
request.setDoOutput(true);
request.setRequestMethod(Constants.HTTP_PUT);
if (accessCondition != null) {
accessCondition.applyConditionToRequest(request);
}
return request;
}
示例8: putBlockList
import com.microsoft.azure.storage.AccessCondition; //导入方法依赖的package包/类
/**
* Constructs a HttpURLConnection to write a blob by specifying the list of block IDs that make up the blob. Sign
* with length of block list data.
*
* @param uri
* A <code>java.net.URI</code> object that specifies the absolute URI.
* @param blobOptions
* A {@link BlobRequestOptions} object that specifies execution options such as retry policy and timeout
* settings for the operation. Specify <code>null</code> to use the request options specified on the
* {@link CloudBlobClient}.
* @param opContext
* An {@link 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.
* @param accessCondition
* An {@link AccessCondition} object that represents the access conditions for the blob.
* @return a HttpURLConnection to use to perform the operation.
* @throws IOException
* if there is an error opening the connection
* @throws URISyntaxException
* if the resource URI is invalid
* @throws StorageException
* an exception representing any error which occurred during the operation.
* @throws IllegalArgumentException
*/
public static HttpURLConnection putBlockList(final URI uri, final BlobRequestOptions blobOptions,
final OperationContext opContext, final AccessCondition accessCondition, final BlobProperties properties)
throws IOException, URISyntaxException, StorageException {
final UriQueryBuilder builder = new UriQueryBuilder();
builder.add(Constants.QueryConstants.COMPONENT, BLOCK_LIST_QUERY_ELEMENT_NAME);
final HttpURLConnection request = createURLConnection(uri, builder, blobOptions, opContext);
request.setDoOutput(true);
request.setRequestMethod(Constants.HTTP_PUT);
if (accessCondition != null) {
accessCondition.applyConditionToRequest(request);
}
addProperties(request, properties);
return request;
}
示例9: putBlob
import com.microsoft.azure.storage.AccessCondition; //导入方法依赖的package包/类
/**
* Constructs a HttpURLConnection to upload a blob. Sign with blob length, or -1 for pageblob create.
*
* @param uri
* A <code>java.net.URI</code> object that specifies the absolute URI.
* @param blobOptions
* A {@link BlobRequestOptions} object that specifies execution options such as retry policy and timeout
* settings for the operation. Specify <code>null</code> to use the request options specified on the
* {@link CloudBlobClient}.
* @param opContext
* An {@link 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.
* @param accessCondition
* An {@link AccessCondition} object that represents the access conditions for the blob.
* @param properties
* The properties to set for the blob.
* @param blobType
* The type of the blob.
* @param pageBlobSize
* For a page blob, the size of the blob. This parameter is ignored for block blobs.
* @param premiumPageBlobTier
* A {@link PremiumPageBlobTier} object representing the tier to set.
* @return a HttpURLConnection to use to perform the operation.
* @throws IOException
* if there is an error opening the connection
* @throws URISyntaxException
* if the resource URI is invalid
* @throws StorageException
* an exception representing any error which occurred during the operation.
* @throws IllegalArgumentException
*/
public static HttpURLConnection putBlob(final URI uri, final BlobRequestOptions blobOptions,
final OperationContext opContext, final AccessCondition accessCondition, final BlobProperties properties,
final BlobType blobType, final long pageBlobSize, final PremiumPageBlobTier premiumPageBlobTier) throws IOException, URISyntaxException, StorageException {
if (blobType == BlobType.UNSPECIFIED) {
throw new IllegalArgumentException(SR.BLOB_TYPE_NOT_DEFINED);
}
final HttpURLConnection request = createURLConnection(uri, null, blobOptions, opContext);
request.setDoOutput(true);
request.setRequestMethod(Constants.HTTP_PUT);
addProperties(request, properties);
if (blobType == BlobType.PAGE_BLOB) {
request.setFixedLengthStreamingMode(0);
request.setRequestProperty(Constants.HeaderConstants.CONTENT_LENGTH, "0");
request.setRequestProperty(BlobConstants.BLOB_TYPE_HEADER, BlobConstants.PAGE_BLOB);
request.setRequestProperty(BlobConstants.SIZE, String.valueOf(pageBlobSize));
if (premiumPageBlobTier != null)
{
request.setRequestProperty(BlobConstants.ACCESS_TIER_HEADER, String.valueOf(premiumPageBlobTier));
}
properties.setLength(pageBlobSize);
}
else if (blobType == BlobType.BLOCK_BLOB){
request.setRequestProperty(BlobConstants.BLOB_TYPE_HEADER, BlobConstants.BLOCK_BLOB);
}
else if (blobType == BlobType.APPEND_BLOB){
request.setFixedLengthStreamingMode(0);
request.setRequestProperty(BlobConstants.BLOB_TYPE_HEADER, BlobConstants.APPEND_BLOB);
request.setRequestProperty(Constants.HeaderConstants.CONTENT_LENGTH, "0");
}
if (accessCondition != null) {
accessCondition.applyConditionToRequest(request);
}
return request;
}
示例10: getPageRanges
import com.microsoft.azure.storage.AccessCondition; //导入方法依赖的package包/类
/**
* Constructs a HttpURLConnection to return a list of the PageBlob's page ranges. Sign with no length specified.
*
* @param uri
* A <code>java.net.URI</code> object that specifies the absolute URI.
* @param blobOptions
* A {@link BlobRequestOptions} object that specifies execution options such as retry policy and timeout
* settings for the operation. Specify <code>null</code> to use the request options specified on the
* {@link CloudBlobClient}.
* @param opContext
* An {@link 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.
* @param accessCondition
* An {@link AccessCondition} object that represents the access conditions for the blob.
* @param snapshotVersion
* The snapshot version, if the blob is a snapshot.
* @param offset
* The offset at which to begin returning content.
* @param count
* The number of bytes to return.
* @return a HttpURLConnection to use to perform the operation.
* @throws IOException
* if there is an error opening the connection
* @throws URISyntaxException
* if the resource URI is invalid
* @throws StorageException
* an exception representing any error which occurred during the operation.
* @throws IllegalArgumentException
*/
public static HttpURLConnection getPageRanges(final URI uri, final BlobRequestOptions blobOptions,
final OperationContext opContext, final AccessCondition accessCondition, final String snapshotVersion,
final Long offset, final Long count) throws StorageException, IOException, URISyntaxException {
final UriQueryBuilder builder = new UriQueryBuilder();
builder.add(Constants.QueryConstants.COMPONENT, PAGE_LIST_QUERY_ELEMENT_NAME);
BlobRequest.addSnapshot(builder, snapshotVersion);
final HttpURLConnection request = createURLConnection(uri, builder, blobOptions, opContext);
request.setRequestMethod(Constants.HTTP_GET);
if (accessCondition != null) {
accessCondition.applyConditionToRequest(request);
}
addRange(request, offset, count);
return request;
}
示例11: putRange
import com.microsoft.azure.storage.AccessCondition; //导入方法依赖的package包/类
/**
* Constructs a HttpURLConnection to upload a file range. Sign with file size for update, or 0 for clear.
*
* @param uri
* A <code>java.net.URI</code> object that specifies the absolute URI.
* @param fileOptions
* A {@link FileRequestOptions} object that specifies execution options such as retry policy and timeout
* settings for the operation. Specify <code>null</code> to use the request options specified on the
* {@link CloudFileClient}.
* @param opContext
* An {@link 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.
* @param accessCondition
* An {@link AccessCondition} object that represents the access conditions for the file.
* @param range
* a {link @FileRange} representing the file range
* @param operationType
* a {link @FileRangeOperationType} enumeration value representing the file range operation type.
*
* @return a HttpURLConnection to use to perform the operation.
* @throws IOException
* if there is an error opening the connection
* @throws URISyntaxException
* if the resource URI is invalid
* @throws StorageException
* an exception representing any error which occurred during the operation.
* @throws IllegalArgumentException
*/
public static HttpURLConnection putRange(final URI uri, final FileRequestOptions fileOptions,
final OperationContext opContext, final AccessCondition accessCondition, final FileRange range,
FileRangeOperationType operationType) throws IOException, URISyntaxException, StorageException {
final UriQueryBuilder builder = new UriQueryBuilder();
builder.add(Constants.QueryConstants.COMPONENT, RANGE_QUERY_ELEMENT_NAME);
final HttpURLConnection request = BaseRequest.createURLConnection(uri, fileOptions, builder, opContext);
request.setDoOutput(true);
request.setRequestMethod(Constants.HTTP_PUT);
if (operationType == FileRangeOperationType.CLEAR) {
request.setFixedLengthStreamingMode(0);
}
// Range write is either update or clear; required
request.setRequestProperty(FileConstants.FILE_RANGE_WRITE, operationType.toString());
request.setRequestProperty(Constants.HeaderConstants.STORAGE_RANGE_HEADER, range.toString());
if (accessCondition != null) {
accessCondition.applyConditionToRequest(request);
}
return request;
}
示例12: putPage
import com.microsoft.azure.storage.AccessCondition; //导入方法依赖的package包/类
/**
* Constructs a HttpURLConnection to upload a page. Sign with page length for update, or 0 for clear.
*
* @param uri
* A <code>java.net.URI</code> object that specifies the absolute URI.
* @param blobOptions
* A {@link BlobRequestOptions} object that specifies execution options such as retry policy and timeout
* settings for the operation. Specify <code>null</code> to use the request options specified on the
* {@link CloudBlobClient}.
* @param opContext
* An {@link 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.
* @param accessCondition
* An {@link AccessCondition} object that represents the access conditions for the blob.
* @param pageRange
* A {@link PageRange} object that represents the page range.
* @param operationType
* A {@link PageOperationType} object that represents the page range operation type.
* @return a HttpURLConnection to use to perform the operation.
* @throws IOException
* if there is an error opening the connection
* @throws URISyntaxException
* if the resource URI is invalid
* @throws StorageException
* an exception representing any error which occurred during the operation.
* @throws IllegalArgumentException
*/
public static HttpURLConnection putPage(final URI uri, final BlobRequestOptions blobOptions,
final OperationContext opContext, final AccessCondition accessCondition, final PageRange pageRange,
final PageOperationType operationType) throws IOException, URISyntaxException, StorageException {
final UriQueryBuilder builder = new UriQueryBuilder();
builder.add(Constants.QueryConstants.COMPONENT, PAGE_QUERY_ELEMENT_NAME);
final HttpURLConnection request = createURLConnection(uri, builder, blobOptions, opContext);
request.setDoOutput(true);
request.setRequestMethod(Constants.HTTP_PUT);
if (operationType == PageOperationType.CLEAR) {
request.setFixedLengthStreamingMode(0);
}
// Page write is either update or clean; required
request.setRequestProperty(BlobConstants.PAGE_WRITE, operationType.toString());
request.setRequestProperty(Constants.HeaderConstants.STORAGE_RANGE_HEADER, pageRange.toString());
if (accessCondition != null) {
accessCondition.applyConditionToRequest(request);
}
return request;
}
示例13: getBlockList
import com.microsoft.azure.storage.AccessCondition; //导入方法依赖的package包/类
/**
* Constructs a HttpURLConnection to return a list of the block blobs blocks. Sign with no length specified.
*
* @param uri
* A <code>java.net.URI</code> object that specifies the absolute URI.
* @param blobOptions
* A {@link BlobRequestOptions} object that specifies execution options such as retry policy and timeout
* settings for the operation. Specify <code>null</code> to use the request options specified on the
* {@link CloudBlobClient}.
* @param opContext
* An {@link 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.
* @param accessCondition
* An {@link AccessCondition} object that represents the access conditions for the blob.
* @param snapshotVersion
* The snapshot version, if the blob is a snapshot.
* @param blockFilter
* The types of blocks to include in the list: committed, uncommitted, or both.
* @return a HttpURLConnection to use to perform the operation.
* @throws IOException
* if there is an error opening the connection
* @throws URISyntaxException
* if the resource URI is invalid
* @throws StorageException
* an exception representing any error which occurred during the operation.
* @throws IllegalArgumentException
*/
public static HttpURLConnection getBlockList(final URI uri, final BlobRequestOptions blobOptions,
final OperationContext opContext, final AccessCondition accessCondition, final String snapshotVersion,
final BlockListingFilter blockFilter) throws StorageException, IOException, URISyntaxException {
final UriQueryBuilder builder = new UriQueryBuilder();
builder.add(Constants.QueryConstants.COMPONENT, BLOCK_LIST_QUERY_ELEMENT_NAME);
builder.add(BLOCK_LIST_TYPE_QUERY_ELEMENT_NAME, blockFilter.toString());
BlobRequest.addSnapshot(builder, snapshotVersion);
final HttpURLConnection request = BaseRequest.createURLConnection(uri, blobOptions, builder, opContext);
request.setRequestMethod(Constants.HTTP_GET);
if (accessCondition != null) {
accessCondition.applyConditionToRequest(request);
}
return request;
}
示例14: getFileRanges
import com.microsoft.azure.storage.AccessCondition; //导入方法依赖的package包/类
/**
* Constructs a HttpURLConnection to return a list of the file's file ranges. Sign with no length specified.
*
* @param uri
* A <code>java.net.URI</code> object that specifies the absolute URI.
* @param fileOptions
* A {@link FileRequestOptions} object that specifies execution options such as retry policy and timeout
* settings for the operation. Specify <code>null</code> to use the request options specified on the
* {@link CloudFileClient}.
* @param opContext
* An {@link 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.
* @param accessCondition
* An {@link AccessCondition} object that represents the access conditions for the file.
* @return a HttpURLConnection to use to perform the operation.
* @throws IOException
* if there is an error opening the connection
* @throws URISyntaxException
* if the resource URI is invalid
* @throws StorageException
* an exception representing any error which occurred during the operation.
* @throws IllegalArgumentException
*/
public static HttpURLConnection getFileRanges(final URI uri, final FileRequestOptions fileOptions,
final OperationContext opContext, final AccessCondition accessCondition) throws StorageException,
IOException, URISyntaxException {
final UriQueryBuilder builder = new UriQueryBuilder();
builder.add(Constants.QueryConstants.COMPONENT, RANGE_LIST_QUERY_ELEMENT_NAME);
final HttpURLConnection request = BaseRequest.createURLConnection(uri, fileOptions, builder, opContext);
request.setRequestMethod(Constants.HTTP_GET);
if (accessCondition != null) {
accessCondition.applyConditionToRequest(request);
}
return request;
}
示例15: setMetadata
import com.microsoft.azure.storage.AccessCondition; //导入方法依赖的package包/类
/**
* Constructs a HttpURLConnection to set metadata, Sign with 0 length.
*
* @param uri
* A <code>java.net.URI</code> object that specifies the absolute URI.
* @param fileOptions
* A {@link FileRequestOptions} object that specifies execution options such as retry policy and timeout
* settings for the operation. Specify <code>null</code> to use the request options specified on the
* {@link CloudFileClient}.
* @param opContext
* An {@link 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.
* @param accessCondition
* An {@link AccessCondition} object that represents the access conditions.
* @return a HttpURLConnection to use to perform the operation.
* @throws IOException
* if there is an error opening the connection
* @throws URISyntaxException
* if the resource URI is invalid
* @throws StorageException
* an exception representing any error which occurred during the operation.
* @throws IllegalArgumentException
*/
private static HttpURLConnection setMetadata(final URI uri, final FileRequestOptions fileOptions,
final OperationContext opContext, final AccessCondition accessCondition, final UriQueryBuilder builder)
throws IOException, URISyntaxException, StorageException {
final HttpURLConnection request = BaseRequest.setMetadata(uri, fileOptions, builder, opContext);
if (accessCondition != null) {
accessCondition.applyConditionToRequest(request);
}
return request;
}