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

Commit a2546d2

Browse files
SynapticloopSynapticloop
authored andcommitted
merge conflicts
2 parents 946180d + 71429f8 commit a2546d2

File tree

3 files changed

+33
-23
lines changed

3 files changed

+33
-23
lines changed

src/main/java/synapticloop/b2/Action.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,9 @@ public enum Action {
3131
* "hide" means a file version marking the file as hidden, so that it will not show up in b2_list_file_names.
3232
*/
3333
hide,
34-
/**
35-
* "upload" means a file that was uploaded.
36-
*/
37-
upload,
3834
/**
3935
* Pending multipart upload. "start" means that a large file has been started, but not finished or canceled.
4036
*/
37+
upload,
4138
start
4239
}

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

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
package synapticloop.b2.response;
22

3+
import java.util.HashMap;
4+
import java.util.Iterator;
5+
import java.util.Map;
6+
37
/*
4-
* Copyright (c) 2016 Synapticloop.
8+
* Copyright (c) 2016 synapticloop.
59
*
610
* All rights reserved.
711
*
@@ -19,13 +23,10 @@
1923
import org.json.JSONObject;
2024
import org.slf4j.Logger;
2125
import org.slf4j.LoggerFactory;
26+
2227
import synapticloop.b2.Action;
2328
import synapticloop.b2.exception.B2ApiException;
2429

25-
import java.util.HashMap;
26-
import java.util.Iterator;
27-
import java.util.Map;
28-
2930
public class B2FileInfoResponse extends BaseB2Response {
3031
private static final Logger LOGGER = LoggerFactory.getLogger(B2FileInfoResponse.class);
3132

@@ -36,9 +37,9 @@ public class B2FileInfoResponse extends BaseB2Response {
3637
private final Long contentLength;
3738

3839
private final Map<String, String> fileInfo;
39-
private final Action action;
40-
private final Long size;
41-
private final Long uploadTimestamp;
40+
private Action action;
41+
private final int size;
42+
private final long uploadTimestamp;
4243

4344
/**
4445
* Instantiate a file info response with the JSON response as a string from
@@ -70,13 +71,19 @@ public B2FileInfoResponse(final JSONObject response) throws B2ApiException {
7071

7172
String action = this.readString(B2ResponseProperties.KEY_ACTION);
7273
if(null != action) {
73-
this.action = Action.valueOf(action);
74+
try {
75+
this.action = Action.valueOf(action);
76+
}
77+
catch(IllegalArgumentException e) {
78+
LOGGER.warn("Unknown action value " + action);
79+
this.action = null;
80+
}
7481
} else {
7582
// Default
7683
this.action = Action.upload;
7784
}
7885

79-
this.size = this.readLong(B2ResponseProperties.KEY_SIZE);
86+
this.size = this.readInt(B2ResponseProperties.KEY_SIZE);
8087
this.uploadTimestamp = this.readLong(B2ResponseProperties.KEY_UPLOAD_TIMESTAMP);
8188

8289
this.warnOnMissedKeys();
@@ -135,14 +142,14 @@ public B2FileInfoResponse(final JSONObject response) throws B2ApiException {
135142
/**
136143
* @return The number of bytes in the file.
137144
*/
138-
public Long getSize() { return this.size; }
145+
public int getSize() { return this.size; }
139146

140147
/**
141148
* Return the timestamp that the file was uploaded
142149
*
143150
* @return the timestamp for when the file was uploaded
144151
*/
145-
public Long getUploadTimestamp() { return this.uploadTimestamp; }
152+
public long getUploadTimestamp() { return this.uploadTimestamp; }
146153

147154
@Override
148155
protected Logger getLogger() { return LOGGER; }
@@ -161,4 +168,4 @@ public String toString() {
161168
sb.append('}');
162169
return sb.toString();
163170
}
164-
}
171+
}

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

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ public class B2HideFileResponse extends BaseB2Response {
4343

4444
private final String fileId;
4545
private final String fileName;
46-
private final Action action;
47-
private final Integer size;
48-
private final Long uploadTimestamp;
46+
private Action action;
47+
private final int size;
48+
private final long uploadTimestamp;
4949

5050
/**
5151
* Instantiate a hide file response with the JSON response as a string from
@@ -61,9 +61,15 @@ public B2HideFileResponse(String json) throws B2ApiException {
6161
this.fileId = this.readString(B2ResponseProperties.KEY_FILE_ID);
6262
this.fileName = this.readString(B2ResponseProperties.KEY_FILE_NAME);
6363

64-
final String actionValue = this.readString(B2ResponseProperties.KEY_ACTION);
65-
if(null != actionValue) {
66-
this.action = Action.valueOf(actionValue);
64+
final String action = this.readString(B2ResponseProperties.KEY_ACTION);
65+
if(null != action) {
66+
try {
67+
this.action = Action.valueOf(action);
68+
}
69+
catch(IllegalArgumentException e) {
70+
LOGGER.warn("Unknown action value " + action);
71+
this.action = null;
72+
}
6773
} else {
6874
this.action = null;
6975
}

0 commit comments

Comments
 (0)