Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions sdk/storage/azure-storage-queue/checkstyle-suppressions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,6 @@
<suppress files="com.azure.storage.queue.implementation.MessagesImpl.java" checks="io.clientcore.linting.extensions.checkstyle.checks.ThrowFromClientLoggerCheck" />
<suppress files="com.azure.storage.queue.implementation.QueuesImpl.java" checks="io.clientcore.linting.extensions.checkstyle.checks.ThrowFromClientLoggerCheck" />
<suppress files="com.azure.storage.queue.implementation.ServicesImpl.java" checks="io.clientcore.linting.extensions.checkstyle.checks.ThrowFromClientLoggerCheck" />
<suppress files="com.azure.storage.queue.implementation.XmlSerializer.java" checks="io.clientcore.linting.extensions.checkstyle.checks.ThrowFromClientLoggerCheck" />
<suppress files="com.azure.storage.queue.implementation.util.QueueUrlTrailingSlashPolicy.java" checks="io.clientcore.linting.extensions.checkstyle.checks.HttpPipelinePolicyCheck" />
</suppressions>
21 changes: 21 additions & 0 deletions sdk/storage/azure-storage-queue/customization/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>com.azure</groupId>
<artifactId>azure-code-customization-parent</artifactId>
<version>1.0.0-beta.1</version> <!-- {x-version-update;com.azure:azure-code-customization-parent;current} -->
<relativePath>../../../parents/azure-code-customization-parent</relativePath>
</parent>

<name>Microsoft Azure Queue Storage client customization for Java</name>
<description>This package contains client customization for Microsoft Azure Queue Storage</description>

<groupId>com.azure.tools</groupId>
<artifactId>azure-storage-queue-customization</artifactId>
<version>1.0.0-beta.1</version>
<packaging>jar</packaging>
</project>

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -721,7 +721,7 @@ private AzureQueueStorageImpl createAzureQueueStorageImpl(QueueServiceVersion ve
endpoint, retryOptions, coreRetryOptions, logOptions, clientOptions, httpClient, perCallPolicies,
perRetryPolicies, configuration, audience, LOGGER);

return new AzureQueueStorageImpl(pipeline, endpoint, version.getVersion());
return new AzureQueueStorageImpl(pipeline, endpoint + "/" + queueName, version);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@
import com.azure.core.util.logging.ClientLogger;
import com.azure.storage.common.StorageSharedKeyCredential;
import com.azure.storage.common.implementation.AccountSasImplUtil;
import com.azure.storage.common.implementation.Constants;
import com.azure.storage.common.implementation.SasImplUtils;
import com.azure.storage.common.implementation.StorageImplUtils;
import com.azure.storage.common.sas.AccountSasSignatureValues;
import com.azure.storage.queue.implementation.AzureQueueStorageImpl;
import com.azure.storage.queue.implementation.models.KeyInfo;
import com.azure.storage.queue.implementation.util.ModelHelper;
import com.azure.storage.queue.models.QueueCorsRule;
import com.azure.storage.queue.models.QueueGetUserDelegationKeyOptions;
import com.azure.storage.queue.models.QueueItem;
Expand Down Expand Up @@ -132,9 +132,11 @@ public QueueMessageEncoding getMessageEncoding() {
* @return QueueAsyncClient that interacts with the specified queue
*/
public QueueAsyncClient getQueueAsyncClient(String queueName) {
QueueClient queueClient = new QueueClient(client, queueName, accountName, serviceVersion, messageEncoding,
AzureQueueStorageImpl queueStorage = new AzureQueueStorageImpl(client.getHttpPipeline(),
client.getSerializerAdapter(), client.getUrl() + "/" + queueName, client.getServiceVersion());
QueueClient queueClient = new QueueClient(queueStorage, queueName, accountName, serviceVersion, messageEncoding,
processMessageDecodingErrorAsyncHandler, processMessageDecodingErrorHandler, null);
return new QueueAsyncClient(client, queueName, accountName, serviceVersion, messageEncoding,
return new QueueAsyncClient(queueStorage, queueName, accountName, serviceVersion, messageEncoding,
processMessageDecodingErrorAsyncHandler, processMessageDecodingErrorHandler, queueClient);
}

Expand Down Expand Up @@ -349,9 +351,9 @@ PagedFlux<QueueItem> listQueuesWithOptionalTimeout(String marker, QueuesSegmentO

BiFunction<String, Integer, Mono<PagedResponse<QueueItem>>> retriever = (nextMarker,
pageSize) -> StorageImplUtils.applyOptionalTimeout(this.client.getServices()
.listQueuesSegmentSinglePageAsync(prefix, nextMarker, pageSize == null ? maxResultsPerPage : pageSize,
include, null, null, context),
timeout);
.getQueuesWithResponseAsync(ModelHelper.listQueuesRequestOptions(context, prefix, nextMarker,
pageSize == null ? maxResultsPerPage : pageSize, include))
.map(ModelHelper::toQueueItemPage), timeout);

return new PagedFlux<>(pageSize -> retriever.apply(marker, pageSize), retriever);
}
Expand Down Expand Up @@ -420,10 +422,10 @@ public Mono<Response<QueueServiceProperties>> getPropertiesWithResponse() {
}

Mono<Response<QueueServiceProperties>> getPropertiesWithResponse(Context context) {
context = context == null ? Context.NONE : context;
return client.getServices()
.getPropertiesWithResponseAsync(null, null, context)
.map(response -> new SimpleResponse<>(response, response.getValue()));
.getPropertiesWithResponseAsync(ModelHelper.requestOptions(context))
.map(response -> new SimpleResponse<>(response,
ModelHelper.deserializeXmlBody(response.getValue(), QueueServiceProperties::fromXml)));
}

/**
Expand Down Expand Up @@ -545,8 +547,9 @@ public Mono<Response<Void>> setPropertiesWithResponse(QueueServiceProperties pro
}

Mono<Response<Void>> setPropertiesWithResponse(QueueServiceProperties properties, Context context) {
context = context == null ? Context.NONE : context;
return client.getServices().setPropertiesNoCustomHeadersWithResponseAsync(properties, null, null, context);
return client.getServices()
.setPropertiesWithResponseAsync(ModelHelper.serializeXmlBody(properties),
ModelHelper.requestOptions(context));
}

/**
Expand Down Expand Up @@ -609,10 +612,10 @@ public Mono<Response<QueueServiceStatistics>> getStatisticsWithResponse() {
}

Mono<Response<QueueServiceStatistics>> getStatisticsWithResponse(Context context) {
context = context == null ? Context.NONE : context;
return client.getServices()
.getStatisticsWithResponseAsync(null, null, context)
.map(response -> new SimpleResponse<>(response, response.getValue()));
.getStatisticsWithResponseAsync(ModelHelper.requestOptions(context))
.map(response -> new SimpleResponse<>(response,
ModelHelper.deserializeXmlBody(response.getValue(), QueueServiceStatistics::fromXml)));
}

/**
Expand Down Expand Up @@ -788,12 +791,11 @@ Mono<Response<UserDelegationKey>> getUserDelegationKeyWithResponse(OffsetDateTim
new IllegalArgumentException("`start` must be null or a datetime before `expiry`."));
}

KeyInfo keyInfo = new KeyInfo(expiry).setStart(start).setDelegatedUserTenantId(delegatedUserTenantId);
return client.getServices()
.getUserDelegationKeyWithResponseAsync(
new KeyInfo().setStart(start == null ? "" : Constants.ISO_8601_UTC_DATE_FORMATTER.format(start))
.setExpiry(Constants.ISO_8601_UTC_DATE_FORMATTER.format(expiry))
.setDelegatedUserTenantId(delegatedUserTenantId),
null, null, context)
.map(rb -> new SimpleResponse<>(rb, rb.getValue()));
.getUserDelegationKeyWithResponseAsync(ModelHelper.serializeXmlBody(keyInfo),
ModelHelper.requestOptions(context))
.map(rb -> new SimpleResponse<>(rb,
ModelHelper.deserializeXmlBody(rb.getValue(), UserDelegationKey::fromXml)));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,18 @@
import com.azure.core.http.rest.PagedIterable;
import com.azure.core.http.rest.PagedResponse;
import com.azure.core.http.rest.Response;
import com.azure.core.http.rest.ResponseBase;
import com.azure.core.http.rest.SimpleResponse;
import com.azure.core.util.BinaryData;
import com.azure.core.util.Context;
import com.azure.core.util.logging.ClientLogger;
import com.azure.storage.common.StorageSharedKeyCredential;
import com.azure.storage.common.implementation.AccountSasImplUtil;
import com.azure.storage.common.implementation.Constants;
import com.azure.storage.common.implementation.SasImplUtils;
import com.azure.storage.common.implementation.StorageImplUtils;
import com.azure.storage.common.sas.AccountSasSignatureValues;
import com.azure.storage.queue.implementation.AzureQueueStorageImpl;
import com.azure.storage.queue.implementation.util.ModelHelper;
import com.azure.storage.queue.implementation.models.KeyInfo;
import com.azure.storage.queue.implementation.models.ServicesGetStatisticsHeaders;
import com.azure.storage.queue.implementation.models.ServicesGetUserDelegationKeyHeaders;
import com.azure.storage.queue.models.QueueCorsRule;
import com.azure.storage.queue.models.QueueGetUserDelegationKeyOptions;
import com.azure.storage.queue.models.QueueItem;
Expand Down Expand Up @@ -141,10 +139,12 @@ public QueueMessageEncoding getMessageEncoding() {
* @return QueueClient that interacts with the specified queue
*/
public QueueClient getQueueClient(String queueName) {
QueueAsyncClient queueAsyncClient
= new QueueAsyncClient(this.azureQueueStorage, queueName, accountName, serviceVersion, messageEncoding,
processMessageDecodingErrorAsyncHandler, processMessageDecodingErrorHandler, null);
return new QueueClient(this.azureQueueStorage, queueName, accountName, serviceVersion, messageEncoding,
AzureQueueStorageImpl queueStorage = new AzureQueueStorageImpl(this.azureQueueStorage.getHttpPipeline(),
this.azureQueueStorage.getSerializerAdapter(), this.azureQueueStorage.getUrl() + "/" + queueName,
this.azureQueueStorage.getServiceVersion());
QueueAsyncClient queueAsyncClient = new QueueAsyncClient(queueStorage, queueName, accountName, serviceVersion,
messageEncoding, processMessageDecodingErrorAsyncHandler, processMessageDecodingErrorHandler, null);
return new QueueClient(queueStorage, queueName, accountName, serviceVersion, messageEncoding,
processMessageDecodingErrorAsyncHandler, processMessageDecodingErrorHandler, queueAsyncClient);
}

Expand Down Expand Up @@ -335,9 +335,10 @@ public PagedIterable<QueueItem> listQueues(QueuesSegmentOptions options, Duratio
}
}
BiFunction<String, Integer, PagedResponse<QueueItem>> retriever = (nextMarker, pageSize) -> {
Supplier<PagedResponse<QueueItem>> operation = () -> this.azureQueueStorage.getServices()
.listQueuesSegmentSinglePage(prefix, nextMarker, pageSize == null ? maxResultsPerPage : pageSize,
include, null, null, finalContext);
Supplier<PagedResponse<QueueItem>> operation
= () -> ModelHelper.toQueueItemPage(this.azureQueueStorage.getServices()
.getQueuesWithResponse(ModelHelper.listQueuesRequestOptions(finalContext, prefix, nextMarker,
pageSize == null ? maxResultsPerPage : pageSize, include)));

return submitThreadPool(operation, LOGGER, timeout);

Expand Down Expand Up @@ -403,8 +404,12 @@ public QueueServiceProperties getProperties() {
@ServiceMethod(returns = ReturnType.SINGLE)
public Response<QueueServiceProperties> getPropertiesWithResponse(Duration timeout, Context context) {
Context finalContext = context == null ? Context.NONE : context;
Supplier<Response<QueueServiceProperties>> operation
= () -> this.azureQueueStorage.getServices().getPropertiesWithResponse(null, null, finalContext);
Supplier<Response<QueueServiceProperties>> operation = () -> {
Response<BinaryData> response = this.azureQueueStorage.getServices()
.getPropertiesWithResponse(ModelHelper.requestOptions(finalContext));
return new SimpleResponse<>(response,
ModelHelper.deserializeXmlBody(response.getValue(), QueueServiceProperties::fromXml));
};

return submitThreadPool(operation, LOGGER, timeout);
}
Expand Down Expand Up @@ -538,7 +543,8 @@ public Response<Void> setPropertiesWithResponse(QueueServiceProperties propertie
Context context) {
Context finalContext = context == null ? Context.NONE : context;
Supplier<Response<Void>> operation = () -> this.azureQueueStorage.getServices()
.setPropertiesNoCustomHeadersWithResponse(properties, null, null, finalContext);
.setPropertiesWithResponse(ModelHelper.serializeXmlBody(properties),
ModelHelper.requestOptions(finalContext));

return submitThreadPool(operation, LOGGER, timeout);
}
Expand Down Expand Up @@ -596,8 +602,12 @@ public QueueServiceStatistics getStatistics() {
@ServiceMethod(returns = ReturnType.SINGLE)
public Response<QueueServiceStatistics> getStatisticsWithResponse(Duration timeout, Context context) {
Context finalContext = context == null ? Context.NONE : context;
Supplier<ResponseBase<ServicesGetStatisticsHeaders, QueueServiceStatistics>> operation
= () -> this.azureQueueStorage.getServices().getStatisticsWithResponse(null, null, finalContext);
Supplier<Response<QueueServiceStatistics>> operation = () -> {
Response<BinaryData> response = this.azureQueueStorage.getServices()
.getStatisticsWithResponse(ModelHelper.requestOptions(finalContext));
return new SimpleResponse<>(response,
ModelHelper.deserializeXmlBody(response.getValue(), QueueServiceStatistics::fromXml));
};
return submitThreadPool(operation, LOGGER, timeout);
}

Expand Down Expand Up @@ -754,17 +764,16 @@ public Response<UserDelegationKey> getUserDelegationKeyWithResponse(QueueGetUser
new IllegalArgumentException("`start` must be null or a datetime before `expiry`."));
}

Callable<ResponseBase<ServicesGetUserDelegationKeyHeaders, UserDelegationKey>> operation
= () -> this.azureQueueStorage.getServices()
.getUserDelegationKeyWithResponse(new KeyInfo()
.setStart(options.getStartsOn() == null
? ""
: Constants.ISO_8601_UTC_DATE_FORMATTER.format(options.getStartsOn()))
.setExpiry(Constants.ISO_8601_UTC_DATE_FORMATTER.format(options.getExpiresOn()))
.setDelegatedUserTenantId(options.getDelegatedUserTenantId()), null, null, finalContext);

ResponseBase<ServicesGetUserDelegationKeyHeaders, UserDelegationKey> response
= sendRequest(operation, timeout, QueueStorageException.class);
KeyInfo keyInfo = new KeyInfo(options.getExpiresOn()).setStart(options.getStartsOn())
.setDelegatedUserTenantId(options.getDelegatedUserTenantId());
Callable<Response<UserDelegationKey>> operation = () -> {
Response<BinaryData> rb = this.azureQueueStorage.getServices()
.getUserDelegationKeyWithResponse(ModelHelper.serializeXmlBody(keyInfo),
ModelHelper.requestOptions(finalContext));
return new SimpleResponse<>(rb, ModelHelper.deserializeXmlBody(rb.getValue(), UserDelegationKey::fromXml));
};

Response<UserDelegationKey> response = sendRequest(operation, timeout, QueueStorageException.class);
return new SimpleResponse<>(response, response.getValue());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -702,7 +702,7 @@ private AzureQueueStorageImpl createAzureQueueStorageImpl(QueueServiceVersion ve
endpoint, retryOptions, coreRetryOptions, logOptions, clientOptions, httpClient, perCallPolicies,
perRetryPolicies, configuration, audience, LOGGER);

return new AzureQueueStorageImpl(pipeline, endpoint, version.getVersion());
return new AzureQueueStorageImpl(pipeline, endpoint, version);
}

/**
Expand Down
Loading