Skip to content

Commit 982c816

Browse files
author
Caitlin Bales (MSFT)
committed
Merge branch 'master' into preview-release
2 parents 614449f + aeb0eb9 commit 982c816

File tree

568 files changed

+1874
-2289
lines changed

Some content is hidden

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

568 files changed

+1874
-2289
lines changed

README.md

Lines changed: 17 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
# Preview Microsoft Graph SDK for Java
22
*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.*
33

4-
# Get started with the Microsoft Graph SDK for Java
5-
6-
Integrate the [Microsoft Graph API](https://developer.microsoft.com/graph) into your Java application!
4+
Get started with the Microsoft Graph SDK for Java by integrating the [Microsoft Graph API](https://graph.microsoft.io/en-us/getting-started) into your Java application!
75

86
## 1. Installation
7+
98
### 1.1 Install via Gradle
10-
Add the JCenter repository and a compile dependency for `microsoft-graph` to your project's `build.gradle`
9+
Add the JCenter repository and a compile dependency for `microsoft-graph` to your project's `build.gradle`:
1110

1211
```gradle
1312
repository {
@@ -21,27 +20,22 @@ dependency {
2120
```
2221

2322
### 1.2 Enable ProGuard (Android)
24-
25-
The nature of the Graph API is such that the SDK needs quite a large set of classes to describe its functionality. You will 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 necessary 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).
23+
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).
2624

2725
## 2. Getting started
2826

2927
### 2.1 Register your application
3028

31-
Register your application by following [these](https://developer.microsoft.com/en-us/graph/docs/concepts/auth_register_app_v2) steps.
29+
Register your application by following the steps at [Register your app with the Azure AD v2.0 endpoint](https://developer.microsoft.com/en-us/graph/docs/concepts/auth_register_app_v2).
3230

3331
### 2.2 Create an IAuthenticationProvider object
3432

35-
An instance of the **GraphServiceClient** class handles building requests,
36-
sending them to the Microsoft Graph API, and processing the responses. To create a
37-
new instance of this class, you need to provide an instance of
38-
`IAuthenticationProvider` which can authenticate requests to Microsoft Graph.
33+
An instance of the **GraphServiceClient** class handles building requests, sending them to the Microsoft Graph API, and processing the responses. To create a new instance of this class, you need to provide an instance of `IAuthenticationProvider`, which can authenticate requests to Microsoft Graph.
3934

40-
For an example of authentication in a client application see the [MSGraph SDK Android MSA Auth for Android Adapter](https://github.com/microsoftgraph/msgraph-sdk-android-msa-auth-for-android-adapter).
35+
For an example of authentication in a client application, see the [MSGraph SDK Android MSA Auth for Android Adapter](https://github.com/microsoftgraph/msgraph-sdk-android-msa-auth-for-android-adapter).
4136

4237
### 2.3 Get a GraphServiceClient object
43-
44-
Once you have set the correct application ID and url, you must get a **GraphServiceClient** object to make requests against the service. The SDK will store the account information for you, but when a user logs on for the first time, it will invoke UI to get the user's account information.
38+
After you have set the correct application ID and URL, you must get a **GraphServiceClient** object to make requests against the service. The SDK stores the account information for you, but when a user signs in for the first time, it invokes the UI to get the user's account information.
4539

4640
```java
4741
IClientConfig clientConfig =
@@ -55,9 +49,9 @@ IGraphServiceClient graphClient =
5549

5650
## 3. Make requests against the service
5751

58-
Once you have a GraphServiceClient that is authenticated you can begin making calls against the service. The requests against the service look like our [REST API](https://developer.microsoft.com/en-us/graph/docs/concepts/overview).
52+
After you have a GraphServiceClient that is authenticated, you can begin making calls against the service. The requests against the service look like our [REST API](https://developer.microsoft.com/en-us/graph/docs/concepts/overview).
5953

60-
### Get the user's drive
54+
### 3.1 Get the user's drive
6155

6256
To retrieve the user's drive:
6357

@@ -80,14 +74,14 @@ For a general overview of how the SDK is designed, see [overview](https://github
8074

8175
## 4. Documentation
8276

83-
For a more detailed documentation see:
77+
For more detailed documentation, see:
8478

8579
* [Overview](https://github.com/microsoftgraph/msgraph-sdk-java/wiki/Overview)
8680
* [Extending the library](https://github.com/microsoftgraph/msgraph-sdk-java/wiki/Extending-the-Library)
8781
* [Handling Open Types, PATCH support with `null` values](https://github.com/microsoftgraph/msgraph-sdk-java/wiki/Working-with-Open-Types)
8882
* [Collections](https://github.com/microsoftgraph/msgraph-sdk-java/wiki/Working-with-Collections)
89-
* [Making Custom Requests](https://github.com/microsoftgraph/msgraph-sdk-java/wiki/Custom-Requests)
90-
* [Known Issues](https://github.com/microsoftgraph/msgraph-sdk-java/wiki/Known-Issues)
83+
* [Making custom requests](https://github.com/microsoftgraph/msgraph-sdk-java/wiki/Custom-Requests)
84+
* [Known issues](https://github.com/microsoftgraph/msgraph-sdk-java/wiki/Known-Issues)
9185
* [Contributions](https://github.com/microsoftgraph/msgraph-sdk-java/blob/master/CONTRIBUTING.md)
9286

9387
## 5. Issues
@@ -96,7 +90,7 @@ For known issues, see [issues](https://github.com/MicrosoftGraph/msgraph-sdk-jav
9690

9791
## 6. Contributions
9892

99-
The Microsoft Graph SDK is open for contribution. Please read how to contribute to this project [here](https://github.com/microsoftgraph/msgraph-sdk-java/blob/master/CONTRIBUTING.md).
93+
The Microsoft Graph SDK is open for contribution. To contribute to this project, see [Contributing](https://github.com/microsoftgraph/msgraph-sdk-java/blob/master/CONTRIBUTING.md).
10094

10195
Thanks to everyone who has already devoted time to improving the library:
10296

@@ -109,13 +103,13 @@ Thanks to everyone who has already devoted time to improving the library:
109103

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

112-
## 7. Supported Java Versions
106+
## 7. Supported Java versions
113107
The Microsoft Graph SDK for Java library is supported at runtime for Java 7+ and [Android API revision 15](http://source.android.com/source/build-numbers.html) and greater.
114108

115109
## 8. License
116110

117111
Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the [MIT license](LICENSE).
118112

119-
## 9. Third Party Notices
113+
## 9. Third-party notices
120114

121-
[Third Party Notices](THIRD%20PARTY%20NOTICES)
115+
[Third-party notices](THIRD%20PARTY%20NOTICES)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ public void upload(final List<Option> options,
177177
ChunkedUploadRequest request =
178178
new ChunkedUploadRequest(this.uploadUrl, this.client, options, buffer, read,
179179
maxRetry, this.readSoFar, this.streamSize);
180-
ChunkedUploadResult result = request.upload(this.responseHandler);
180+
ChunkedUploadResult<UploadType> result = request.upload(this.responseHandler);
181181

182182
if (result.uploadCompleted()) {
183183
callback.progress(this.streamSize, this.streamSize);

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public void configConnection(final IConnection connection) {
7878
* @throws Exception An exception occurs if the request was unable to complete for any reason.
7979
*/
8080
@Override
81-
public ChunkedUploadResult generateResult(
81+
public ChunkedUploadResult<UploadType> generateResult(
8282
final IHttpRequest request,
8383
final IConnection connection,
8484
final ISerializer serializer,
@@ -89,10 +89,10 @@ public ChunkedUploadResult generateResult(
8989
if (connection.getResponseCode() == HttpResponseCode.HTTP_ACCEPTED) {
9090
logger.logDebug("Chunk bytes has been accepted by the server.");
9191
in = new BufferedInputStream(connection.getInputStream());
92-
final UploadSession seesion = serializer.deserializeObject(
92+
final UploadSession session = serializer.deserializeObject(
9393
DefaultHttpProvider.streamToString(in), UploadSession.class);
9494

95-
return new ChunkedUploadResult(seesion);
95+
return new ChunkedUploadResult<UploadType>(session);
9696

9797
} else if (connection.getResponseCode() == HttpResponseCode.HTTP_CREATED
9898
|| connection.getResponseCode() == HttpResponseCode.HTTP_OK) {
@@ -102,13 +102,13 @@ public ChunkedUploadResult generateResult(
102102
UploadType uploadedItem = serializer.deserializeObject(rawJson,
103103
this.deserializeTypeClass);
104104

105-
return new ChunkedUploadResult(uploadedItem);
105+
return new ChunkedUploadResult<UploadType>(uploadedItem);
106106
} else if (connection.getResponseCode() >= HttpResponseCode.HTTP_CLIENT_ERROR) {
107107
logger.logDebug("Receiving error during upload, see detail on result error");
108108

109-
return new ChunkedUploadResult(
109+
return new ChunkedUploadResult<UploadType>(
110110
GraphServiceException.createFromConnection(request, null, serializer,
111-
connection));
111+
connection, logger));
112112
}
113113
} finally {
114114
if (in != null) {

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

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

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

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

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ protected boolean hasParameter(final String name) {
5353
* @param <T> The type to which this object should be cast
5454
* @return The stored instance of T, otherwise null
5555
*/
56+
@SuppressWarnings("unchecked")
5657
protected <T> T getParameter(final String name) {
5758
return (T) bodyParams.get(name);
5859
}

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

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -27,28 +27,15 @@
2727
*/
2828
public class ClientException extends RuntimeException {
2929

30-
/**
31-
* The error code for this exception.
32-
*/
33-
private final GraphErrorCodes errorCode;
30+
private static final long serialVersionUID = -1066560879567392559L;
3431

3532
/**
3633
* Creates the client exception.
3734
* @param message The message to display.
3835
* @param ex The exception from.
3936
* @param errorCode The error code for this exception.
4037
*/
41-
public ClientException(final String message, final Throwable ex, final GraphErrorCodes errorCode) {
38+
public ClientException(final String message, final Throwable ex) {
4239
super(message, ex);
43-
this.errorCode = errorCode;
44-
}
45-
46-
/**
47-
* Determines if the given error code is expected.
48-
* @param expectedCode The expected error code.
49-
* @return true if the error code matches, and false if there was no match.
50-
*/
51-
public boolean isError(final GraphErrorCodes expectedCode) {
52-
return this.errorCode == expectedCode;
5340
}
5441
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ public IHttpProvider getHttpProvider() {
106106
getAuthenticationProvider(),
107107
getExecutors(),
108108
getLogger());
109-
logger.logDebug("Created DefaultHttpProvider");
109+
getLogger().logDebug("Created DefaultHttpProvider");
110110
}
111111
return httpProvider;
112112
}
@@ -120,7 +120,7 @@ public IHttpProvider getHttpProvider() {
120120
public ISerializer getSerializer() {
121121
if (serializer == null) {
122122
serializer = new DefaultSerializer(getLogger());
123-
logger.logDebug("Created DefaultSerializer");
123+
getLogger().logDebug("Created DefaultSerializer");
124124
}
125125
return serializer;
126126
}
@@ -134,7 +134,7 @@ public ISerializer getSerializer() {
134134
public IExecutors getExecutors() {
135135
if (executors == null) {
136136
executors = new DefaultExecutors(getLogger());
137-
logger.logDebug("Created DefaultExecutors");
137+
getLogger().logDebug("Created DefaultExecutors");
138138
}
139139
return executors;
140140
}

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

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ public abstract class BaseRequest implements IHttpRequest {
107107
public BaseRequest(final String requestUrl,
108108
final IBaseClient client,
109109
final List<? extends Option> options,
110-
final Class responseClass) {
110+
final Class<?> responseClass) {
111111
this.requestUrl = requestUrl;
112112
this.client = client;
113113
this.responseClass = responseClass;
@@ -153,8 +153,13 @@ public URL getRequestUrl() {
153153
try {
154154
return new URL(uriBuilder.build().toString());
155155
} catch (final MalformedURLException e) {
156-
throw new ClientException("Invalid URL: " + uriBuilder.toString(), e, GraphErrorCodes.INVALID_REQUEST);
156+
if (this instanceof CustomRequest) {
157+
this.getClient().getLogger().logError("Invalid custom URL: " + uriBuilder.toString(), e);
158+
} else {
159+
throw new ClientException("Invalid URL: " + uriBuilder.toString(), e);
160+
}
157161
}
162+
return null;
158163
}
159164

160165
private String addFunctionParameters() {
@@ -344,7 +349,8 @@ public IBaseClient getClient() {
344349
*
345350
* @return The response type.
346351
*/
347-
public Class getResponseType() {
352+
@SuppressWarnings("unchecked")
353+
public Class getResponseType() {
348354
return responseClass;
349355
}
350356
}

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

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,6 @@ public abstract class BaseRequestBuilder implements IRequestBuilder {
5050
*/
5151
private final List<Option> options = new ArrayList<>();
5252

53-
private final IJsonBackedObject body;
54-
5553
/**
5654
* Creates the request builder.
5755
*
@@ -66,23 +64,6 @@ public BaseRequestBuilder(
6664
) {
6765
this.requestUrl = requestUrl;
6866
this.client = client;
69-
this.body = null;
70-
71-
if (options != null) {
72-
this.options.addAll(options);
73-
}
74-
}
75-
76-
public BaseRequestBuilder(
77-
final String requestUrl,
78-
final IJsonBackedObject body,
79-
final IBaseClient client,
80-
final List<? extends Option> options
81-
) {
82-
this.requestUrl = requestUrl;
83-
this.client = client;
84-
this.body = body;
85-
8667
if (options != null) {
8768
this.options.addAll(options);
8869
}

0 commit comments

Comments
 (0)