From e9ee06db9f386448af4422ded4c54b3b17f35d33 Mon Sep 17 00:00:00 2001 From: Naveen Kumar Singh Date: Tue, 19 May 2020 17:18:08 -0400 Subject: [PATCH 1/3] removingAccessConditionClassType --- .../multimaster/samples/ConflictWorker.java | 10 +--- .../cosmos/implementation/RequestOptions.java | 38 +++++++++---- .../implementation/RxDocumentClientImpl.java | 13 ++--- .../DocumentServiceLeaseStore.java | 7 +-- .../DocumentServiceLeaseUpdaterImpl.java | 9 +-- .../azure/cosmos/models/AccessCondition.java | 55 ------------------- .../cosmos/models/AccessConditionType.java | 19 ------- .../models/CosmosConflictRequestOptions.java | 42 ++++++++++---- .../models/CosmosContainerRequestOptions.java | 42 ++++++++++---- .../models/CosmosDatabaseRequestOptions.java | 42 ++++++++++---- .../models/CosmosItemRequestOptions.java | 44 +++++++++++---- .../CosmosPermissionRequestOptions.java | 42 ++++++++++---- .../CosmosStoredProcedureRequestOptions.java | 42 ++++++++++---- .../implementation/ConsistencyTestsBase.java | 8 +-- 14 files changed, 232 insertions(+), 181 deletions(-) delete mode 100644 sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/models/AccessCondition.java delete mode 100644 sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/models/AccessConditionType.java diff --git a/sdk/cosmos/azure-cosmos-examples/src/main/java/com/azure/cosmos/rx/examples/multimaster/samples/ConflictWorker.java b/sdk/cosmos/azure-cosmos-examples/src/main/java/com/azure/cosmos/rx/examples/multimaster/samples/ConflictWorker.java index 13d8ea9c94b1..7cc26116af14 100644 --- a/sdk/cosmos/azure-cosmos-examples/src/main/java/com/azure/cosmos/rx/examples/multimaster/samples/ConflictWorker.java +++ b/sdk/cosmos/azure-cosmos-examples/src/main/java/com/azure/cosmos/rx/examples/multimaster/samples/ConflictWorker.java @@ -3,8 +3,6 @@ package com.azure.cosmos.rx.examples.multimaster.samples; -import com.azure.cosmos.models.AccessCondition; -import com.azure.cosmos.models.AccessConditionType; import com.azure.cosmos.BridgeInternal; import com.azure.cosmos.models.ConflictResolutionPolicy; import com.azure.cosmos.CosmosClientException; @@ -530,9 +528,7 @@ private Mono tryUpdateDocument(AsyncDocumentClient client, String coll BridgeInternal.setProperty(document, "regionEndpoint", client.getReadEndpoint()); RequestOptions options = new RequestOptions(); - options.setAccessCondition(new AccessCondition()); - options.getAccessCondition().setType(AccessConditionType.IF_MATCH); - options.getAccessCondition().setCondition(document.getETag()); + options.setIfMatchEtag(document.getETag()); return client.replaceDocument(document.getSelfLink(), document, null).onErrorResume(e -> { @@ -552,9 +548,7 @@ private Mono tryDeleteDocument(AsyncDocumentClient client, String coll BridgeInternal.setProperty(document, "regionEndpoint", client.getReadEndpoint()); RequestOptions options = new RequestOptions(); - options.setAccessCondition(new AccessCondition()); - options.getAccessCondition().setType(AccessConditionType.IF_MATCH); - options.getAccessCondition().setCondition(document.getETag()); + options.setIfMatchEtag(document.getETag()); return client.deleteDocument(document.getSelfLink(), options).onErrorResume(e -> { diff --git a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/RequestOptions.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/RequestOptions.java index 31cc4e95ec4e..0ac4c2521fb3 100644 --- a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/RequestOptions.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/RequestOptions.java @@ -3,7 +3,6 @@ package com.azure.cosmos.implementation; -import com.azure.cosmos.models.AccessCondition; import com.azure.cosmos.ConsistencyLevel; import com.azure.cosmos.models.IndexingDirective; import com.azure.cosmos.models.PartitionKey; @@ -20,12 +19,13 @@ public class RequestOptions { private Map customOptions; private List preTriggerInclude; private List postTriggerInclude; - private AccessCondition accessCondition; private IndexingDirective indexingDirective; private ConsistencyLevel consistencyLevel; private String sessionToken; private Integer resourceTokenExpirySeconds; private String offerType; + private String ifMatchEtag; + private String ifNoneMatchEtag; private Integer offerThroughput; private PartitionKey partitionkey; private String partitionKeyRangeId; @@ -71,21 +71,39 @@ public void setPostTriggerInclude(List postTriggerInclude) { } /** - * Gets the conditions associated with the request. + * Gets the If-Match (ETag) associated with the request in the Azure Cosmos DB service. * - * @return the access condition. + * @return tthe ifMatchEtag associated with the request. */ - public AccessCondition getAccessCondition() { - return this.accessCondition; + public String getIfMatchEtag() { + return this.ifMatchEtag; } /** - * Sets the conditions associated with the request. + * Sets the the If-Match (ETag) associated with the request in the Azure Cosmos DB service. * - * @param accessCondition the access condition. + * @param ifMatchEtag the ifMatchEtag associated with the request. */ - public void setAccessCondition(AccessCondition accessCondition) { - this.accessCondition = accessCondition; + public void setIfMatchEtag(String ifMatchEtag) { + this.ifMatchEtag = ifMatchEtag; + } + + /** + * Gets the If-None-Match (ETag) associated with the request in the Azure Cosmos DB service. + * + * @return the ifNoneMatchEtag associated with the request. + */ + public String getIfNoneMatchEtag() { + return this.ifNoneMatchEtag; + } + + /** + * Sets the the If-None-Match (ETag) associated with the request in the Azure Cosmos DB service. + * + * @param ifNoneMatchEtag the ifNoneMatchEtag associated with the request. + */ + public void setIfNoneMatchEtag(String ifNoneMatchEtag) { + this.ifNoneMatchEtag = ifNoneMatchEtag; } /** diff --git a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/RxDocumentClientImpl.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/RxDocumentClientImpl.java index 31e246975910..c5d2ea6bb88b 100644 --- a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/RxDocumentClientImpl.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/RxDocumentClientImpl.java @@ -35,7 +35,6 @@ import com.azure.cosmos.implementation.routing.PartitionKeyAndResourceTokenPair; import com.azure.cosmos.implementation.routing.PartitionKeyInternal; import com.azure.cosmos.implementation.routing.PartitionKeyInternalHelper; -import com.azure.cosmos.models.AccessConditionType; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.node.ObjectNode; import org.slf4j.Logger; @@ -874,12 +873,12 @@ private Map getRequestHeaders(RequestOptions options, ResourceTy headers.putAll(customOptions); } - if (options.getAccessCondition() != null) { - if (options.getAccessCondition().getType() == AccessConditionType.IF_MATCH) { - headers.put(HttpConstants.HttpHeaders.IF_MATCH, options.getAccessCondition().getCondition()); - } else { - headers.put(HttpConstants.HttpHeaders.IF_NONE_MATCH, options.getAccessCondition().getCondition()); - } + if (options.getIfMatchEtag() != null) { + headers.put(HttpConstants.HttpHeaders.IF_MATCH, options.getIfMatchEtag()); + } + + if(options.getIfNoneMatchEtag() != null) { + headers.put(HttpConstants.HttpHeaders.IF_NONE_MATCH, options.getIfNoneMatchEtag()); } if (options.getConsistencyLevel() != null) { diff --git a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/changefeed/implementation/DocumentServiceLeaseStore.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/changefeed/implementation/DocumentServiceLeaseStore.java index 5d8eaef10843..a0f264b801fa 100644 --- a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/changefeed/implementation/DocumentServiceLeaseStore.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/changefeed/implementation/DocumentServiceLeaseStore.java @@ -2,8 +2,6 @@ // Licensed under the MIT License. package com.azure.cosmos.implementation.changefeed.implementation; -import com.azure.cosmos.models.AccessCondition; -import com.azure.cosmos.models.AccessConditionType; import com.azure.cosmos.BridgeInternal; import com.azure.cosmos.CosmosClientException; import com.azure.cosmos.implementation.CosmosItemProperties; @@ -133,10 +131,7 @@ public Mono releaseInitializationLock() { requestOptions = new CosmosItemRequestOptions(); } - AccessCondition accessCondition = new AccessCondition(); - accessCondition.setType(AccessConditionType.IF_MATCH); - accessCondition.setCondition(this.lockETag); - requestOptions.setAccessCondition(accessCondition); + requestOptions.setIfMatchEtag(this.lockETag); return this.client.deleteItem(lockId, new PartitionKey(lockId), requestOptions) .map(documentResourceResponse -> { diff --git a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/changefeed/implementation/DocumentServiceLeaseUpdaterImpl.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/changefeed/implementation/DocumentServiceLeaseUpdaterImpl.java index 310ff890ad75..1c9e831314c6 100644 --- a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/changefeed/implementation/DocumentServiceLeaseUpdaterImpl.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/changefeed/implementation/DocumentServiceLeaseUpdaterImpl.java @@ -2,8 +2,6 @@ // Licensed under the MIT License. package com.azure.cosmos.implementation.changefeed.implementation; -import com.azure.cosmos.models.AccessCondition; -import com.azure.cosmos.models.AccessConditionType; import com.azure.cosmos.BridgeInternal; import com.azure.cosmos.CosmosClientException; import com.azure.cosmos.implementation.CosmosItemProperties; @@ -17,7 +15,6 @@ import com.azure.cosmos.implementation.changefeed.exceptions.LeaseLostException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; import java.time.ZoneId; @@ -150,12 +147,8 @@ private Mono tryReplaceLease(Lease lease, String itemId, P } private CosmosItemRequestOptions getCreateIfMatchOptions(Lease lease) { - AccessCondition ifMatchCondition = new AccessCondition(); - ifMatchCondition.setType(AccessConditionType.IF_MATCH); - ifMatchCondition.setCondition(lease.getConcurrencyToken()); - CosmosItemRequestOptions createIfMatchOptions = new CosmosItemRequestOptions(); - createIfMatchOptions.setAccessCondition(ifMatchCondition); + createIfMatchOptions.setIfMatchEtag(lease.getConcurrencyToken()); return createIfMatchOptions; } diff --git a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/models/AccessCondition.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/models/AccessCondition.java deleted file mode 100644 index 9335c8b36ecd..000000000000 --- a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/models/AccessCondition.java +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.cosmos.models; - -/** - * Represents a set of access conditions to be used for operations against the Azure Cosmos DB database service. - */ -public final class AccessCondition { - - private AccessConditionType type = AccessConditionType.IF_MATCH; - private String condition; - - /** - * Gets the condition type. - * - * @return the condition type. - */ - public AccessConditionType getType() { - return this.type; - } - - /** - * Sets the condition type. - * - * @param type the condition type to use. - * @return the Access Condition - */ - public AccessCondition setType(AccessConditionType type) { - this.type = type; - return this; - } - - /** - * Gets the value of the condition - for AccessConditionType IfMatchs and IfNotMatch, this is the ETag that has to - * be compared to. - * - * @return the condition. - */ - public String getCondition() { - return this.condition; - } - - /** - * Sets the value of the condition - for AccessConditionType IfMatchs and IfNotMatch, this is the ETag that has to - * be compared to. - * - * @param condition the condition to use. - * @return the Access Condition - */ - public AccessCondition setCondition(String condition) { - this.condition = condition; - return this; - } -} diff --git a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/models/AccessConditionType.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/models/AccessConditionType.java deleted file mode 100644 index 3bdc5a6ff4b3..000000000000 --- a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/models/AccessConditionType.java +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.cosmos.models; - -/** - * Specifies the set of access condition types that can be used for operations in the Azure Cosmos DB database service. - */ -public enum AccessConditionType { - /** - * Check if the resource's ETag value matches the ETag value performed. - */ - IF_MATCH, - - /** - * Check if the resource's ETag value does not match ETag value performed. - */ - IF_NONE_MATCH -} diff --git a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/models/CosmosConflictRequestOptions.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/models/CosmosConflictRequestOptions.java index 7988080c84fa..05a60c5596b4 100644 --- a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/models/CosmosConflictRequestOptions.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/models/CosmosConflictRequestOptions.java @@ -8,31 +8,53 @@ * The type Cosmos conflict request options. */ public final class CosmosConflictRequestOptions { - private AccessCondition accessCondition; + private String ifMatchEtag; + private String ifNoneMatchEtag; /** - * Gets the conditions associated with the request. + * Gets the If-Match (ETag) associated with the request in the Azure Cosmos DB service. * - * @return the access condition. + * @return ifMatchEtag the ifMatchEtag associated with the request. */ - public AccessCondition getAccessCondition() { - return accessCondition; + public String getIfMatchEtag() { + return this.ifMatchEtag; } /** - * Sets the conditions associated with the request. + * Sets the the If-Match (ETag) associated with the request in the Azure Cosmos DB service. * - * @param accessCondition the access condition. + * @param ifMatchEtag the ifMatchEtag associated with the request. * @return the current request options */ - public CosmosConflictRequestOptions setAccessCondition(AccessCondition accessCondition) { - this.accessCondition = accessCondition; + public CosmosConflictRequestOptions setIfMatchEtag(String ifMatchEtag) { + this.ifMatchEtag = ifMatchEtag; + return this; + } + + /** + * Gets the If-None-Match (ETag) associated with the request in the Azure Cosmos DB service. + * + * @return the ifNoneMatchEtag associated with the request. + */ + public String getIfNoneMatchEtag() { + return this.ifNoneMatchEtag; + } + + /** + * Sets the the If-None-Match (ETag) associated with the request in the Azure Cosmos DB service. + * + * @param ifNoneMatchEtag the ifNoneMatchEtag associated with the request. + * @return the current request options + */ + public CosmosConflictRequestOptions setIfNoneMatchEtag(String ifNoneMatchEtag) { + this.ifNoneMatchEtag = ifNoneMatchEtag; return this; } RequestOptions toRequestOptions() { RequestOptions requestOptions = new RequestOptions(); - requestOptions.setAccessCondition(accessCondition); + requestOptions.setIfMatchEtag(getIfMatchEtag()); + requestOptions.setIfNoneMatchEtag(getIfNoneMatchEtag()); return requestOptions; } } diff --git a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/models/CosmosContainerRequestOptions.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/models/CosmosContainerRequestOptions.java index 5374f8732dee..32ca6565891e 100644 --- a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/models/CosmosContainerRequestOptions.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/models/CosmosContainerRequestOptions.java @@ -13,7 +13,8 @@ public final class CosmosContainerRequestOptions { private boolean populateQuotaInfo; private ConsistencyLevel consistencyLevel; private String sessionToken; - private AccessCondition accessCondition; + private String ifMatchEtag; + private String ifNoneMatchEtag; private ThroughputProperties throughputProperties; /** @@ -101,22 +102,42 @@ public CosmosContainerRequestOptions setSessionToken(String sessionToken) { } /** - * Gets the conditions associated with the request. + * Gets the If-Match (ETag) associated with the request in the Azure Cosmos DB service. * - * @return the access condition. + * @return the ifMatchEtag associated with the request. */ - public AccessCondition getAccessCondition() { - return accessCondition; + public String getIfMatchEtag() { + return this.ifMatchEtag; } /** - * Sets the conditions associated with the request. + * Sets the the If-Match (ETag) associated with the request in the Azure Cosmos DB service. * - * @param accessCondition the access condition. + * @param ifMatchEtag the ifMatchEtag associated with the request. * @return the current request options */ - public CosmosContainerRequestOptions setAccessCondition(AccessCondition accessCondition) { - this.accessCondition = accessCondition; + public CosmosContainerRequestOptions setIfMatchEtag(String ifMatchEtag) { + this.ifMatchEtag = ifMatchEtag; + return this; + } + + /** + * Gets the If-None-Match (ETag) associated with the request in the Azure Cosmos DB service. + * + * @return the ifNoneMatchEtag associated with the request. + */ + public String getIfNoneMatchEtag() { + return this.ifNoneMatchEtag; + } + + /** + * Sets the the If-None-Match (ETag) associated with the request in the Azure Cosmos DB service. + * + * @param ifNoneMatchEtag the ifNoneMatchEtag associated with the request. + * @return the current request options + */ + public CosmosContainerRequestOptions setIfNoneMatchEtag(String ifNoneMatchEtag) { + this.ifNoneMatchEtag = ifNoneMatchEtag; return this; } @@ -127,7 +148,8 @@ CosmosContainerRequestOptions setThroughputProperties(ThroughputProperties throu RequestOptions toRequestOptions() { RequestOptions options = new RequestOptions(); - options.setAccessCondition(accessCondition); + options.setIfMatchEtag(getIfMatchEtag()); + options.setIfNoneMatchEtag(getIfNoneMatchEtag()); options.setOfferThroughput(offerThroughput); options.setPopulateQuotaInfo(populateQuotaInfo); options.setSessionToken(sessionToken); diff --git a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/models/CosmosDatabaseRequestOptions.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/models/CosmosDatabaseRequestOptions.java index 4ba9b6d7d4a6..5a63cbf76303 100644 --- a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/models/CosmosDatabaseRequestOptions.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/models/CosmosDatabaseRequestOptions.java @@ -9,26 +9,47 @@ */ public final class CosmosDatabaseRequestOptions { private Integer offerThroughput; - private AccessCondition accessCondition; + private String ifMatchEtag; + private String ifNoneMatchEtag; private ThroughputProperties throughputProperties; /** - * Gets the conditions associated with the request. + * Gets the If-Match (ETag) associated with the request in the Azure Cosmos DB service. * - * @return the access condition. + * @return the ifMatchEtag associated with the request. */ - public AccessCondition getAccessCondition() { - return accessCondition; + public String getIfMatchEtag() { + return this.ifMatchEtag; } /** - * Sets the conditions associated with the request. + * Sets the the If-Match (ETag) associated with the request in the Azure Cosmos DB service. * - * @param accessCondition the access condition. + * @param ifMatchEtag the ifMatchEtag associated with the request. * @return the current request options */ - public CosmosDatabaseRequestOptions setAccessCondition(AccessCondition accessCondition) { - this.accessCondition = accessCondition; + public CosmosDatabaseRequestOptions setIfMatchEtag(String ifMatchEtag) { + this.ifMatchEtag = ifMatchEtag; + return this; + } + + /** + * Gets the If-None-Match (ETag) associated with the request in the Azure Cosmos DB service. + * + * @return the ifNoneMatchEtag associated with the request. + */ + public String getIfNoneMatchEtag() { + return this.ifNoneMatchEtag; + } + + /** + * Sets the the If-None-Match (ETag) associated with the request in the Azure Cosmos DB service. + * + * @param ifNoneMatchEtag the ifNoneMatchEtag associated with the request. + * @return the current request options + */ + public CosmosDatabaseRequestOptions setIfNoneMatchEtag(String ifNoneMatchEtag) { + this.ifNoneMatchEtag = ifNoneMatchEtag; return this; } @@ -59,7 +80,8 @@ CosmosDatabaseRequestOptions setThroughputProperties(ThroughputProperties throug RequestOptions toRequestOptions() { RequestOptions options = new RequestOptions(); - options.setAccessCondition(accessCondition); + options.setIfMatchEtag(getIfMatchEtag()); + options.setIfNoneMatchEtag(getIfNoneMatchEtag()); options.setOfferThroughput(offerThroughput); options.setThroughputProperties(this.throughputProperties); return options; diff --git a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/models/CosmosItemRequestOptions.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/models/CosmosItemRequestOptions.java index eca7ee674abc..4292132c7894 100644 --- a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/models/CosmosItemRequestOptions.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/models/CosmosItemRequestOptions.java @@ -17,7 +17,8 @@ public final class CosmosItemRequestOptions { private List postTriggerInclude; private String sessionToken; private PartitionKey partitionKey; - private AccessCondition accessCondition; + private String ifMatchEtag; + private String ifNoneMatchEtag; /** * Constructor @@ -37,22 +38,42 @@ public CosmosItemRequestOptions() { } /** - * Gets the conditions associated with the request. + * Gets the If-Match (ETag) associated with the request in the Azure Cosmos DB service. * - * @return the access condition. + * @return the ifMatchEtag associated with the request. */ - public AccessCondition getAccessCondition() { - return accessCondition; + public String getIfMatchEtag() { + return this.ifMatchEtag; } /** - * Sets the conditions associated with the request. + * Sets the the If-Match (ETag) associated with the request in the Azure Cosmos DB service. * - * @param accessCondition the access condition. + * @param ifMatchEtag the ifMatchEtag associated with the request. * @return the current request options */ - public CosmosItemRequestOptions setAccessCondition(AccessCondition accessCondition) { - this.accessCondition = accessCondition; + public CosmosItemRequestOptions setIfMatchEtag(String ifMatchEtag) { + this.ifMatchEtag = ifMatchEtag; + return this; + } + + /** + * Gets the If-None-Match (ETag) associated with the request in the Azure Cosmos DB service. + * + * @return the ifNoneMatchEtag associated with the request. + */ + public String getIfNoneMatchEtag() { + return this.ifNoneMatchEtag; + } + + /** + * Sets the the If-None-Match (ETag) associated with the request in the Azure Cosmos DB service. + * + * @param ifNoneMatchEtag the ifNoneMatchEtag associated with the request. + * @return the current request options + */ + public CosmosItemRequestOptions setIfNoneMatchEtag(String ifNoneMatchEtag) { + this.ifNoneMatchEtag = ifNoneMatchEtag; return this; } @@ -61,6 +82,7 @@ public CosmosItemRequestOptions setAccessCondition(AccessCondition accessConditi * * @return the consistency level. */ + ConsistencyLevel getConsistencyLevel() { return consistencyLevel; } @@ -179,8 +201,8 @@ CosmosItemRequestOptions setPartitionKey(PartitionKey partitionKey) { RequestOptions toRequestOptions() { //TODO: Should we set any default values instead of nulls? RequestOptions requestOptions = new RequestOptions(); - requestOptions.setAccessCondition(accessCondition); - requestOptions.setAccessCondition(getAccessCondition()); + requestOptions.setIfMatchEtag(getIfMatchEtag()); + requestOptions.setIfNoneMatchEtag(getIfNoneMatchEtag()); requestOptions.setConsistencyLevel(getConsistencyLevel()); requestOptions.setIndexingDirective(indexingDirective); requestOptions.setPreTriggerInclude(preTriggerInclude); diff --git a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/models/CosmosPermissionRequestOptions.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/models/CosmosPermissionRequestOptions.java index 0afb3817c729..c9de6e350dae 100644 --- a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/models/CosmosPermissionRequestOptions.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/models/CosmosPermissionRequestOptions.java @@ -9,32 +9,54 @@ */ public final class CosmosPermissionRequestOptions { //TODO: Need to add respective options - private AccessCondition accessCondition; + private String ifMatchEtag; + private String ifNoneMatchEtag; /** - * Gets the conditions associated with the request. + * Gets the If-Match (ETag) associated with the request in the Azure Cosmos DB service. * - * @return the access condition. + * @return the ifMatchEtag associated with the request. */ - public AccessCondition getAccessCondition() { - return accessCondition; + public String getIfMatchEtag() { + return this.ifMatchEtag; } /** - * Sets the conditions associated with the request. + * Sets the the If-Match (ETag) associated with the request in the Azure Cosmos DB service. * - * @param accessCondition the access condition. + * @param ifMatchEtag the ifMatchEtag associated with the request. * @return the current request options */ - public CosmosPermissionRequestOptions setAccessCondition(AccessCondition accessCondition) { - this.accessCondition = accessCondition; + public CosmosPermissionRequestOptions setIfMatchEtag(String ifMatchEtag) { + this.ifMatchEtag = ifMatchEtag; + return this; + } + + /** + * Gets the If-None-Match (ETag) associated with the request in the Azure Cosmos DB service. + * + * @return the ifNoneMatchEtag associated with the request. + */ + public String getIfNoneMatchEtag() { + return this.ifNoneMatchEtag; + } + + /** + * Sets the the If-None-Match (ETag) associated with the request in the Azure Cosmos DB service. + * + * @param ifNoneMatchEtag the ifNoneMatchEtag associated with the request. + * @return the current request options + */ + public CosmosPermissionRequestOptions setIfNoneMatchEtag(String ifNoneMatchEtag) { + this.ifNoneMatchEtag = ifNoneMatchEtag; return this; } RequestOptions toRequestOptions() { //TODO: Should we set any default values instead of nulls? RequestOptions requestOptions = new RequestOptions(); - requestOptions.setAccessCondition(accessCondition); + requestOptions.setIfMatchEtag(getIfMatchEtag()); + requestOptions.setIfNoneMatchEtag(getIfNoneMatchEtag()); return requestOptions; } } diff --git a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/models/CosmosStoredProcedureRequestOptions.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/models/CosmosStoredProcedureRequestOptions.java index 9c8197859cc8..e0363aa964f5 100644 --- a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/models/CosmosStoredProcedureRequestOptions.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/models/CosmosStoredProcedureRequestOptions.java @@ -12,25 +12,46 @@ public final class CosmosStoredProcedureRequestOptions { private ConsistencyLevel consistencyLevel; private PartitionKey partitionKey; private String sessionToken; - private AccessCondition accessCondition; + private String ifMatchEtag; + private String ifNoneMatchEtag; /** - * Gets the conditions associated with the request. + * Gets the If-Match (ETag) associated with the request in the Azure Cosmos DB service. * - * @return the access condition. + * @return the ifMatchEtag associated with the request. */ - public AccessCondition getAccessCondition() { - return accessCondition; + public String getIfMatchEtag() { + return this.ifMatchEtag; } /** - * Sets the conditions associated with the request. + * Sets the the If-Match (ETag) associated with the request in the Azure Cosmos DB service. * - * @param accessCondition the access condition. + * @param ifMatchEtag the ifMatchEtag associated with the request. * @return the current request options */ - public CosmosStoredProcedureRequestOptions setAccessCondition(AccessCondition accessCondition) { - this.accessCondition = accessCondition; + public CosmosStoredProcedureRequestOptions setIfMatchEtag(String ifMatchEtag) { + this.ifMatchEtag = ifMatchEtag; + return this; + } + + /** + * Gets the If-None-Match (ETag) associated with the request in the Azure Cosmos DB service. + * + * @return the ifNoneMatchEtag associated with the request. + */ + public String getIfNoneMatchEtag() { + return this.ifNoneMatchEtag; + } + + /** + * Sets the the If-None-Match (ETag) associated with the request in the Azure Cosmos DB service. + * + * @param ifNoneMatchEtag the ifNoneMatchEtag associated with the request. + * @return the current request options + */ + public CosmosStoredProcedureRequestOptions setIfNoneMatchEtag(String ifNoneMatchEtag) { + this.ifNoneMatchEtag = ifNoneMatchEtag; return this; } @@ -96,7 +117,8 @@ public CosmosStoredProcedureRequestOptions setSessionToken(String sessionToken) RequestOptions toRequestOptions() { RequestOptions requestOptions = new RequestOptions(); - requestOptions.setAccessCondition(accessCondition); + requestOptions.setIfMatchEtag(getIfMatchEtag()); + requestOptions.setIfNoneMatchEtag(getIfNoneMatchEtag()); requestOptions.setConsistencyLevel(getConsistencyLevel()); requestOptions.setPartitionKey(partitionKey); requestOptions.setSessionToken(sessionToken); diff --git a/sdk/cosmos/azure-cosmos/src/test/java/com/azure/cosmos/implementation/ConsistencyTestsBase.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/cosmos/implementation/ConsistencyTestsBase.java index 2c7bdcc3cd76..e2c63ae19ddb 100644 --- a/sdk/cosmos/azure-cosmos/src/test/java/com/azure/cosmos/implementation/ConsistencyTestsBase.java +++ b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/cosmos/implementation/ConsistencyTestsBase.java @@ -7,10 +7,7 @@ import com.azure.cosmos.DirectConnectionConfig; import com.azure.cosmos.GatewayConnectionConfig; import com.azure.cosmos.implementation.apachecommons.collections.map.UnmodifiableMap; -import com.azure.cosmos.models.AccessCondition; -import com.azure.cosmos.models.AccessConditionType; import com.azure.cosmos.BridgeInternal; -import com.azure.cosmos.ConnectionMode; import com.azure.cosmos.ConsistencyLevel; import com.azure.cosmos.models.ModelBridgeInternal; import com.azure.cosmos.models.PartitionKey; @@ -518,12 +515,9 @@ void validateSessionTokenWithPreConditionFailure(boolean useGateway) throws Exce writeClient.upsertDocument(BridgeInternal.getAltLink(createdCollection), documentResponse.getResource(), requestOptions, true).block(); // create a conditioned read request, with first write request's etag, so the read fails with PreconditionFailure - AccessCondition ac = new AccessCondition(); - ac.setCondition(documentResponse.getResource().getETag()); - ac.setType(AccessConditionType.IF_MATCH); RequestOptions requestOptions1 = new RequestOptions(); requestOptions.setPartitionKey(new PartitionKey(ModelBridgeInternal.getObjectFromJsonSerializable(documentResponse.getResource(), "mypk"))); - requestOptions1.setAccessCondition(ac); + requestOptions1.setIfMatchEtag(documentResponse.getResource().getETag()); Mono> preConditionFailureResponseObservable = validationClient.upsertDocument(BridgeInternal.getAltLink(createdCollection), documentResponse.getResource(), requestOptions1, true); FailureValidator failureValidator = new FailureValidator.Builder().statusCode(HttpConstants.StatusCodes.PRECONDITION_FAILED).build(); From 66a71ba41391c7129cb656d4b0532cf4a9c5dfa6 Mon Sep 17 00:00:00 2001 From: Naveen Kumar Singh Date: Tue, 19 May 2020 17:28:10 -0400 Subject: [PATCH 2/3] doc correction --- .../java/com/azure/cosmos/implementation/RequestOptions.java | 4 ++-- .../com/azure/cosmos/models/CosmosConflictRequestOptions.java | 4 ++-- .../azure/cosmos/models/CosmosContainerRequestOptions.java | 4 ++-- .../com/azure/cosmos/models/CosmosDatabaseRequestOptions.java | 4 ++-- .../com/azure/cosmos/models/CosmosItemRequestOptions.java | 4 ++-- .../azure/cosmos/models/CosmosPermissionRequestOptions.java | 4 ++-- .../cosmos/models/CosmosStoredProcedureRequestOptions.java | 4 ++-- 7 files changed, 14 insertions(+), 14 deletions(-) diff --git a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/RequestOptions.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/RequestOptions.java index 0ac4c2521fb3..f9f97bd2e502 100644 --- a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/RequestOptions.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/RequestOptions.java @@ -80,7 +80,7 @@ public String getIfMatchEtag() { } /** - * Sets the the If-Match (ETag) associated with the request in the Azure Cosmos DB service. + * Sets the If-Match (ETag) associated with the request in the Azure Cosmos DB service. * * @param ifMatchEtag the ifMatchEtag associated with the request. */ @@ -98,7 +98,7 @@ public String getIfNoneMatchEtag() { } /** - * Sets the the If-None-Match (ETag) associated with the request in the Azure Cosmos DB service. + * Sets the If-None-Match (ETag) associated with the request in the Azure Cosmos DB service. * * @param ifNoneMatchEtag the ifNoneMatchEtag associated with the request. */ diff --git a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/models/CosmosConflictRequestOptions.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/models/CosmosConflictRequestOptions.java index 05a60c5596b4..c416308f58a8 100644 --- a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/models/CosmosConflictRequestOptions.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/models/CosmosConflictRequestOptions.java @@ -21,7 +21,7 @@ public String getIfMatchEtag() { } /** - * Sets the the If-Match (ETag) associated with the request in the Azure Cosmos DB service. + * Sets the If-Match (ETag) associated with the request in the Azure Cosmos DB service. * * @param ifMatchEtag the ifMatchEtag associated with the request. * @return the current request options @@ -41,7 +41,7 @@ public String getIfNoneMatchEtag() { } /** - * Sets the the If-None-Match (ETag) associated with the request in the Azure Cosmos DB service. + * Sets the If-None-Match (ETag) associated with the request in the Azure Cosmos DB service. * * @param ifNoneMatchEtag the ifNoneMatchEtag associated with the request. * @return the current request options diff --git a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/models/CosmosContainerRequestOptions.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/models/CosmosContainerRequestOptions.java index 32ca6565891e..bb17e87128c7 100644 --- a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/models/CosmosContainerRequestOptions.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/models/CosmosContainerRequestOptions.java @@ -111,7 +111,7 @@ public String getIfMatchEtag() { } /** - * Sets the the If-Match (ETag) associated with the request in the Azure Cosmos DB service. + * Sets the If-Match (ETag) associated with the request in the Azure Cosmos DB service. * * @param ifMatchEtag the ifMatchEtag associated with the request. * @return the current request options @@ -131,7 +131,7 @@ public String getIfNoneMatchEtag() { } /** - * Sets the the If-None-Match (ETag) associated with the request in the Azure Cosmos DB service. + * Sets the If-None-Match (ETag) associated with the request in the Azure Cosmos DB service. * * @param ifNoneMatchEtag the ifNoneMatchEtag associated with the request. * @return the current request options diff --git a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/models/CosmosDatabaseRequestOptions.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/models/CosmosDatabaseRequestOptions.java index 5a63cbf76303..48f3cc75d86f 100644 --- a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/models/CosmosDatabaseRequestOptions.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/models/CosmosDatabaseRequestOptions.java @@ -23,7 +23,7 @@ public String getIfMatchEtag() { } /** - * Sets the the If-Match (ETag) associated with the request in the Azure Cosmos DB service. + * Sets the If-Match (ETag) associated with the request in the Azure Cosmos DB service. * * @param ifMatchEtag the ifMatchEtag associated with the request. * @return the current request options @@ -43,7 +43,7 @@ public String getIfNoneMatchEtag() { } /** - * Sets the the If-None-Match (ETag) associated with the request in the Azure Cosmos DB service. + * Sets the If-None-Match (ETag) associated with the request in the Azure Cosmos DB service. * * @param ifNoneMatchEtag the ifNoneMatchEtag associated with the request. * @return the current request options diff --git a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/models/CosmosItemRequestOptions.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/models/CosmosItemRequestOptions.java index 4292132c7894..8b8b70dad81d 100644 --- a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/models/CosmosItemRequestOptions.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/models/CosmosItemRequestOptions.java @@ -47,7 +47,7 @@ public String getIfMatchEtag() { } /** - * Sets the the If-Match (ETag) associated with the request in the Azure Cosmos DB service. + * Sets the If-Match (ETag) associated with the request in the Azure Cosmos DB service. * * @param ifMatchEtag the ifMatchEtag associated with the request. * @return the current request options @@ -67,7 +67,7 @@ public String getIfNoneMatchEtag() { } /** - * Sets the the If-None-Match (ETag) associated with the request in the Azure Cosmos DB service. + * Sets the If-None-Match (ETag) associated with the request in the Azure Cosmos DB service. * * @param ifNoneMatchEtag the ifNoneMatchEtag associated with the request. * @return the current request options diff --git a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/models/CosmosPermissionRequestOptions.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/models/CosmosPermissionRequestOptions.java index c9de6e350dae..27a243356c9d 100644 --- a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/models/CosmosPermissionRequestOptions.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/models/CosmosPermissionRequestOptions.java @@ -22,7 +22,7 @@ public String getIfMatchEtag() { } /** - * Sets the the If-Match (ETag) associated with the request in the Azure Cosmos DB service. + * Sets the If-Match (ETag) associated with the request in the Azure Cosmos DB service. * * @param ifMatchEtag the ifMatchEtag associated with the request. * @return the current request options @@ -42,7 +42,7 @@ public String getIfNoneMatchEtag() { } /** - * Sets the the If-None-Match (ETag) associated with the request in the Azure Cosmos DB service. + * Sets the If-None-Match (ETag) associated with the request in the Azure Cosmos DB service. * * @param ifNoneMatchEtag the ifNoneMatchEtag associated with the request. * @return the current request options diff --git a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/models/CosmosStoredProcedureRequestOptions.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/models/CosmosStoredProcedureRequestOptions.java index e0363aa964f5..88d3dbc8dff5 100644 --- a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/models/CosmosStoredProcedureRequestOptions.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/models/CosmosStoredProcedureRequestOptions.java @@ -25,7 +25,7 @@ public String getIfMatchEtag() { } /** - * Sets the the If-Match (ETag) associated with the request in the Azure Cosmos DB service. + * Sets the If-Match (ETag) associated with the request in the Azure Cosmos DB service. * * @param ifMatchEtag the ifMatchEtag associated with the request. * @return the current request options @@ -45,7 +45,7 @@ public String getIfNoneMatchEtag() { } /** - * Sets the the If-None-Match (ETag) associated with the request in the Azure Cosmos DB service. + * Sets the If-None-Match (ETag) associated with the request in the Azure Cosmos DB service. * * @param ifNoneMatchEtag the ifNoneMatchEtag associated with the request. * @return the current request options From 464bf67b4d0fd980dcdf4a0ac260b4218062db06 Mon Sep 17 00:00:00 2001 From: Naveen Kumar Singh Date: Wed, 20 May 2020 10:51:33 -0400 Subject: [PATCH 3/3] Etag -> ETag --- .../multimaster/samples/ConflictWorker.java | 4 +-- .../cosmos/implementation/RequestOptions.java | 28 ++++++++-------- .../implementation/RxDocumentClientImpl.java | 8 ++--- .../DocumentServiceLeaseStore.java | 2 +- .../DocumentServiceLeaseUpdaterImpl.java | 2 +- .../models/CosmosConflictRequestOptions.java | 32 +++++++++---------- .../models/CosmosContainerRequestOptions.java | 32 +++++++++---------- .../models/CosmosDatabaseRequestOptions.java | 32 +++++++++---------- .../models/CosmosItemRequestOptions.java | 32 +++++++++---------- .../CosmosPermissionRequestOptions.java | 32 +++++++++---------- .../CosmosStoredProcedureRequestOptions.java | 32 +++++++++---------- .../implementation/ConsistencyTestsBase.java | 2 +- 12 files changed, 119 insertions(+), 119 deletions(-) diff --git a/sdk/cosmos/azure-cosmos-examples/src/main/java/com/azure/cosmos/rx/examples/multimaster/samples/ConflictWorker.java b/sdk/cosmos/azure-cosmos-examples/src/main/java/com/azure/cosmos/rx/examples/multimaster/samples/ConflictWorker.java index 7cc26116af14..8f708ec9e3a1 100644 --- a/sdk/cosmos/azure-cosmos-examples/src/main/java/com/azure/cosmos/rx/examples/multimaster/samples/ConflictWorker.java +++ b/sdk/cosmos/azure-cosmos-examples/src/main/java/com/azure/cosmos/rx/examples/multimaster/samples/ConflictWorker.java @@ -528,7 +528,7 @@ private Mono tryUpdateDocument(AsyncDocumentClient client, String coll BridgeInternal.setProperty(document, "regionEndpoint", client.getReadEndpoint()); RequestOptions options = new RequestOptions(); - options.setIfMatchEtag(document.getETag()); + options.setIfMatchETag(document.getETag()); return client.replaceDocument(document.getSelfLink(), document, null).onErrorResume(e -> { @@ -548,7 +548,7 @@ private Mono tryDeleteDocument(AsyncDocumentClient client, String coll BridgeInternal.setProperty(document, "regionEndpoint", client.getReadEndpoint()); RequestOptions options = new RequestOptions(); - options.setIfMatchEtag(document.getETag()); + options.setIfMatchETag(document.getETag()); return client.deleteDocument(document.getSelfLink(), options).onErrorResume(e -> { diff --git a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/RequestOptions.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/RequestOptions.java index f9f97bd2e502..39e73e3868f4 100644 --- a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/RequestOptions.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/RequestOptions.java @@ -24,8 +24,8 @@ public class RequestOptions { private String sessionToken; private Integer resourceTokenExpirySeconds; private String offerType; - private String ifMatchEtag; - private String ifNoneMatchEtag; + private String ifMatchETag; + private String ifNoneMatchETag; private Integer offerThroughput; private PartitionKey partitionkey; private String partitionKeyRangeId; @@ -73,37 +73,37 @@ public void setPostTriggerInclude(List postTriggerInclude) { /** * Gets the If-Match (ETag) associated with the request in the Azure Cosmos DB service. * - * @return tthe ifMatchEtag associated with the request. + * @return tthe ifMatchETag associated with the request. */ - public String getIfMatchEtag() { - return this.ifMatchEtag; + public String getIfMatchETag() { + return this.ifMatchETag; } /** * Sets the If-Match (ETag) associated with the request in the Azure Cosmos DB service. * - * @param ifMatchEtag the ifMatchEtag associated with the request. + * @param ifMatchETag the ifMatchETag associated with the request. */ - public void setIfMatchEtag(String ifMatchEtag) { - this.ifMatchEtag = ifMatchEtag; + public void setIfMatchETag(String ifMatchETag) { + this.ifMatchETag = ifMatchETag; } /** * Gets the If-None-Match (ETag) associated with the request in the Azure Cosmos DB service. * - * @return the ifNoneMatchEtag associated with the request. + * @return the ifNoneMatchETag associated with the request. */ - public String getIfNoneMatchEtag() { - return this.ifNoneMatchEtag; + public String getIfNoneMatchETag() { + return this.ifNoneMatchETag; } /** * Sets the If-None-Match (ETag) associated with the request in the Azure Cosmos DB service. * - * @param ifNoneMatchEtag the ifNoneMatchEtag associated with the request. + * @param ifNoneMatchETag the ifNoneMatchETag associated with the request. */ - public void setIfNoneMatchEtag(String ifNoneMatchEtag) { - this.ifNoneMatchEtag = ifNoneMatchEtag; + public void setIfNoneMatchETag(String ifNoneMatchETag) { + this.ifNoneMatchETag = ifNoneMatchETag; } /** diff --git a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/RxDocumentClientImpl.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/RxDocumentClientImpl.java index c5d2ea6bb88b..4456303a5756 100644 --- a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/RxDocumentClientImpl.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/RxDocumentClientImpl.java @@ -873,12 +873,12 @@ private Map getRequestHeaders(RequestOptions options, ResourceTy headers.putAll(customOptions); } - if (options.getIfMatchEtag() != null) { - headers.put(HttpConstants.HttpHeaders.IF_MATCH, options.getIfMatchEtag()); + if (options.getIfMatchETag() != null) { + headers.put(HttpConstants.HttpHeaders.IF_MATCH, options.getIfMatchETag()); } - if(options.getIfNoneMatchEtag() != null) { - headers.put(HttpConstants.HttpHeaders.IF_NONE_MATCH, options.getIfNoneMatchEtag()); + if(options.getIfNoneMatchETag() != null) { + headers.put(HttpConstants.HttpHeaders.IF_NONE_MATCH, options.getIfNoneMatchETag()); } if (options.getConsistencyLevel() != null) { diff --git a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/changefeed/implementation/DocumentServiceLeaseStore.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/changefeed/implementation/DocumentServiceLeaseStore.java index a0f264b801fa..73f6b264bf05 100644 --- a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/changefeed/implementation/DocumentServiceLeaseStore.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/changefeed/implementation/DocumentServiceLeaseStore.java @@ -131,7 +131,7 @@ public Mono releaseInitializationLock() { requestOptions = new CosmosItemRequestOptions(); } - requestOptions.setIfMatchEtag(this.lockETag); + requestOptions.setIfMatchETag(this.lockETag); return this.client.deleteItem(lockId, new PartitionKey(lockId), requestOptions) .map(documentResourceResponse -> { diff --git a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/changefeed/implementation/DocumentServiceLeaseUpdaterImpl.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/changefeed/implementation/DocumentServiceLeaseUpdaterImpl.java index 1c9e831314c6..e510a0ee1d31 100644 --- a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/changefeed/implementation/DocumentServiceLeaseUpdaterImpl.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/changefeed/implementation/DocumentServiceLeaseUpdaterImpl.java @@ -148,7 +148,7 @@ private Mono tryReplaceLease(Lease lease, String itemId, P private CosmosItemRequestOptions getCreateIfMatchOptions(Lease lease) { CosmosItemRequestOptions createIfMatchOptions = new CosmosItemRequestOptions(); - createIfMatchOptions.setIfMatchEtag(lease.getConcurrencyToken()); + createIfMatchOptions.setIfMatchETag(lease.getConcurrencyToken()); return createIfMatchOptions; } diff --git a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/models/CosmosConflictRequestOptions.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/models/CosmosConflictRequestOptions.java index c416308f58a8..f40e104138da 100644 --- a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/models/CosmosConflictRequestOptions.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/models/CosmosConflictRequestOptions.java @@ -8,53 +8,53 @@ * The type Cosmos conflict request options. */ public final class CosmosConflictRequestOptions { - private String ifMatchEtag; - private String ifNoneMatchEtag; + private String ifMatchETag; + private String ifNoneMatchETag; /** * Gets the If-Match (ETag) associated with the request in the Azure Cosmos DB service. * - * @return ifMatchEtag the ifMatchEtag associated with the request. + * @return ifMatchETag the ifMatchETag associated with the request. */ - public String getIfMatchEtag() { - return this.ifMatchEtag; + public String getIfMatchETag() { + return this.ifMatchETag; } /** * Sets the If-Match (ETag) associated with the request in the Azure Cosmos DB service. * - * @param ifMatchEtag the ifMatchEtag associated with the request. + * @param ifMatchETag the ifMatchETag associated with the request. * @return the current request options */ - public CosmosConflictRequestOptions setIfMatchEtag(String ifMatchEtag) { - this.ifMatchEtag = ifMatchEtag; + public CosmosConflictRequestOptions setIfMatchETag(String ifMatchETag) { + this.ifMatchETag = ifMatchETag; return this; } /** * Gets the If-None-Match (ETag) associated with the request in the Azure Cosmos DB service. * - * @return the ifNoneMatchEtag associated with the request. + * @return the ifNoneMatchETag associated with the request. */ - public String getIfNoneMatchEtag() { - return this.ifNoneMatchEtag; + public String getIfNoneMatchETag() { + return this.ifNoneMatchETag; } /** * Sets the If-None-Match (ETag) associated with the request in the Azure Cosmos DB service. * - * @param ifNoneMatchEtag the ifNoneMatchEtag associated with the request. + * @param ifNoneMatchEtag the ifNoneMatchETag associated with the request. * @return the current request options */ - public CosmosConflictRequestOptions setIfNoneMatchEtag(String ifNoneMatchEtag) { - this.ifNoneMatchEtag = ifNoneMatchEtag; + public CosmosConflictRequestOptions setIfNoneMatchETag(String ifNoneMatchEtag) { + this.ifNoneMatchETag = ifNoneMatchEtag; return this; } RequestOptions toRequestOptions() { RequestOptions requestOptions = new RequestOptions(); - requestOptions.setIfMatchEtag(getIfMatchEtag()); - requestOptions.setIfNoneMatchEtag(getIfNoneMatchEtag()); + requestOptions.setIfMatchETag(getIfMatchETag()); + requestOptions.setIfNoneMatchETag(getIfNoneMatchETag()); return requestOptions; } } diff --git a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/models/CosmosContainerRequestOptions.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/models/CosmosContainerRequestOptions.java index bb17e87128c7..bdfbf57beb69 100644 --- a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/models/CosmosContainerRequestOptions.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/models/CosmosContainerRequestOptions.java @@ -13,8 +13,8 @@ public final class CosmosContainerRequestOptions { private boolean populateQuotaInfo; private ConsistencyLevel consistencyLevel; private String sessionToken; - private String ifMatchEtag; - private String ifNoneMatchEtag; + private String ifMatchETag; + private String ifNoneMatchETag; private ThroughputProperties throughputProperties; /** @@ -104,40 +104,40 @@ public CosmosContainerRequestOptions setSessionToken(String sessionToken) { /** * Gets the If-Match (ETag) associated with the request in the Azure Cosmos DB service. * - * @return the ifMatchEtag associated with the request. + * @return the ifMatchETag associated with the request. */ - public String getIfMatchEtag() { - return this.ifMatchEtag; + public String getIfMatchETag() { + return this.ifMatchETag; } /** * Sets the If-Match (ETag) associated with the request in the Azure Cosmos DB service. * - * @param ifMatchEtag the ifMatchEtag associated with the request. + * @param ifMatchETag the ifMatchETag associated with the request. * @return the current request options */ - public CosmosContainerRequestOptions setIfMatchEtag(String ifMatchEtag) { - this.ifMatchEtag = ifMatchEtag; + public CosmosContainerRequestOptions setIfMatchETag(String ifMatchETag) { + this.ifMatchETag = ifMatchETag; return this; } /** * Gets the If-None-Match (ETag) associated with the request in the Azure Cosmos DB service. * - * @return the ifNoneMatchEtag associated with the request. + * @return the ifNoneMatchETag associated with the request. */ - public String getIfNoneMatchEtag() { - return this.ifNoneMatchEtag; + public String getIfNoneMatchETag() { + return this.ifNoneMatchETag; } /** * Sets the If-None-Match (ETag) associated with the request in the Azure Cosmos DB service. * - * @param ifNoneMatchEtag the ifNoneMatchEtag associated with the request. + * @param ifNoneMatchETag the ifNoneMatchETag associated with the request. * @return the current request options */ - public CosmosContainerRequestOptions setIfNoneMatchEtag(String ifNoneMatchEtag) { - this.ifNoneMatchEtag = ifNoneMatchEtag; + public CosmosContainerRequestOptions setIfNoneMatchETag(String ifNoneMatchETag) { + this.ifNoneMatchETag = ifNoneMatchETag; return this; } @@ -148,8 +148,8 @@ CosmosContainerRequestOptions setThroughputProperties(ThroughputProperties throu RequestOptions toRequestOptions() { RequestOptions options = new RequestOptions(); - options.setIfMatchEtag(getIfMatchEtag()); - options.setIfNoneMatchEtag(getIfNoneMatchEtag()); + options.setIfMatchETag(getIfMatchETag()); + options.setIfNoneMatchETag(getIfNoneMatchETag()); options.setOfferThroughput(offerThroughput); options.setPopulateQuotaInfo(populateQuotaInfo); options.setSessionToken(sessionToken); diff --git a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/models/CosmosDatabaseRequestOptions.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/models/CosmosDatabaseRequestOptions.java index 48f3cc75d86f..94a2e9e0e10c 100644 --- a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/models/CosmosDatabaseRequestOptions.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/models/CosmosDatabaseRequestOptions.java @@ -9,47 +9,47 @@ */ public final class CosmosDatabaseRequestOptions { private Integer offerThroughput; - private String ifMatchEtag; - private String ifNoneMatchEtag; + private String ifMatchETag; + private String ifNoneMatchETag; private ThroughputProperties throughputProperties; /** * Gets the If-Match (ETag) associated with the request in the Azure Cosmos DB service. * - * @return the ifMatchEtag associated with the request. + * @return the ifMatchETag associated with the request. */ - public String getIfMatchEtag() { - return this.ifMatchEtag; + public String getIfMatchETag() { + return this.ifMatchETag; } /** * Sets the If-Match (ETag) associated with the request in the Azure Cosmos DB service. * - * @param ifMatchEtag the ifMatchEtag associated with the request. + * @param ifMatchETag the ifMatchETag associated with the request. * @return the current request options */ - public CosmosDatabaseRequestOptions setIfMatchEtag(String ifMatchEtag) { - this.ifMatchEtag = ifMatchEtag; + public CosmosDatabaseRequestOptions setIfMatchETag(String ifMatchETag) { + this.ifMatchETag = ifMatchETag; return this; } /** * Gets the If-None-Match (ETag) associated with the request in the Azure Cosmos DB service. * - * @return the ifNoneMatchEtag associated with the request. + * @return the ifNoneMatchETag associated with the request. */ - public String getIfNoneMatchEtag() { - return this.ifNoneMatchEtag; + public String getIfNoneMatchETag() { + return this.ifNoneMatchETag; } /** * Sets the If-None-Match (ETag) associated with the request in the Azure Cosmos DB service. * - * @param ifNoneMatchEtag the ifNoneMatchEtag associated with the request. + * @param ifNoneMatchETag the ifNoneMatchETag associated with the request. * @return the current request options */ - public CosmosDatabaseRequestOptions setIfNoneMatchEtag(String ifNoneMatchEtag) { - this.ifNoneMatchEtag = ifNoneMatchEtag; + public CosmosDatabaseRequestOptions setIfNoneMatchETag(String ifNoneMatchETag) { + this.ifNoneMatchETag = ifNoneMatchETag; return this; } @@ -80,8 +80,8 @@ CosmosDatabaseRequestOptions setThroughputProperties(ThroughputProperties throug RequestOptions toRequestOptions() { RequestOptions options = new RequestOptions(); - options.setIfMatchEtag(getIfMatchEtag()); - options.setIfNoneMatchEtag(getIfNoneMatchEtag()); + options.setIfMatchETag(getIfMatchETag()); + options.setIfNoneMatchETag(getIfNoneMatchETag()); options.setOfferThroughput(offerThroughput); options.setThroughputProperties(this.throughputProperties); return options; diff --git a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/models/CosmosItemRequestOptions.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/models/CosmosItemRequestOptions.java index 8b8b70dad81d..4f56ebcdb94a 100644 --- a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/models/CosmosItemRequestOptions.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/models/CosmosItemRequestOptions.java @@ -17,8 +17,8 @@ public final class CosmosItemRequestOptions { private List postTriggerInclude; private String sessionToken; private PartitionKey partitionKey; - private String ifMatchEtag; - private String ifNoneMatchEtag; + private String ifMatchETag; + private String ifNoneMatchETag; /** * Constructor @@ -40,40 +40,40 @@ public CosmosItemRequestOptions() { /** * Gets the If-Match (ETag) associated with the request in the Azure Cosmos DB service. * - * @return the ifMatchEtag associated with the request. + * @return the ifMatchETag associated with the request. */ - public String getIfMatchEtag() { - return this.ifMatchEtag; + public String getIfMatchETag() { + return this.ifMatchETag; } /** * Sets the If-Match (ETag) associated with the request in the Azure Cosmos DB service. * - * @param ifMatchEtag the ifMatchEtag associated with the request. + * @param ifMatchETag the ifMatchETag associated with the request. * @return the current request options */ - public CosmosItemRequestOptions setIfMatchEtag(String ifMatchEtag) { - this.ifMatchEtag = ifMatchEtag; + public CosmosItemRequestOptions setIfMatchETag(String ifMatchETag) { + this.ifMatchETag = ifMatchETag; return this; } /** * Gets the If-None-Match (ETag) associated with the request in the Azure Cosmos DB service. * - * @return the ifNoneMatchEtag associated with the request. + * @return the ifNoneMatchETag associated with the request. */ - public String getIfNoneMatchEtag() { - return this.ifNoneMatchEtag; + public String getIfNoneMatchETag() { + return this.ifNoneMatchETag; } /** * Sets the If-None-Match (ETag) associated with the request in the Azure Cosmos DB service. * - * @param ifNoneMatchEtag the ifNoneMatchEtag associated with the request. + * @param ifNoneMatchETag the ifNoneMatchETag associated with the request. * @return the current request options */ - public CosmosItemRequestOptions setIfNoneMatchEtag(String ifNoneMatchEtag) { - this.ifNoneMatchEtag = ifNoneMatchEtag; + public CosmosItemRequestOptions setIfNoneMatchETag(String ifNoneMatchETag) { + this.ifNoneMatchETag = ifNoneMatchETag; return this; } @@ -201,8 +201,8 @@ CosmosItemRequestOptions setPartitionKey(PartitionKey partitionKey) { RequestOptions toRequestOptions() { //TODO: Should we set any default values instead of nulls? RequestOptions requestOptions = new RequestOptions(); - requestOptions.setIfMatchEtag(getIfMatchEtag()); - requestOptions.setIfNoneMatchEtag(getIfNoneMatchEtag()); + requestOptions.setIfMatchETag(getIfMatchETag()); + requestOptions.setIfNoneMatchETag(getIfNoneMatchETag()); requestOptions.setConsistencyLevel(getConsistencyLevel()); requestOptions.setIndexingDirective(indexingDirective); requestOptions.setPreTriggerInclude(preTriggerInclude); diff --git a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/models/CosmosPermissionRequestOptions.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/models/CosmosPermissionRequestOptions.java index 27a243356c9d..5fcaede8b479 100644 --- a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/models/CosmosPermissionRequestOptions.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/models/CosmosPermissionRequestOptions.java @@ -9,54 +9,54 @@ */ public final class CosmosPermissionRequestOptions { //TODO: Need to add respective options - private String ifMatchEtag; - private String ifNoneMatchEtag; + private String ifMatchETag; + private String ifNoneMatchETag; /** * Gets the If-Match (ETag) associated with the request in the Azure Cosmos DB service. * - * @return the ifMatchEtag associated with the request. + * @return the ifMatchETag associated with the request. */ - public String getIfMatchEtag() { - return this.ifMatchEtag; + public String getIfMatchETag() { + return this.ifMatchETag; } /** * Sets the If-Match (ETag) associated with the request in the Azure Cosmos DB service. * - * @param ifMatchEtag the ifMatchEtag associated with the request. + * @param ifMatchETag the ifMatchETag associated with the request. * @return the current request options */ - public CosmosPermissionRequestOptions setIfMatchEtag(String ifMatchEtag) { - this.ifMatchEtag = ifMatchEtag; + public CosmosPermissionRequestOptions setIfMatchETag(String ifMatchETag) { + this.ifMatchETag = ifMatchETag; return this; } /** * Gets the If-None-Match (ETag) associated with the request in the Azure Cosmos DB service. * - * @return the ifNoneMatchEtag associated with the request. + * @return the ifNoneMatchETag associated with the request. */ - public String getIfNoneMatchEtag() { - return this.ifNoneMatchEtag; + public String getIfNoneMatchETag() { + return this.ifNoneMatchETag; } /** * Sets the If-None-Match (ETag) associated with the request in the Azure Cosmos DB service. * - * @param ifNoneMatchEtag the ifNoneMatchEtag associated with the request. + * @param ifNoneMatchETag the ifNoneMatchETag associated with the request. * @return the current request options */ - public CosmosPermissionRequestOptions setIfNoneMatchEtag(String ifNoneMatchEtag) { - this.ifNoneMatchEtag = ifNoneMatchEtag; + public CosmosPermissionRequestOptions setIfNoneMatchETag(String ifNoneMatchETag) { + this.ifNoneMatchETag = ifNoneMatchETag; return this; } RequestOptions toRequestOptions() { //TODO: Should we set any default values instead of nulls? RequestOptions requestOptions = new RequestOptions(); - requestOptions.setIfMatchEtag(getIfMatchEtag()); - requestOptions.setIfNoneMatchEtag(getIfNoneMatchEtag()); + requestOptions.setIfMatchETag(getIfMatchETag()); + requestOptions.setIfNoneMatchETag(getIfNoneMatchETag()); return requestOptions; } } diff --git a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/models/CosmosStoredProcedureRequestOptions.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/models/CosmosStoredProcedureRequestOptions.java index 88d3dbc8dff5..b68fe54ff873 100644 --- a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/models/CosmosStoredProcedureRequestOptions.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/models/CosmosStoredProcedureRequestOptions.java @@ -12,46 +12,46 @@ public final class CosmosStoredProcedureRequestOptions { private ConsistencyLevel consistencyLevel; private PartitionKey partitionKey; private String sessionToken; - private String ifMatchEtag; - private String ifNoneMatchEtag; + private String ifMatchETag; + private String ifNoneMatchETag; /** * Gets the If-Match (ETag) associated with the request in the Azure Cosmos DB service. * - * @return the ifMatchEtag associated with the request. + * @return the ifMatchETag associated with the request. */ - public String getIfMatchEtag() { - return this.ifMatchEtag; + public String getIfMatchETag() { + return this.ifMatchETag; } /** * Sets the If-Match (ETag) associated with the request in the Azure Cosmos DB service. * - * @param ifMatchEtag the ifMatchEtag associated with the request. + * @param ifMatchETag the ifMatchETag associated with the request. * @return the current request options */ - public CosmosStoredProcedureRequestOptions setIfMatchEtag(String ifMatchEtag) { - this.ifMatchEtag = ifMatchEtag; + public CosmosStoredProcedureRequestOptions setIfMatchETag(String ifMatchETag) { + this.ifMatchETag = ifMatchETag; return this; } /** * Gets the If-None-Match (ETag) associated with the request in the Azure Cosmos DB service. * - * @return the ifNoneMatchEtag associated with the request. + * @return the ifNoneMatchETag associated with the request. */ - public String getIfNoneMatchEtag() { - return this.ifNoneMatchEtag; + public String getIfNoneMatchETag() { + return this.ifNoneMatchETag; } /** * Sets the If-None-Match (ETag) associated with the request in the Azure Cosmos DB service. * - * @param ifNoneMatchEtag the ifNoneMatchEtag associated with the request. + * @param ifNoneMatchETag the ifNoneMatchETag associated with the request. * @return the current request options */ - public CosmosStoredProcedureRequestOptions setIfNoneMatchEtag(String ifNoneMatchEtag) { - this.ifNoneMatchEtag = ifNoneMatchEtag; + public CosmosStoredProcedureRequestOptions setIfNoneMatchETag(String ifNoneMatchETag) { + this.ifNoneMatchETag = ifNoneMatchETag; return this; } @@ -117,8 +117,8 @@ public CosmosStoredProcedureRequestOptions setSessionToken(String sessionToken) RequestOptions toRequestOptions() { RequestOptions requestOptions = new RequestOptions(); - requestOptions.setIfMatchEtag(getIfMatchEtag()); - requestOptions.setIfNoneMatchEtag(getIfNoneMatchEtag()); + requestOptions.setIfMatchETag(getIfMatchETag()); + requestOptions.setIfNoneMatchETag(getIfNoneMatchETag()); requestOptions.setConsistencyLevel(getConsistencyLevel()); requestOptions.setPartitionKey(partitionKey); requestOptions.setSessionToken(sessionToken); diff --git a/sdk/cosmos/azure-cosmos/src/test/java/com/azure/cosmos/implementation/ConsistencyTestsBase.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/cosmos/implementation/ConsistencyTestsBase.java index e2c63ae19ddb..90419d102166 100644 --- a/sdk/cosmos/azure-cosmos/src/test/java/com/azure/cosmos/implementation/ConsistencyTestsBase.java +++ b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/cosmos/implementation/ConsistencyTestsBase.java @@ -517,7 +517,7 @@ void validateSessionTokenWithPreConditionFailure(boolean useGateway) throws Exce // create a conditioned read request, with first write request's etag, so the read fails with PreconditionFailure RequestOptions requestOptions1 = new RequestOptions(); requestOptions.setPartitionKey(new PartitionKey(ModelBridgeInternal.getObjectFromJsonSerializable(documentResponse.getResource(), "mypk"))); - requestOptions1.setIfMatchEtag(documentResponse.getResource().getETag()); + requestOptions1.setIfMatchETag(documentResponse.getResource().getETag()); Mono> preConditionFailureResponseObservable = validationClient.upsertDocument(BridgeInternal.getAltLink(createdCollection), documentResponse.getResource(), requestOptions1, true); FailureValidator failureValidator = new FailureValidator.Builder().statusCode(HttpConstants.StatusCodes.PRECONDITION_FAILED).build();