Skip to content

Commit 1e581e4

Browse files
committed
Initial Commit - DocumentDB Java SDK Preview
0 parents  commit 1e581e4

Some content is hidden

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

65 files changed

+9134
-0
lines changed

.classpath

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<classpath>
3+
<classpathentry kind="src" output="target/classes" path="src">
4+
<attributes>
5+
<attribute name="optional" value="true"/>
6+
<attribute name="maven.pomderived" value="true"/>
7+
</attributes>
8+
</classpathentry>
9+
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
10+
<attributes>
11+
<attribute name="maven.pomderived" value="true"/>
12+
</attributes>
13+
</classpathentry>
14+
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7">
15+
<attributes>
16+
<attribute name="maven.pomderived" value="true"/>
17+
</attributes>
18+
</classpathentry>
19+
<classpathentry kind="output" path="target/classes"/>
20+
</classpath>

.gitignore

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
*.class
2+
3+
# Mobile Tools for Java (J2ME)
4+
.mtj.tmp/
5+
6+
# Package Files #
7+
*.jar
8+
*.war
9+
*.ear
10+
11+
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
12+
hs_err_pid*
13+

.project

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>DocumentDB</name>
4+
<comment></comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
<buildCommand>
9+
<name>org.eclipse.jdt.core.javabuilder</name>
10+
<arguments>
11+
</arguments>
12+
</buildCommand>
13+
<buildCommand>
14+
<name>org.eclipse.m2e.core.maven2Builder</name>
15+
<arguments>
16+
</arguments>
17+
</buildCommand>
18+
</buildSpec>
19+
<natures>
20+
<nature>org.eclipse.m2e.core.maven2Nature</nature>
21+
<nature>org.eclipse.jdt.core.javanature</nature>
22+
</natures>
23+
</projectDescription>

.settings/org.eclipse.jdt.core.prefs

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
eclipse.preferences.version=1
2+
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
3+
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
4+
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
5+
org.eclipse.jdt.core.compiler.compliance=1.7
6+
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
7+
org.eclipse.jdt.core.compiler.debug.localVariable=generate
8+
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
9+
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
10+
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
11+
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
12+
org.eclipse.jdt.core.compiler.source=1.7

.settings/org.eclipse.m2e.core.prefs

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
activeProfiles=
2+
eclipse.preferences.version=1
3+
resolveWorkspaceProjects=true
4+
version=1

LICENSE

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
The MIT License (MIT)
2+
Copyright (c) 2014 Microsoft Corporation
3+
4+
Permission is hereby granted, free of charge, to any person obtaining a copy
5+
of this software and associated documentation files (the "Software"), to deal
6+
in the Software without restriction, including without limitation the rights
7+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8+
copies of the Software, and to permit persons to whom the Software is
9+
furnished to do so, subject to the following conditions:
10+
11+
The above copyright notice and this permission notice shall be included in all
12+
copies or substantial portions of the Software.
13+
14+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20+
SOFTWARE.

README.md

+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
#Microsoft Azure DocumentDB Java SDK
2+
3+
This project provides a client library in Java that makes it easy to consume Azure DocumentDB services. For documentation please see the Microsoft Azure [Java Developer Center](http://azure.microsoft.com/en-us/develop/java/) and the [JavaDocs](http://dl.windowsazure.com/documentdb/javadoc).
4+
5+
##Download
6+
###Option 1: Via Maven
7+
8+
To get the binaries of this library as distributed by Microsoft, ready for use within your project, you can use Maven.
9+
10+
<dependency>
11+
<groupId>com.microsoft.azure</groupId>
12+
<artifactId>azure-documentdb</artifactId>
13+
<version>0.9.0</version>
14+
</dependency>
15+
16+
###Option 2: Source Via Git
17+
18+
To get the source code of the SDK via git just type:
19+
20+
git clone git://github.com/Azure/azure-documentdb-java.git
21+
22+
###Option 3: Source Zip
23+
24+
To download a copy of the source code, click "Download ZIP" on the right side of the page or click [here](https://github.com/Azure/azure-documentdb-java/archive/master.zip).
25+
26+
27+
##Minimum Requirements
28+
* Java Development Kit 7
29+
* (Optional) Maven
30+
31+
### Dependencies
32+
* Apache Commons Lang 3.3.2 (org.apache.commons / commons-lang3 / 3.3.2)
33+
* Apache HttpClient 4.2.5 (org.apache.httpcomponents / httpclient / 4.2.5)
34+
* Jackson Data Mapper 1.8 (org.codehaus.jackson / jackson-mapper-asl / 1.8.5)
35+
* JSON 20140107 (org.json / json / 20140107)
36+
* JUnit 4.11 (junit / junit / 4.11)
37+
38+
Dependencies will be added automatically if Maven is used. Otherwise, please download the jars and add them to your build path.
39+
40+
##Usage
41+
42+
To use this SDK to call Azure DocumentDB, you need to first [create an account](http://azure.microsoft.com/en-us/documentation/articles/documentdb-create-account/).
43+
44+
Samples are provided in the unit tests.
45+
46+
##Need Help?
47+
48+
Be sure to check out the Microsoft Azure [Developer Forums on MSDN](https://social.msdn.microsoft.com/forums/azure/en-US/home?forum=AzureDocumentDB) or the [Developer Forums on Stack Overflow](http://stackoverflow.com/questions/tagged/azure-documentdb) if you have trouble with the provided code.
49+
50+
##Contribute Code or Provide Feedback
51+
52+
If you would like to become an active contributor to this project please follow the instructions provided in [Azure Projects Contribution Guidelines](http://azure.github.io/guidelines.html).
53+
54+
If you encounter any bugs with the library please file an issue in the [Issues](https://github.com/Azure/azure-documentdb-java/issues) section of the project.
55+
56+
##Learn More
57+
58+
* [Azure Developer Center](http://azure.microsoft.com/en-us/develop/java/)
59+
* [Azure DocumentDB Service](http://azure.microsoft.com/en-us/documentation/services/documentdb/)
60+
* [Azure DocumentDB Team Blog](http://blogs.msdn.com/b/documentdb/)
61+
* [JavaDocs](http://dl.windowsazure.com/documentdb/javadoc)

pom.xml

+71
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
<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">
2+
<modelVersion>4.0.0</modelVersion>
3+
<groupId>com.microsoft.azure.documentdb</groupId>
4+
<artifactId>DocumentDB</artifactId>
5+
<version>0.9.0-preview</version>
6+
<name>DocumentDB</name>
7+
<description>DocumentDB</description>
8+
<build>
9+
<sourceDirectory>src</sourceDirectory>
10+
<plugins>
11+
<plugin>
12+
<artifactId>maven-compiler-plugin</artifactId>
13+
<version>3.1</version>
14+
<configuration>
15+
<source>1.7</source>
16+
<target>1.7</target>
17+
</configuration>
18+
</plugin>
19+
<plugin>
20+
<artifactId>maven-assembly-plugin</artifactId>
21+
<version>2.2</version>
22+
<configuration>
23+
<descriptorRefs>
24+
<descriptorRef>jar-with-dependencies</descriptorRef>
25+
</descriptorRefs>
26+
</configuration>
27+
<executions>
28+
<execution>
29+
<id>make-assembly</id>
30+
<phase>package</phase>
31+
<goals>
32+
<goal>single</goal>
33+
</goals>
34+
</execution>
35+
</executions>
36+
</plugin>
37+
</plugins>
38+
</build>
39+
<dependencies>
40+
<dependency>
41+
<groupId>org.codehaus.jackson</groupId>
42+
<artifactId>jackson-mapper-asl</artifactId>
43+
<version>1.8.5</version>
44+
</dependency>
45+
<dependency>
46+
<groupId>org.json</groupId>
47+
<artifactId>json</artifactId>
48+
<version>20140107</version>
49+
</dependency>
50+
<dependency>
51+
<groupId>org.apache.commons</groupId>
52+
<artifactId>commons-lang3</artifactId>
53+
<version>3.3.2</version>
54+
</dependency>
55+
<dependency>
56+
<groupId>junit</groupId>
57+
<artifactId>junit</artifactId>
58+
<version>4.11</version>
59+
</dependency>
60+
<dependency>
61+
<groupId>org.apache.httpcomponents</groupId>
62+
<artifactId>httpclient</artifactId>
63+
<version>4.2.5</version>
64+
</dependency>
65+
<dependency>
66+
<groupId>org.apache.httpcomponents</groupId>
67+
<artifactId>httpcore</artifactId>
68+
<version>4.2.5</version>
69+
</dependency>
70+
</dependencies>
71+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/*
2+
* Copyright (c) Microsoft Corporation. All rights reserved.
3+
*/
4+
5+
package com.microsoft.azure.documentdb;
6+
7+
/**
8+
* Represents a set of access conditions to be used for operations against DocumentDB.
9+
*/
10+
public final class AccessCondition {
11+
12+
private AccessConditionType type = AccessConditionType.IfMatch;
13+
14+
/**
15+
* Gets the condition type.
16+
*
17+
* @return the condition type.
18+
*/
19+
public AccessConditionType getType() {
20+
return this.type;
21+
}
22+
23+
/**
24+
* Sets the condition type.
25+
*
26+
* @param type the condition type to use.
27+
*/
28+
public void setType(AccessConditionType type) {
29+
this.type = type;
30+
}
31+
32+
private String condition;
33+
34+
/**
35+
* Gets the value of the condition - for AccessConditionType IfMatchs and IfNotMatch, this is the ETag that has to
36+
* be compared to.
37+
*
38+
* @return the condition.
39+
*/
40+
public String getCondition() {
41+
return this.condition;
42+
}
43+
44+
/**
45+
* Sets the value of the condition - for AccessConditionType IfMatchs and IfNotMatch, this is the ETag that has to
46+
* be compared to.
47+
*
48+
* @param condition the condition to use.
49+
*/
50+
public void setCondition(String condition) {
51+
this.condition = condition;
52+
}
53+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/*
2+
* Copyright (c) Microsoft Corporation. All rights reserved.
3+
*/
4+
5+
package com.microsoft.azure.documentdb;
6+
7+
/**
8+
* Specifies the set of access condition types that can be used for operations.
9+
*/
10+
public enum AccessConditionType {
11+
/**
12+
* Check if the resource's ETag value matches the ETag value performed.
13+
*/
14+
IfMatch,
15+
16+
/**
17+
* Check if the resource's ETag value does not match ETag value performed.
18+
*/
19+
IfNoneMatch
20+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
package com.microsoft.azure.documentdb;
2+
3+
import org.json.JSONObject;
4+
5+
/**
6+
*
7+
* Represents a document attachment.
8+
*
9+
* Each document may contain zero or more attachemnts. Attachments can be of any MIME type - text, image, binary data.
10+
* These are stored externally in Azure Blob storage. Attachments are automatically deleted when the parent document
11+
* is deleted.
12+
*
13+
*/
14+
public class Attachment extends Resource {
15+
/**
16+
* Initialize an attachment object.
17+
*/
18+
public Attachment() {
19+
super();
20+
}
21+
22+
/**
23+
* Initialize an attachment object from json string.
24+
*
25+
* @param source the json string representation of the Attachment.
26+
*/
27+
public Attachment(String source) {
28+
super(source);
29+
}
30+
31+
/**
32+
* Initialize an attachment object from json object.
33+
*
34+
* @param jsonObject the json object representation of the Attachment.
35+
*/
36+
public Attachment(JSONObject jsonObject) {
37+
super(jsonObject);
38+
}
39+
40+
/**
41+
* Gets the MIME content type of the attachment.
42+
*
43+
* @return the content type.
44+
*/
45+
public String getContentType() {
46+
return super.getString(Constants.Properties.CONTENT_TYPE);
47+
}
48+
49+
/**
50+
* Sets the MIME content type of the attachment.
51+
*
52+
* @param contentType the content type to use.
53+
*/
54+
public void setContentType(String contentType) {
55+
super.set(Constants.Properties.CONTENT_TYPE, contentType);
56+
}
57+
58+
/**
59+
* Gets the media link associated with the attachment content.
60+
*
61+
* @return the media link.
62+
*/
63+
public String getMediaLink() {
64+
return super.getString(Constants.Properties.MEDIA_LINK);
65+
}
66+
67+
/**
68+
* Sets the media link associated with the attachment content.
69+
*
70+
* @param mediaLink the media link to use.
71+
*/
72+
public void setMediaLink(String mediaLink) {
73+
super.set(Constants.Properties.MEDIA_LINK, mediaLink);
74+
}
75+
}

0 commit comments

Comments
 (0)