当前位置: 首页>>代码示例>>Java>>正文


Java UriQueryBuilder类代码示例

本文整理汇总了Java中com.microsoft.azure.storage.core.UriQueryBuilder的典型用法代码示例。如果您正苦于以下问题:Java UriQueryBuilder类的具体用法?Java UriQueryBuilder怎么用?Java UriQueryBuilder使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


UriQueryBuilder类属于com.microsoft.azure.storage.core包,在下文中一共展示了UriQueryBuilder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setAcl

import com.microsoft.azure.storage.core.UriQueryBuilder; //导入依赖的package包/类
/**
 * Sets the ACL for the container. Sign with length of aclBytes.
 * 
 * @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 container.
 * @param publicAccess
 *            The type of public access to allow for the container.
 * @return a HttpURLConnection configured for the operation.
 * @throws StorageException
 * */
public static HttpURLConnection setAcl(final URI uri, final BlobRequestOptions blobOptions,
        final OperationContext opContext, final AccessCondition accessCondition,
        final BlobContainerPublicAccessType publicAccess) throws IOException, URISyntaxException, StorageException {
    if (publicAccess == BlobContainerPublicAccessType.UNKNOWN) {
        throw new IllegalArgumentException(String.format(Utility.LOCALE_US, SR.ARGUMENT_OUT_OF_RANGE_ERROR, "accessType", publicAccess));
    }

    final UriQueryBuilder builder = getContainerUriQueryBuilder();
    builder.add(Constants.QueryConstants.COMPONENT, Constants.QueryConstants.ACL);

    final HttpURLConnection request = createURLConnection(uri, builder, blobOptions, opContext);

    request.setRequestMethod(Constants.HTTP_PUT);
    request.setDoOutput(true);

    if (publicAccess != BlobContainerPublicAccessType.OFF) {
        request.setRequestProperty(BlobConstants.BLOB_PUBLIC_ACCESS_HEADER, publicAccess.toString().toLowerCase());
    }

    if (accessCondition != null) {
        accessCondition.applyLeaseConditionToRequest(request);
    }

    return request;
}
 
开发者ID:Azure,项目名称:azure-storage-android,代码行数:46,代码来源:BlobRequest.java

示例2: generateSharedAccessSignature

import com.microsoft.azure.storage.core.UriQueryBuilder; //导入依赖的package包/类
/**
 * Returns a shared access signature for the container. Note this does not contain the leading "?".
 * 
 * @param policy
 *            An {@link SharedAccessBlobPolicy} object that represents the access policy for the shared access
 *            signature.
 * @param groupPolicyIdentifier
 *            A <code>String</code> which represents the container-level access policy.
 * 
 * @return A <code>String</code> which represents a shared access signature for the container.
 * 
 * @throws StorageException
 *             If a storage service error occurred.
 * @throws InvalidKeyException
 *             If the key is invalid.
 */
public String generateSharedAccessSignature(final SharedAccessBlobPolicy policy, final String groupPolicyIdentifier)
        throws InvalidKeyException, StorageException {

    if (!StorageCredentialsHelper.canCredentialsSignRequest(this.blobServiceClient.getCredentials())) {
        final String errorMessage = SR.CANNOT_CREATE_SAS_WITHOUT_ACCOUNT_KEY;
        throw new IllegalArgumentException(errorMessage);
    }

    final String resourceName = this.getSharedAccessCanonicalName();

    final String signature = SharedAccessSignatureHelper.generateSharedAccessSignatureHashForBlob(policy,
            null /* SharedAccessBlobHeaders */, groupPolicyIdentifier, resourceName, this.blobServiceClient, null);

    final UriQueryBuilder builder = SharedAccessSignatureHelper.generateSharedAccessSignatureForBlob(policy,
            null /* SharedAccessBlobHeaders */, groupPolicyIdentifier, "c", signature);

    return builder.toString();
}
 
开发者ID:horizon-institute,项目名称:runspotrun-android-client,代码行数:35,代码来源:CloudBlobContainer.java

示例3: listFilesAndDirectories

import com.microsoft.azure.storage.core.UriQueryBuilder; //导入依赖的package包/类
/**
 * Constructs a request to return a listing of all files and directories in this storage account. 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 listingContext
 *            A set of parameters for the listing operation.
 * @return a HttpURLConnection configured for the operation.
 * @throws IOException
 * @throws URISyntaxException
 * @throws StorageException
 * @throws IllegalArgumentException
 */
public static HttpURLConnection listFilesAndDirectories(final URI uri, final FileRequestOptions fileOptions,
        final OperationContext opContext, final ListingContext listingContext) throws URISyntaxException,
        IOException, StorageException {

    final UriQueryBuilder builder = getDirectoryUriQueryBuilder();
    builder.add(Constants.QueryConstants.COMPONENT, Constants.QueryConstants.LIST);

    if (listingContext != null) {
        if (!Utility.isNullOrEmpty(listingContext.getMarker())) {
            builder.add(Constants.QueryConstants.MARKER, listingContext.getMarker());
        }

        if (listingContext.getMaxResults() != null && listingContext.getMaxResults() > 0) {
            builder.add(Constants.QueryConstants.MAX_RESULTS, listingContext.getMaxResults().toString());
        }
    }

    final HttpURLConnection request = BaseRequest.createURLConnection(uri, fileOptions, builder, opContext);

    request.setRequestMethod(Constants.HTTP_GET);

    return request;
}
 
开发者ID:horizon-institute,项目名称:runspotrun-android-client,代码行数:46,代码来源:FileRequest.java

示例4: applyContinuationToQueryBuilder

import com.microsoft.azure.storage.core.UriQueryBuilder; //导入依赖的package包/类
/**
 * Reserved for internal use. Adds continuation token values to the specified query builder, if set.
 * 
 * @param builder
 *            The {@link UriQueryBuilder} object to apply the continuation token properties to.
 * @param continuationToken
 *            The {@link ResultContinuation} object containing the continuation token values to apply to the query
 *            builder. Specify <code>null</code> if no continuation token values are set.
 * 
 * @throws StorageException
 *             if an error occurs in accessing the query builder or continuation token.
 */
private static void applyContinuationToQueryBuilder(final UriQueryBuilder builder,
        final ResultContinuation continuationToken) throws StorageException {
    if (continuationToken != null) {
        if (continuationToken.getNextPartitionKey() != null) {
            builder.add(TableConstants.TABLE_SERVICE_NEXT_PARTITION_KEY, continuationToken.getNextPartitionKey());
        }

        if (continuationToken.getNextRowKey() != null) {
            builder.add(TableConstants.TABLE_SERVICE_NEXT_ROW_KEY, continuationToken.getNextRowKey());
        }

        if (continuationToken.getNextTableName() != null) {
            builder.add(TableConstants.TABLE_SERVICE_NEXT_TABLE_NAME, continuationToken.getNextTableName());
        }
    }
}
 
开发者ID:horizon-institute,项目名称:runspotrun-android-client,代码行数:29,代码来源:TableRequest.java

示例5: generateSharedAccessSignature

import com.microsoft.azure.storage.core.UriQueryBuilder; //导入依赖的package包/类
/**
 * Returns a shared access signature for the share. Note this does not contain the leading "?".
 * 
 * @param policy
 *            An {@link SharedAccessFilePolicy} object that represents the access policy for the
 *            shared access signature.
 * @param groupPolicyIdentifier
 *            A <code>String</code> which represents the share-level access policy.
 * @param ipRange
 *            A {@link IPRange} object containing the range of allowed IP addresses.
 * @param protocols
 *            A {@link SharedAccessProtocols} representing the allowed Internet protocols.
 * 
 * @return A <code>String</code> which represents a shared access signature for the share.
 * 
 * @throws StorageException
 *             If a storage service error occurred.
 * @throws InvalidKeyException
 *             If the key is invalid.
 */
public String generateSharedAccessSignature(
        final SharedAccessFilePolicy policy, final String groupPolicyIdentifier, final IPRange ipRange,
        final SharedAccessProtocols protocols)
        throws InvalidKeyException, StorageException {

    if (!StorageCredentialsHelper.canCredentialsSignRequest(this.fileServiceClient.getCredentials())) {
        final String errorMessage = SR.CANNOT_CREATE_SAS_WITHOUT_ACCOUNT_KEY;
        throw new IllegalArgumentException(errorMessage);
    }

    final String resourceName = this.getSharedAccessCanonicalName();

    final String signature = SharedAccessSignatureHelper.generateSharedAccessSignatureHashForBlobAndFile(
            policy, null /* SharedAccessHeaders */, groupPolicyIdentifier, resourceName,
            ipRange, protocols, this.fileServiceClient);

    final UriQueryBuilder builder = SharedAccessSignatureHelper.generateSharedAccessSignatureForBlobAndFile(
            policy, null /* SharedAccessHeaders */, groupPolicyIdentifier, "s", ipRange, protocols, signature);

    return builder.toString();
}
 
开发者ID:Azure,项目名称:azure-storage-android,代码行数:42,代码来源:CloudFileShare.java

示例6: abortCopy

import com.microsoft.azure.storage.core.UriQueryBuilder; //导入依赖的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;
}
 
开发者ID:Azure,项目名称:azure-storage-android,代码行数:49,代码来源:FileRequest.java

示例7: getDirectoryUriQueryBuilder

import com.microsoft.azure.storage.core.UriQueryBuilder; //导入依赖的package包/类
/**
 * Gets the share Uri query builder.
 * 
 * A <CODE>UriQueryBuilder</CODE> for the share.
 * 
 * @throws StorageException
 */
private static UriQueryBuilder getDirectoryUriQueryBuilder() throws StorageException {
    final UriQueryBuilder uriBuilder = new UriQueryBuilder();
    try {
        uriBuilder.add(Constants.QueryConstants.RESOURCETYPE, "directory");
    }
    catch (final IllegalArgumentException e) {
        throw Utility.generateNewUnexpectedStorageException(e);
    }
    return uriBuilder;
}
 
开发者ID:Azure,项目名称:azure-storage-android,代码行数:18,代码来源:FileRequest.java

示例8: deleteBlob

import com.microsoft.azure.storage.core.UriQueryBuilder; //导入依赖的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;
}
 
开发者ID:horizon-institute,项目名称:runspotrun-android-client,代码行数:64,代码来源:BlobRequest.java

示例9: getFile

import com.microsoft.azure.storage.core.UriQueryBuilder; //导入依赖的package包/类
/**
 * Constructs a HttpURLConnection to download the file, 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.
 * @param snapshotVersion
 *            The snapshot version, if the share is a snapshot.
 * @param offset
 *            The offset at which to begin returning content.
 * @param count
 *            The number of bytes to return.
 * @param requestRangeContentMD5
 *            If set to true, request an MD5 header for the specified range.
 * @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 getFile(final URI uri, final FileRequestOptions fileOptions,
        final OperationContext opContext, final AccessCondition accessCondition, final String snapshotVersion, final Long offset,
        final Long count, boolean requestRangeContentMD5) throws IOException, URISyntaxException, StorageException {

    if (offset != null && requestRangeContentMD5) {
        Utility.assertNotNull("count", count);
        Utility.assertInBounds("count", count, 1, Constants.MAX_BLOCK_SIZE);
    }

    final UriQueryBuilder builder = new UriQueryBuilder();
    FileRequest.addShareSnapshot(builder, snapshotVersion);
    final HttpURLConnection request = BaseRequest.createURLConnection(uri, fileOptions, builder, opContext);
    request.setRequestMethod(Constants.HTTP_GET);

    if (accessCondition != null) {
        accessCondition.applyConditionToRequest(request);
    }

    if (offset != null) {
        long rangeStart = offset;
        long rangeEnd;
        if (count != null) {
            rangeEnd = offset + count - 1;
            request.setRequestProperty(Constants.HeaderConstants.STORAGE_RANGE_HEADER, String.format(
                    Utility.LOCALE_US, Constants.HeaderConstants.RANGE_HEADER_FORMAT, rangeStart, rangeEnd));
        }
        else {
            request.setRequestProperty(Constants.HeaderConstants.STORAGE_RANGE_HEADER, String.format(
                    Utility.LOCALE_US, Constants.HeaderConstants.BEGIN_RANGE_HEADER_FORMAT, rangeStart));
        }
    }

    if (offset != null && requestRangeContentMD5) {
        request.setRequestProperty(Constants.HeaderConstants.RANGE_GET_CONTENT_MD5, Constants.TRUE);
    }

    return request;
}
 
开发者ID:Azure,项目名称:azure-storage-android,代码行数:71,代码来源:FileRequest.java

示例10: getShareUriQueryBuilder

import com.microsoft.azure.storage.core.UriQueryBuilder; //导入依赖的package包/类
/**
 * Gets the share Uri query builder.
 * 
 * A <CODE>UriQueryBuilder</CODE> for the share.
 * 
 * @throws StorageException
 */
private static UriQueryBuilder getShareUriQueryBuilder() throws StorageException {
    final UriQueryBuilder uriBuilder = new UriQueryBuilder();
    try {
        uriBuilder.add(Constants.QueryConstants.RESOURCETYPE, "share");
    }
    catch (final IllegalArgumentException e) {
        throw Utility.generateNewUnexpectedStorageException(e);
    }
    return uriBuilder;
}
 
开发者ID:Azure,项目名称:azure-storage-android,代码行数:18,代码来源:FileRequest.java

示例11: coreCreate

import com.microsoft.azure.storage.core.UriQueryBuilder; //导入依赖的package包/类
/**
 * Reserved for internal use. Constructs the core <code>HttpURLConnection</code> to perform an operation.
 * 
 * @param rootUri
 *            A <code>java.net.URI</code> containing an absolute URI to the resource.
 * @param queryBuilder
 *            The <code>UriQueryBuilder</code> for the request.
 * @param opContext
 *            An {@link OperationContext} object for tracking the current operation.
 * @param tableName
 *            The name of the table.
 * @param identity
 *            The identity of the entity, to pass in the Service Managment REST operation URI as
 *            <code><em>tableName</em>(<em>identity</em>)</code>. If <code>null</code>, only the <em>tableName</em>
 *            value will be passed.
 * @param requestMethod
 *            The HTTP request method to set.
 * @param options
 *            A {@link TableRequestOptions} object that specifies execution options such as retry policy and timeout
 *            settings for the operation. This parameter is unused.
 * @return
 *         An <code>HttpURLConnection</code> 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
 *             if a storage service error occurred during the operation.
 */
private static HttpURLConnection coreCreate(final URI rootUri, final TableRequestOptions tableOptions,
        final UriQueryBuilder queryBuilder, final OperationContext opContext, final String tableName,
        final String eTag, final String identity, final String requestMethod) throws IOException,
        URISyntaxException, StorageException {

    URI queryUri = null;

    // Do point query / delete etc.
    if (!Utility.isNullOrEmpty(identity)) {
        queryUri = PathUtility.appendPathToSingleUri(rootUri, tableName.concat(String.format("(%s)", identity)));
    }
    else {
        queryUri = PathUtility.appendPathToSingleUri(rootUri, tableName);
    }

    final HttpURLConnection retConnection = BaseRequest.createURLConnection(queryUri, tableOptions, queryBuilder,
            opContext);

    setAcceptHeaderForHttpWebRequest(retConnection, tableOptions.getTablePayloadFormat());

    retConnection.setRequestProperty(Constants.HeaderConstants.CONTENT_TYPE,
            TableConstants.HeaderConstants.JSON_CONTENT_TYPE);

    retConnection.setRequestProperty(TableConstants.HeaderConstants.MAX_DATA_SERVICE_VERSION,
            TableConstants.HeaderConstants.MAX_DATA_SERVICE_VERSION_VALUE);

    if (!Utility.isNullOrEmpty(eTag)) {
        retConnection.setRequestProperty(Constants.HeaderConstants.IF_MATCH, eTag);
    }

    retConnection.setRequestMethod(requestMethod);
    return retConnection;
}
 
开发者ID:horizon-institute,项目名称:runspotrun-android-client,代码行数:64,代码来源:TableRequest.java

示例12: listShares

import com.microsoft.azure.storage.core.UriQueryBuilder; //导入依赖的package包/类
/**
 * Constructs a request to return a listing of all shares in this storage account. 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 listingContext
 *            A set of parameters for the listing operation.
 * @param detailsIncluded
 *            A <code>java.util.EnumSet</code> object that contains {@link ShareListingDetails} values that indicate
 *            whether share snapshots and/or metadata will be returned.
 * @return a HttpURLConnection configured for the operation.
 * @throws IOException
 * @throws URISyntaxException
 * @throws StorageException
 * @throws IllegalArgumentException
 */
public static HttpURLConnection listShares(final URI uri, final FileRequestOptions fileOptions,
        final OperationContext opContext, final ListingContext listingContext,
        final EnumSet<ShareListingDetails> detailsIncluded) throws URISyntaxException, IOException, StorageException {
    final UriQueryBuilder builder = BaseRequest.getListUriQueryBuilder(listingContext);

    if (detailsIncluded != null && detailsIncluded.size() > 0) {
        final StringBuilder sb = new StringBuilder();
        boolean started = false;

        if (detailsIncluded.contains(ShareListingDetails.SNAPSHOTS)) {
            started = true;
            sb.append(SNAPSHOTS_QUERY_ELEMENT_NAME);
        }

        if (detailsIncluded.contains(ShareListingDetails.METADATA)) {
            if (started)
            {
                sb.append(",");
            }

            sb.append(Constants.QueryConstants.METADATA);
        }

        builder.add(Constants.QueryConstants.INCLUDE, sb.toString());
    }

    final HttpURLConnection request = BaseRequest.createURLConnection(uri, fileOptions, builder, opContext);

    request.setRequestMethod(Constants.HTTP_GET);

    return request;
}
 
开发者ID:Azure,项目名称:azure-storage-android,代码行数:58,代码来源:FileRequest.java

示例13: listFilesAndDirectories

import com.microsoft.azure.storage.core.UriQueryBuilder; //导入依赖的package包/类
/**
 * Constructs a request to return a listing of all files and directories in this storage account. 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 listingContext
 *            A set of parameters for the listing operation.
 * @param snapshotVersion
 *            the snapshot version to the query builder.
 * @return a HttpURLConnection configured for the operation.
 * @throws IOException
 * @throws URISyntaxException
 * @throws StorageException
 * @throws IllegalArgumentException
 */
public static HttpURLConnection listFilesAndDirectories(final URI uri, final FileRequestOptions fileOptions,
        final OperationContext opContext, final ListingContext listingContext, String snapshotVersion) throws URISyntaxException,
        IOException, StorageException {

    final UriQueryBuilder builder = getDirectoryUriQueryBuilder();
    addShareSnapshot(builder, snapshotVersion);
    builder.add(Constants.QueryConstants.COMPONENT, Constants.QueryConstants.LIST);

    if (listingContext != null) {
        if (!Utility.isNullOrEmpty(listingContext.getMarker())) {
            builder.add(Constants.QueryConstants.MARKER, listingContext.getMarker());
        }

        if (listingContext.getMaxResults() != null && listingContext.getMaxResults() > 0) {
            builder.add(Constants.QueryConstants.MAX_RESULTS, listingContext.getMaxResults().toString());
        }

        if (!Utility.isNullOrEmpty(listingContext.getPrefix())) {
            builder.add(Constants.QueryConstants.PREFIX, listingContext.getPrefix().toString());
        }
    }

    final HttpURLConnection request = BaseRequest.createURLConnection(uri, fileOptions, builder, opContext);

    request.setRequestMethod(Constants.HTTP_GET);

    return request;
}
 
开发者ID:Azure,项目名称:azure-storage-android,代码行数:53,代码来源:FileRequest.java

示例14: list

import com.microsoft.azure.storage.core.UriQueryBuilder; //导入依赖的package包/类
/**
 * Constructs a web request to return a listing of all queues in this
 * storage account. Sign the web request with a length of -1L.
 * 
 * @param uri
 *            A <code>URI</code> object that specifies the absolute URI to
 *            the storage account.
 * @param queueOptions
 *            A {@link QueueRequestOptions} 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 CloudQueueClient}.
 * @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 listingContext
 *            A {@link ListingContext} object that specifies parameters for
 *            the listing operation, if any. May be <code>null</code>.
 * @param detailsIncluded
 *            A {@link QueueListingDetails} object that specifies additional
 *            details to return with the listing, if any. May be <code>null</code>.
 * @return An <code>HttpURLConnection</code> configured for the specified
 *         operation.
 * 
 * @throws IOException
 * @throws URISyntaxException
 *             If the URI is not valid.
 * @throws StorageException
 *             If a storage service error occurred during the operation.
 */
public static HttpURLConnection list(final URI uri, final QueueRequestOptions queueOptions,
        final OperationContext opContext, final ListingContext listingContext,
        final QueueListingDetails detailsIncluded) throws URISyntaxException, IOException, StorageException {

    final UriQueryBuilder builder = new UriQueryBuilder();
    builder.add(Constants.QueryConstants.COMPONENT, Constants.QueryConstants.LIST);

    if (listingContext != null) {
        if (!Utility.isNullOrEmpty(listingContext.getPrefix())) {
            builder.add(Constants.QueryConstants.PREFIX, listingContext.getPrefix());
        }

        if (!Utility.isNullOrEmpty(listingContext.getMarker())) {
            builder.add(Constants.QueryConstants.MARKER, listingContext.getMarker());
        }

        if (listingContext.getMaxResults() != null && listingContext.getMaxResults() > 0) {
            builder.add(Constants.QueryConstants.MAX_RESULTS, listingContext.getMaxResults().toString());
        }
    }

    if (detailsIncluded == QueueListingDetails.ALL || detailsIncluded == QueueListingDetails.METADATA) {
        builder.add(Constants.QueryConstants.INCLUDE, Constants.QueryConstants.METADATA);
    }

    final HttpURLConnection request = BaseRequest.createURLConnection(uri, queueOptions, builder, opContext);

    request.setRequestMethod(Constants.HTTP_GET);

    return request;
}
 
开发者ID:horizon-institute,项目名称:runspotrun-android-client,代码行数:63,代码来源:QueueRequest.java

示例15: testSupportedFileApisInShareSnapshot

import com.microsoft.azure.storage.core.UriQueryBuilder; //导入依赖的package包/类
@Test
public void testSupportedFileApisInShareSnapshot() throws StorageException, URISyntaxException, UnsupportedEncodingException {
    CloudFileDirectory dir = this.share.getRootDirectoryReference().getDirectoryReference("dir1");
    dir.deleteIfExists();
    dir.create();
    CloudFile file = dir.getFileReference("file");
    file.create(1024);

    HashMap<String, String> meta = new HashMap<String, String>();
    meta.put("key1", "value1");
    file.setMetadata(meta);
    file.uploadMetadata();

    CloudFileShare snapshot = this.share.createSnapshot();
    CloudFile snapshotFile = snapshot.getRootDirectoryReference()
                                     .getDirectoryReference("dir1").getFileReference("file");

    HashMap<String, String> meta2 = new HashMap<String, String>();
    meta2.put("key2", "value2");
    file.setMetadata(meta2);
    file.uploadMetadata();
    snapshotFile.downloadAttributes();
    
    assertTrue(snapshotFile.getMetadata().size() == 1 && snapshotFile.getMetadata().get("key1").equals("value1"));
    assertNotNull(snapshotFile.getProperties().getEtag());

    file.downloadAttributes();
    assertTrue(file.getMetadata().size() == 1 && file.getMetadata().get("key2").equals("value2"));
    assertNotNull(file.getProperties().getEtag());
    assertNotEquals(file.getProperties().getEtag(), snapshotFile.getProperties().getEtag());

    final UriQueryBuilder uriBuilder = new UriQueryBuilder();
    uriBuilder.add("sharesnapshot", snapshot.snapshotID);
    CloudFile snapshotFile2 = new CloudFile(uriBuilder.addToURI(file.getUri()), this.share.getServiceClient().getCredentials());
    assertEquals(snapshot.snapshotID, snapshotFile2.getShare().snapshotID);
    assertTrue(snapshotFile2.exists());
    
    snapshot.delete();
}
 
开发者ID:Azure,项目名称:azure-storage-android,代码行数:40,代码来源:CloudFileTests.java


注:本文中的com.microsoft.azure.storage.core.UriQueryBuilder类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。