Skip to content

Commit 5246e7e

Browse files
committed
- adds missing javadoc comments
1 parent 358d052 commit 5246e7e

17 files changed

Lines changed: 360 additions & 139 deletions

‎src/main/java/com/microsoft/graph/content/MSBatchRequestContent.java‎

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,18 @@
2424
import okhttp3.RequestBody;
2525
import okio.Buffer;
2626

27+
/**
28+
* Represents the content of a batch request
29+
*/
2730
public class MSBatchRequestContent {
2831
private final LinkedHashMap<String, MSBatchRequestStep> batchRequestStepsHashMap;
2932

30-
// Maximum number of requests that can be sent in a batch
33+
/**
34+
* Maximum number of requests that can be sent in a batch
35+
*/
3136
public static final int MAX_NUMBER_OF_REQUESTS = 20;
3237

33-
/*
38+
/**
3439
* Creates Batch request content using list provided
3540
*
3641
* @param batchRequestStepsArray List of batch steps for batching
@@ -44,16 +49,16 @@ public MSBatchRequestContent(@Nonnull final List<MSBatchRequestStep> batchReques
4449
addBatchRequestStep(requestStep);
4550
}
4651

47-
/*
52+
/**
4853
* Creates empty batch request content
4954
*/
5055
public MSBatchRequestContent() {
5156
this.batchRequestStepsHashMap = new LinkedHashMap<>();
5257
}
5358

54-
/*
59+
/**
60+
* Adds a step to the current batch
5561
* @param batchRequestStep Batch request step adding to batch content
56-
*
5762
* @return true or false based on addition or no addition of batch request step
5863
* given
5964
*/
@@ -83,7 +88,7 @@ public String addBatchRequestStep(@Nonnull final Request request, @Nullable fina
8388
throw new IllegalArgumentException("unable to add step to batch. Number of batch request steps cannot exceed " + MAX_NUMBER_OF_REQUESTS);
8489
}
8590

86-
/*
91+
/**
8792
* @param requestId Id of Batch request step to be removed
8893
*
8994
* @return true or false based on removal or no removal of batch request step
@@ -104,7 +109,7 @@ public boolean removeBatchRequestStepWithId(@Nonnull final String requestId) {
104109
return removed;
105110
}
106111

107-
/*
112+
/**
108113
* @return Batch request content's json as String
109114
*/
110115
@Nonnull

‎src/main/java/com/microsoft/graph/content/MSBatchRequestStep.java‎

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,34 +7,55 @@
77

88
import okhttp3.Request;
99

10+
/**
11+
* Respresents a step in a batch request
12+
*/
1013
public class MSBatchRequestStep {
1114
private String requestId;
1215
private Request request;
1316
private List<String> arrayOfDependsOnIds;
14-
17+
18+
/**
19+
* Initializes a batch step from a raw HTTP request
20+
* @param requestId the id to assign to this step
21+
* @param request the request to send in the batch
22+
* @param arrayOfDependsOnIds the ids of steps this step depends on
23+
*/
1524
public MSBatchRequestStep(@Nonnull final String requestId, @Nonnull final Request request, @Nullable final List<String> arrayOfDependsOnIds) {
1625
if(requestId == null)
1726
throw new IllegalArgumentException("Request Id cannot be null.");
1827
if(requestId.length() == 0)
1928
throw new IllegalArgumentException("Request Id cannot be empty.");
2029
if(request == null)
2130
new IllegalArgumentException("Request cannot be null.");
22-
31+
2332
this.requestId = requestId;
2433
this.request = request;
2534
this.arrayOfDependsOnIds = arrayOfDependsOnIds;
2635
}
27-
36+
37+
/**
38+
* Gets the current step ID
39+
* @return the current step ID
40+
*/
2841
@Nonnull
2942
public String getRequestId() {
3043
return requestId;
3144
}
32-
45+
46+
/**
47+
* Gets the raw HTTP request representation for the step
48+
* @return the raw HTTP request representation for the step
49+
*/
3350
@Nonnull
3451
public Request getRequest() {
3552
return request;
3653
}
37-
54+
55+
/**
56+
* Gets the list of steps this step depends on
57+
* @return the list of steps this step depends on
58+
*/
3859
@Nullable
3960
public List<String> getArrayOfDependsOnIds(){
4061
return arrayOfDependsOnIds;

‎src/main/java/com/microsoft/graph/content/MSBatchResponseContent.java‎

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,26 +21,29 @@
2121
import okhttp3.ResponseBody;
2222
import okio.Buffer;
2323

24+
/**
25+
* Represents the response of a batch request
26+
*/
2427
public class MSBatchResponseContent {
2528

2629
private final Response batchResponse;
2730
private LinkedHashMap<String, Request> batchRequestsHashMap;
2831
private JsonArray batchResponseArray;
2932
private String nextLink;
3033

31-
/*
34+
/**
3235
* @param batchResponse OkHttp batch response on execution of batch requests
3336
*/
3437
public MSBatchResponseContent(@Nullable final Response batchResponse) {
3538
this.batchResponse = batchResponse;
3639
update(batchResponse);
3740
}
3841

39-
/*
42+
/**
4043
* Returns OkHttp Response of given request Id
41-
*
44+
*
4245
* @param requestId Request Id of batch step
43-
*
46+
*
4447
* @return OkHttp Response corresponding to requestId
4548
*/
4649
@Nullable
@@ -107,7 +110,7 @@ public Response getResponseById(@Nonnull final String requestId) {
107110

108111
/**
109112
* Get map of id and responses
110-
*
113+
*
111114
* @return responses in Map of id and response
112115
*/
113116
@Nonnull
@@ -123,7 +126,7 @@ public Map<String, Response> getResponses() {
123126

124127
/**
125128
* Get iterator over the responses
126-
*
129+
*
127130
* @return iterator for responses
128131
*/
129132
@Nullable
@@ -132,6 +135,10 @@ public Iterator<Map.Entry<String, Response>> getResponsesIterator() {
132135
return responsesMap != null ? responsesMap.entrySet().iterator() : null;
133136
}
134137

138+
/**
139+
* Updates the response content using the raw http response object
140+
* @param batchResponse the response from the service.
141+
*/
135142
public void update(@Nonnull final Response batchResponse) {
136143
if (batchResponse == null)
137144
throw new IllegalArgumentException("Batch Response cannot be null");
@@ -169,7 +176,7 @@ public void update(@Nonnull final Response batchResponse) {
169176
}
170177
}
171178

172-
/*
179+
/**
173180
* @return nextLink of batch response
174181
*/
175182
@Nullable

‎src/main/java/com/microsoft/graph/httpcore/AuthenticationHandler.java‎

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,25 +12,35 @@
1212
import okhttp3.Request;
1313
import okhttp3.Response;
1414

15+
/**
16+
* Interceptor responsible for injecting the token in the request headers
17+
*/
1518
public class AuthenticationHandler implements Interceptor {
16-
17-
public final MiddlewareType MIDDLEWARE_TYPE = MiddlewareType.AUTHENTICATION;
19+
20+
/**
21+
* The current middleware type
22+
*/
23+
public final MiddlewareType MIDDLEWARE_TYPE = MiddlewareType.AUTHENTICATION;
1824

1925
private ICoreAuthenticationProvider authProvider;
20-
21-
public AuthenticationHandler(@Nonnull final ICoreAuthenticationProvider authProvider) {
26+
27+
/**
28+
* Initialize a the handler with a authentication provider
29+
* @param authProvider the authentication provider to use
30+
*/
31+
public AuthenticationHandler(@Nonnull final ICoreAuthenticationProvider authProvider) {
2232
this.authProvider = authProvider;
2333
}
2434

2535
@Override
2636
@Nullable
2737
public Response intercept(@Nonnull final Chain chain) throws IOException {
2838
Request originalRequest = chain.request();
29-
39+
3040
if(originalRequest.tag(TelemetryOptions.class) == null)
3141
originalRequest = originalRequest.newBuilder().tag(TelemetryOptions.class, new TelemetryOptions()).build();
3242
originalRequest.tag(TelemetryOptions.class).setFeatureUsage(TelemetryOptions.AUTH_HANDLER_ENABLED_FLAG);
33-
43+
3444
Request authenticatedRequest = authProvider.authenticateRequest(originalRequest);
3545
return chain.proceed(authenticatedRequest);
3646
}

‎src/main/java/com/microsoft/graph/httpcore/ChaosHttpHandler.java‎

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,11 @@
2121
* interceptor that randomly fails the responses for unit testing purposes
2222
*/
2323
public class ChaosHttpHandler implements Interceptor {
24+
/**
25+
* The current middleware type
26+
*/
2427
public final MiddlewareType MIDDLEWARE_TYPE = MiddlewareType.RETRY;
25-
/*
28+
/**
2629
* constant string being used
2730
*/
2831
private final String RETRY_AFTER = "Retry-After";
@@ -38,17 +41,20 @@ public class ChaosHttpHandler implements Interceptor {
3841
* body to respond on failed requests
3942
*/
4043
private final String responseBody = "{\"error\": {\"code\": \"TooManyRequests\",\"innerError\": {\"code\": \"429\",\"date\": \"2020-08-18T12:51:51\",\"message\": \"Please retry after\",\"request-id\": \"94fb3b52-452a-4535-a601-69e0a90e3aa2\",\"status\": \"429\"},\"message\": \"Please retry again later.\"}}";
41-
public static final int MSClientErrorCodeTooManyRequests = 429;
42-
44+
/**
45+
* Too many requests status code
46+
*/
47+
public static final int MSClientErrorCodeTooManyRequests = 429;
48+
4349
@Override
4450
@Nullable
4551
public Response intercept(@Nonnull final Chain chain) throws IOException {
4652
Request request = chain.request();
47-
53+
4854
if(request.tag(TelemetryOptions.class) == null)
4955
request = request.newBuilder().tag(TelemetryOptions.class, new TelemetryOptions()).build();
5056
request.tag(TelemetryOptions.class).setFeatureUsage(TelemetryOptions.RETRY_HANDLER_ENABLED_FLAG);
51-
57+
5258
final Integer dice = ThreadLocalRandom.current().nextInt(1, Integer.MAX_VALUE);
5359

5460
if(dice % failureRate == 0) {
@@ -66,4 +72,4 @@ public Response intercept(@Nonnull final Chain chain) throws IOException {
6672
}
6773
}
6874

69-
}
75+
}

‎src/main/java/com/microsoft/graph/httpcore/HttpClients.java‎

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
import okhttp3.Protocol;
1111
import okhttp3.OkHttpClient.Builder;
1212

13+
/**
14+
* Builder to get a custom HttpClient to be used for requests against Microsoft Graph
15+
*/
1316
public class HttpClients {
1417
private HttpClients() {
1518
super();
@@ -18,7 +21,7 @@ private HttpClients() {
1821
/**
1922
* Creates builder object for construction of custom
2023
* {@link OkHttpClient} instances.
21-
*
24+
*
2225
* @return OkHttpClient.Builder() custom builder for developer to add its own interceptors to it
2326
*/
2427
@Nonnull
@@ -32,9 +35,9 @@ public static Builder custom() {
3235
/**
3336
* Creates {@link OkHttpClient} instance with default
3437
* configuration and provided authProvider
35-
*
38+
*
3639
* @param auth Use IAuthenticationProvider instance provided while constructing http client
37-
* @return OkHttpClient build with authentication provider given, default redirect and default retry handlers
40+
* @return OkHttpClient build with authentication provider given, default redirect and default retry handlers
3841
*/
3942
@Nonnull
4043
public static OkHttpClient createDefault(@Nonnull final ICoreAuthenticationProvider auth) {
@@ -44,12 +47,12 @@ public static OkHttpClient createDefault(@Nonnull final ICoreAuthenticationProvi
4447
.addInterceptor(new RedirectHandler())
4548
.build();
4649
}
47-
50+
4851
/**
4952
* Creates {@link OkHttpClient} instance with interceptors
50-
*
53+
*
5154
* @param interceptors Use interceptors provided while constructing http client
52-
* @return OkHttpClient build with interceptors provided
55+
* @return OkHttpClient build with interceptors provided
5356
*/
5457
@Nonnull
5558
public static OkHttpClient createFromInterceptors(@Nullable final Interceptor[] interceptors) {

‎src/main/java/com/microsoft/graph/httpcore/ICoreAuthenticationProvider.java‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,13 @@
44

55
import javax.annotation.Nonnull;
66

7+
/**
8+
* Authenticates requests to be sent to the API
9+
*/
710
public interface ICoreAuthenticationProvider {
811
/**
912
* Authenticates the request
10-
*
13+
*
1114
* @param request the request to authenticate
1215
* @return Request with Authorization header added to it
1316
*/

0 commit comments

Comments
 (0)