Skip to content

Commit 7f01748

Browse files
committed
Merge pull request #45 from shellygms/master
DocumentDB Java SDK 1.7.0 Release
2 parents 35fe64f + ae2c688 commit 7f01748

13 files changed

+361
-24
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ To get the binaries of this library as distributed by Microsoft, ready for use w
1414
<dependency>
1515
<groupId>com.microsoft.azure</groupId>
1616
<artifactId>azure-documentdb</artifactId>
17-
<version>1.6.0</version>
17+
<version>1.7.0</version>
1818
</dependency>
1919

2020
###Option 2: Source Via Git
@@ -92,9 +92,9 @@ public class SampleApp {
9292
DocumentCollection myCollection = new DocumentCollection();
9393
myCollection.setId(COLLECTION_ID);
9494

95-
// Configure the new collection performance tier to S1.
95+
// Set the provisioned throughput for this collection to be 1000 RUs.
9696
RequestOptions requestOptions = new RequestOptions();
97-
requestOptions.setOfferType("S1");
97+
requestOptions.setOfferThroughput(1000);
9898

9999
// Create a new collection.
100100
myCollection = documentClient.createCollection(

changelog.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## Changes in 1.7.0 : ##
2+
3+
- Added support for expiring documents by setting the default time-to-live on collections and time-to-live override on documents.
4+
15
## Changes in 1.6.0 : ##
26

37
- Added support to set offer throughput for collections created with variable pricing structure.

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<modelVersion>4.0.0</modelVersion>
44
<groupId>com.microsoft.azure</groupId>
55
<artifactId>azure-documentdb</artifactId>
6-
<version>1.6.0</version>
6+
<version>1.7.0</version>
77
<name>${project.groupId}:${project.artifactId}</name>
88
<description>Java SDK for Microsoft Azure DocumentDB</description>
99
<url>http://azure.microsoft.com/en-us/services/documentdb/</url>

src/com/microsoft/azure/documentdb/Constants.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,11 @@ static class Properties {
117117
static final String PARTITION_KEY_PATHS = "paths";
118118
static final String PARTITION_KIND = "kind";
119119
static final String RESOURCE_PARTITION_KEY = "resourcePartitionKey";
120-
}
120+
121+
//Time-to-Live
122+
static final String TTL = "ttl";
123+
static final String DEFAULT_TTL = "defaultTtl";
124+
}
121125

122126
static class ResourceKeys {
123127
static final String ATTACHMENTS = "Attachments";

src/com/microsoft/azure/documentdb/Document.java

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,4 +53,41 @@ static Document FromObject(Object document) {
5353
}
5454
return typedDocument;
5555
}
56+
57+
/**
58+
* Sets the document's time-to-live value.
59+
* <p>
60+
* A document's time-to-live value is an optional property. If set, the document expires after the specified number
61+
* of seconds since its last write time. The value of this property should be one of the following:
62+
* null - indicates the time-to-live value for this document inherits from the parent collection's default time-to-live value.
63+
* nonzero positive integer - indicates the number of seconds before the document expires. It overrides the default time-to-live
64+
* value specified on the parent collection, unless the parent collection's default time-to-live is null.
65+
* -1 - indicates the document never expires. It overrides the default time-to-live
66+
* value specified on the parent collection, unless the parent collection's default time-to-live is null.
67+
*
68+
* @param timeToLive the document's time-to-live value in seconds.
69+
*/
70+
public void setTimeToLive(Integer timeToLive) {
71+
// a "null" value is represented as a missing element on the wire.
72+
// setting timeToLive to null should remove the property from the property bag.
73+
if (timeToLive != null) {
74+
super.set(Constants.Properties.TTL, timeToLive);
75+
}
76+
else if (super.has(Constants.Properties.TTL)) {
77+
super.remove(Constants.Properties.TTL);
78+
}
79+
}
80+
81+
/**
82+
* Gets the document's time-to-live value.
83+
*
84+
* @return the document's time-to-live value in seconds.
85+
*/
86+
public Integer getTimeToLive() {
87+
if (super.has(Constants.Properties.TTL)) {
88+
return super.getInt(Constants.Properties.TTL);
89+
}
90+
91+
return null;
92+
}
5693
}

src/com/microsoft/azure/documentdb/DocumentCollection.java

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,44 @@ public PartitionKeyDefinition getPartitionKey() {
9595
return null;
9696
}
9797

98+
/**
99+
* Sets the collection's default time-to-live value.
100+
* <p>
101+
* The default time-to-live value on a collection is an optional property. If set, the documents within the collection
102+
* expires after the specified number of seconds since their last write time. The value of this property should be one of the following:
103+
* null - indicates evaluation of time-to-live is disabled and documents within the collection will never expire, regardless whether
104+
* individual documents have their time-to-live set.
105+
* nonzero positive integer - indicates the default time-to-live value for all documents within the collection. This value can be overridden
106+
* by individual documents' time-to-live value.
107+
* -1 - indicates by default all documents within the collection never expire. This value can be overridden by individual documents'
108+
* time-to-live value.
109+
*
110+
* @param timeToLive the default time-to-live value in seconds.
111+
*/
112+
public void setDefaultTimeToLive(Integer timeToLive) {
113+
// a "null" value is represented as a missing element on the wire.
114+
// setting timeToLive to null should remove the property from the property bag.
115+
if (timeToLive != null) {
116+
super.set(Constants.Properties.DEFAULT_TTL, timeToLive);
117+
}
118+
else if (super.has(Constants.Properties.DEFAULT_TTL)) {
119+
super.remove(Constants.Properties.DEFAULT_TTL);
120+
}
121+
}
122+
123+
/**
124+
* Gets the collection's default time-to-live value.
125+
*
126+
* @return the the default time-to-live value in seconds.
127+
*/
128+
public Integer getDefaultTimeToLive() {
129+
if (super.has(Constants.Properties.DEFAULT_TTL)) {
130+
return super.getInt(Constants.Properties.DEFAULT_TTL);
131+
}
132+
133+
return null;
134+
}
135+
98136
/**
99137
* Gets the self-link for documents in a collection.
100138
*

src/com/microsoft/azure/documentdb/HashPartitionResolver.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ public String resolveForCreate(Object document) {
130130
/**
131131
* Resolves the collection for reading/querying the documents based on the partition key.
132132
*
133-
* @param partitionKey the partition key used to resolve the collection.
133+
* @param partitionKey the partition key value
134134
*
135135
* @return collection Self link(s) or Name based link(s) which should handle the Read operation
136136
*/

src/com/microsoft/azure/documentdb/HttpConstants.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ public static class HttpHeaders {
166166

167167
public static class Versions {
168168
public static String CURRENT_VERSION = "2015-12-16";
169-
public static String USER_AGENT = "documentdb-java-sdk-1.6.0";
169+
public static String USER_AGENT = "documentdb-java-sdk-1.7.0";
170170
}
171171

172172
public static class StatusCodes {

src/com/microsoft/azure/documentdb/PartitionKey.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public PartitionKey(Object key) {
2828
* Create a new instance of the PartitionKey object from a serialized JSON string.
2929
*
3030
* @param jsonString
31-
* the value of the partition key in JSON form.
31+
* the JSON string representation of this PartitionKey object.
3232
*
3333
* @return the PartitionKey instance.
3434
*/

src/com/microsoft/azure/documentdb/RangePartitionResolver.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public String resolveForCreate(Object document) {
8181
/**
8282
* Resolves the collection for reading/querying the documents based on the partition key.
8383
*
84-
* @param partitionKey the partition key used to resolve the collection.
84+
* @param partitionKey the partition key value.
8585
*
8686
* @return collection Self link(s) or Name based link(s) which should handle the Read operation.
8787
*/

0 commit comments

Comments
 (0)