Skip to content

Commit d376823

Browse files
authored
Merge pull request #51 from shellygms/master
DocumentDB Java SDK 1.8.0 commit.
2 parents 71e5ba6 + 536a4e8 commit d376823

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+2354
-506
lines changed

.classpath

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@
66
<attribute name="maven.pomderived" value="true"/>
77
</attributes>
88
</classpathentry>
9-
<classpathentry kind="src" output="target/classes" path="test"/>
10-
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
9+
<classpathentry kind="src" output="target/test-classes" path="test"/>
10+
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7">
1111
<attributes>
1212
<attribute name="maven.pomderived" value="true"/>
1313
</attributes>
1414
</classpathentry>
15-
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7">
15+
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
1616
<attributes>
1717
<attribute name="maven.pomderived" value="true"/>
1818
</attributes>

README.md

Lines changed: 1 addition & 1 deletion
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.7.1</version>
17+
<version>1.8.0</version>
1818
</dependency>
1919

2020
###Option 2: Source Via Git

changelog.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
## Changes in 1.8.0 : ##
2+
3+
- Added support for endpoint management for geo-distributed databases. User can customize
4+
how endpoints are selected for each request by setting the ConnectionPolicy.EnableEndpointDiscovery
5+
and ConnectionPolicy.PreferredLocations properties when creating a DocumentClient instance.
6+
- Added support for automatic retry on throttled requests with options to customize the max retry attempts
7+
and max retry wait time. See RetryOptions and ConnectionPolicy.getRetryOptions().
8+
- Deprecated IPartitionResolver based custom partitioning code. Please use partitioned collections for higher storage and throughput.
9+
110
## Changes in 1.7.1 : ##
211

312
- Setting Cookie policy on httpclient to ignoring server cookies as we don't use them.

pom.xml

Lines changed: 11 additions & 9 deletions
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.7.1</version>
6+
<version>1.8.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>
@@ -151,11 +151,6 @@
151151
<artifactId>commons-lang3</artifactId>
152152
<version>3.3.2</version>
153153
</dependency>
154-
<dependency>
155-
<groupId>junit</groupId>
156-
<artifactId>junit</artifactId>
157-
<version>4.11</version>
158-
</dependency>
159154
<dependency>
160155
<groupId>org.apache.httpcomponents</groupId>
161156
<artifactId>httpclient</artifactId>
@@ -167,9 +162,16 @@
167162
<version>4.2.5</version>
168163
</dependency>
169164
<dependency>
170-
<groupId>org.mockito</groupId>
171-
<artifactId>mockito-core</artifactId>
172-
<version>1.10.19</version>
165+
<groupId>junit</groupId>
166+
<artifactId>junit</artifactId>
167+
<version>4.11</version>
168+
<scope>test</scope>
169+
</dependency>
170+
<dependency>
171+
<groupId>org.mockito</groupId>
172+
<artifactId>mockito-core</artifactId>
173+
<version>1.10.19</version>
174+
<scope>test</scope>
173175
</dependency>
174176
</dependencies>
175177
<distributionManagement>

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

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import javax.crypto.spec.SecretKeySpec;
1616

1717
import org.apache.commons.codec.binary.Base64;
18+
import org.apache.commons.lang3.StringUtils;
1819

1920
/**
2021
* This class is used by both client (for generating the auth header with master/system key) and by the G/W when
@@ -110,41 +111,39 @@ public static String GenerateKeyAuthorizationSignature(String verb,
110111
* @param resourceId the resource id.
111112
* @return the authorization token.
112113
*/
113-
public static String GetAuthorizationTokenUsingResourceTokens(Map<String, String> resourceTokens,
114+
public static String getAuthorizationTokenUsingResourceTokens(Map<String, String> resourceTokens,
114115
String path,
115116
String resourceId) {
116117
if (resourceTokens == null) {
117118
throw new IllegalArgumentException("resourceTokens");
118119
}
119120

120-
if (path == null || path.isEmpty()) {
121-
throw new IllegalArgumentException("path");
122-
}
123-
124-
if (resourceId == null || resourceId.isEmpty()) {
125-
throw new IllegalArgumentException("resourceId");
126-
}
127-
121+
String resourceToken = null;
128122
if (resourceTokens.containsKey(resourceId) && resourceTokens.get(resourceId) != null) {
129-
return resourceTokens.get(resourceId);
123+
resourceToken = resourceTokens.get(resourceId);
124+
} else if (StringUtils.isEmpty(path) || StringUtils.isEmpty(resourceId)) {
125+
if (resourceTokens.size() > 0) {
126+
resourceToken = resourceTokens.values().iterator().next();
127+
}
130128
} else {
129+
// Get the last resource id from the path and use that to find the corresponding token.
131130
String[] pathParts = path.split("/");
132131
String[] resourceTypes = { "dbs", "colls", "docs", "sprocs", "udfs", "triggers", "users", "permissions",
133132
"attachments", "media", "conflicts" };
134133
HashSet<String> resourceTypesSet = new HashSet<String>();
135134
for (String resourceType : resourceTypes) {
136135
resourceTypesSet.add(resourceType);
137136
}
138-
137+
139138
for (int i = pathParts.length - 1; i >= 0; --i) {
140-
139+
141140
if (!resourceTypesSet.contains(pathParts[i]) && resourceTokens.containsKey(pathParts[i])) {
142-
return resourceTokens.get(pathParts[i]);
141+
resourceToken = resourceTokens.get(pathParts[i]);
143142
}
144143
}
145-
146-
return null;
147144
}
145+
146+
return resourceToken;
148147
}
149148

150149
private static String getResourceSegement(ResourceType resourceType) {

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

Lines changed: 0 additions & 86 deletions
This file was deleted.

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

Lines changed: 0 additions & 25 deletions
This file was deleted.

0 commit comments

Comments
 (0)