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
Original file line number Diff line number Diff line change
Expand Up @@ -142,13 +142,12 @@ public Message deleteFile(String token, String appId, String fileName) throws IO
Message message = new Message();

try (Response response = client.newCall(request).execute()) {
message.setStatusCode(response.code());
message.setStatusText(response.message());

if (response.isSuccessful() && response.body() != null) {
String responseBody = response.body().string();
message = gson.fromJson(responseBody, Message.class);
}
message.setStatusCode(response.code());
message.setStatusText(response.message());
} catch (JsonSyntaxException e) {
log.error(e.getMessage(), e);
}
Expand All @@ -173,13 +172,12 @@ public ResumableUploads listResumableUploads(String token, String appId) throws
ResumableUploads resumableUploads = new ResumableUploads();

try (Response response = client.newCall(request).execute()) {
resumableUploads.setStatusCode(response.code());
resumableUploads.setStatusText(response.message());

if (response.isSuccessful() && response.body() != null) {
String responseBody = response.body().string();
resumableUploads = gson.fromJson(responseBody, ResumableUploads.class);
}
resumableUploads.setStatusCode(response.code());
resumableUploads.setStatusText(response.message());
} catch (JsonSyntaxException e) {
log.error(e.getMessage(), e);
}
Expand Down Expand Up @@ -233,12 +231,12 @@ public Chunk initializeResumableUpload(
Chunk chunkResponse = new Chunk();

try (Response response = client.newCall(request).execute()) {
chunkResponse.setStatusCode(response.code());
chunkResponse.setStatusText(response.message());
String _body = Objects.requireNonNull(response.body()).string();
if (response.isSuccessful() && _body != null) {
chunkResponse = gson.fromJson(_body, Chunk.class);
}
chunkResponse.setStatusCode(response.code());
chunkResponse.setStatusText(response.message());
} catch (JsonSyntaxException e) {
log.error(e.getMessage(), e);
}
Expand Down Expand Up @@ -285,13 +283,12 @@ public Chunk uploadChunk(
Chunk chunkResponse = new Chunk();

try (Response response = client.newCall(request).execute()) {
chunkResponse.setStatusCode(response.code());
chunkResponse.setStatusText(response.message());

if (response.isSuccessful() && response.body() != null) {
String responseBody = response.body().string();
chunkResponse = gson.fromJson(responseBody, Chunk.class);
}
chunkResponse.setStatusCode(response.code());
chunkResponse.setStatusText(response.message());
} catch (JsonSyntaxException e) {
log.error(e.getMessage(), e);
}
Expand Down Expand Up @@ -364,13 +361,12 @@ public Message deleteResumableUpload(String token, String appId, String uploadId
Message message = new Message();

try (Response response = client.newCall(request).execute()) {
message.setStatusCode(response.code());
message.setStatusText(response.message());

if (response.isSuccessful() && response.body() != null) {
String responseBody = response.body().string();
message = gson.fromJson(responseBody, Message.class);
}
message.setStatusCode(response.code());
message.setStatusText(response.message());
} catch (JsonSyntaxException e) {
log.error(e.getMessage(), e);
}
Expand Down Expand Up @@ -442,14 +438,14 @@ public Token getToken(String tokenType, String oidcProvider, String idToken) thr

try {
response = client.newCall(request).execute();
token.setStatusCode(response.code());
token.setStatusText(response.message());
ResponseBody responseBody = response.body();
if (response.isSuccessful() && responseBody != null) {
String bodyString = responseBody.string();
token.setToken(
JsonParser.parseString(bodyString).getAsJsonObject().get("token").getAsString());
}
token.setStatusCode(response.code());
token.setStatusText(response.message());
response.close();
} catch (Exception e) {
log.error(e.getMessage(), e);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package no.uio.ifi.tc.model.pojo;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.gson.annotations.SerializedName;
import lombok.Data;
import lombok.ToString;
Expand All @@ -8,9 +9,11 @@
@ToString
public class TSDFileAPIResponse {

@JsonProperty("statusCode")
@SerializedName("statusCode")
private int statusCode;

@JsonProperty("statusText")
@SerializedName("statusText")
private String statusText;
}