Skip to content
This repository was archived by the owner on Dec 6, 2024. It is now read-only.

Commit 7c8c934

Browse files
authored
Merge pull request #26 from iterate-ch/feature/action-field
Feature/action field
2 parents cfb99c3 + e83dec3 commit 7c8c934

3 files changed

Lines changed: 19 additions & 9 deletions

File tree

src/main/java/synapticloop/b2/response/B2FileInfoResponse.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,7 @@ public B2FileInfoResponse(final JSONObject response) throws B2ApiException {
7676
}
7777
catch(IllegalArgumentException e) {
7878
LOGGER.warn("Unknown action value " + action);
79-
this.action = null;
8079
}
81-
} else {
82-
// Default
83-
this.action = Action.upload;
8480
}
8581

8682
this.size = this.readLong(B2ResponseProperties.KEY_SIZE);

src/main/java/synapticloop/b2/response/B2FileResponse.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import org.slf4j.Logger;
2525
import org.slf4j.LoggerFactory;
2626

27+
import synapticloop.b2.Action;
2728
import synapticloop.b2.exception.B2ApiException;
2829

2930
public class B2FileResponse extends BaseB2Response {
@@ -37,6 +38,7 @@ public class B2FileResponse extends BaseB2Response {
3738
private final String contentSha1;
3839
private final String contentType;
3940
private final Map<String, String> fileInfo;
41+
private Action action;
4042

4143
/**
4244
* Instantiate a file response with the JSON response as a string from
@@ -69,6 +71,16 @@ public B2FileResponse(String json) throws B2ApiException {
6971
}
7072
}
7173

74+
String action = this.readString(B2ResponseProperties.KEY_ACTION);
75+
if(null != action) {
76+
try {
77+
this.action = Action.valueOf(action);
78+
}
79+
catch(IllegalArgumentException e) {
80+
LOGGER.warn("Unknown action value " + action);
81+
}
82+
}
83+
7284
this.warnOnMissedKeys();
7385
}
7486

src/main/java/synapticloop/b2/response/B2FinishLargeFileResponse.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public class B2FinishLargeFileResponse extends BaseB2Response {
3838
private final String contentType;
3939

4040
private final Map<String, String> fileInfo;
41-
private final Action action;
41+
private Action action;
4242

4343
public B2FinishLargeFileResponse(final String json) throws B2ApiException {
4444
super(json);
@@ -63,10 +63,12 @@ public B2FinishLargeFileResponse(final String json) throws B2ApiException {
6363

6464
String action = this.readString(B2ResponseProperties.KEY_ACTION);
6565
if(null != action) {
66-
this.action = Action.valueOf(action);
67-
} else {
68-
// Default
69-
this.action = Action.upload;
66+
try {
67+
this.action = Action.valueOf(action);
68+
}
69+
catch(IllegalArgumentException e) {
70+
LOGGER.warn("Unknown action value " + action);
71+
}
7072
}
7173

7274
this.warnOnMissedKeys();

0 commit comments

Comments
 (0)