11package 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 *
1923import org .json .JSONObject ;
2024import org .slf4j .Logger ;
2125import org .slf4j .LoggerFactory ;
26+
2227import synapticloop .b2 .Action ;
2328import synapticloop .b2 .exception .B2ApiException ;
2429
25- import java .util .HashMap ;
26- import java .util .Iterator ;
27- import java .util .Map ;
28-
2930public 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+ }
0 commit comments