Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 0 additions & 29 deletions src/main/java/com/microsoft/graph/Util.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,8 @@
import com.google.common.io.ByteStreams;

import com.microsoft.graph.core.ClientException;
import com.microsoft.graph.core.Constants;
import com.microsoft.graph.http.GraphServiceException;
import com.microsoft.graph.http.HttpResponseCode;
import com.microsoft.graph.http.HttpResponseHeadersHelper;
import com.microsoft.graph.http.IHttpRequest;
import com.microsoft.graph.http.IStatefulResponseHandler;
import com.microsoft.graph.logger.ILogger;
Expand All @@ -37,12 +35,12 @@
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Map;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;

import okhttp3.Response;
import okhttp3.ResponseBody;

import static com.microsoft.graph.http.HttpResponseCode.HTTP_OK;

Expand All @@ -53,8 +51,6 @@
*/
public class ChunkedUploadResponseHandler<UploadType>
implements IStatefulResponseHandler<ChunkedUploadResult<UploadType>, UploadType> {

private final static HttpResponseHeadersHelper responseHeadersHelper = new HttpResponseHeadersHelper();
/**
* The expected deserialized upload type
*/
Expand Down Expand Up @@ -107,25 +103,24 @@ public ChunkedUploadResult<UploadType> generateResult(
response, logger));
} else if (response.code() >= HTTP_OK
&& response.code() < HttpResponseCode.HTTP_MULTIPLE_CHOICES) {
final Map<String, String> headers = responseHeadersHelper.getResponseHeadersAsMapStringString(response);
final String contentType = headers.get(Constants.CONTENT_TYPE_HEADER_NAME);
final String location = headers.get("Location");
if (contentType != null
&& contentType.contains(Constants.JSON_CONTENT_TYPE)) {
return parseJsonUploadResult(response, serializer, logger);
} else if (location != null) {
logger.logDebug("Upload session is completed (Outlook), uploaded item returned.");
return new ChunkedUploadResult<>(this.deserializeTypeClass.getDeclaredConstructor().newInstance());
} else {
logger.logDebug("Upload session returned an unexpected response");
}
try(final ResponseBody body = response.body()) {
final String location = response.headers().get("Location");
if (body.contentType() != null && body.contentType().subtype().contains("json")) {
return parseJsonUploadResult(body, serializer, logger);
} else if (location != null) {
logger.logDebug("Upload session is completed (Outlook), uploaded item returned.");
return new ChunkedUploadResult<>(this.deserializeTypeClass.getDeclaredConstructor().newInstance());
} else {
logger.logDebug("Upload session returned an unexpected response");
}
}
}
return new ChunkedUploadResult<>(new ClientException("Received an unexpected response from the service, response code: " + response.code(), null));
}

@Nonnull
private ChunkedUploadResult<UploadType> parseJsonUploadResult(@Nonnull Response response, @Nonnull ISerializer serializer, @Nonnull ILogger logger) throws IOException {
try (final InputStream in = response.body().byteStream()) {
private ChunkedUploadResult<UploadType> parseJsonUploadResult(@Nonnull final ResponseBody responseBody, @Nonnull final ISerializer serializer, @Nonnull final ILogger logger) throws IOException {
try (final InputStream in = responseBody.byteStream()) {
final byte[] responseBytes = ByteStreams.toByteArray(in);
final IUploadSession session = serializer.deserializeObject(new ByteArrayInputStream(responseBytes), uploadSessionClass);

Expand Down
28 changes: 0 additions & 28 deletions src/main/java/com/microsoft/graph/core/Constants.java

This file was deleted.

2 changes: 0 additions & 2 deletions src/main/java/com/microsoft/graph/http/BaseRequest.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,9 @@
import com.microsoft.graph.options.FunctionOption;
import com.microsoft.graph.options.QueryOption;
import com.microsoft.graph.core.ClientException;
import com.microsoft.graph.core.Constants;
import com.microsoft.graph.options.HeaderOption;
import com.microsoft.graph.options.Option;

import java.lang.reflect.Field;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
Expand Down
Loading