Skip to content

Commit 5bd8c8d

Browse files
authored
Merge pull request #139 from microsoftgraph/dev
Bringing in changes from released dev branch to master branch
2 parents 759d5a8 + c24cac3 commit 5bd8c8d

File tree

11,307 files changed

+81597
-129484
lines changed

Some content is hidden

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

11,307 files changed

+81597
-129484
lines changed

README.md

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
# Preview Microsoft Graph SDK for Java
2-
*This SDK is currently in preview. Please continue to provide [feedback](https://github.com/microsoftgraph/msgraph-sdk-java/issues/new) as we iterate towards a production-supported library.*
1+
# Microsoft Graph SDK for Java
32

43
[ ![Download](https://api.bintray.com/packages/microsoftgraph/Maven/microsoft-graph/images/download.svg) ](https://bintray.com/microsoftgraph/Maven/microsoft-graph/_latestVersion)
54

@@ -14,18 +13,26 @@ Add the repository and a compile dependency for `microsoft-graph` to your projec
1413

1514
```gradle
1615
repository {
17-
jcenter {
18-
url "https://dl.bintray.com/microsoftgraph/Maven"
19-
}
16+
jcenter()
2017
}
2118
2219
dependency {
2320
// Include the sdk as a dependency
24-
compile('com.microsoft.graph:microsoft-graph:0.1.+')
21+
compile('com.microsoft.graph:microsoft-graph:1.0.+')
2522
}
2623
```
2724

28-
### 1.2 Enable ProGuard (Android)
25+
### 1.2 Install via Maven
26+
Add the dependency in `dependencies` in pom.xml
27+
```dependency
28+
<dependency>
29+
<groupId>com.microsoft.graph</groupId>
30+
<artifactId>microsoft-graph</artifactId>
31+
<version>1.0.0</version>
32+
</dependency>
33+
```
34+
35+
### 1.3 Enable ProGuard (Android)
2936
The nature of the Graph API is such that the SDK needs quite a large set of classes to describe its functionality. You need to ensure that [ProGuard](https://developer.android.com/studio/build/shrink-code.html) is enabled on your project. Otherwise, you will incur long build times for functionality that is not necessarily relevant to your particular application. If you are still hitting the 64K method limit, you can also enable [multidexing](https://developer.android.com/studio/build/multidex.html).
3037

3138
## 2. Getting started
@@ -102,7 +109,7 @@ Thanks to everyone who has already devoted time to improving the library:
102109
<!-- prettier-ignore -->
103110
| [<img src="https://avatars.githubusercontent.com/u/2273297?v=4" width="100px;"/><br /><sub><b>Caitlin Bales</b></sub>](https://developer.microsoft.com/graph)<br />[💬](#question-cbales "Answering Questions") [💻](https://github.com/microsoftgraph/msgraph-sdk-java/commits?author=cbales "Code") [📖](https://github.com/microsoftgraph/msgraph-sdk-java/wiki "Documentation") [👀](#review-cbales "Reviewed Pull Requests") [⚠️](https://github.com/microsoftgraph/msgraph-sdk-java/commits?author=cbales "Tests")| [<img src="https://avatars.githubusercontent.com/u/318187?v=4" width="100px;"/><br /><sub><b>David Moten</b></sub>](https://github.com/davidmoten)<br /> [🐛](https://github.com/microsoftgraph/msgraph-sdk-java/issues?q=is%3Aissue+author%3Adavidmoten "Bug reports") [💻](https://github.com/microsoftgraph/msgraph-sdk-java/commits?author=davidmoten "Code") [📖](https://github.com/microsoftgraph/msgraph-sdk-java/commit/87389b5a4240072e3f2226a2f04f089916ffed0b#diff-04c6e90faac2675aa89e2176d2eec7d8 "Documentation") [🤔](#ideas-davidmoten "Ideas & Planning") [👀](#review-davidmoten "Reviewed Pull Requests") [⚠️](https://github.com/microsoftgraph/msgraph-sdk-java/commits?author=davidmoten "Tests") | [<img src="https://avatars.githubusercontent.com/u/8527305?v=4" width="100px;"/><br /><sub><b>Michael Mainer</b></sub>](https://developer.microsoft.com/graph)<br /> [💬](#question-cbales "Answering Questions") [🤔](#ideas-MIchaelMainer "Ideas & Planning") [👀](#review-MIchaelMainer "Reviewed Pull Requests") | [<img src="https://avatars.githubusercontent.com/u/27295799?v=4" width="100px;"/><br /><sub><b>Linda Caputo</b></sub>](https://developer.microsoft.com/graph)<br />[📖](https://github.com/microsoftgraph/msgraph-sdk-java/wiki "Documentation") | [<img src="https://avatars.githubusercontent.com/u/8884923?v=4" width="100px;"/><br /><sub><b>John Austin</b></sub>](https://developer.microsoft.com/graph)<br />[🐛](https://github.com/microsoftgraph/msgraph-sdk-java/issues "Bug reports") | [<img src="https://avatars.githubusercontent.com/u/3460953?v=4" width="100px;"/><br /><sub><b>Dmitry Pimenov</b></sub>](https://developer.microsoft.com/graph)<br />[🤔](#ideas-dpim "Ideas & Planning") | [<img src="https://avatars.githubusercontent.com/u/1427840?v=4" width="100px;"/><br /><sub><b>Jonathan Giles</b></sub>](https://github.com/JonathanGiles)<br />[🤔](#ideas-JonathanGiles "Ideas & Planning") |
104111
| :---: | :---: | :---: | :---: | :---: | :---: | :---: |
105-
| [<img src="https://avatars.githubusercontent.com/u/881767?v=4" width="100px;"/><br /><sub><b>Martin Sawicki</b></sub>](https://github.com/martinsawicki)<br />[🤔](#ideas-martinsawicki "Ideas & Planning") | [<img src="https://avatars.githubusercontent.com/u/29152134?v=4" width="100px;"/><br /><sub><b>Louis Maresca</b></sub>](https://github.com/LouMM)<br />[🤔](#ideas-LouMM "Ideas & Planning") [👀](#review-LouMM "Reviewed Pull Requests") |
112+
| [<img src="https://avatars.githubusercontent.com/u/881767?v=4" width="100px;"/><br /><sub><b>Martin Sawicki</b></sub>](https://github.com/martinsawicki)<br />[🤔](#ideas-martinsawicki "Ideas & Planning") | [<img src="https://avatars.githubusercontent.com/u/29152134?v=4" width="100px;"/><br /><sub><b>Louis Maresca</b></sub>](https://github.com/LouMM)<br />[🤔](#ideas-LouMM "Ideas & Planning") [👀](#review-LouMM "Reviewed Pull Requests") | [<img src="https://avatars.githubusercontent.com/u/604089?v=4" width="100px;"/><br /><sub><b>Josef H.B. Schneider</b></sub>](https://j0s.at/)<br />[🐛](https://github.com/microsoftgraph/msgraph-sdk-java/issues?q=is%3Aissue+author%3AJ0s3f "Bug reports") [💻](https://github.com/microsoftgraph/msgraph-sdk-java/commits?author=J0s3f "Code") | [<img src="https://avatars2.githubusercontent.com/u/3197588?v=4" width="100px;"/><br /><sub><b>Deepak Agrawal</b></sub>](https://github.com/deepak2016)<br />[💻](https://github.com/microsoftgraph/msgraph-sdk-java/commits?author=deepak2016 "Code")
106113
<!-- ALL-CONTRIBUTORS-LIST:END -->
107114

108115
This project follows the [all-contributors](https://github.com/kentcdodds/all-contributors) specification. Contributions of any kind are welcome!

build.gradle

Lines changed: 123 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,14 @@ apply plugin: 'java'
1212
apply plugin: 'eclipse'
1313
apply plugin: 'maven'
1414
apply plugin: 'maven-publish'
15+
apply plugin: 'signing'
1516

1617
// In this section you declare where to find the dependencies of your project
1718
repositories {
1819
// Use jcenter for resolving your dependencies.
1920
// You can declare any Maven/Ivy/file repository here.
2021
jcenter()
22+
mavenCentral()
2123
}
2224

2325
dependencies {
@@ -35,6 +37,15 @@ dependencies {
3537
compile 'com.sun.jersey:jersey-server:1.19.4'
3638
}
3739

40+
def pomConfig = {
41+
licenses {
42+
license([:]) {
43+
name "MIT License"
44+
url "http://opensource.org/licenses/MIT"
45+
distribution "repo"
46+
}
47+
}
48+
}
3849

3950
publishing {
4051

@@ -46,14 +57,62 @@ publishing {
4657

4758
artifactId 'microsoft-graph'
4859

49-
version '${mavenMajorVersion}.${mavenMinorVersion}-SNAPSHOT'
60+
version "${mavenMajorVersion}.${mavenMinorVersion}.${mavenPatchVersion}${mavenArtifactSuffix}"
5061

5162
from components.java
5263

5364
artifact sourceJar
65+
pom.withXml {
66+
def root = asNode()
67+
root.appendNode('name', 'Preview Microsoft Graph SDK for Java')
68+
root.appendNode('url', 'https://github.com/microsoftgraph/msgraph-sdk-java')
69+
root.children().last() + pomConfig
70+
}
5471

5572
}
56-
73+
mavenJava(MavenPublication) {
74+
customizePom(pom)
75+
groupId 'com.microsoft.graph'
76+
artifactId 'microsoft-graph'
77+
version "${mavenMajorVersion}.${mavenMinorVersion}.${mavenPatchVersion}${mavenArtifactSuffix}"
78+
from components.java
79+
pom.withXml {
80+
def pomFile = file("${project.buildDir}/generated-pom.xml")
81+
writeTo(pomFile)
82+
def pomAscFile = signing.sign(pomFile).signatureFiles[0]
83+
artifact(pomAscFile) {
84+
classifier = null
85+
extension = 'pom.asc'
86+
}
87+
}
88+
artifact(sourceJar) {
89+
classifier = 'sources'
90+
}
91+
artifact(javadocJar) {
92+
classifier = 'javadoc'
93+
}
94+
project.tasks.signArchives.signatureFiles.each {
95+
artifact(it) {
96+
def matcher = it.file =~ /-(sources|javadoc)\.jar\.asc$/
97+
if(matcher.find()){
98+
classifier = matcher.group(1)
99+
}
100+
else{
101+
classifier = null
102+
}
103+
extension = 'jar.asc'
104+
}
105+
}
106+
}
107+
}
108+
repositories {
109+
maven {
110+
url = project.property('mavenCentralUploadUrl')
111+
credentials {
112+
username = project.property('sonatypeUsername')
113+
password = project.property('sonatypePassword')
114+
}
115+
}
57116
}
58117

59118
}
@@ -73,7 +132,7 @@ def getVersionCode() {
73132
}
74133

75134
def getVersionName() {
76-
return "${mavenMajorVersion}.${mavenMinorVersion}.${mavenPatchVersion}"
135+
return "${mavenMajorVersion}.${mavenMinorVersion}.${mavenPatchVersion}${mavenArtifactSuffix}"
77136
}
78137

79138
uploadArchives {
@@ -132,6 +191,67 @@ task javadocJar(type: Jar, dependsOn: javadoc) {
132191
}
133192

134193
artifacts {
194+
archives jar
135195
archives sourceJar
136196
archives javadocJar
137197
}
198+
199+
signing {
200+
sign configurations.archives
201+
}
202+
tasks.withType(Sign)*.enabled = mavenCentralPublishingEnabled.toBoolean()
203+
204+
def customizePom(pom) {
205+
pom.withXml {
206+
def root = asNode()
207+
208+
root.dependencies.removeAll { dep ->
209+
dep.scope == "test"
210+
}
211+
212+
root.children().last() + {
213+
resolveStrategy = Closure.DELEGATE_FIRST
214+
215+
description 'Microsoft Graph SDK'
216+
name 'Microsoft Graph Java SDK'
217+
url 'https://github.com/microsoftgraph/msgraph-sdk-java'
218+
organization {
219+
name 'Microsoft'
220+
url 'https://github.com/microsoftgraph/msgraph-sdk-java'
221+
}
222+
issueManagement {
223+
system 'GitHub'
224+
url 'https://github.com/microsoftgraph/msgraph-sdk-java/issues'
225+
}
226+
licenses {
227+
license {
228+
name "MIT License"
229+
url "http://opensource.org/licenses/MIT"
230+
distribution "repo"
231+
}
232+
}
233+
scm {
234+
url 'https://github.com/microsoftgraph/msgraph-sdk-java'
235+
connection 'scm:git:git://github.com/microsoftgraph/msgraph-sdk-java.git'
236+
developerConnection 'scm:git:ssh://[email protected]:microsoftgraph/msgraph-sdk-java.git'
237+
}
238+
developers {
239+
developer {
240+
name 'Microsoft'
241+
}
242+
}
243+
}
244+
}
245+
}
246+
247+
model {
248+
tasks.generatePomFileForMavenJavaPublication {
249+
destination = file("$buildDir/generated-pom.xml")
250+
}
251+
tasks.publishMavenJavaPublicationToMavenLocal {
252+
dependsOn project.tasks.signArchives
253+
}
254+
tasks.publishMavenJavaPublicationToMavenRepository {
255+
dependsOn project.tasks.signArchives
256+
}
257+
}

gradle.properties

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,16 @@
1818
# org.gradle.parallel=true
1919

2020
# The size of the library demands a large amount of RAM to build. Increase as necessary if you get GC errors
21-
org.gradle.jvmargs=-XX:MaxPermSize=512m -Xmx4g
21+
## linux requires 10G, OSX requires 11G
22+
org.gradle.jvmargs=-XX:MaxPermSize=512m -Xmx2g
2223

23-
mavenRepoUrl = https://api.bintray.com/maven/microsoftgraph/Maven/microsoft-graph
24+
mavenRepoUrl = https://api.bintray.com/content/microsoftgraph/Maven/microsoft-graph
2425
mavenGroupId = com.microsoft.graph
2526
mavenArtifactId = microsoft-graph
26-
mavenMajorVersion = 0
27-
mavenMinorVersion = 2
27+
mavenMajorVersion = 1
28+
mavenMinorVersion = 1
2829
mavenPatchVersion = 0
30+
mavenArtifactSuffix =
2931
nightliesUrl = http://dl.bintray.com/MicrosoftGraph/Maven
3032

3133
#These values are used to run functional tests
@@ -35,3 +37,12 @@ nightliesUrl = http://dl.bintray.com/MicrosoftGraph/Maven
3537
ClientId="CLIENT_ID"
3638
Username="USERNAME"
3739
Password="PASSWORD"
40+
41+
#enter below credentials and enable mavenCentralPublishingEnabled to publish to maven central
42+
signing.keyId="keyId"
43+
signing.secretKeyRingFile="fileLocation"
44+
signing.password="passphrase"
45+
sonatypeUsername="USERNAME"
46+
sonatypePassword="PASSWORD"
47+
mavenCentralUploadUrl=https://oss.sonatype.org/content/repositories/snapshots
48+
mavenCentralPublishingEnabled=false

src/main/java/com/microsoft/graph/concurrency/ChunkedUploadProvider.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,4 +193,19 @@ public void upload(final List<Option> options,
193193
this.readSoFar += read;
194194
}
195195
}
196+
197+
/**
198+
* Uploads content to remote upload session based on the input stream
199+
*
200+
* @param callback the progress callback invoked during uploading
201+
* @param configs the optional configurations for the upload options. [0] should be the customized chunk
202+
* size and [1] should be the maxRetry for upload retry.
203+
* @throws IOException the IO exception that occurred during upload
204+
*/
205+
public void upload(final IProgressCallback<UploadType> callback,
206+
final int...configs)
207+
throws IOException {
208+
upload(null, callback, configs);
209+
210+
}
196211
}

src/main/java/com/microsoft/graph/concurrency/DefaultExecutors.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,5 +144,8 @@ public void run() {
144144
public ILogger getLogger() {
145145
return logger;
146146
}
147-
147+
148+
public void shutdownBackgroundExecutors() {
149+
this.backgroundExecutor.shutdown();
150+
}
148151
}

src/main/java/com/microsoft/graph/concurrency/IExecutors.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,4 +67,9 @@ <Result> void performOnForeground(final int progress,
6767
*/
6868
<Result> void performOnForeground(final ClientException exception,
6969
final ICallback<Result> callback);
70+
71+
/**
72+
* Shuts down the background executors
73+
*/
74+
void shutdownBackgroundExecutors();
7075
}

src/main/java/com/microsoft/graph/core/BaseClient.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,4 +173,8 @@ protected void setHttpProvider(final IHttpProvider httpProvider) {
173173
public void setSerializer(final ISerializer serializer) {
174174
this.serializer = serializer;
175175
}
176+
177+
public void shutdown() {
178+
this.executors.shutdownBackgroundExecutors();
179+
}
176180
}

src/main/java/com/microsoft/graph/core/IBaseClient.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,4 +86,9 @@ public interface IBaseClient {
8686
* Validates this client
8787
*/
8888
void validate();
89+
90+
/*
91+
* Shuts down the executors.
92+
*/
93+
void shutdown();
8994
}

src/main/java/com/microsoft/graph/http/BaseCollectionRequest.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,13 +91,11 @@ protected T1 send() throws ClientException {
9191
* Posts this request
9292
*
9393
* @param serializedObject the object to serialize as the body
94-
* @param <T1> the type of the callback result
95-
* @param <T2> the type of the serialized body
94+
* @param <BodyType> the type of the serialized body, some times Action use different body than collection item
9695
* @return the response object
9796
* @throws ClientException an exception occurs if there was an error while the request was sent
9897
*/
99-
@SuppressWarnings("unchecked")
100-
protected <T1, T2> T1 post(final T2 serializedObject) throws ClientException {
98+
protected <BodyType> T1 post(final BodyType serializedObject) throws ClientException {
10199
baseRequest.setHttpMethod(HttpMethod.POST);
102100
return (T1) baseRequest.getClient().getHttpProvider().send(this, responseClass, serializedObject);
103101
}

src/main/java/com/microsoft/graph/http/DefaultHttpProvider.java

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
import java.io.IOException;
4040
import java.io.InputStream;
4141
import java.io.OutputStream;
42+
import java.io.UnsupportedEncodingException;
4243
import java.net.URL;
4344
import java.util.List;
4445
import java.util.Map;
@@ -58,6 +59,11 @@ public class DefaultHttpProvider implements IHttpProvider {
5859
* The content type for JSON responses
5960
*/
6061
static final String JSON_CONTENT_TYPE = "application/json";
62+
63+
/**
64+
* The encoding type for getBytes
65+
*/
66+
static final String JSON_ENCODING = "UTF-8";
6167

6268
/**
6369
* The serializer
@@ -254,7 +260,7 @@ private <Result, Body, DeserializeType> Result sendRequestInternal(final IHttpRe
254260
} else {
255261
logger.logDebug("Sending " + serializable.getClass().getName() + " as request body");
256262
final String serializeObject = serializer.serializeObject(serializable);
257-
bytesToWrite = serializeObject.getBytes();
263+
bytesToWrite = serializeObject.getBytes(JSON_ENCODING);
258264

259265
// If the user hasn't specified a Content-Type for the request
260266
if (!hasHeader(requestHeaders, CONTENT_TYPE_HEADER_NAME)) {
@@ -341,6 +347,11 @@ private <Result, Body, DeserializeType> Result sendRequestInternal(final IHttpRe
341347
final boolean shouldLogVerbosely = logger.getLoggingLevel() == LoggerLevel.DEBUG;
342348
logger.logError("Graph service exception " + ex.getMessage(shouldLogVerbosely), ex);
343349
throw ex;
350+
} catch (final UnsupportedEncodingException ex) {
351+
final ClientException clientException = new ClientException("Unsupported encoding problem: ",
352+
ex);
353+
logger.logError("Unsupported encoding problem: " + ex.getMessage(), ex);
354+
throw clientException;
344355
} catch (final Exception ex) {
345356
final ClientException clientException = new ClientException("Error during http request",
346357
ex);
@@ -401,10 +412,10 @@ private <Result> Result handleJsonResponse(final InputStream in, Map<String, Lis
401412
* @param clazz the type of the response object
402413
* @return the JSON object
403414
*/
404-
private <Result> Result handleEmptyResponse(Map<String, List<String>> responseHeaders, final Class<Result> clazz) {
415+
private <Result> Result handleEmptyResponse(Map<String, List<String>> responseHeaders, final Class<Result> clazz)
416+
throws UnsupportedEncodingException{
405417
//Create an empty object to attach the response headers to
406-
InputStream in = new ByteArrayInputStream("{}".getBytes());
407-
418+
InputStream in = new ByteArrayInputStream("{}".getBytes(JSON_ENCODING));
408419
return handleJsonResponse(in, responseHeaders, clazz);
409420
}
410421

0 commit comments

Comments
 (0)