Skip to content

Commit cc3e58e

Browse files
author
Ryan CrawCour
committed
Merge pull request #37 from rnagpal/master
Java SDK 1.4.0 release
2 parents 1e6fa97 + 25b6147 commit cc3e58e

20 files changed

+2544
-641
lines changed

.classpath

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@
1717
</attributes>
1818
</classpathentry>
1919
<classpathentry kind="output" path="target/classes"/>
20-
</classpath>
20+
</classpath>

README.md

Lines changed: 3 additions & 2 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.2.0</version>
17+
<version>1.4.0</version>
1818
</dependency>
1919

2020
###Option 2: Source Via Git
@@ -35,6 +35,7 @@ To download a copy of the source code, click "Download ZIP" on the right side of
3535
### Dependencies
3636
* Apache Commons Lang 3.3.2 (org.apache.commons / commons-lang3 / 3.3.2)
3737
* Apache HttpClient 4.2.5 (org.apache.httpcomponents / httpclient / 4.2.5)
38+
* Apache HttpCore 4.2.5 (org.apache.httpcomponents / httpcore / 4.2.5)
3839
* Jackson Data Mapper 1.8 (org.codehaus.jackson / jackson-mapper-asl / 1.8.5)
3940
* JSON 20140107 (org.json / json / 20140107)
4041
* JUnit 4.11 (junit / junit / 4.11)
@@ -91,7 +92,7 @@ public class SampleApp {
9192
myCollection.setId(COLLECTION_ID);
9293

9394
// Configure the new collection performance tier to S1.
94-
RequestOptions requestOptions = new RequestOptions();
95+
RequestOptions requestOptions = new RequestOptions();
9596
requestOptions.setOfferType("S1");
9697

9798
// Create a new collection.

changelog.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,16 @@
1+
## Changes in 1.4.0 : ##
2+
3+
- Implement Upsert. New upsertXXX methods added to support Upsert feature.
4+
- Implement ID Based Routing. No public API changes, all changes internal.
5+
6+
## Changes in 1.3.0 : ##
7+
8+
- Release skipped to bring version number in alignment with other SDKs
9+
110
## Changes in 1.2.0 : ##
211

312
- Supports GeoSpatial index.
4-
- Validates resource id.
13+
- Validates id property for all resources. Ids for resources cannot contain ?, /, #, \\, characters or end with a space.
514
- Adds new header "index transformation progress" to ResourceResponse.
615

716
## Changes in 1.1.0 : ##

pom.xml

Lines changed: 6 additions & 3 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.2.0</version>
6+
<version>1.4.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>
@@ -13,10 +13,13 @@
1313
<url>http://www.opensource.org/licenses/mit-license.php</url>
1414
</license>
1515
</licenses>
16+
<properties>
17+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
18+
</properties>
1619
<developers>
1720
<developer>
18-
<name>Pu Shi</name>
19-
<email>pushi@microsoft.com</email>
21+
<name>Rajesh Nagpal</name>
22+
<email>rnagpal@microsoft.com</email>
2023
<organization>Microsoft</organization>
2124
<organizationUrl>http://www.microsoft.com/</organizationUrl>
2225
</developer>

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

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -27,23 +27,23 @@ final class AuthorizationHelper {
2727
* This API is a helper method to create auth header based on client request using masterkey.
2828
*
2929
* @param verb the verb.
30-
* @param resourceId the resource id.
30+
* @param resourceIdOrFullName the resource id or full name
3131
* @param resourceType the resource type.
3232
* @param headers the request headers.
3333
* @param masterKey the master key.
3434
* @return the key authorization signature.
3535
*/
3636
public static String GenerateKeyAuthorizationSignature(String verb,
37-
String resourceId,
37+
String resourceIdOrFullName,
3838
ResourceType resourceType,
3939
Map<String, String> headers,
4040
String masterKey) {
4141
if (verb == null || verb.isEmpty()) {
4242
throw new IllegalArgumentException("verb");
4343
}
4444

45-
if (resourceId == null) {
46-
resourceId = "";
45+
if (resourceIdOrFullName == null) {
46+
resourceIdOrFullName = "";
4747
}
4848

4949
if (resourceType == null) {
@@ -60,26 +60,25 @@ public static String GenerateKeyAuthorizationSignature(String verb,
6060

6161
byte[] decodedBytes = Base64.decodeBase64(masterKey.getBytes());
6262
SecretKey signingKey = new SecretKeySpec(decodedBytes, "HMACSHA256");
63-
64-
String text = String.format("%s\n%s\n%s\n",
65-
verb,
66-
AuthorizationHelper.getResourceSegement(resourceType),
67-
resourceId.toLowerCase());
63+
64+
// Skipping lower casing of resourceId since it may now contain "ID" of the resource as part of the FullName
65+
String body = String.format("%s\n%s\n%s\n",
66+
verb.toLowerCase(),
67+
AuthorizationHelper.getResourceSegement(resourceType).toLowerCase(),
68+
resourceIdOrFullName);
6869

6970
if (headers.containsKey(HttpConstants.HttpHeaders.X_DATE)) {
70-
text += headers.get(HttpConstants.HttpHeaders.X_DATE);
71+
body += headers.get(HttpConstants.HttpHeaders.X_DATE).toLowerCase();
7172
}
7273

73-
text += '\n';
74+
body += '\n';
7475

7576
if (headers.containsKey(HttpConstants.HttpHeaders.HTTP_DATE)) {
76-
text += headers.get(HttpConstants.HttpHeaders.HTTP_DATE);
77+
body += headers.get(HttpConstants.HttpHeaders.HTTP_DATE).toLowerCase();
7778
}
7879

79-
text += '\n';
80-
81-
String body = text.toLowerCase();
82-
80+
body += '\n';
81+
8382
Mac mac = null;
8483
try {
8584
mac = Mac.getInstance("HMACSHA256");
@@ -96,7 +95,7 @@ public static String GenerateKeyAuthorizationSignature(String verb,
9695

9796
byte[] digest = mac.doFinal(body.getBytes());
9897

99-
String auth = Helper.encodeBase64String(digest);
98+
String auth = Utils.encodeBase64String(digest);
10099

101100
String authtoken = "type=master&ver=1.0&sig=" + auth;
102101

0 commit comments

Comments
 (0)