Repository navigation
Conversation
|
Verified that @iamharish has signed the CLA. Thanks for the pull request! |
| requests.add(createAppUserRequest); | ||
|
|
||
| //Get Root Folder Request | ||
| URL getRootFolderURL = BoxFolder.FOLDER_INFO_URL_TEMPLATE.build(api.getBaseURL(), 0); |
There was a problem hiding this comment.
what will happen if more than 20 request?
What about the non-whitelisted request?
There was a problem hiding this comment.
API will throw an error. No special handling in the SDK
| * Batch URL Template. | ||
| */ | ||
| public static final URLTemplate BATCH_URL_TEMPLATE = new URLTemplate("batch"); | ||
| private static final Logger LOGGER = Logger.getLogger(BoxAPIRequest.class.getName()); |
| Iterator<JsonValue> responseIterator = responseJSON.get("responses").asArray().iterator(); | ||
| while (responseIterator.hasNext()) { | ||
| JsonObject jsonResponse = responseIterator.next().asObject(); | ||
| BoxAPIResponse response = null; |
There was a problem hiding this comment.
Is it possible the batch API will throw 500?
There was a problem hiding this comment.
Totally. That will be thrown as BoxAPIException
| private static final int BUFFER_SIZE = 8192; | ||
|
|
||
| private final HttpURLConnection connection; | ||
| private final Map<String, String> headers; |
There was a problem hiding this comment.
Should not it be in the BoxBatchAPIResponse?
There was a problem hiding this comment.
Reusing BoxAPIResponse. It's an existing class. No need for special BoxBatchAPIResponse as the response will be same but a list instead of one response
| * @param responseCode http response code | ||
| * @param headers map of headers | ||
| */ | ||
| public BoxAPIResponse(int responseCode, Map<String, String> headers) { |
There was a problem hiding this comment.
Reusing BoxAPIResponse. It's an existing class. No need for special BoxBatchAPIResponse as the response will be same but a list instead of one response
| /** | ||
| * File URL Template. | ||
| */ | ||
| public static final URLTemplate FILE_URL_TEMPLATE = new URLTemplate("files/%s"); |
There was a problem hiding this comment.
I am not sure making them all public is a good idea, they should be only accessible internally to Batch class right? Why open them all to public?
There was a problem hiding this comment.
why should the URLs be only private? It's not a data we have to hide
| * Gets a JSON string containing any pending changes to this object that can be sent back to the Box API. | ||
| * @return a JSON string containing the pending changes. | ||
| */ | ||
| public JsonObject getPendingChangesAsJsonObject() { |
There was a problem hiding this comment.
added a new method in BoxJSONRequest which can take in JsonObject. This method can be used along with that to set body for a PUT request
| /** | ||
| * Get response as Json Object. | ||
| * @return response as JsonObject | ||
| */ |
There was a problem hiding this comment.
Java SDK deals with strings instead of JsonObject making it hard for devs who want to read contents in a response that's JSON, unless it's cast to a resource element. This method gives that feature
| InputStreamReader reader = new InputStreamReader(this.getBody(), StandardCharsets.UTF_8); | ||
| StringBuilder builder = new StringBuilder(); | ||
| char[] buffer = new char[BUFFER_SIZE]; | ||
| InputStreamReader reader = new InputStreamReader(this.getBody(), StandardCharsets.UTF_8); |
There was a problem hiding this comment.
that's correct. I have this enclosed in an else block now
No description provided.