id
int32
0
165k
repo
stringlengths
7
58
path
stringlengths
12
218
func_name
stringlengths
3
140
original_string
stringlengths
73
34.1k
language
stringclasses
1 value
code
stringlengths
73
34.1k
code_tokens
sequence
docstring
stringlengths
3
16k
docstring_tokens
sequence
sha
stringlengths
40
40
url
stringlengths
105
339
163,500
box/box-java-sdk
src/main/java/com/box/sdk/BoxRetentionPolicy.java
BoxRetentionPolicy.getAll
public static Iterable<BoxRetentionPolicy.Info> getAll(final BoxAPIConnection api, String ... fields) { return getAll(null, null, null, DEFAULT_LIMIT, api, fields); }
java
public static Iterable<BoxRetentionPolicy.Info> getAll(final BoxAPIConnection api, String ... fields) { return getAll(null, null, null, DEFAULT_LIMIT, api, fields); }
[ "public", "static", "Iterable", "<", "BoxRetentionPolicy", ".", "Info", ">", "getAll", "(", "final", "BoxAPIConnection", "api", ",", "String", "...", "fields", ")", "{", "return", "getAll", "(", "null", ",", "null", ",", "null", ",", "DEFAULT_LIMIT", ",", "api", ",", "fields", ")", ";", "}" ]
Returns all the retention policies. @param api the API connection to be used by the resource. @param fields the fields to retrieve. @return an iterable with all the retention policies.
[ "Returns", "all", "the", "retention", "policies", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxRetentionPolicy.java#L346-L348
163,501
box/box-java-sdk
src/main/java/com/box/sdk/BoxRetentionPolicy.java
BoxRetentionPolicy.getAll
public static Iterable<BoxRetentionPolicy.Info> getAll( String name, String type, String userID, int limit, final BoxAPIConnection api, String ... fields) { QueryStringBuilder queryString = new QueryStringBuilder(); if (name != null) { queryString.appendParam("policy_name", name); } if (type != null) { queryString.appendParam("policy_type", type); } if (userID != null) { queryString.appendParam("created_by_user_id", userID); } if (fields.length > 0) { queryString.appendParam("fields", fields); } URL url = RETENTION_POLICIES_URL_TEMPLATE.buildWithQuery(api.getBaseURL(), queryString.toString()); return new BoxResourceIterable<BoxRetentionPolicy.Info>(api, url, limit) { @Override protected BoxRetentionPolicy.Info factory(JsonObject jsonObject) { BoxRetentionPolicy policy = new BoxRetentionPolicy(api, jsonObject.get("id").asString()); return policy.new Info(jsonObject); } }; }
java
public static Iterable<BoxRetentionPolicy.Info> getAll( String name, String type, String userID, int limit, final BoxAPIConnection api, String ... fields) { QueryStringBuilder queryString = new QueryStringBuilder(); if (name != null) { queryString.appendParam("policy_name", name); } if (type != null) { queryString.appendParam("policy_type", type); } if (userID != null) { queryString.appendParam("created_by_user_id", userID); } if (fields.length > 0) { queryString.appendParam("fields", fields); } URL url = RETENTION_POLICIES_URL_TEMPLATE.buildWithQuery(api.getBaseURL(), queryString.toString()); return new BoxResourceIterable<BoxRetentionPolicy.Info>(api, url, limit) { @Override protected BoxRetentionPolicy.Info factory(JsonObject jsonObject) { BoxRetentionPolicy policy = new BoxRetentionPolicy(api, jsonObject.get("id").asString()); return policy.new Info(jsonObject); } }; }
[ "public", "static", "Iterable", "<", "BoxRetentionPolicy", ".", "Info", ">", "getAll", "(", "String", "name", ",", "String", "type", ",", "String", "userID", ",", "int", "limit", ",", "final", "BoxAPIConnection", "api", ",", "String", "...", "fields", ")", "{", "QueryStringBuilder", "queryString", "=", "new", "QueryStringBuilder", "(", ")", ";", "if", "(", "name", "!=", "null", ")", "{", "queryString", ".", "appendParam", "(", "\"policy_name\"", ",", "name", ")", ";", "}", "if", "(", "type", "!=", "null", ")", "{", "queryString", ".", "appendParam", "(", "\"policy_type\"", ",", "type", ")", ";", "}", "if", "(", "userID", "!=", "null", ")", "{", "queryString", ".", "appendParam", "(", "\"created_by_user_id\"", ",", "userID", ")", ";", "}", "if", "(", "fields", ".", "length", ">", "0", ")", "{", "queryString", ".", "appendParam", "(", "\"fields\"", ",", "fields", ")", ";", "}", "URL", "url", "=", "RETENTION_POLICIES_URL_TEMPLATE", ".", "buildWithQuery", "(", "api", ".", "getBaseURL", "(", ")", ",", "queryString", ".", "toString", "(", ")", ")", ";", "return", "new", "BoxResourceIterable", "<", "BoxRetentionPolicy", ".", "Info", ">", "(", "api", ",", "url", ",", "limit", ")", "{", "@", "Override", "protected", "BoxRetentionPolicy", ".", "Info", "factory", "(", "JsonObject", "jsonObject", ")", "{", "BoxRetentionPolicy", "policy", "=", "new", "BoxRetentionPolicy", "(", "api", ",", "jsonObject", ".", "get", "(", "\"id\"", ")", ".", "asString", "(", ")", ")", ";", "return", "policy", ".", "new", "Info", "(", "jsonObject", ")", ";", "}", "}", ";", "}" ]
Returns all the retention policies with specified filters. @param name a name to filter the retention policies by. A trailing partial match search is performed. Set to null if no name filtering is required. @param type a policy type to filter the retention policies by. Set to null if no type filtering is required. @param userID a user id to filter the retention policies by. Set to null if no type filtering is required. @param limit the limit of items per single response. The default value is 100. @param api the API connection to be used by the resource. @param fields the fields to retrieve. @return an iterable with all the retention policies met search conditions.
[ "Returns", "all", "the", "retention", "policies", "with", "specified", "filters", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxRetentionPolicy.java#L361-L386
163,502
box/box-java-sdk
src/main/java/com/box/sdk/EventStream.java
EventStream.start
public void start() { if (this.started) { throw new IllegalStateException("Cannot start the EventStream because it isn't stopped."); } final long initialPosition; if (this.startingPosition == STREAM_POSITION_NOW) { BoxAPIRequest request = new BoxAPIRequest(this.api, EVENT_URL.build(this.api.getBaseURL(), "now"), "GET"); BoxJSONResponse response = (BoxJSONResponse) request.send(); JsonObject jsonObject = JsonObject.readFrom(response.getJSON()); initialPosition = jsonObject.get("next_stream_position").asLong(); } else { assert this.startingPosition >= 0 : "Starting position must be non-negative"; initialPosition = this.startingPosition; } this.poller = new Poller(initialPosition); this.pollerThread = new Thread(this.poller); this.pollerThread.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { public void uncaughtException(Thread t, Throwable e) { EventStream.this.notifyException(e); } }); this.pollerThread.start(); this.started = true; }
java
public void start() { if (this.started) { throw new IllegalStateException("Cannot start the EventStream because it isn't stopped."); } final long initialPosition; if (this.startingPosition == STREAM_POSITION_NOW) { BoxAPIRequest request = new BoxAPIRequest(this.api, EVENT_URL.build(this.api.getBaseURL(), "now"), "GET"); BoxJSONResponse response = (BoxJSONResponse) request.send(); JsonObject jsonObject = JsonObject.readFrom(response.getJSON()); initialPosition = jsonObject.get("next_stream_position").asLong(); } else { assert this.startingPosition >= 0 : "Starting position must be non-negative"; initialPosition = this.startingPosition; } this.poller = new Poller(initialPosition); this.pollerThread = new Thread(this.poller); this.pollerThread.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { public void uncaughtException(Thread t, Throwable e) { EventStream.this.notifyException(e); } }); this.pollerThread.start(); this.started = true; }
[ "public", "void", "start", "(", ")", "{", "if", "(", "this", ".", "started", ")", "{", "throw", "new", "IllegalStateException", "(", "\"Cannot start the EventStream because it isn't stopped.\"", ")", ";", "}", "final", "long", "initialPosition", ";", "if", "(", "this", ".", "startingPosition", "==", "STREAM_POSITION_NOW", ")", "{", "BoxAPIRequest", "request", "=", "new", "BoxAPIRequest", "(", "this", ".", "api", ",", "EVENT_URL", ".", "build", "(", "this", ".", "api", ".", "getBaseURL", "(", ")", ",", "\"now\"", ")", ",", "\"GET\"", ")", ";", "BoxJSONResponse", "response", "=", "(", "BoxJSONResponse", ")", "request", ".", "send", "(", ")", ";", "JsonObject", "jsonObject", "=", "JsonObject", ".", "readFrom", "(", "response", ".", "getJSON", "(", ")", ")", ";", "initialPosition", "=", "jsonObject", ".", "get", "(", "\"next_stream_position\"", ")", ".", "asLong", "(", ")", ";", "}", "else", "{", "assert", "this", ".", "startingPosition", ">=", "0", ":", "\"Starting position must be non-negative\"", ";", "initialPosition", "=", "this", ".", "startingPosition", ";", "}", "this", ".", "poller", "=", "new", "Poller", "(", "initialPosition", ")", ";", "this", ".", "pollerThread", "=", "new", "Thread", "(", "this", ".", "poller", ")", ";", "this", ".", "pollerThread", ".", "setUncaughtExceptionHandler", "(", "new", "Thread", ".", "UncaughtExceptionHandler", "(", ")", "{", "public", "void", "uncaughtException", "(", "Thread", "t", ",", "Throwable", "e", ")", "{", "EventStream", ".", "this", ".", "notifyException", "(", "e", ")", ";", "}", "}", ")", ";", "this", ".", "pollerThread", ".", "start", "(", ")", ";", "this", ".", "started", "=", "true", ";", "}" ]
Starts this EventStream and begins long polling the API. @throws IllegalStateException if the EventStream is already started.
[ "Starts", "this", "EventStream", "and", "begins", "long", "polling", "the", "API", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/EventStream.java#L109-L137
163,503
box/box-java-sdk
src/main/java/com/box/sdk/EventStream.java
EventStream.isDuplicate
protected boolean isDuplicate(String eventID) { if (this.receivedEvents == null) { this.receivedEvents = new LRUCache<String>(); } return !this.receivedEvents.add(eventID); }
java
protected boolean isDuplicate(String eventID) { if (this.receivedEvents == null) { this.receivedEvents = new LRUCache<String>(); } return !this.receivedEvents.add(eventID); }
[ "protected", "boolean", "isDuplicate", "(", "String", "eventID", ")", "{", "if", "(", "this", ".", "receivedEvents", "==", "null", ")", "{", "this", ".", "receivedEvents", "=", "new", "LRUCache", "<", "String", ">", "(", ")", ";", "}", "return", "!", "this", ".", "receivedEvents", ".", "add", "(", "eventID", ")", ";", "}" ]
Indicates whether or not an event ID is a duplicate. <p>This method can be overridden by a subclass in order to provide custom de-duping logic.</p> @param eventID the event ID. @return true if the event is a duplicate; otherwise false.
[ "Indicates", "whether", "or", "not", "an", "event", "ID", "is", "a", "duplicate", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/EventStream.java#L147-L153
163,504
box/box-java-sdk
src/main/java/com/box/sdk/BoxRetentionPolicyAssignment.java
BoxRetentionPolicyAssignment.createAssignmentToEnterprise
public static BoxRetentionPolicyAssignment.Info createAssignmentToEnterprise(BoxAPIConnection api, String policyID) { return createAssignment(api, policyID, new JsonObject().add("type", TYPE_ENTERPRISE), null); }
java
public static BoxRetentionPolicyAssignment.Info createAssignmentToEnterprise(BoxAPIConnection api, String policyID) { return createAssignment(api, policyID, new JsonObject().add("type", TYPE_ENTERPRISE), null); }
[ "public", "static", "BoxRetentionPolicyAssignment", ".", "Info", "createAssignmentToEnterprise", "(", "BoxAPIConnection", "api", ",", "String", "policyID", ")", "{", "return", "createAssignment", "(", "api", ",", "policyID", ",", "new", "JsonObject", "(", ")", ".", "add", "(", "\"type\"", ",", "TYPE_ENTERPRISE", ")", ",", "null", ")", ";", "}" ]
Assigns retention policy with givenID to the enterprise. @param api the API connection to be used by the created assignment. @param policyID id of the assigned retention policy. @return info about created assignment.
[ "Assigns", "retention", "policy", "with", "givenID", "to", "the", "enterprise", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxRetentionPolicyAssignment.java#L65-L68
163,505
box/box-java-sdk
src/main/java/com/box/sdk/BoxRetentionPolicyAssignment.java
BoxRetentionPolicyAssignment.createAssignmentToFolder
public static BoxRetentionPolicyAssignment.Info createAssignmentToFolder(BoxAPIConnection api, String policyID, String folderID) { return createAssignment(api, policyID, new JsonObject().add("type", TYPE_FOLDER).add("id", folderID), null); }
java
public static BoxRetentionPolicyAssignment.Info createAssignmentToFolder(BoxAPIConnection api, String policyID, String folderID) { return createAssignment(api, policyID, new JsonObject().add("type", TYPE_FOLDER).add("id", folderID), null); }
[ "public", "static", "BoxRetentionPolicyAssignment", ".", "Info", "createAssignmentToFolder", "(", "BoxAPIConnection", "api", ",", "String", "policyID", ",", "String", "folderID", ")", "{", "return", "createAssignment", "(", "api", ",", "policyID", ",", "new", "JsonObject", "(", ")", ".", "add", "(", "\"type\"", ",", "TYPE_FOLDER", ")", ".", "add", "(", "\"id\"", ",", "folderID", ")", ",", "null", ")", ";", "}" ]
Assigns retention policy with givenID to the folder. @param api the API connection to be used by the created assignment. @param policyID id of the assigned retention policy. @param folderID id of the folder to assign policy to. @return info about created assignment.
[ "Assigns", "retention", "policy", "with", "givenID", "to", "the", "folder", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxRetentionPolicyAssignment.java#L77-L80
163,506
box/box-java-sdk
src/main/java/com/box/sdk/BoxRetentionPolicyAssignment.java
BoxRetentionPolicyAssignment.createAssignmentToMetadata
public static BoxRetentionPolicyAssignment.Info createAssignmentToMetadata(BoxAPIConnection api, String policyID, String templateID, MetadataFieldFilter... filter) { JsonObject assignTo = new JsonObject().add("type", TYPE_METADATA).add("id", templateID); JsonArray filters = null; if (filter.length > 0) { filters = new JsonArray(); for (MetadataFieldFilter f : filter) { filters.add(f.getJsonObject()); } } return createAssignment(api, policyID, assignTo, filters); }
java
public static BoxRetentionPolicyAssignment.Info createAssignmentToMetadata(BoxAPIConnection api, String policyID, String templateID, MetadataFieldFilter... filter) { JsonObject assignTo = new JsonObject().add("type", TYPE_METADATA).add("id", templateID); JsonArray filters = null; if (filter.length > 0) { filters = new JsonArray(); for (MetadataFieldFilter f : filter) { filters.add(f.getJsonObject()); } } return createAssignment(api, policyID, assignTo, filters); }
[ "public", "static", "BoxRetentionPolicyAssignment", ".", "Info", "createAssignmentToMetadata", "(", "BoxAPIConnection", "api", ",", "String", "policyID", ",", "String", "templateID", ",", "MetadataFieldFilter", "...", "filter", ")", "{", "JsonObject", "assignTo", "=", "new", "JsonObject", "(", ")", ".", "add", "(", "\"type\"", ",", "TYPE_METADATA", ")", ".", "add", "(", "\"id\"", ",", "templateID", ")", ";", "JsonArray", "filters", "=", "null", ";", "if", "(", "filter", ".", "length", ">", "0", ")", "{", "filters", "=", "new", "JsonArray", "(", ")", ";", "for", "(", "MetadataFieldFilter", "f", ":", "filter", ")", "{", "filters", ".", "add", "(", "f", ".", "getJsonObject", "(", ")", ")", ";", "}", "}", "return", "createAssignment", "(", "api", ",", "policyID", ",", "assignTo", ",", "filters", ")", ";", "}" ]
Assigns a retention policy to all items with a given metadata template, optionally matching on fields. @param api the API connection to be used by the created assignment. @param policyID id of the assigned retention policy. @param templateID the ID of the metadata template to assign the policy to. @param filter optional fields to match against in the metadata template. @return info about the created assignment.
[ "Assigns", "a", "retention", "policy", "to", "all", "items", "with", "a", "given", "metadata", "template", "optionally", "matching", "on", "fields", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxRetentionPolicyAssignment.java#L90-L103
163,507
box/box-java-sdk
src/main/java/com/box/sdk/BoxRetentionPolicyAssignment.java
BoxRetentionPolicyAssignment.createAssignment
private static BoxRetentionPolicyAssignment.Info createAssignment(BoxAPIConnection api, String policyID, JsonObject assignTo, JsonArray filter) { URL url = ASSIGNMENTS_URL_TEMPLATE.build(api.getBaseURL()); BoxJSONRequest request = new BoxJSONRequest(api, url, "POST"); JsonObject requestJSON = new JsonObject() .add("policy_id", policyID) .add("assign_to", assignTo); if (filter != null) { requestJSON.add("filter_fields", filter); } request.setBody(requestJSON.toString()); BoxJSONResponse response = (BoxJSONResponse) request.send(); JsonObject responseJSON = JsonObject.readFrom(response.getJSON()); BoxRetentionPolicyAssignment createdAssignment = new BoxRetentionPolicyAssignment(api, responseJSON.get("id").asString()); return createdAssignment.new Info(responseJSON); }
java
private static BoxRetentionPolicyAssignment.Info createAssignment(BoxAPIConnection api, String policyID, JsonObject assignTo, JsonArray filter) { URL url = ASSIGNMENTS_URL_TEMPLATE.build(api.getBaseURL()); BoxJSONRequest request = new BoxJSONRequest(api, url, "POST"); JsonObject requestJSON = new JsonObject() .add("policy_id", policyID) .add("assign_to", assignTo); if (filter != null) { requestJSON.add("filter_fields", filter); } request.setBody(requestJSON.toString()); BoxJSONResponse response = (BoxJSONResponse) request.send(); JsonObject responseJSON = JsonObject.readFrom(response.getJSON()); BoxRetentionPolicyAssignment createdAssignment = new BoxRetentionPolicyAssignment(api, responseJSON.get("id").asString()); return createdAssignment.new Info(responseJSON); }
[ "private", "static", "BoxRetentionPolicyAssignment", ".", "Info", "createAssignment", "(", "BoxAPIConnection", "api", ",", "String", "policyID", ",", "JsonObject", "assignTo", ",", "JsonArray", "filter", ")", "{", "URL", "url", "=", "ASSIGNMENTS_URL_TEMPLATE", ".", "build", "(", "api", ".", "getBaseURL", "(", ")", ")", ";", "BoxJSONRequest", "request", "=", "new", "BoxJSONRequest", "(", "api", ",", "url", ",", "\"POST\"", ")", ";", "JsonObject", "requestJSON", "=", "new", "JsonObject", "(", ")", ".", "add", "(", "\"policy_id\"", ",", "policyID", ")", ".", "add", "(", "\"assign_to\"", ",", "assignTo", ")", ";", "if", "(", "filter", "!=", "null", ")", "{", "requestJSON", ".", "add", "(", "\"filter_fields\"", ",", "filter", ")", ";", "}", "request", ".", "setBody", "(", "requestJSON", ".", "toString", "(", ")", ")", ";", "BoxJSONResponse", "response", "=", "(", "BoxJSONResponse", ")", "request", ".", "send", "(", ")", ";", "JsonObject", "responseJSON", "=", "JsonObject", ".", "readFrom", "(", "response", ".", "getJSON", "(", ")", ")", ";", "BoxRetentionPolicyAssignment", "createdAssignment", "=", "new", "BoxRetentionPolicyAssignment", "(", "api", ",", "responseJSON", ".", "get", "(", "\"id\"", ")", ".", "asString", "(", ")", ")", ";", "return", "createdAssignment", ".", "new", "Info", "(", "responseJSON", ")", ";", "}" ]
Assigns retention policy with givenID to folder or enterprise. @param api the API connection to be used by the created assignment. @param policyID id of the assigned retention policy. @param assignTo object representing folder or enterprise to assign policy to. @return info about created assignment.
[ "Assigns", "retention", "policy", "with", "givenID", "to", "folder", "or", "enterprise", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxRetentionPolicyAssignment.java#L112-L131
163,508
box/box-java-sdk
src/main/java/com/box/sdk/Metadata.java
Metadata.getAllMetadata
public static Iterable<Metadata> getAllMetadata(BoxItem item, String ... fields) { QueryStringBuilder builder = new QueryStringBuilder(); if (fields.length > 0) { builder.appendParam("fields", fields); } return new BoxResourceIterable<Metadata>( item.getAPI(), GET_ALL_METADATA_URL_TEMPLATE.buildWithQuery(item.getItemURL().toString(), builder.toString()), DEFAULT_LIMIT) { @Override protected Metadata factory(JsonObject jsonObject) { return new Metadata(jsonObject); } }; }
java
public static Iterable<Metadata> getAllMetadata(BoxItem item, String ... fields) { QueryStringBuilder builder = new QueryStringBuilder(); if (fields.length > 0) { builder.appendParam("fields", fields); } return new BoxResourceIterable<Metadata>( item.getAPI(), GET_ALL_METADATA_URL_TEMPLATE.buildWithQuery(item.getItemURL().toString(), builder.toString()), DEFAULT_LIMIT) { @Override protected Metadata factory(JsonObject jsonObject) { return new Metadata(jsonObject); } }; }
[ "public", "static", "Iterable", "<", "Metadata", ">", "getAllMetadata", "(", "BoxItem", "item", ",", "String", "...", "fields", ")", "{", "QueryStringBuilder", "builder", "=", "new", "QueryStringBuilder", "(", ")", ";", "if", "(", "fields", ".", "length", ">", "0", ")", "{", "builder", ".", "appendParam", "(", "\"fields\"", ",", "fields", ")", ";", "}", "return", "new", "BoxResourceIterable", "<", "Metadata", ">", "(", "item", ".", "getAPI", "(", ")", ",", "GET_ALL_METADATA_URL_TEMPLATE", ".", "buildWithQuery", "(", "item", ".", "getItemURL", "(", ")", ".", "toString", "(", ")", ",", "builder", ".", "toString", "(", ")", ")", ",", "DEFAULT_LIMIT", ")", "{", "@", "Override", "protected", "Metadata", "factory", "(", "JsonObject", "jsonObject", ")", "{", "return", "new", "Metadata", "(", "jsonObject", ")", ";", "}", "}", ";", "}" ]
Used to retrieve all metadata associated with the item. @param item item to get metadata for. @param fields the optional fields to retrieve. @return An iterable of metadata instances associated with the item.
[ "Used", "to", "retrieve", "all", "metadata", "associated", "with", "the", "item", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/Metadata.java#L106-L122
163,509
box/box-java-sdk
src/main/java/com/box/sdk/Metadata.java
Metadata.add
public Metadata add(String path, String value) { this.values.add(this.pathToProperty(path), value); this.addOp("add", path, value); return this; }
java
public Metadata add(String path, String value) { this.values.add(this.pathToProperty(path), value); this.addOp("add", path, value); return this; }
[ "public", "Metadata", "add", "(", "String", "path", ",", "String", "value", ")", "{", "this", ".", "values", ".", "add", "(", "this", ".", "pathToProperty", "(", "path", ")", ",", "value", ")", ";", "this", ".", "addOp", "(", "\"add\"", ",", "path", ",", "value", ")", ";", "return", "this", ";", "}" ]
Adds a new metadata value. @param path the path that designates the key. Must be prefixed with a "/". @param value the value. @return this metadata object.
[ "Adds", "a", "new", "metadata", "value", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/Metadata.java#L170-L174
163,510
box/box-java-sdk
src/main/java/com/box/sdk/Metadata.java
Metadata.add
public Metadata add(String path, List<String> values) { JsonArray arr = new JsonArray(); for (String value : values) { arr.add(value); } this.values.add(this.pathToProperty(path), arr); this.addOp("add", path, arr); return this; }
java
public Metadata add(String path, List<String> values) { JsonArray arr = new JsonArray(); for (String value : values) { arr.add(value); } this.values.add(this.pathToProperty(path), arr); this.addOp("add", path, arr); return this; }
[ "public", "Metadata", "add", "(", "String", "path", ",", "List", "<", "String", ">", "values", ")", "{", "JsonArray", "arr", "=", "new", "JsonArray", "(", ")", ";", "for", "(", "String", "value", ":", "values", ")", "{", "arr", ".", "add", "(", "value", ")", ";", "}", "this", ".", "values", ".", "add", "(", "this", ".", "pathToProperty", "(", "path", ")", ",", "arr", ")", ";", "this", ".", "addOp", "(", "\"add\"", ",", "path", ",", "arr", ")", ";", "return", "this", ";", "}" ]
Adds a new metadata value of array type. @param path the path to the field. @param values the collection of values. @return the metadata object for chaining.
[ "Adds", "a", "new", "metadata", "value", "of", "array", "type", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/Metadata.java#L194-L202
163,511
box/box-java-sdk
src/main/java/com/box/sdk/Metadata.java
Metadata.replace
public Metadata replace(String path, String value) { this.values.set(this.pathToProperty(path), value); this.addOp("replace", path, value); return this; }
java
public Metadata replace(String path, String value) { this.values.set(this.pathToProperty(path), value); this.addOp("replace", path, value); return this; }
[ "public", "Metadata", "replace", "(", "String", "path", ",", "String", "value", ")", "{", "this", ".", "values", ".", "set", "(", "this", ".", "pathToProperty", "(", "path", ")", ",", "value", ")", ";", "this", ".", "addOp", "(", "\"replace\"", ",", "path", ",", "value", ")", ";", "return", "this", ";", "}" ]
Replaces an existing metadata value. @param path the path that designates the key. Must be prefixed with a "/". @param value the value. @return this metadata object.
[ "Replaces", "an", "existing", "metadata", "value", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/Metadata.java#L210-L214
163,512
box/box-java-sdk
src/main/java/com/box/sdk/Metadata.java
Metadata.remove
public Metadata remove(String path) { this.values.remove(this.pathToProperty(path)); this.addOp("remove", path, (String) null); return this; }
java
public Metadata remove(String path) { this.values.remove(this.pathToProperty(path)); this.addOp("remove", path, (String) null); return this; }
[ "public", "Metadata", "remove", "(", "String", "path", ")", "{", "this", ".", "values", ".", "remove", "(", "this", ".", "pathToProperty", "(", "path", ")", ")", ";", "this", ".", "addOp", "(", "\"remove\"", ",", "path", ",", "(", "String", ")", "null", ")", ";", "return", "this", ";", "}" ]
Removes an existing metadata value. @param path the path that designates the key. Must be prefixed with a "/". @return this metadata object.
[ "Removes", "an", "existing", "metadata", "value", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/Metadata.java#L233-L237
163,513
box/box-java-sdk
src/main/java/com/box/sdk/Metadata.java
Metadata.get
@Deprecated public String get(String path) { final JsonValue value = this.values.get(this.pathToProperty(path)); if (value == null) { return null; } if (!value.isString()) { return value.toString(); } return value.asString(); }
java
@Deprecated public String get(String path) { final JsonValue value = this.values.get(this.pathToProperty(path)); if (value == null) { return null; } if (!value.isString()) { return value.toString(); } return value.asString(); }
[ "@", "Deprecated", "public", "String", "get", "(", "String", "path", ")", "{", "final", "JsonValue", "value", "=", "this", ".", "values", ".", "get", "(", "this", ".", "pathToProperty", "(", "path", ")", ")", ";", "if", "(", "value", "==", "null", ")", "{", "return", "null", ";", "}", "if", "(", "!", "value", ".", "isString", "(", ")", ")", "{", "return", "value", ".", "toString", "(", ")", ";", "}", "return", "value", ".", "asString", "(", ")", ";", "}" ]
Returns a value. @param path the path that designates the key. Must be prefixed with a "/". @return the metadata property value. @deprecated Metadata#get() does not handle all possible metadata types; use Metadata#getValue() instead
[ "Returns", "a", "value", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/Metadata.java#L272-L282
163,514
box/box-java-sdk
src/main/java/com/box/sdk/Metadata.java
Metadata.getDate
public Date getDate(String path) throws ParseException { return BoxDateFormat.parse(this.getValue(path).asString()); }
java
public Date getDate(String path) throws ParseException { return BoxDateFormat.parse(this.getValue(path).asString()); }
[ "public", "Date", "getDate", "(", "String", "path", ")", "throws", "ParseException", "{", "return", "BoxDateFormat", ".", "parse", "(", "this", ".", "getValue", "(", "path", ")", ".", "asString", "(", ")", ")", ";", "}" ]
Get a value from a date metadata field. @param path the key path in the metadata object. Must be prefixed with a "/". @return the metadata value as a Date. @throws ParseException when the value cannot be parsed as a valid date
[ "Get", "a", "value", "from", "a", "date", "metadata", "field", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/Metadata.java#L318-L320
163,515
box/box-java-sdk
src/main/java/com/box/sdk/Metadata.java
Metadata.getMultiSelect
public List<String> getMultiSelect(String path) { List<String> values = new ArrayList<String>(); for (JsonValue val : this.getValue(path).asArray()) { values.add(val.asString()); } return values; }
java
public List<String> getMultiSelect(String path) { List<String> values = new ArrayList<String>(); for (JsonValue val : this.getValue(path).asArray()) { values.add(val.asString()); } return values; }
[ "public", "List", "<", "String", ">", "getMultiSelect", "(", "String", "path", ")", "{", "List", "<", "String", ">", "values", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "for", "(", "JsonValue", "val", ":", "this", ".", "getValue", "(", "path", ")", ".", "asArray", "(", ")", ")", "{", "values", ".", "add", "(", "val", ".", "asString", "(", ")", ")", ";", "}", "return", "values", ";", "}" ]
Get a value from a multiselect metadata field. @param path the key path in the metadata object. Must be prefixed with a "/". @return the list of values set in the field.
[ "Get", "a", "value", "from", "a", "multiselect", "metadata", "field", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/Metadata.java#L327-L334
163,516
box/box-java-sdk
src/main/java/com/box/sdk/Metadata.java
Metadata.getPropertyPaths
public List<String> getPropertyPaths() { List<String> result = new ArrayList<String>(); for (String property : this.values.names()) { if (!property.startsWith("$")) { result.add(this.propertyToPath(property)); } } return result; }
java
public List<String> getPropertyPaths() { List<String> result = new ArrayList<String>(); for (String property : this.values.names()) { if (!property.startsWith("$")) { result.add(this.propertyToPath(property)); } } return result; }
[ "public", "List", "<", "String", ">", "getPropertyPaths", "(", ")", "{", "List", "<", "String", ">", "result", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "for", "(", "String", "property", ":", "this", ".", "values", ".", "names", "(", ")", ")", "{", "if", "(", "!", "property", ".", "startsWith", "(", "\"$\"", ")", ")", "{", "result", ".", "add", "(", "this", ".", "propertyToPath", "(", "property", ")", ")", ";", "}", "}", "return", "result", ";", "}" ]
Returns a list of metadata property paths. @return the list of metdata property paths.
[ "Returns", "a", "list", "of", "metadata", "property", "paths", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/Metadata.java#L340-L350
163,517
box/box-java-sdk
src/main/java/com/box/sdk/Metadata.java
Metadata.pathToProperty
private String pathToProperty(String path) { if (path == null || !path.startsWith("/")) { throw new IllegalArgumentException("Path must be prefixed with a \"/\"."); } return path.substring(1); }
java
private String pathToProperty(String path) { if (path == null || !path.startsWith("/")) { throw new IllegalArgumentException("Path must be prefixed with a \"/\"."); } return path.substring(1); }
[ "private", "String", "pathToProperty", "(", "String", "path", ")", "{", "if", "(", "path", "==", "null", "||", "!", "path", ".", "startsWith", "(", "\"/\"", ")", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Path must be prefixed with a \\\"/\\\".\"", ")", ";", "}", "return", "path", ".", "substring", "(", "1", ")", ";", "}" ]
Converts a JSON patch path to a JSON property name. Currently the metadata API only supports flat maps. @param path the path that designates the key. Must be prefixed with a "/". @return the JSON property name.
[ "Converts", "a", "JSON", "patch", "path", "to", "a", "JSON", "property", "name", ".", "Currently", "the", "metadata", "API", "only", "supports", "flat", "maps", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/Metadata.java#L386-L391
163,518
box/box-java-sdk
src/main/java/com/box/sdk/Metadata.java
Metadata.addOp
private void addOp(String op, String path, String value) { if (this.operations == null) { this.operations = new JsonArray(); } this.operations.add(new JsonObject() .add("op", op) .add("path", path) .add("value", value)); }
java
private void addOp(String op, String path, String value) { if (this.operations == null) { this.operations = new JsonArray(); } this.operations.add(new JsonObject() .add("op", op) .add("path", path) .add("value", value)); }
[ "private", "void", "addOp", "(", "String", "op", ",", "String", "path", ",", "String", "value", ")", "{", "if", "(", "this", ".", "operations", "==", "null", ")", "{", "this", ".", "operations", "=", "new", "JsonArray", "(", ")", ";", "}", "this", ".", "operations", ".", "add", "(", "new", "JsonObject", "(", ")", ".", "add", "(", "\"op\"", ",", "op", ")", ".", "add", "(", "\"path\"", ",", "path", ")", ".", "add", "(", "\"value\"", ",", "value", ")", ")", ";", "}" ]
Adds a patch operation. @param op the operation type. Must be add, replace, remove, or test. @param path the path that designates the key. Must be prefixed with a "/". @param value the value to be set.
[ "Adds", "a", "patch", "operation", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/Metadata.java#L411-L420
163,519
box/box-java-sdk
src/main/java/com/box/sdk/BoxCollaboration.java
BoxCollaboration.create
protected static BoxCollaboration.Info create(BoxAPIConnection api, JsonObject accessibleBy, JsonObject item, BoxCollaboration.Role role, Boolean notify, Boolean canViewPath) { String queryString = ""; if (notify != null) { queryString = new QueryStringBuilder().appendParam("notify", notify.toString()).toString(); } URL url; if (queryString.length() > 0) { url = COLLABORATIONS_URL_TEMPLATE.buildWithQuery(api.getBaseURL(), queryString); } else { url = COLLABORATIONS_URL_TEMPLATE.build(api.getBaseURL()); } JsonObject requestJSON = new JsonObject(); requestJSON.add("item", item); requestJSON.add("accessible_by", accessibleBy); requestJSON.add("role", role.toJSONString()); if (canViewPath != null) { requestJSON.add("can_view_path", canViewPath.booleanValue()); } BoxJSONRequest request = new BoxJSONRequest(api, url, "POST"); request.setBody(requestJSON.toString()); BoxJSONResponse response = (BoxJSONResponse) request.send(); JsonObject responseJSON = JsonObject.readFrom(response.getJSON()); BoxCollaboration newCollaboration = new BoxCollaboration(api, responseJSON.get("id").asString()); return newCollaboration.new Info(responseJSON); }
java
protected static BoxCollaboration.Info create(BoxAPIConnection api, JsonObject accessibleBy, JsonObject item, BoxCollaboration.Role role, Boolean notify, Boolean canViewPath) { String queryString = ""; if (notify != null) { queryString = new QueryStringBuilder().appendParam("notify", notify.toString()).toString(); } URL url; if (queryString.length() > 0) { url = COLLABORATIONS_URL_TEMPLATE.buildWithQuery(api.getBaseURL(), queryString); } else { url = COLLABORATIONS_URL_TEMPLATE.build(api.getBaseURL()); } JsonObject requestJSON = new JsonObject(); requestJSON.add("item", item); requestJSON.add("accessible_by", accessibleBy); requestJSON.add("role", role.toJSONString()); if (canViewPath != null) { requestJSON.add("can_view_path", canViewPath.booleanValue()); } BoxJSONRequest request = new BoxJSONRequest(api, url, "POST"); request.setBody(requestJSON.toString()); BoxJSONResponse response = (BoxJSONResponse) request.send(); JsonObject responseJSON = JsonObject.readFrom(response.getJSON()); BoxCollaboration newCollaboration = new BoxCollaboration(api, responseJSON.get("id").asString()); return newCollaboration.new Info(responseJSON); }
[ "protected", "static", "BoxCollaboration", ".", "Info", "create", "(", "BoxAPIConnection", "api", ",", "JsonObject", "accessibleBy", ",", "JsonObject", "item", ",", "BoxCollaboration", ".", "Role", "role", ",", "Boolean", "notify", ",", "Boolean", "canViewPath", ")", "{", "String", "queryString", "=", "\"\"", ";", "if", "(", "notify", "!=", "null", ")", "{", "queryString", "=", "new", "QueryStringBuilder", "(", ")", ".", "appendParam", "(", "\"notify\"", ",", "notify", ".", "toString", "(", ")", ")", ".", "toString", "(", ")", ";", "}", "URL", "url", ";", "if", "(", "queryString", ".", "length", "(", ")", ">", "0", ")", "{", "url", "=", "COLLABORATIONS_URL_TEMPLATE", ".", "buildWithQuery", "(", "api", ".", "getBaseURL", "(", ")", ",", "queryString", ")", ";", "}", "else", "{", "url", "=", "COLLABORATIONS_URL_TEMPLATE", ".", "build", "(", "api", ".", "getBaseURL", "(", ")", ")", ";", "}", "JsonObject", "requestJSON", "=", "new", "JsonObject", "(", ")", ";", "requestJSON", ".", "add", "(", "\"item\"", ",", "item", ")", ";", "requestJSON", ".", "add", "(", "\"accessible_by\"", ",", "accessibleBy", ")", ";", "requestJSON", ".", "add", "(", "\"role\"", ",", "role", ".", "toJSONString", "(", ")", ")", ";", "if", "(", "canViewPath", "!=", "null", ")", "{", "requestJSON", ".", "add", "(", "\"can_view_path\"", ",", "canViewPath", ".", "booleanValue", "(", ")", ")", ";", "}", "BoxJSONRequest", "request", "=", "new", "BoxJSONRequest", "(", "api", ",", "url", ",", "\"POST\"", ")", ";", "request", ".", "setBody", "(", "requestJSON", ".", "toString", "(", ")", ")", ";", "BoxJSONResponse", "response", "=", "(", "BoxJSONResponse", ")", "request", ".", "send", "(", ")", ";", "JsonObject", "responseJSON", "=", "JsonObject", ".", "readFrom", "(", "response", ".", "getJSON", "(", ")", ")", ";", "BoxCollaboration", "newCollaboration", "=", "new", "BoxCollaboration", "(", "api", ",", "responseJSON", ".", "get", "(", "\"id\"", ")", ".", "asString", "(", ")", ")", ";", "return", "newCollaboration", ".", "new", "Info", "(", "responseJSON", ")", ";", "}" ]
Create a new collaboration object. @param api the API connection used to make the request. @param accessibleBy the JSON object describing who should be collaborated. @param item the JSON object describing which item to collaborate. @param role the role to give the collaborators. @param notify the user/group should receive email notification of the collaboration or not. @param canViewPath the view path collaboration feature is enabled or not. @return info about the new collaboration.
[ "Create", "a", "new", "collaboration", "object", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxCollaboration.java#L68-L99
163,520
box/box-java-sdk
src/main/java/com/box/sdk/BoxCollaboration.java
BoxCollaboration.getPendingCollaborations
public static Collection<Info> getPendingCollaborations(BoxAPIConnection api) { URL url = PENDING_COLLABORATIONS_URL.build(api.getBaseURL()); BoxAPIRequest request = new BoxAPIRequest(api, url, "GET"); BoxJSONResponse response = (BoxJSONResponse) request.send(); JsonObject responseJSON = JsonObject.readFrom(response.getJSON()); int entriesCount = responseJSON.get("total_count").asInt(); Collection<BoxCollaboration.Info> collaborations = new ArrayList<BoxCollaboration.Info>(entriesCount); JsonArray entries = responseJSON.get("entries").asArray(); for (JsonValue entry : entries) { JsonObject entryObject = entry.asObject(); BoxCollaboration collaboration = new BoxCollaboration(api, entryObject.get("id").asString()); BoxCollaboration.Info info = collaboration.new Info(entryObject); collaborations.add(info); } return collaborations; }
java
public static Collection<Info> getPendingCollaborations(BoxAPIConnection api) { URL url = PENDING_COLLABORATIONS_URL.build(api.getBaseURL()); BoxAPIRequest request = new BoxAPIRequest(api, url, "GET"); BoxJSONResponse response = (BoxJSONResponse) request.send(); JsonObject responseJSON = JsonObject.readFrom(response.getJSON()); int entriesCount = responseJSON.get("total_count").asInt(); Collection<BoxCollaboration.Info> collaborations = new ArrayList<BoxCollaboration.Info>(entriesCount); JsonArray entries = responseJSON.get("entries").asArray(); for (JsonValue entry : entries) { JsonObject entryObject = entry.asObject(); BoxCollaboration collaboration = new BoxCollaboration(api, entryObject.get("id").asString()); BoxCollaboration.Info info = collaboration.new Info(entryObject); collaborations.add(info); } return collaborations; }
[ "public", "static", "Collection", "<", "Info", ">", "getPendingCollaborations", "(", "BoxAPIConnection", "api", ")", "{", "URL", "url", "=", "PENDING_COLLABORATIONS_URL", ".", "build", "(", "api", ".", "getBaseURL", "(", ")", ")", ";", "BoxAPIRequest", "request", "=", "new", "BoxAPIRequest", "(", "api", ",", "url", ",", "\"GET\"", ")", ";", "BoxJSONResponse", "response", "=", "(", "BoxJSONResponse", ")", "request", ".", "send", "(", ")", ";", "JsonObject", "responseJSON", "=", "JsonObject", ".", "readFrom", "(", "response", ".", "getJSON", "(", ")", ")", ";", "int", "entriesCount", "=", "responseJSON", ".", "get", "(", "\"total_count\"", ")", ".", "asInt", "(", ")", ";", "Collection", "<", "BoxCollaboration", ".", "Info", ">", "collaborations", "=", "new", "ArrayList", "<", "BoxCollaboration", ".", "Info", ">", "(", "entriesCount", ")", ";", "JsonArray", "entries", "=", "responseJSON", ".", "get", "(", "\"entries\"", ")", ".", "asArray", "(", ")", ";", "for", "(", "JsonValue", "entry", ":", "entries", ")", "{", "JsonObject", "entryObject", "=", "entry", ".", "asObject", "(", ")", ";", "BoxCollaboration", "collaboration", "=", "new", "BoxCollaboration", "(", "api", ",", "entryObject", ".", "get", "(", "\"id\"", ")", ".", "asString", "(", ")", ")", ";", "BoxCollaboration", ".", "Info", "info", "=", "collaboration", ".", "new", "Info", "(", "entryObject", ")", ";", "collaborations", ".", "add", "(", "info", ")", ";", "}", "return", "collaborations", ";", "}" ]
Gets all pending collaboration invites for the current user. @param api the API connection to use. @return a collection of pending collaboration infos.
[ "Gets", "all", "pending", "collaboration", "invites", "for", "the", "current", "user", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxCollaboration.java#L107-L125
163,521
box/box-java-sdk
src/main/java/com/box/sdk/BoxCollaboration.java
BoxCollaboration.getInfo
public Info getInfo() { BoxAPIConnection api = this.getAPI(); URL url = COLLABORATION_URL_TEMPLATE.build(api.getBaseURL(), this.getID()); BoxAPIRequest request = new BoxAPIRequest(api, url, "GET"); BoxJSONResponse response = (BoxJSONResponse) request.send(); JsonObject jsonObject = JsonObject.readFrom(response.getJSON()); return new Info(jsonObject); }
java
public Info getInfo() { BoxAPIConnection api = this.getAPI(); URL url = COLLABORATION_URL_TEMPLATE.build(api.getBaseURL(), this.getID()); BoxAPIRequest request = new BoxAPIRequest(api, url, "GET"); BoxJSONResponse response = (BoxJSONResponse) request.send(); JsonObject jsonObject = JsonObject.readFrom(response.getJSON()); return new Info(jsonObject); }
[ "public", "Info", "getInfo", "(", ")", "{", "BoxAPIConnection", "api", "=", "this", ".", "getAPI", "(", ")", ";", "URL", "url", "=", "COLLABORATION_URL_TEMPLATE", ".", "build", "(", "api", ".", "getBaseURL", "(", ")", ",", "this", ".", "getID", "(", ")", ")", ";", "BoxAPIRequest", "request", "=", "new", "BoxAPIRequest", "(", "api", ",", "url", ",", "\"GET\"", ")", ";", "BoxJSONResponse", "response", "=", "(", "BoxJSONResponse", ")", "request", ".", "send", "(", ")", ";", "JsonObject", "jsonObject", "=", "JsonObject", ".", "readFrom", "(", "response", ".", "getJSON", "(", ")", ")", ";", "return", "new", "Info", "(", "jsonObject", ")", ";", "}" ]
Gets information about this collaboration. @return info about this collaboration.
[ "Gets", "information", "about", "this", "collaboration", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxCollaboration.java#L132-L140
163,522
box/box-java-sdk
src/main/java/com/box/sdk/BoxCollaboration.java
BoxCollaboration.updateInfo
public void updateInfo(Info info) { BoxAPIConnection api = this.getAPI(); URL url = COLLABORATION_URL_TEMPLATE.build(api.getBaseURL(), this.getID()); BoxJSONRequest request = new BoxJSONRequest(api, url, "PUT"); request.setBody(info.getPendingChanges()); BoxAPIResponse boxAPIResponse = request.send(); if (boxAPIResponse instanceof BoxJSONResponse) { BoxJSONResponse response = (BoxJSONResponse) boxAPIResponse; JsonObject jsonObject = JsonObject.readFrom(response.getJSON()); info.update(jsonObject); } }
java
public void updateInfo(Info info) { BoxAPIConnection api = this.getAPI(); URL url = COLLABORATION_URL_TEMPLATE.build(api.getBaseURL(), this.getID()); BoxJSONRequest request = new BoxJSONRequest(api, url, "PUT"); request.setBody(info.getPendingChanges()); BoxAPIResponse boxAPIResponse = request.send(); if (boxAPIResponse instanceof BoxJSONResponse) { BoxJSONResponse response = (BoxJSONResponse) boxAPIResponse; JsonObject jsonObject = JsonObject.readFrom(response.getJSON()); info.update(jsonObject); } }
[ "public", "void", "updateInfo", "(", "Info", "info", ")", "{", "BoxAPIConnection", "api", "=", "this", ".", "getAPI", "(", ")", ";", "URL", "url", "=", "COLLABORATION_URL_TEMPLATE", ".", "build", "(", "api", ".", "getBaseURL", "(", ")", ",", "this", ".", "getID", "(", ")", ")", ";", "BoxJSONRequest", "request", "=", "new", "BoxJSONRequest", "(", "api", ",", "url", ",", "\"PUT\"", ")", ";", "request", ".", "setBody", "(", "info", ".", "getPendingChanges", "(", ")", ")", ";", "BoxAPIResponse", "boxAPIResponse", "=", "request", ".", "send", "(", ")", ";", "if", "(", "boxAPIResponse", "instanceof", "BoxJSONResponse", ")", "{", "BoxJSONResponse", "response", "=", "(", "BoxJSONResponse", ")", "boxAPIResponse", ";", "JsonObject", "jsonObject", "=", "JsonObject", ".", "readFrom", "(", "response", ".", "getJSON", "(", ")", ")", ";", "info", ".", "update", "(", "jsonObject", ")", ";", "}", "}" ]
Updates the information about this collaboration with any info fields that have been modified locally. @param info the updated info.
[ "Updates", "the", "information", "about", "this", "collaboration", "with", "any", "info", "fields", "that", "have", "been", "modified", "locally", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxCollaboration.java#L162-L175
163,523
box/box-java-sdk
src/main/java/com/box/sdk/BoxCollaboration.java
BoxCollaboration.delete
public void delete() { BoxAPIConnection api = this.getAPI(); URL url = COLLABORATION_URL_TEMPLATE.build(api.getBaseURL(), this.getID()); BoxAPIRequest request = new BoxAPIRequest(api, url, "DELETE"); BoxAPIResponse response = request.send(); response.disconnect(); }
java
public void delete() { BoxAPIConnection api = this.getAPI(); URL url = COLLABORATION_URL_TEMPLATE.build(api.getBaseURL(), this.getID()); BoxAPIRequest request = new BoxAPIRequest(api, url, "DELETE"); BoxAPIResponse response = request.send(); response.disconnect(); }
[ "public", "void", "delete", "(", ")", "{", "BoxAPIConnection", "api", "=", "this", ".", "getAPI", "(", ")", ";", "URL", "url", "=", "COLLABORATION_URL_TEMPLATE", ".", "build", "(", "api", ".", "getBaseURL", "(", ")", ",", "this", ".", "getID", "(", ")", ")", ";", "BoxAPIRequest", "request", "=", "new", "BoxAPIRequest", "(", "api", ",", "url", ",", "\"DELETE\"", ")", ";", "BoxAPIResponse", "response", "=", "request", ".", "send", "(", ")", ";", "response", ".", "disconnect", "(", ")", ";", "}" ]
Deletes this collaboration.
[ "Deletes", "this", "collaboration", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxCollaboration.java#L180-L187
163,524
box/box-java-sdk
src/main/java/com/box/sdk/BoxLegalHoldAssignment.java
BoxLegalHoldAssignment.create
public static BoxLegalHoldAssignment.Info create(BoxAPIConnection api, String policyID, String resourceType, String resourceID) { URL url = ASSIGNMENTS_URL_TEMPLATE.build(api.getBaseURL()); BoxJSONRequest request = new BoxJSONRequest(api, url, "POST"); JsonObject requestJSON = new JsonObject() .add("policy_id", policyID) .add("assign_to", new JsonObject() .add("type", resourceType) .add("id", resourceID)); request.setBody(requestJSON.toString()); BoxJSONResponse response = (BoxJSONResponse) request.send(); JsonObject responseJSON = JsonObject.readFrom(response.getJSON()); BoxLegalHoldAssignment createdAssignment = new BoxLegalHoldAssignment(api, responseJSON.get("id").asString()); return createdAssignment.new Info(responseJSON); }
java
public static BoxLegalHoldAssignment.Info create(BoxAPIConnection api, String policyID, String resourceType, String resourceID) { URL url = ASSIGNMENTS_URL_TEMPLATE.build(api.getBaseURL()); BoxJSONRequest request = new BoxJSONRequest(api, url, "POST"); JsonObject requestJSON = new JsonObject() .add("policy_id", policyID) .add("assign_to", new JsonObject() .add("type", resourceType) .add("id", resourceID)); request.setBody(requestJSON.toString()); BoxJSONResponse response = (BoxJSONResponse) request.send(); JsonObject responseJSON = JsonObject.readFrom(response.getJSON()); BoxLegalHoldAssignment createdAssignment = new BoxLegalHoldAssignment(api, responseJSON.get("id").asString()); return createdAssignment.new Info(responseJSON); }
[ "public", "static", "BoxLegalHoldAssignment", ".", "Info", "create", "(", "BoxAPIConnection", "api", ",", "String", "policyID", ",", "String", "resourceType", ",", "String", "resourceID", ")", "{", "URL", "url", "=", "ASSIGNMENTS_URL_TEMPLATE", ".", "build", "(", "api", ".", "getBaseURL", "(", ")", ")", ";", "BoxJSONRequest", "request", "=", "new", "BoxJSONRequest", "(", "api", ",", "url", ",", "\"POST\"", ")", ";", "JsonObject", "requestJSON", "=", "new", "JsonObject", "(", ")", ".", "add", "(", "\"policy_id\"", ",", "policyID", ")", ".", "add", "(", "\"assign_to\"", ",", "new", "JsonObject", "(", ")", ".", "add", "(", "\"type\"", ",", "resourceType", ")", ".", "add", "(", "\"id\"", ",", "resourceID", ")", ")", ";", "request", ".", "setBody", "(", "requestJSON", ".", "toString", "(", ")", ")", ";", "BoxJSONResponse", "response", "=", "(", "BoxJSONResponse", ")", "request", ".", "send", "(", ")", ";", "JsonObject", "responseJSON", "=", "JsonObject", ".", "readFrom", "(", "response", ".", "getJSON", "(", ")", ")", ";", "BoxLegalHoldAssignment", "createdAssignment", "=", "new", "BoxLegalHoldAssignment", "(", "api", ",", "responseJSON", ".", "get", "(", "\"id\"", ")", ".", "asString", "(", ")", ")", ";", "return", "createdAssignment", ".", "new", "Info", "(", "responseJSON", ")", ";", "}" ]
Creates new legal hold policy assignment. @param api the API connection to be used by the resource. @param policyID ID of policy to create assignment for. @param resourceType type of target resource. Can be 'file_version', 'file', 'folder', or 'user'. @param resourceID ID of the target resource. @return info about created legal hold policy assignment.
[ "Creates", "new", "legal", "hold", "policy", "assignment", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxLegalHoldAssignment.java#L72-L87
163,525
box/box-java-sdk
src/main/java/com/box/sdk/RetentionPolicyParams.java
RetentionPolicyParams.addCustomNotificationRecipient
public void addCustomNotificationRecipient(String userID) { BoxUser user = new BoxUser(null, userID); this.customNotificationRecipients.add(user.new Info()); }
java
public void addCustomNotificationRecipient(String userID) { BoxUser user = new BoxUser(null, userID); this.customNotificationRecipients.add(user.new Info()); }
[ "public", "void", "addCustomNotificationRecipient", "(", "String", "userID", ")", "{", "BoxUser", "user", "=", "new", "BoxUser", "(", "null", ",", "userID", ")", ";", "this", ".", "customNotificationRecipients", ".", "add", "(", "user", ".", "new", "Info", "(", ")", ")", ";", "}" ]
Add a user by ID to the list of people to notify when the retention period is ending. @param userID The ID of the user to add to the list.
[ "Add", "a", "user", "by", "ID", "to", "the", "list", "of", "people", "to", "notify", "when", "the", "retention", "period", "is", "ending", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/RetentionPolicyParams.java#L85-L89
163,526
box/box-java-sdk
src/main/java/com/box/sdk/BoxCollection.java
BoxCollection.getAllCollections
public static Iterable<BoxCollection.Info> getAllCollections(final BoxAPIConnection api) { return new Iterable<BoxCollection.Info>() { public Iterator<BoxCollection.Info> iterator() { URL url = GET_COLLECTIONS_URL_TEMPLATE.build(api.getBaseURL()); return new BoxCollectionIterator(api, url); } }; }
java
public static Iterable<BoxCollection.Info> getAllCollections(final BoxAPIConnection api) { return new Iterable<BoxCollection.Info>() { public Iterator<BoxCollection.Info> iterator() { URL url = GET_COLLECTIONS_URL_TEMPLATE.build(api.getBaseURL()); return new BoxCollectionIterator(api, url); } }; }
[ "public", "static", "Iterable", "<", "BoxCollection", ".", "Info", ">", "getAllCollections", "(", "final", "BoxAPIConnection", "api", ")", "{", "return", "new", "Iterable", "<", "BoxCollection", ".", "Info", ">", "(", ")", "{", "public", "Iterator", "<", "BoxCollection", ".", "Info", ">", "iterator", "(", ")", "{", "URL", "url", "=", "GET_COLLECTIONS_URL_TEMPLATE", ".", "build", "(", "api", ".", "getBaseURL", "(", ")", ")", ";", "return", "new", "BoxCollectionIterator", "(", "api", ",", "url", ")", ";", "}", "}", ";", "}" ]
Gets an iterable of all the collections for the given user. @param api the API connection to be used when retrieving the collections. @return an iterable containing info about all the collections.
[ "Gets", "an", "iterable", "of", "all", "the", "collections", "for", "the", "given", "user", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxCollection.java#L44-L51
163,527
box/box-java-sdk
src/main/java/com/box/sdk/BoxCollection.java
BoxCollection.getItemsRange
public PartialCollection<BoxItem.Info> getItemsRange(long offset, long limit, String... fields) { QueryStringBuilder builder = new QueryStringBuilder() .appendParam("offset", offset) .appendParam("limit", limit); if (fields.length > 0) { builder.appendParam("fields", fields).toString(); } URL url = GET_COLLECTION_ITEMS_URL.buildWithQuery(getAPI().getBaseURL(), builder.toString(), getID()); BoxAPIRequest request = new BoxAPIRequest(this.getAPI(), url, "GET"); BoxJSONResponse response = (BoxJSONResponse) request.send(); JsonObject responseJSON = JsonObject.readFrom(response.getJSON()); String totalCountString = responseJSON.get("total_count").toString(); long fullSize = Double.valueOf(totalCountString).longValue(); PartialCollection<BoxItem.Info> items = new PartialCollection<BoxItem.Info>(offset, limit, fullSize); JsonArray entries = responseJSON.get("entries").asArray(); for (JsonValue entry : entries) { BoxItem.Info entryInfo = (BoxItem.Info) BoxResource.parseInfo(this.getAPI(), entry.asObject()); if (entryInfo != null) { items.add(entryInfo); } } return items; }
java
public PartialCollection<BoxItem.Info> getItemsRange(long offset, long limit, String... fields) { QueryStringBuilder builder = new QueryStringBuilder() .appendParam("offset", offset) .appendParam("limit", limit); if (fields.length > 0) { builder.appendParam("fields", fields).toString(); } URL url = GET_COLLECTION_ITEMS_URL.buildWithQuery(getAPI().getBaseURL(), builder.toString(), getID()); BoxAPIRequest request = new BoxAPIRequest(this.getAPI(), url, "GET"); BoxJSONResponse response = (BoxJSONResponse) request.send(); JsonObject responseJSON = JsonObject.readFrom(response.getJSON()); String totalCountString = responseJSON.get("total_count").toString(); long fullSize = Double.valueOf(totalCountString).longValue(); PartialCollection<BoxItem.Info> items = new PartialCollection<BoxItem.Info>(offset, limit, fullSize); JsonArray entries = responseJSON.get("entries").asArray(); for (JsonValue entry : entries) { BoxItem.Info entryInfo = (BoxItem.Info) BoxResource.parseInfo(this.getAPI(), entry.asObject()); if (entryInfo != null) { items.add(entryInfo); } } return items; }
[ "public", "PartialCollection", "<", "BoxItem", ".", "Info", ">", "getItemsRange", "(", "long", "offset", ",", "long", "limit", ",", "String", "...", "fields", ")", "{", "QueryStringBuilder", "builder", "=", "new", "QueryStringBuilder", "(", ")", ".", "appendParam", "(", "\"offset\"", ",", "offset", ")", ".", "appendParam", "(", "\"limit\"", ",", "limit", ")", ";", "if", "(", "fields", ".", "length", ">", "0", ")", "{", "builder", ".", "appendParam", "(", "\"fields\"", ",", "fields", ")", ".", "toString", "(", ")", ";", "}", "URL", "url", "=", "GET_COLLECTION_ITEMS_URL", ".", "buildWithQuery", "(", "getAPI", "(", ")", ".", "getBaseURL", "(", ")", ",", "builder", ".", "toString", "(", ")", ",", "getID", "(", ")", ")", ";", "BoxAPIRequest", "request", "=", "new", "BoxAPIRequest", "(", "this", ".", "getAPI", "(", ")", ",", "url", ",", "\"GET\"", ")", ";", "BoxJSONResponse", "response", "=", "(", "BoxJSONResponse", ")", "request", ".", "send", "(", ")", ";", "JsonObject", "responseJSON", "=", "JsonObject", ".", "readFrom", "(", "response", ".", "getJSON", "(", ")", ")", ";", "String", "totalCountString", "=", "responseJSON", ".", "get", "(", "\"total_count\"", ")", ".", "toString", "(", ")", ";", "long", "fullSize", "=", "Double", ".", "valueOf", "(", "totalCountString", ")", ".", "longValue", "(", ")", ";", "PartialCollection", "<", "BoxItem", ".", "Info", ">", "items", "=", "new", "PartialCollection", "<", "BoxItem", ".", "Info", ">", "(", "offset", ",", "limit", ",", "fullSize", ")", ";", "JsonArray", "entries", "=", "responseJSON", ".", "get", "(", "\"entries\"", ")", ".", "asArray", "(", ")", ";", "for", "(", "JsonValue", "entry", ":", "entries", ")", "{", "BoxItem", ".", "Info", "entryInfo", "=", "(", "BoxItem", ".", "Info", ")", "BoxResource", ".", "parseInfo", "(", "this", ".", "getAPI", "(", ")", ",", "entry", ".", "asObject", "(", ")", ")", ";", "if", "(", "entryInfo", "!=", "null", ")", "{", "items", ".", "add", "(", "entryInfo", ")", ";", "}", "}", "return", "items", ";", "}" ]
Retrieves a specific range of items in this collection. @param offset the index of the first item to retrieve. @param limit the maximum number of items to retrieve after the offset. @param fields the fields to retrieve. @return a partial collection containing the specified range of items.
[ "Retrieves", "a", "specific", "range", "of", "items", "in", "this", "collection", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxCollection.java#L86-L111
163,528
box/box-java-sdk
src/main/java/com/box/sdk/BoxCollection.java
BoxCollection.iterator
@Override public Iterator<BoxItem.Info> iterator() { URL url = GET_COLLECTION_ITEMS_URL.build(this.getAPI().getBaseURL(), BoxCollection.this.getID()); return new BoxItemIterator(BoxCollection.this.getAPI(), url); }
java
@Override public Iterator<BoxItem.Info> iterator() { URL url = GET_COLLECTION_ITEMS_URL.build(this.getAPI().getBaseURL(), BoxCollection.this.getID()); return new BoxItemIterator(BoxCollection.this.getAPI(), url); }
[ "@", "Override", "public", "Iterator", "<", "BoxItem", ".", "Info", ">", "iterator", "(", ")", "{", "URL", "url", "=", "GET_COLLECTION_ITEMS_URL", ".", "build", "(", "this", ".", "getAPI", "(", ")", ".", "getBaseURL", "(", ")", ",", "BoxCollection", ".", "this", ".", "getID", "(", ")", ")", ";", "return", "new", "BoxItemIterator", "(", "BoxCollection", ".", "this", ".", "getAPI", "(", ")", ",", "url", ")", ";", "}" ]
Returns an iterator over the items in this collection. @return an iterator over the items in this collection.
[ "Returns", "an", "iterator", "over", "the", "items", "in", "this", "collection", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxCollection.java#L117-L121
163,529
box/box-java-sdk
src/main/java/com/box/sdk/BoxCollaborationWhitelistExemptTarget.java
BoxCollaborationWhitelistExemptTarget.create
public static BoxCollaborationWhitelistExemptTarget.Info create(final BoxAPIConnection api, String userID) { URL url = COLLABORATION_WHITELIST_EXEMPT_TARGET_ENTRIES_URL_TEMPLATE.build(api.getBaseURL()); BoxJSONRequest request = new BoxJSONRequest(api, url, HttpMethod.POST); JsonObject requestJSON = new JsonObject() .add("user", new JsonObject() .add("type", "user") .add("id", userID)); request.setBody(requestJSON.toString()); BoxJSONResponse response = (BoxJSONResponse) request.send(); JsonObject responseJSON = JsonObject.readFrom(response.getJSON()); BoxCollaborationWhitelistExemptTarget userWhitelist = new BoxCollaborationWhitelistExemptTarget(api, responseJSON.get("id").asString()); return userWhitelist.new Info(responseJSON); }
java
public static BoxCollaborationWhitelistExemptTarget.Info create(final BoxAPIConnection api, String userID) { URL url = COLLABORATION_WHITELIST_EXEMPT_TARGET_ENTRIES_URL_TEMPLATE.build(api.getBaseURL()); BoxJSONRequest request = new BoxJSONRequest(api, url, HttpMethod.POST); JsonObject requestJSON = new JsonObject() .add("user", new JsonObject() .add("type", "user") .add("id", userID)); request.setBody(requestJSON.toString()); BoxJSONResponse response = (BoxJSONResponse) request.send(); JsonObject responseJSON = JsonObject.readFrom(response.getJSON()); BoxCollaborationWhitelistExemptTarget userWhitelist = new BoxCollaborationWhitelistExemptTarget(api, responseJSON.get("id").asString()); return userWhitelist.new Info(responseJSON); }
[ "public", "static", "BoxCollaborationWhitelistExemptTarget", ".", "Info", "create", "(", "final", "BoxAPIConnection", "api", ",", "String", "userID", ")", "{", "URL", "url", "=", "COLLABORATION_WHITELIST_EXEMPT_TARGET_ENTRIES_URL_TEMPLATE", ".", "build", "(", "api", ".", "getBaseURL", "(", ")", ")", ";", "BoxJSONRequest", "request", "=", "new", "BoxJSONRequest", "(", "api", ",", "url", ",", "HttpMethod", ".", "POST", ")", ";", "JsonObject", "requestJSON", "=", "new", "JsonObject", "(", ")", ".", "add", "(", "\"user\"", ",", "new", "JsonObject", "(", ")", ".", "add", "(", "\"type\"", ",", "\"user\"", ")", ".", "add", "(", "\"id\"", ",", "userID", ")", ")", ";", "request", ".", "setBody", "(", "requestJSON", ".", "toString", "(", ")", ")", ";", "BoxJSONResponse", "response", "=", "(", "BoxJSONResponse", ")", "request", ".", "send", "(", ")", ";", "JsonObject", "responseJSON", "=", "JsonObject", ".", "readFrom", "(", "response", ".", "getJSON", "(", ")", ")", ";", "BoxCollaborationWhitelistExemptTarget", "userWhitelist", "=", "new", "BoxCollaborationWhitelistExemptTarget", "(", "api", ",", "responseJSON", ".", "get", "(", "\"id\"", ")", ".", "asString", "(", ")", ")", ";", "return", "userWhitelist", ".", "new", "Info", "(", "responseJSON", ")", ";", "}" ]
Creates a collaboration whitelist for a Box User with a given ID. @param api the API connection to be used by the collaboration whitelist. @param userID the ID of the Box User to add to the collaboration whitelist. @return information about the collaboration whitelist created for user.
[ "Creates", "a", "collaboration", "whitelist", "for", "a", "Box", "User", "with", "a", "given", "ID", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxCollaborationWhitelistExemptTarget.java#L56-L71
163,530
box/box-java-sdk
src/main/java/com/box/sdk/BoxCollaborationWhitelistExemptTarget.java
BoxCollaborationWhitelistExemptTarget.getInfo
public BoxCollaborationWhitelistExemptTarget.Info getInfo() { URL url = COLLABORATION_WHITELIST_EXEMPT_TARGET_ENTRY_URL_TEMPLATE.build(this.getAPI().getBaseURL(), this.getID()); BoxAPIRequest request = new BoxAPIRequest(this.getAPI(), url, HttpMethod.GET); BoxJSONResponse response = (BoxJSONResponse) request.send(); return new Info(JsonObject.readFrom(response.getJSON())); }
java
public BoxCollaborationWhitelistExemptTarget.Info getInfo() { URL url = COLLABORATION_WHITELIST_EXEMPT_TARGET_ENTRY_URL_TEMPLATE.build(this.getAPI().getBaseURL(), this.getID()); BoxAPIRequest request = new BoxAPIRequest(this.getAPI(), url, HttpMethod.GET); BoxJSONResponse response = (BoxJSONResponse) request.send(); return new Info(JsonObject.readFrom(response.getJSON())); }
[ "public", "BoxCollaborationWhitelistExemptTarget", ".", "Info", "getInfo", "(", ")", "{", "URL", "url", "=", "COLLABORATION_WHITELIST_EXEMPT_TARGET_ENTRY_URL_TEMPLATE", ".", "build", "(", "this", ".", "getAPI", "(", ")", ".", "getBaseURL", "(", ")", ",", "this", ".", "getID", "(", ")", ")", ";", "BoxAPIRequest", "request", "=", "new", "BoxAPIRequest", "(", "this", ".", "getAPI", "(", ")", ",", "url", ",", "HttpMethod", ".", "GET", ")", ";", "BoxJSONResponse", "response", "=", "(", "BoxJSONResponse", ")", "request", ".", "send", "(", ")", ";", "return", "new", "Info", "(", "JsonObject", ".", "readFrom", "(", "response", ".", "getJSON", "(", ")", ")", ")", ";", "}" ]
Retrieves information for a collaboration whitelist for a given whitelist ID. @return information about this {@link BoxCollaborationWhitelistExemptTarget}.
[ "Retrieves", "information", "for", "a", "collaboration", "whitelist", "for", "a", "given", "whitelist", "ID", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxCollaborationWhitelistExemptTarget.java#L78-L85
163,531
box/box-java-sdk
src/main/java/com/box/sdk/BoxDeveloperEditionAPIConnection.java
BoxDeveloperEditionAPIConnection.getAppEnterpriseConnection
public static BoxDeveloperEditionAPIConnection getAppEnterpriseConnection(String enterpriseId, String clientId, String clientSecret, JWTEncryptionPreferences encryptionPref, IAccessTokenCache accessTokenCache) { BoxDeveloperEditionAPIConnection connection = new BoxDeveloperEditionAPIConnection(enterpriseId, DeveloperEditionEntityType.ENTERPRISE, clientId, clientSecret, encryptionPref, accessTokenCache); connection.tryRestoreUsingAccessTokenCache(); return connection; }
java
public static BoxDeveloperEditionAPIConnection getAppEnterpriseConnection(String enterpriseId, String clientId, String clientSecret, JWTEncryptionPreferences encryptionPref, IAccessTokenCache accessTokenCache) { BoxDeveloperEditionAPIConnection connection = new BoxDeveloperEditionAPIConnection(enterpriseId, DeveloperEditionEntityType.ENTERPRISE, clientId, clientSecret, encryptionPref, accessTokenCache); connection.tryRestoreUsingAccessTokenCache(); return connection; }
[ "public", "static", "BoxDeveloperEditionAPIConnection", "getAppEnterpriseConnection", "(", "String", "enterpriseId", ",", "String", "clientId", ",", "String", "clientSecret", ",", "JWTEncryptionPreferences", "encryptionPref", ",", "IAccessTokenCache", "accessTokenCache", ")", "{", "BoxDeveloperEditionAPIConnection", "connection", "=", "new", "BoxDeveloperEditionAPIConnection", "(", "enterpriseId", ",", "DeveloperEditionEntityType", ".", "ENTERPRISE", ",", "clientId", ",", "clientSecret", ",", "encryptionPref", ",", "accessTokenCache", ")", ";", "connection", ".", "tryRestoreUsingAccessTokenCache", "(", ")", ";", "return", "connection", ";", "}" ]
Creates a new Box Developer Edition connection with enterprise token leveraging an access token cache. @param enterpriseId the enterprise ID to use for requesting access token. @param clientId the client ID to use when exchanging the JWT assertion for an access token. @param clientSecret the client secret to use when exchanging the JWT assertion for an access token. @param encryptionPref the encryption preferences for signing the JWT. @param accessTokenCache the cache for storing access token information (to minimize fetching new tokens) @return a new instance of BoxAPIConnection.
[ "Creates", "a", "new", "Box", "Developer", "Edition", "connection", "with", "enterprise", "token", "leveraging", "an", "access", "token", "cache", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxDeveloperEditionAPIConnection.java#L193-L202
163,532
box/box-java-sdk
src/main/java/com/box/sdk/BoxDeveloperEditionAPIConnection.java
BoxDeveloperEditionAPIConnection.getAppEnterpriseConnection
public static BoxDeveloperEditionAPIConnection getAppEnterpriseConnection(BoxConfig boxConfig) { BoxDeveloperEditionAPIConnection connection = getAppEnterpriseConnection(boxConfig.getEnterpriseId(), boxConfig.getClientId(), boxConfig.getClientSecret(), boxConfig.getJWTEncryptionPreferences()); return connection; }
java
public static BoxDeveloperEditionAPIConnection getAppEnterpriseConnection(BoxConfig boxConfig) { BoxDeveloperEditionAPIConnection connection = getAppEnterpriseConnection(boxConfig.getEnterpriseId(), boxConfig.getClientId(), boxConfig.getClientSecret(), boxConfig.getJWTEncryptionPreferences()); return connection; }
[ "public", "static", "BoxDeveloperEditionAPIConnection", "getAppEnterpriseConnection", "(", "BoxConfig", "boxConfig", ")", "{", "BoxDeveloperEditionAPIConnection", "connection", "=", "getAppEnterpriseConnection", "(", "boxConfig", ".", "getEnterpriseId", "(", ")", ",", "boxConfig", ".", "getClientId", "(", ")", ",", "boxConfig", ".", "getClientSecret", "(", ")", ",", "boxConfig", ".", "getJWTEncryptionPreferences", "(", ")", ")", ";", "return", "connection", ";", "}" ]
Creates a new Box Developer Edition connection with enterprise token leveraging BoxConfig. @param boxConfig box configuration settings object @return a new instance of BoxAPIConnection.
[ "Creates", "a", "new", "Box", "Developer", "Edition", "connection", "with", "enterprise", "token", "leveraging", "BoxConfig", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxDeveloperEditionAPIConnection.java#L209-L215
163,533
box/box-java-sdk
src/main/java/com/box/sdk/BoxDeveloperEditionAPIConnection.java
BoxDeveloperEditionAPIConnection.getAppUserConnection
public static BoxDeveloperEditionAPIConnection getAppUserConnection(String userId, String clientId, String clientSecret, JWTEncryptionPreferences encryptionPref, IAccessTokenCache accessTokenCache) { BoxDeveloperEditionAPIConnection connection = new BoxDeveloperEditionAPIConnection(userId, DeveloperEditionEntityType.USER, clientId, clientSecret, encryptionPref, accessTokenCache); connection.tryRestoreUsingAccessTokenCache(); return connection; }
java
public static BoxDeveloperEditionAPIConnection getAppUserConnection(String userId, String clientId, String clientSecret, JWTEncryptionPreferences encryptionPref, IAccessTokenCache accessTokenCache) { BoxDeveloperEditionAPIConnection connection = new BoxDeveloperEditionAPIConnection(userId, DeveloperEditionEntityType.USER, clientId, clientSecret, encryptionPref, accessTokenCache); connection.tryRestoreUsingAccessTokenCache(); return connection; }
[ "public", "static", "BoxDeveloperEditionAPIConnection", "getAppUserConnection", "(", "String", "userId", ",", "String", "clientId", ",", "String", "clientSecret", ",", "JWTEncryptionPreferences", "encryptionPref", ",", "IAccessTokenCache", "accessTokenCache", ")", "{", "BoxDeveloperEditionAPIConnection", "connection", "=", "new", "BoxDeveloperEditionAPIConnection", "(", "userId", ",", "DeveloperEditionEntityType", ".", "USER", ",", "clientId", ",", "clientSecret", ",", "encryptionPref", ",", "accessTokenCache", ")", ";", "connection", ".", "tryRestoreUsingAccessTokenCache", "(", ")", ";", "return", "connection", ";", "}" ]
Creates a new Box Developer Edition connection with App User token. @param userId the user ID to use for an App User. @param clientId the client ID to use when exchanging the JWT assertion for an access token. @param clientSecret the client secret to use when exchanging the JWT assertion for an access token. @param encryptionPref the encryption preferences for signing the JWT. @param accessTokenCache the cache for storing access token information (to minimize fetching new tokens) @return a new instance of BoxAPIConnection.
[ "Creates", "a", "new", "Box", "Developer", "Edition", "connection", "with", "App", "User", "token", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxDeveloperEditionAPIConnection.java#L265-L274
163,534
box/box-java-sdk
src/main/java/com/box/sdk/BoxDeveloperEditionAPIConnection.java
BoxDeveloperEditionAPIConnection.getAppUserConnection
public static BoxDeveloperEditionAPIConnection getAppUserConnection(String userId, BoxConfig boxConfig) { return getAppUserConnection(userId, boxConfig.getClientId(), boxConfig.getClientSecret(), boxConfig.getJWTEncryptionPreferences()); }
java
public static BoxDeveloperEditionAPIConnection getAppUserConnection(String userId, BoxConfig boxConfig) { return getAppUserConnection(userId, boxConfig.getClientId(), boxConfig.getClientSecret(), boxConfig.getJWTEncryptionPreferences()); }
[ "public", "static", "BoxDeveloperEditionAPIConnection", "getAppUserConnection", "(", "String", "userId", ",", "BoxConfig", "boxConfig", ")", "{", "return", "getAppUserConnection", "(", "userId", ",", "boxConfig", ".", "getClientId", "(", ")", ",", "boxConfig", ".", "getClientSecret", "(", ")", ",", "boxConfig", ".", "getJWTEncryptionPreferences", "(", ")", ")", ";", "}" ]
Creates a new Box Developer Edition connection with App User token levaraging BoxConfig. @param userId the user ID to use for an App User. @param boxConfig box configuration settings object @return a new instance of BoxAPIConnection.
[ "Creates", "a", "new", "Box", "Developer", "Edition", "connection", "with", "App", "User", "token", "levaraging", "BoxConfig", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxDeveloperEditionAPIConnection.java#L282-L285
163,535
box/box-java-sdk
src/main/java/com/box/sdk/BoxDeveloperEditionAPIConnection.java
BoxDeveloperEditionAPIConnection.authenticate
public void authenticate() { URL url; try { url = new URL(this.getTokenURL()); } catch (MalformedURLException e) { assert false : "An invalid token URL indicates a bug in the SDK."; throw new RuntimeException("An invalid token URL indicates a bug in the SDK.", e); } String jwtAssertion = this.constructJWTAssertion(); String urlParameters = String.format(JWT_GRANT_TYPE, this.getClientID(), this.getClientSecret(), jwtAssertion); BoxAPIRequest request = new BoxAPIRequest(this, url, "POST"); request.shouldAuthenticate(false); request.setBody(urlParameters); String json; try { BoxJSONResponse response = (BoxJSONResponse) request.send(); json = response.getJSON(); } catch (BoxAPIException ex) { // Use the Date advertised by the Box server as the current time to synchronize clocks List<String> responseDates = ex.getHeaders().get("Date"); NumericDate currentTime; if (responseDates != null) { String responseDate = responseDates.get(0); SimpleDateFormat dateFormat = new SimpleDateFormat("EEE, d MMM yyyy HH:mm:ss zzz"); try { Date date = dateFormat.parse(responseDate); currentTime = NumericDate.fromMilliseconds(date.getTime()); } catch (ParseException e) { currentTime = NumericDate.now(); } } else { currentTime = NumericDate.now(); } // Reconstruct the JWT assertion, which regenerates the jti claim, with the new "current" time jwtAssertion = this.constructJWTAssertion(currentTime); urlParameters = String.format(JWT_GRANT_TYPE, this.getClientID(), this.getClientSecret(), jwtAssertion); // Re-send the updated request request = new BoxAPIRequest(this, url, "POST"); request.shouldAuthenticate(false); request.setBody(urlParameters); BoxJSONResponse response = (BoxJSONResponse) request.send(); json = response.getJSON(); } JsonObject jsonObject = JsonObject.readFrom(json); this.setAccessToken(jsonObject.get("access_token").asString()); this.setLastRefresh(System.currentTimeMillis()); this.setExpires(jsonObject.get("expires_in").asLong() * 1000); //if token cache is specified, save to cache if (this.accessTokenCache != null) { String key = this.getAccessTokenCacheKey(); JsonObject accessTokenCacheInfo = new JsonObject() .add("accessToken", this.getAccessToken()) .add("lastRefresh", this.getLastRefresh()) .add("expires", this.getExpires()); this.accessTokenCache.put(key, accessTokenCacheInfo.toString()); } }
java
public void authenticate() { URL url; try { url = new URL(this.getTokenURL()); } catch (MalformedURLException e) { assert false : "An invalid token URL indicates a bug in the SDK."; throw new RuntimeException("An invalid token URL indicates a bug in the SDK.", e); } String jwtAssertion = this.constructJWTAssertion(); String urlParameters = String.format(JWT_GRANT_TYPE, this.getClientID(), this.getClientSecret(), jwtAssertion); BoxAPIRequest request = new BoxAPIRequest(this, url, "POST"); request.shouldAuthenticate(false); request.setBody(urlParameters); String json; try { BoxJSONResponse response = (BoxJSONResponse) request.send(); json = response.getJSON(); } catch (BoxAPIException ex) { // Use the Date advertised by the Box server as the current time to synchronize clocks List<String> responseDates = ex.getHeaders().get("Date"); NumericDate currentTime; if (responseDates != null) { String responseDate = responseDates.get(0); SimpleDateFormat dateFormat = new SimpleDateFormat("EEE, d MMM yyyy HH:mm:ss zzz"); try { Date date = dateFormat.parse(responseDate); currentTime = NumericDate.fromMilliseconds(date.getTime()); } catch (ParseException e) { currentTime = NumericDate.now(); } } else { currentTime = NumericDate.now(); } // Reconstruct the JWT assertion, which regenerates the jti claim, with the new "current" time jwtAssertion = this.constructJWTAssertion(currentTime); urlParameters = String.format(JWT_GRANT_TYPE, this.getClientID(), this.getClientSecret(), jwtAssertion); // Re-send the updated request request = new BoxAPIRequest(this, url, "POST"); request.shouldAuthenticate(false); request.setBody(urlParameters); BoxJSONResponse response = (BoxJSONResponse) request.send(); json = response.getJSON(); } JsonObject jsonObject = JsonObject.readFrom(json); this.setAccessToken(jsonObject.get("access_token").asString()); this.setLastRefresh(System.currentTimeMillis()); this.setExpires(jsonObject.get("expires_in").asLong() * 1000); //if token cache is specified, save to cache if (this.accessTokenCache != null) { String key = this.getAccessTokenCacheKey(); JsonObject accessTokenCacheInfo = new JsonObject() .add("accessToken", this.getAccessToken()) .add("lastRefresh", this.getLastRefresh()) .add("expires", this.getExpires()); this.accessTokenCache.put(key, accessTokenCacheInfo.toString()); } }
[ "public", "void", "authenticate", "(", ")", "{", "URL", "url", ";", "try", "{", "url", "=", "new", "URL", "(", "this", ".", "getTokenURL", "(", ")", ")", ";", "}", "catch", "(", "MalformedURLException", "e", ")", "{", "assert", "false", ":", "\"An invalid token URL indicates a bug in the SDK.\"", ";", "throw", "new", "RuntimeException", "(", "\"An invalid token URL indicates a bug in the SDK.\"", ",", "e", ")", ";", "}", "String", "jwtAssertion", "=", "this", ".", "constructJWTAssertion", "(", ")", ";", "String", "urlParameters", "=", "String", ".", "format", "(", "JWT_GRANT_TYPE", ",", "this", ".", "getClientID", "(", ")", ",", "this", ".", "getClientSecret", "(", ")", ",", "jwtAssertion", ")", ";", "BoxAPIRequest", "request", "=", "new", "BoxAPIRequest", "(", "this", ",", "url", ",", "\"POST\"", ")", ";", "request", ".", "shouldAuthenticate", "(", "false", ")", ";", "request", ".", "setBody", "(", "urlParameters", ")", ";", "String", "json", ";", "try", "{", "BoxJSONResponse", "response", "=", "(", "BoxJSONResponse", ")", "request", ".", "send", "(", ")", ";", "json", "=", "response", ".", "getJSON", "(", ")", ";", "}", "catch", "(", "BoxAPIException", "ex", ")", "{", "// Use the Date advertised by the Box server as the current time to synchronize clocks", "List", "<", "String", ">", "responseDates", "=", "ex", ".", "getHeaders", "(", ")", ".", "get", "(", "\"Date\"", ")", ";", "NumericDate", "currentTime", ";", "if", "(", "responseDates", "!=", "null", ")", "{", "String", "responseDate", "=", "responseDates", ".", "get", "(", "0", ")", ";", "SimpleDateFormat", "dateFormat", "=", "new", "SimpleDateFormat", "(", "\"EEE, d MMM yyyy HH:mm:ss zzz\"", ")", ";", "try", "{", "Date", "date", "=", "dateFormat", ".", "parse", "(", "responseDate", ")", ";", "currentTime", "=", "NumericDate", ".", "fromMilliseconds", "(", "date", ".", "getTime", "(", ")", ")", ";", "}", "catch", "(", "ParseException", "e", ")", "{", "currentTime", "=", "NumericDate", ".", "now", "(", ")", ";", "}", "}", "else", "{", "currentTime", "=", "NumericDate", ".", "now", "(", ")", ";", "}", "// Reconstruct the JWT assertion, which regenerates the jti claim, with the new \"current\" time", "jwtAssertion", "=", "this", ".", "constructJWTAssertion", "(", "currentTime", ")", ";", "urlParameters", "=", "String", ".", "format", "(", "JWT_GRANT_TYPE", ",", "this", ".", "getClientID", "(", ")", ",", "this", ".", "getClientSecret", "(", ")", ",", "jwtAssertion", ")", ";", "// Re-send the updated request", "request", "=", "new", "BoxAPIRequest", "(", "this", ",", "url", ",", "\"POST\"", ")", ";", "request", ".", "shouldAuthenticate", "(", "false", ")", ";", "request", ".", "setBody", "(", "urlParameters", ")", ";", "BoxJSONResponse", "response", "=", "(", "BoxJSONResponse", ")", "request", ".", "send", "(", ")", ";", "json", "=", "response", ".", "getJSON", "(", ")", ";", "}", "JsonObject", "jsonObject", "=", "JsonObject", ".", "readFrom", "(", "json", ")", ";", "this", ".", "setAccessToken", "(", "jsonObject", ".", "get", "(", "\"access_token\"", ")", ".", "asString", "(", ")", ")", ";", "this", ".", "setLastRefresh", "(", "System", ".", "currentTimeMillis", "(", ")", ")", ";", "this", ".", "setExpires", "(", "jsonObject", ".", "get", "(", "\"expires_in\"", ")", ".", "asLong", "(", ")", "*", "1000", ")", ";", "//if token cache is specified, save to cache", "if", "(", "this", ".", "accessTokenCache", "!=", "null", ")", "{", "String", "key", "=", "this", ".", "getAccessTokenCacheKey", "(", ")", ";", "JsonObject", "accessTokenCacheInfo", "=", "new", "JsonObject", "(", ")", ".", "add", "(", "\"accessToken\"", ",", "this", ".", "getAccessToken", "(", ")", ")", ".", "add", "(", "\"lastRefresh\"", ",", "this", ".", "getLastRefresh", "(", ")", ")", ".", "add", "(", "\"expires\"", ",", "this", ".", "getExpires", "(", ")", ")", ";", "this", ".", "accessTokenCache", ".", "put", "(", "key", ",", "accessTokenCacheInfo", ".", "toString", "(", ")", ")", ";", "}", "}" ]
Authenticates the API connection for Box Developer Edition.
[ "Authenticates", "the", "API", "connection", "for", "Box", "Developer", "Edition", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxDeveloperEditionAPIConnection.java#L311-L377
163,536
box/box-java-sdk
src/main/java/com/box/sdk/BoxDeveloperEditionAPIConnection.java
BoxDeveloperEditionAPIConnection.refresh
public void refresh() { this.getRefreshLock().writeLock().lock(); try { this.authenticate(); } catch (BoxAPIException e) { this.notifyError(e); this.getRefreshLock().writeLock().unlock(); throw e; } this.notifyRefresh(); this.getRefreshLock().writeLock().unlock(); }
java
public void refresh() { this.getRefreshLock().writeLock().lock(); try { this.authenticate(); } catch (BoxAPIException e) { this.notifyError(e); this.getRefreshLock().writeLock().unlock(); throw e; } this.notifyRefresh(); this.getRefreshLock().writeLock().unlock(); }
[ "public", "void", "refresh", "(", ")", "{", "this", ".", "getRefreshLock", "(", ")", ".", "writeLock", "(", ")", ".", "lock", "(", ")", ";", "try", "{", "this", ".", "authenticate", "(", ")", ";", "}", "catch", "(", "BoxAPIException", "e", ")", "{", "this", ".", "notifyError", "(", "e", ")", ";", "this", ".", "getRefreshLock", "(", ")", ".", "writeLock", "(", ")", ".", "unlock", "(", ")", ";", "throw", "e", ";", "}", "this", ".", "notifyRefresh", "(", ")", ";", "this", ".", "getRefreshLock", "(", ")", ".", "writeLock", "(", ")", ".", "unlock", "(", ")", ";", "}" ]
Refresh's this connection's access token using Box Developer Edition. @throws IllegalStateException if this connection's access token cannot be refreshed.
[ "Refresh", "s", "this", "connection", "s", "access", "token", "using", "Box", "Developer", "Edition", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxDeveloperEditionAPIConnection.java#L391-L404
163,537
box/box-java-sdk
src/main/java/com/box/sdk/BoxFile.java
BoxFile.addTask
public BoxTask.Info addTask(BoxTask.Action action, String message, Date dueAt) { JsonObject itemJSON = new JsonObject(); itemJSON.add("type", "file"); itemJSON.add("id", this.getID()); JsonObject requestJSON = new JsonObject(); requestJSON.add("item", itemJSON); requestJSON.add("action", action.toJSONString()); if (message != null && !message.isEmpty()) { requestJSON.add("message", message); } if (dueAt != null) { requestJSON.add("due_at", BoxDateFormat.format(dueAt)); } URL url = ADD_TASK_URL_TEMPLATE.build(this.getAPI().getBaseURL()); BoxJSONRequest request = new BoxJSONRequest(this.getAPI(), url, "POST"); request.setBody(requestJSON.toString()); BoxJSONResponse response = (BoxJSONResponse) request.send(); JsonObject responseJSON = JsonObject.readFrom(response.getJSON()); BoxTask addedTask = new BoxTask(this.getAPI(), responseJSON.get("id").asString()); return addedTask.new Info(responseJSON); }
java
public BoxTask.Info addTask(BoxTask.Action action, String message, Date dueAt) { JsonObject itemJSON = new JsonObject(); itemJSON.add("type", "file"); itemJSON.add("id", this.getID()); JsonObject requestJSON = new JsonObject(); requestJSON.add("item", itemJSON); requestJSON.add("action", action.toJSONString()); if (message != null && !message.isEmpty()) { requestJSON.add("message", message); } if (dueAt != null) { requestJSON.add("due_at", BoxDateFormat.format(dueAt)); } URL url = ADD_TASK_URL_TEMPLATE.build(this.getAPI().getBaseURL()); BoxJSONRequest request = new BoxJSONRequest(this.getAPI(), url, "POST"); request.setBody(requestJSON.toString()); BoxJSONResponse response = (BoxJSONResponse) request.send(); JsonObject responseJSON = JsonObject.readFrom(response.getJSON()); BoxTask addedTask = new BoxTask(this.getAPI(), responseJSON.get("id").asString()); return addedTask.new Info(responseJSON); }
[ "public", "BoxTask", ".", "Info", "addTask", "(", "BoxTask", ".", "Action", "action", ",", "String", "message", ",", "Date", "dueAt", ")", "{", "JsonObject", "itemJSON", "=", "new", "JsonObject", "(", ")", ";", "itemJSON", ".", "add", "(", "\"type\"", ",", "\"file\"", ")", ";", "itemJSON", ".", "add", "(", "\"id\"", ",", "this", ".", "getID", "(", ")", ")", ";", "JsonObject", "requestJSON", "=", "new", "JsonObject", "(", ")", ";", "requestJSON", ".", "add", "(", "\"item\"", ",", "itemJSON", ")", ";", "requestJSON", ".", "add", "(", "\"action\"", ",", "action", ".", "toJSONString", "(", ")", ")", ";", "if", "(", "message", "!=", "null", "&&", "!", "message", ".", "isEmpty", "(", ")", ")", "{", "requestJSON", ".", "add", "(", "\"message\"", ",", "message", ")", ";", "}", "if", "(", "dueAt", "!=", "null", ")", "{", "requestJSON", ".", "add", "(", "\"due_at\"", ",", "BoxDateFormat", ".", "format", "(", "dueAt", ")", ")", ";", "}", "URL", "url", "=", "ADD_TASK_URL_TEMPLATE", ".", "build", "(", "this", ".", "getAPI", "(", ")", ".", "getBaseURL", "(", ")", ")", ";", "BoxJSONRequest", "request", "=", "new", "BoxJSONRequest", "(", "this", ".", "getAPI", "(", ")", ",", "url", ",", "\"POST\"", ")", ";", "request", ".", "setBody", "(", "requestJSON", ".", "toString", "(", ")", ")", ";", "BoxJSONResponse", "response", "=", "(", "BoxJSONResponse", ")", "request", ".", "send", "(", ")", ";", "JsonObject", "responseJSON", "=", "JsonObject", ".", "readFrom", "(", "response", ".", "getJSON", "(", ")", ")", ";", "BoxTask", "addedTask", "=", "new", "BoxTask", "(", "this", ".", "getAPI", "(", ")", ",", "responseJSON", ".", "get", "(", "\"id\"", ")", ".", "asString", "(", ")", ")", ";", "return", "addedTask", ".", "new", "Info", "(", "responseJSON", ")", ";", "}" ]
Adds a new task to this file. The task can have an optional message to include, and a due date. @param action the action the task assignee will be prompted to do. @param message an optional message to include with the task. @param dueAt the day at which this task is due. @return information about the newly added task.
[ "Adds", "a", "new", "task", "to", "this", "file", ".", "The", "task", "can", "have", "an", "optional", "message", "to", "include", "and", "a", "due", "date", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxFile.java#L233-L258
163,538
box/box-java-sdk
src/main/java/com/box/sdk/BoxFile.java
BoxFile.getDownloadURL
public URL getDownloadURL() { URL url = CONTENT_URL_TEMPLATE.build(this.getAPI().getBaseURL(), this.getID()); BoxAPIRequest request = new BoxAPIRequest(this.getAPI(), url, "GET"); request.setFollowRedirects(false); BoxRedirectResponse response = (BoxRedirectResponse) request.send(); return response.getRedirectURL(); }
java
public URL getDownloadURL() { URL url = CONTENT_URL_TEMPLATE.build(this.getAPI().getBaseURL(), this.getID()); BoxAPIRequest request = new BoxAPIRequest(this.getAPI(), url, "GET"); request.setFollowRedirects(false); BoxRedirectResponse response = (BoxRedirectResponse) request.send(); return response.getRedirectURL(); }
[ "public", "URL", "getDownloadURL", "(", ")", "{", "URL", "url", "=", "CONTENT_URL_TEMPLATE", ".", "build", "(", "this", ".", "getAPI", "(", ")", ".", "getBaseURL", "(", ")", ",", "this", ".", "getID", "(", ")", ")", ";", "BoxAPIRequest", "request", "=", "new", "BoxAPIRequest", "(", "this", ".", "getAPI", "(", ")", ",", "url", ",", "\"GET\"", ")", ";", "request", ".", "setFollowRedirects", "(", "false", ")", ";", "BoxRedirectResponse", "response", "=", "(", "BoxRedirectResponse", ")", "request", ".", "send", "(", ")", ";", "return", "response", ".", "getRedirectURL", "(", ")", ";", "}" ]
Gets an expiring URL for downloading a file directly from Box. This can be user, for example, for sending as a redirect to a browser to cause the browser to download the file directly from Box. @return the temporary download URL
[ "Gets", "an", "expiring", "URL", "for", "downloading", "a", "file", "directly", "from", "Box", ".", "This", "can", "be", "user", "for", "example", "for", "sending", "as", "a", "redirect", "to", "a", "browser", "to", "cause", "the", "browser", "to", "download", "the", "file", "directly", "from", "Box", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxFile.java#L267-L275
163,539
box/box-java-sdk
src/main/java/com/box/sdk/BoxFile.java
BoxFile.downloadRange
public void downloadRange(OutputStream output, long rangeStart, long rangeEnd) { this.downloadRange(output, rangeStart, rangeEnd, null); }
java
public void downloadRange(OutputStream output, long rangeStart, long rangeEnd) { this.downloadRange(output, rangeStart, rangeEnd, null); }
[ "public", "void", "downloadRange", "(", "OutputStream", "output", ",", "long", "rangeStart", ",", "long", "rangeEnd", ")", "{", "this", ".", "downloadRange", "(", "output", ",", "rangeStart", ",", "rangeEnd", ",", "null", ")", ";", "}" ]
Downloads a part of this file's contents, starting at rangeStart and stopping at rangeEnd. @param output the stream to where the file will be written. @param rangeStart the byte offset at which to start the download. @param rangeEnd the byte offset at which to stop the download.
[ "Downloads", "a", "part", "of", "this", "file", "s", "contents", "starting", "at", "rangeStart", "and", "stopping", "at", "rangeEnd", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxFile.java#L329-L331
163,540
box/box-java-sdk
src/main/java/com/box/sdk/BoxFile.java
BoxFile.downloadRange
public void downloadRange(OutputStream output, long rangeStart, long rangeEnd, ProgressListener listener) { URL url = CONTENT_URL_TEMPLATE.build(this.getAPI().getBaseURL(), this.getID()); BoxAPIRequest request = new BoxAPIRequest(this.getAPI(), url, "GET"); if (rangeEnd > 0) { request.addHeader("Range", String.format("bytes=%s-%s", Long.toString(rangeStart), Long.toString(rangeEnd))); } else { request.addHeader("Range", String.format("bytes=%s-", Long.toString(rangeStart))); } BoxAPIResponse response = request.send(); InputStream input = response.getBody(listener); byte[] buffer = new byte[BUFFER_SIZE]; try { int n = input.read(buffer); while (n != -1) { output.write(buffer, 0, n); n = input.read(buffer); } } catch (IOException e) { throw new BoxAPIException("Couldn't connect to the Box API due to a network error.", e); } finally { response.disconnect(); } }
java
public void downloadRange(OutputStream output, long rangeStart, long rangeEnd, ProgressListener listener) { URL url = CONTENT_URL_TEMPLATE.build(this.getAPI().getBaseURL(), this.getID()); BoxAPIRequest request = new BoxAPIRequest(this.getAPI(), url, "GET"); if (rangeEnd > 0) { request.addHeader("Range", String.format("bytes=%s-%s", Long.toString(rangeStart), Long.toString(rangeEnd))); } else { request.addHeader("Range", String.format("bytes=%s-", Long.toString(rangeStart))); } BoxAPIResponse response = request.send(); InputStream input = response.getBody(listener); byte[] buffer = new byte[BUFFER_SIZE]; try { int n = input.read(buffer); while (n != -1) { output.write(buffer, 0, n); n = input.read(buffer); } } catch (IOException e) { throw new BoxAPIException("Couldn't connect to the Box API due to a network error.", e); } finally { response.disconnect(); } }
[ "public", "void", "downloadRange", "(", "OutputStream", "output", ",", "long", "rangeStart", ",", "long", "rangeEnd", ",", "ProgressListener", "listener", ")", "{", "URL", "url", "=", "CONTENT_URL_TEMPLATE", ".", "build", "(", "this", ".", "getAPI", "(", ")", ".", "getBaseURL", "(", ")", ",", "this", ".", "getID", "(", ")", ")", ";", "BoxAPIRequest", "request", "=", "new", "BoxAPIRequest", "(", "this", ".", "getAPI", "(", ")", ",", "url", ",", "\"GET\"", ")", ";", "if", "(", "rangeEnd", ">", "0", ")", "{", "request", ".", "addHeader", "(", "\"Range\"", ",", "String", ".", "format", "(", "\"bytes=%s-%s\"", ",", "Long", ".", "toString", "(", "rangeStart", ")", ",", "Long", ".", "toString", "(", "rangeEnd", ")", ")", ")", ";", "}", "else", "{", "request", ".", "addHeader", "(", "\"Range\"", ",", "String", ".", "format", "(", "\"bytes=%s-\"", ",", "Long", ".", "toString", "(", "rangeStart", ")", ")", ")", ";", "}", "BoxAPIResponse", "response", "=", "request", ".", "send", "(", ")", ";", "InputStream", "input", "=", "response", ".", "getBody", "(", "listener", ")", ";", "byte", "[", "]", "buffer", "=", "new", "byte", "[", "BUFFER_SIZE", "]", ";", "try", "{", "int", "n", "=", "input", ".", "read", "(", "buffer", ")", ";", "while", "(", "n", "!=", "-", "1", ")", "{", "output", ".", "write", "(", "buffer", ",", "0", ",", "n", ")", ";", "n", "=", "input", ".", "read", "(", "buffer", ")", ";", "}", "}", "catch", "(", "IOException", "e", ")", "{", "throw", "new", "BoxAPIException", "(", "\"Couldn't connect to the Box API due to a network error.\"", ",", "e", ")", ";", "}", "finally", "{", "response", ".", "disconnect", "(", ")", ";", "}", "}" ]
Downloads a part of this file's contents, starting at rangeStart and stopping at rangeEnd, while reporting the progress to a ProgressListener. @param output the stream to where the file will be written. @param rangeStart the byte offset at which to start the download. @param rangeEnd the byte offset at which to stop the download. @param listener a listener for monitoring the download's progress.
[ "Downloads", "a", "part", "of", "this", "file", "s", "contents", "starting", "at", "rangeStart", "and", "stopping", "at", "rangeEnd", "while", "reporting", "the", "progress", "to", "a", "ProgressListener", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxFile.java#L342-L367
163,541
box/box-java-sdk
src/main/java/com/box/sdk/BoxFile.java
BoxFile.rename
public void rename(String newName) { URL url = FILE_URL_TEMPLATE.build(this.getAPI().getBaseURL(), this.getID()); BoxJSONRequest request = new BoxJSONRequest(this.getAPI(), url, "PUT"); JsonObject updateInfo = new JsonObject(); updateInfo.add("name", newName); request.setBody(updateInfo.toString()); BoxAPIResponse response = request.send(); response.disconnect(); }
java
public void rename(String newName) { URL url = FILE_URL_TEMPLATE.build(this.getAPI().getBaseURL(), this.getID()); BoxJSONRequest request = new BoxJSONRequest(this.getAPI(), url, "PUT"); JsonObject updateInfo = new JsonObject(); updateInfo.add("name", newName); request.setBody(updateInfo.toString()); BoxAPIResponse response = request.send(); response.disconnect(); }
[ "public", "void", "rename", "(", "String", "newName", ")", "{", "URL", "url", "=", "FILE_URL_TEMPLATE", ".", "build", "(", "this", ".", "getAPI", "(", ")", ".", "getBaseURL", "(", ")", ",", "this", ".", "getID", "(", ")", ")", ";", "BoxJSONRequest", "request", "=", "new", "BoxJSONRequest", "(", "this", ".", "getAPI", "(", ")", ",", "url", ",", "\"PUT\"", ")", ";", "JsonObject", "updateInfo", "=", "new", "JsonObject", "(", ")", ";", "updateInfo", ".", "add", "(", "\"name\"", ",", "newName", ")", ";", "request", ".", "setBody", "(", "updateInfo", ".", "toString", "(", ")", ")", ";", "BoxAPIResponse", "response", "=", "request", ".", "send", "(", ")", ";", "response", ".", "disconnect", "(", ")", ";", "}" ]
Renames this file. @param newName the new name of the file.
[ "Renames", "this", "file", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxFile.java#L436-L446
163,542
box/box-java-sdk
src/main/java/com/box/sdk/BoxFile.java
BoxFile.getRepresentationContent
public void getRepresentationContent(String representationHint, String assetPath, OutputStream output) { List<Representation> reps = this.getInfoWithRepresentations(representationHint).getRepresentations(); if (reps.size() < 1) { throw new BoxAPIException("No matching representations found"); } Representation representation = reps.get(0); String repState = representation.getStatus().getState(); if (repState.equals("viewable") || repState.equals("success")) { this.makeRepresentationContentRequest(representation.getContent().getUrlTemplate(), assetPath, output); return; } else if (repState.equals("pending") || repState.equals("none")) { String repContentURLString = null; while (repContentURLString == null) { repContentURLString = this.pollRepInfo(representation.getInfo().getUrl()); } this.makeRepresentationContentRequest(repContentURLString, assetPath, output); return; } else if (repState.equals("error")) { throw new BoxAPIException("Representation had error status"); } else { throw new BoxAPIException("Representation had unknown status"); } }
java
public void getRepresentationContent(String representationHint, String assetPath, OutputStream output) { List<Representation> reps = this.getInfoWithRepresentations(representationHint).getRepresentations(); if (reps.size() < 1) { throw new BoxAPIException("No matching representations found"); } Representation representation = reps.get(0); String repState = representation.getStatus().getState(); if (repState.equals("viewable") || repState.equals("success")) { this.makeRepresentationContentRequest(representation.getContent().getUrlTemplate(), assetPath, output); return; } else if (repState.equals("pending") || repState.equals("none")) { String repContentURLString = null; while (repContentURLString == null) { repContentURLString = this.pollRepInfo(representation.getInfo().getUrl()); } this.makeRepresentationContentRequest(repContentURLString, assetPath, output); return; } else if (repState.equals("error")) { throw new BoxAPIException("Representation had error status"); } else { throw new BoxAPIException("Representation had unknown status"); } }
[ "public", "void", "getRepresentationContent", "(", "String", "representationHint", ",", "String", "assetPath", ",", "OutputStream", "output", ")", "{", "List", "<", "Representation", ">", "reps", "=", "this", ".", "getInfoWithRepresentations", "(", "representationHint", ")", ".", "getRepresentations", "(", ")", ";", "if", "(", "reps", ".", "size", "(", ")", "<", "1", ")", "{", "throw", "new", "BoxAPIException", "(", "\"No matching representations found\"", ")", ";", "}", "Representation", "representation", "=", "reps", ".", "get", "(", "0", ")", ";", "String", "repState", "=", "representation", ".", "getStatus", "(", ")", ".", "getState", "(", ")", ";", "if", "(", "repState", ".", "equals", "(", "\"viewable\"", ")", "||", "repState", ".", "equals", "(", "\"success\"", ")", ")", "{", "this", ".", "makeRepresentationContentRequest", "(", "representation", ".", "getContent", "(", ")", ".", "getUrlTemplate", "(", ")", ",", "assetPath", ",", "output", ")", ";", "return", ";", "}", "else", "if", "(", "repState", ".", "equals", "(", "\"pending\"", ")", "||", "repState", ".", "equals", "(", "\"none\"", ")", ")", "{", "String", "repContentURLString", "=", "null", ";", "while", "(", "repContentURLString", "==", "null", ")", "{", "repContentURLString", "=", "this", ".", "pollRepInfo", "(", "representation", ".", "getInfo", "(", ")", ".", "getUrl", "(", ")", ")", ";", "}", "this", ".", "makeRepresentationContentRequest", "(", "repContentURLString", ",", "assetPath", ",", "output", ")", ";", "return", ";", "}", "else", "if", "(", "repState", ".", "equals", "(", "\"error\"", ")", ")", "{", "throw", "new", "BoxAPIException", "(", "\"Representation had error status\"", ")", ";", "}", "else", "{", "throw", "new", "BoxAPIException", "(", "\"Representation had unknown status\"", ")", ";", "}", "}" ]
Fetches the contents of a file representation with asset path and writes them to the provided output stream. @see <a href=https://developer.box.com/reference#section-x-rep-hints-header>X-Rep-Hints Header</a> @param representationHint the X-Rep-Hints query for the representation to fetch. @param assetPath the path of the asset for representations containing multiple files. @param output the output stream to write the contents to.
[ "Fetches", "the", "contents", "of", "a", "file", "representation", "with", "asset", "path", "and", "writes", "them", "to", "the", "provided", "output", "stream", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxFile.java#L511-L543
163,543
box/box-java-sdk
src/main/java/com/box/sdk/BoxFile.java
BoxFile.getVersions
public Collection<BoxFileVersion> getVersions() { URL url = VERSIONS_URL_TEMPLATE.build(this.getAPI().getBaseURL(), this.getID()); BoxAPIRequest request = new BoxAPIRequest(this.getAPI(), url, "GET"); BoxJSONResponse response = (BoxJSONResponse) request.send(); JsonObject jsonObject = JsonObject.readFrom(response.getJSON()); JsonArray entries = jsonObject.get("entries").asArray(); Collection<BoxFileVersion> versions = new ArrayList<BoxFileVersion>(); for (JsonValue entry : entries) { versions.add(new BoxFileVersion(this.getAPI(), entry.asObject(), this.getID())); } return versions; }
java
public Collection<BoxFileVersion> getVersions() { URL url = VERSIONS_URL_TEMPLATE.build(this.getAPI().getBaseURL(), this.getID()); BoxAPIRequest request = new BoxAPIRequest(this.getAPI(), url, "GET"); BoxJSONResponse response = (BoxJSONResponse) request.send(); JsonObject jsonObject = JsonObject.readFrom(response.getJSON()); JsonArray entries = jsonObject.get("entries").asArray(); Collection<BoxFileVersion> versions = new ArrayList<BoxFileVersion>(); for (JsonValue entry : entries) { versions.add(new BoxFileVersion(this.getAPI(), entry.asObject(), this.getID())); } return versions; }
[ "public", "Collection", "<", "BoxFileVersion", ">", "getVersions", "(", ")", "{", "URL", "url", "=", "VERSIONS_URL_TEMPLATE", ".", "build", "(", "this", ".", "getAPI", "(", ")", ".", "getBaseURL", "(", ")", ",", "this", ".", "getID", "(", ")", ")", ";", "BoxAPIRequest", "request", "=", "new", "BoxAPIRequest", "(", "this", ".", "getAPI", "(", ")", ",", "url", ",", "\"GET\"", ")", ";", "BoxJSONResponse", "response", "=", "(", "BoxJSONResponse", ")", "request", ".", "send", "(", ")", ";", "JsonObject", "jsonObject", "=", "JsonObject", ".", "readFrom", "(", "response", ".", "getJSON", "(", ")", ")", ";", "JsonArray", "entries", "=", "jsonObject", ".", "get", "(", "\"entries\"", ")", ".", "asArray", "(", ")", ";", "Collection", "<", "BoxFileVersion", ">", "versions", "=", "new", "ArrayList", "<", "BoxFileVersion", ">", "(", ")", ";", "for", "(", "JsonValue", "entry", ":", "entries", ")", "{", "versions", ".", "add", "(", "new", "BoxFileVersion", "(", "this", ".", "getAPI", "(", ")", ",", "entry", ".", "asObject", "(", ")", ",", "this", ".", "getID", "(", ")", ")", ")", ";", "}", "return", "versions", ";", "}" ]
Gets any previous versions of this file. Note that only users with premium accounts will be able to retrieve previous versions of their files. @return a list of previous file versions.
[ "Gets", "any", "previous", "versions", "of", "this", "file", ".", "Note", "that", "only", "users", "with", "premium", "accounts", "will", "be", "able", "to", "retrieve", "previous", "versions", "of", "their", "files", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxFile.java#L629-L642
163,544
box/box-java-sdk
src/main/java/com/box/sdk/BoxFile.java
BoxFile.canUploadVersion
public boolean canUploadVersion(String name, long fileSize) { URL url = CONTENT_URL_TEMPLATE.build(this.getAPI().getBaseURL(), this.getID()); BoxJSONRequest request = new BoxJSONRequest(this.getAPI(), url, "OPTIONS"); JsonObject preflightInfo = new JsonObject(); if (name != null) { preflightInfo.add("name", name); } preflightInfo.add("size", fileSize); request.setBody(preflightInfo.toString()); try { BoxAPIResponse response = request.send(); return response.getResponseCode() == 200; } catch (BoxAPIException ex) { if (ex.getResponseCode() >= 400 && ex.getResponseCode() < 500) { // This looks like an error response, menaing the upload would fail return false; } else { // This looks like a network error or server error, rethrow exception throw ex; } } }
java
public boolean canUploadVersion(String name, long fileSize) { URL url = CONTENT_URL_TEMPLATE.build(this.getAPI().getBaseURL(), this.getID()); BoxJSONRequest request = new BoxJSONRequest(this.getAPI(), url, "OPTIONS"); JsonObject preflightInfo = new JsonObject(); if (name != null) { preflightInfo.add("name", name); } preflightInfo.add("size", fileSize); request.setBody(preflightInfo.toString()); try { BoxAPIResponse response = request.send(); return response.getResponseCode() == 200; } catch (BoxAPIException ex) { if (ex.getResponseCode() >= 400 && ex.getResponseCode() < 500) { // This looks like an error response, menaing the upload would fail return false; } else { // This looks like a network error or server error, rethrow exception throw ex; } } }
[ "public", "boolean", "canUploadVersion", "(", "String", "name", ",", "long", "fileSize", ")", "{", "URL", "url", "=", "CONTENT_URL_TEMPLATE", ".", "build", "(", "this", ".", "getAPI", "(", ")", ".", "getBaseURL", "(", ")", ",", "this", ".", "getID", "(", ")", ")", ";", "BoxJSONRequest", "request", "=", "new", "BoxJSONRequest", "(", "this", ".", "getAPI", "(", ")", ",", "url", ",", "\"OPTIONS\"", ")", ";", "JsonObject", "preflightInfo", "=", "new", "JsonObject", "(", ")", ";", "if", "(", "name", "!=", "null", ")", "{", "preflightInfo", ".", "add", "(", "\"name\"", ",", "name", ")", ";", "}", "preflightInfo", ".", "add", "(", "\"size\"", ",", "fileSize", ")", ";", "request", ".", "setBody", "(", "preflightInfo", ".", "toString", "(", ")", ")", ";", "try", "{", "BoxAPIResponse", "response", "=", "request", ".", "send", "(", ")", ";", "return", "response", ".", "getResponseCode", "(", ")", "==", "200", ";", "}", "catch", "(", "BoxAPIException", "ex", ")", "{", "if", "(", "ex", ".", "getResponseCode", "(", ")", ">=", "400", "&&", "ex", ".", "getResponseCode", "(", ")", "<", "500", ")", "{", "// This looks like an error response, menaing the upload would fail", "return", "false", ";", "}", "else", "{", "// This looks like a network error or server error, rethrow exception", "throw", "ex", ";", "}", "}", "}" ]
Checks if a new version of the file can be uploaded with the specified name and size. @param name the new name for the file. @param fileSize the size of the new version content in bytes. @return whether or not the file version can be uploaded.
[ "Checks", "if", "a", "new", "version", "of", "the", "file", "can", "be", "uploaded", "with", "the", "specified", "name", "and", "size", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxFile.java#L688-L715
163,545
box/box-java-sdk
src/main/java/com/box/sdk/BoxFile.java
BoxFile.getThumbnail
public byte[] getThumbnail(ThumbnailFileType fileType, int minWidth, int minHeight, int maxWidth, int maxHeight) { QueryStringBuilder builder = new QueryStringBuilder(); builder.appendParam("min_width", minWidth); builder.appendParam("min_height", minHeight); builder.appendParam("max_width", maxWidth); builder.appendParam("max_height", maxHeight); URLTemplate template; if (fileType == ThumbnailFileType.PNG) { template = GET_THUMBNAIL_PNG_TEMPLATE; } else if (fileType == ThumbnailFileType.JPG) { template = GET_THUMBNAIL_JPG_TEMPLATE; } else { throw new BoxAPIException("Unsupported thumbnail file type"); } URL url = template.buildWithQuery(this.getAPI().getBaseURL(), builder.toString(), this.getID()); BoxAPIRequest request = new BoxAPIRequest(this.getAPI(), url, "GET"); BoxAPIResponse response = request.send(); ByteArrayOutputStream thumbOut = new ByteArrayOutputStream(); InputStream body = response.getBody(); byte[] buffer = new byte[BUFFER_SIZE]; try { int n = body.read(buffer); while (n != -1) { thumbOut.write(buffer, 0, n); n = body.read(buffer); } } catch (IOException e) { throw new BoxAPIException("Error reading thumbnail bytes from response body", e); } finally { response.disconnect(); } return thumbOut.toByteArray(); }
java
public byte[] getThumbnail(ThumbnailFileType fileType, int minWidth, int minHeight, int maxWidth, int maxHeight) { QueryStringBuilder builder = new QueryStringBuilder(); builder.appendParam("min_width", minWidth); builder.appendParam("min_height", minHeight); builder.appendParam("max_width", maxWidth); builder.appendParam("max_height", maxHeight); URLTemplate template; if (fileType == ThumbnailFileType.PNG) { template = GET_THUMBNAIL_PNG_TEMPLATE; } else if (fileType == ThumbnailFileType.JPG) { template = GET_THUMBNAIL_JPG_TEMPLATE; } else { throw new BoxAPIException("Unsupported thumbnail file type"); } URL url = template.buildWithQuery(this.getAPI().getBaseURL(), builder.toString(), this.getID()); BoxAPIRequest request = new BoxAPIRequest(this.getAPI(), url, "GET"); BoxAPIResponse response = request.send(); ByteArrayOutputStream thumbOut = new ByteArrayOutputStream(); InputStream body = response.getBody(); byte[] buffer = new byte[BUFFER_SIZE]; try { int n = body.read(buffer); while (n != -1) { thumbOut.write(buffer, 0, n); n = body.read(buffer); } } catch (IOException e) { throw new BoxAPIException("Error reading thumbnail bytes from response body", e); } finally { response.disconnect(); } return thumbOut.toByteArray(); }
[ "public", "byte", "[", "]", "getThumbnail", "(", "ThumbnailFileType", "fileType", ",", "int", "minWidth", ",", "int", "minHeight", ",", "int", "maxWidth", ",", "int", "maxHeight", ")", "{", "QueryStringBuilder", "builder", "=", "new", "QueryStringBuilder", "(", ")", ";", "builder", ".", "appendParam", "(", "\"min_width\"", ",", "minWidth", ")", ";", "builder", ".", "appendParam", "(", "\"min_height\"", ",", "minHeight", ")", ";", "builder", ".", "appendParam", "(", "\"max_width\"", ",", "maxWidth", ")", ";", "builder", ".", "appendParam", "(", "\"max_height\"", ",", "maxHeight", ")", ";", "URLTemplate", "template", ";", "if", "(", "fileType", "==", "ThumbnailFileType", ".", "PNG", ")", "{", "template", "=", "GET_THUMBNAIL_PNG_TEMPLATE", ";", "}", "else", "if", "(", "fileType", "==", "ThumbnailFileType", ".", "JPG", ")", "{", "template", "=", "GET_THUMBNAIL_JPG_TEMPLATE", ";", "}", "else", "{", "throw", "new", "BoxAPIException", "(", "\"Unsupported thumbnail file type\"", ")", ";", "}", "URL", "url", "=", "template", ".", "buildWithQuery", "(", "this", ".", "getAPI", "(", ")", ".", "getBaseURL", "(", ")", ",", "builder", ".", "toString", "(", ")", ",", "this", ".", "getID", "(", ")", ")", ";", "BoxAPIRequest", "request", "=", "new", "BoxAPIRequest", "(", "this", ".", "getAPI", "(", ")", ",", "url", ",", "\"GET\"", ")", ";", "BoxAPIResponse", "response", "=", "request", ".", "send", "(", ")", ";", "ByteArrayOutputStream", "thumbOut", "=", "new", "ByteArrayOutputStream", "(", ")", ";", "InputStream", "body", "=", "response", ".", "getBody", "(", ")", ";", "byte", "[", "]", "buffer", "=", "new", "byte", "[", "BUFFER_SIZE", "]", ";", "try", "{", "int", "n", "=", "body", ".", "read", "(", "buffer", ")", ";", "while", "(", "n", "!=", "-", "1", ")", "{", "thumbOut", ".", "write", "(", "buffer", ",", "0", ",", "n", ")", ";", "n", "=", "body", ".", "read", "(", "buffer", ")", ";", "}", "}", "catch", "(", "IOException", "e", ")", "{", "throw", "new", "BoxAPIException", "(", "\"Error reading thumbnail bytes from response body\"", ",", "e", ")", ";", "}", "finally", "{", "response", ".", "disconnect", "(", ")", ";", "}", "return", "thumbOut", ".", "toByteArray", "(", ")", ";", "}" ]
Retrieves a thumbnail, or smaller image representation, of this file. Sizes of 32x32, 64x64, 128x128, and 256x256 can be returned in the .png format and sizes of 32x32, 94x94, 160x160, and 320x320 can be returned in the .jpg format. @param fileType either PNG of JPG @param minWidth minimum width @param minHeight minimum height @param maxWidth maximum width @param maxHeight maximum height @return the byte array of the thumbnail image
[ "Retrieves", "a", "thumbnail", "or", "smaller", "image", "representation", "of", "this", "file", ".", "Sizes", "of", "32x32", "64x64", "128x128", "and", "256x256", "can", "be", "returned", "in", "the", ".", "png", "format", "and", "sizes", "of", "32x32", "94x94", "160x160", "and", "320x320", "can", "be", "returned", "in", "the", ".", "jpg", "format", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxFile.java#L911-L947
163,546
box/box-java-sdk
src/main/java/com/box/sdk/BoxFile.java
BoxFile.getComments
public List<BoxComment.Info> getComments() { URL url = GET_COMMENTS_URL_TEMPLATE.build(this.getAPI().getBaseURL(), this.getID()); BoxAPIRequest request = new BoxAPIRequest(this.getAPI(), url, "GET"); BoxJSONResponse response = (BoxJSONResponse) request.send(); JsonObject responseJSON = JsonObject.readFrom(response.getJSON()); int totalCount = responseJSON.get("total_count").asInt(); List<BoxComment.Info> comments = new ArrayList<BoxComment.Info>(totalCount); JsonArray entries = responseJSON.get("entries").asArray(); for (JsonValue value : entries) { JsonObject commentJSON = value.asObject(); BoxComment comment = new BoxComment(this.getAPI(), commentJSON.get("id").asString()); BoxComment.Info info = comment.new Info(commentJSON); comments.add(info); } return comments; }
java
public List<BoxComment.Info> getComments() { URL url = GET_COMMENTS_URL_TEMPLATE.build(this.getAPI().getBaseURL(), this.getID()); BoxAPIRequest request = new BoxAPIRequest(this.getAPI(), url, "GET"); BoxJSONResponse response = (BoxJSONResponse) request.send(); JsonObject responseJSON = JsonObject.readFrom(response.getJSON()); int totalCount = responseJSON.get("total_count").asInt(); List<BoxComment.Info> comments = new ArrayList<BoxComment.Info>(totalCount); JsonArray entries = responseJSON.get("entries").asArray(); for (JsonValue value : entries) { JsonObject commentJSON = value.asObject(); BoxComment comment = new BoxComment(this.getAPI(), commentJSON.get("id").asString()); BoxComment.Info info = comment.new Info(commentJSON); comments.add(info); } return comments; }
[ "public", "List", "<", "BoxComment", ".", "Info", ">", "getComments", "(", ")", "{", "URL", "url", "=", "GET_COMMENTS_URL_TEMPLATE", ".", "build", "(", "this", ".", "getAPI", "(", ")", ".", "getBaseURL", "(", ")", ",", "this", ".", "getID", "(", ")", ")", ";", "BoxAPIRequest", "request", "=", "new", "BoxAPIRequest", "(", "this", ".", "getAPI", "(", ")", ",", "url", ",", "\"GET\"", ")", ";", "BoxJSONResponse", "response", "=", "(", "BoxJSONResponse", ")", "request", ".", "send", "(", ")", ";", "JsonObject", "responseJSON", "=", "JsonObject", ".", "readFrom", "(", "response", ".", "getJSON", "(", ")", ")", ";", "int", "totalCount", "=", "responseJSON", ".", "get", "(", "\"total_count\"", ")", ".", "asInt", "(", ")", ";", "List", "<", "BoxComment", ".", "Info", ">", "comments", "=", "new", "ArrayList", "<", "BoxComment", ".", "Info", ">", "(", "totalCount", ")", ";", "JsonArray", "entries", "=", "responseJSON", ".", "get", "(", "\"entries\"", ")", ".", "asArray", "(", ")", ";", "for", "(", "JsonValue", "value", ":", "entries", ")", "{", "JsonObject", "commentJSON", "=", "value", ".", "asObject", "(", ")", ";", "BoxComment", "comment", "=", "new", "BoxComment", "(", "this", ".", "getAPI", "(", ")", ",", "commentJSON", ".", "get", "(", "\"id\"", ")", ".", "asString", "(", ")", ")", ";", "BoxComment", ".", "Info", "info", "=", "comment", ".", "new", "Info", "(", "commentJSON", ")", ";", "comments", ".", "add", "(", "info", ")", ";", "}", "return", "comments", ";", "}" ]
Gets a list of any comments on this file. @return a list of comments on this file.
[ "Gets", "a", "list", "of", "any", "comments", "on", "this", "file", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxFile.java#L954-L971
163,547
box/box-java-sdk
src/main/java/com/box/sdk/BoxFile.java
BoxFile.getTasks
public List<BoxTask.Info> getTasks(String... fields) { QueryStringBuilder builder = new QueryStringBuilder(); if (fields.length > 0) { builder.appendParam("fields", fields).toString(); } URL url = GET_TASKS_URL_TEMPLATE.buildWithQuery(this.getAPI().getBaseURL(), builder.toString(), this.getID()); BoxAPIRequest request = new BoxAPIRequest(this.getAPI(), url, "GET"); BoxJSONResponse response = (BoxJSONResponse) request.send(); JsonObject responseJSON = JsonObject.readFrom(response.getJSON()); int totalCount = responseJSON.get("total_count").asInt(); List<BoxTask.Info> tasks = new ArrayList<BoxTask.Info>(totalCount); JsonArray entries = responseJSON.get("entries").asArray(); for (JsonValue value : entries) { JsonObject taskJSON = value.asObject(); BoxTask task = new BoxTask(this.getAPI(), taskJSON.get("id").asString()); BoxTask.Info info = task.new Info(taskJSON); tasks.add(info); } return tasks; }
java
public List<BoxTask.Info> getTasks(String... fields) { QueryStringBuilder builder = new QueryStringBuilder(); if (fields.length > 0) { builder.appendParam("fields", fields).toString(); } URL url = GET_TASKS_URL_TEMPLATE.buildWithQuery(this.getAPI().getBaseURL(), builder.toString(), this.getID()); BoxAPIRequest request = new BoxAPIRequest(this.getAPI(), url, "GET"); BoxJSONResponse response = (BoxJSONResponse) request.send(); JsonObject responseJSON = JsonObject.readFrom(response.getJSON()); int totalCount = responseJSON.get("total_count").asInt(); List<BoxTask.Info> tasks = new ArrayList<BoxTask.Info>(totalCount); JsonArray entries = responseJSON.get("entries").asArray(); for (JsonValue value : entries) { JsonObject taskJSON = value.asObject(); BoxTask task = new BoxTask(this.getAPI(), taskJSON.get("id").asString()); BoxTask.Info info = task.new Info(taskJSON); tasks.add(info); } return tasks; }
[ "public", "List", "<", "BoxTask", ".", "Info", ">", "getTasks", "(", "String", "...", "fields", ")", "{", "QueryStringBuilder", "builder", "=", "new", "QueryStringBuilder", "(", ")", ";", "if", "(", "fields", ".", "length", ">", "0", ")", "{", "builder", ".", "appendParam", "(", "\"fields\"", ",", "fields", ")", ".", "toString", "(", ")", ";", "}", "URL", "url", "=", "GET_TASKS_URL_TEMPLATE", ".", "buildWithQuery", "(", "this", ".", "getAPI", "(", ")", ".", "getBaseURL", "(", ")", ",", "builder", ".", "toString", "(", ")", ",", "this", ".", "getID", "(", ")", ")", ";", "BoxAPIRequest", "request", "=", "new", "BoxAPIRequest", "(", "this", ".", "getAPI", "(", ")", ",", "url", ",", "\"GET\"", ")", ";", "BoxJSONResponse", "response", "=", "(", "BoxJSONResponse", ")", "request", ".", "send", "(", ")", ";", "JsonObject", "responseJSON", "=", "JsonObject", ".", "readFrom", "(", "response", ".", "getJSON", "(", ")", ")", ";", "int", "totalCount", "=", "responseJSON", ".", "get", "(", "\"total_count\"", ")", ".", "asInt", "(", ")", ";", "List", "<", "BoxTask", ".", "Info", ">", "tasks", "=", "new", "ArrayList", "<", "BoxTask", ".", "Info", ">", "(", "totalCount", ")", ";", "JsonArray", "entries", "=", "responseJSON", ".", "get", "(", "\"entries\"", ")", ".", "asArray", "(", ")", ";", "for", "(", "JsonValue", "value", ":", "entries", ")", "{", "JsonObject", "taskJSON", "=", "value", ".", "asObject", "(", ")", ";", "BoxTask", "task", "=", "new", "BoxTask", "(", "this", ".", "getAPI", "(", ")", ",", "taskJSON", ".", "get", "(", "\"id\"", ")", ".", "asString", "(", ")", ")", ";", "BoxTask", ".", "Info", "info", "=", "task", ".", "new", "Info", "(", "taskJSON", ")", ";", "tasks", ".", "add", "(", "info", ")", ";", "}", "return", "tasks", ";", "}" ]
Gets a list of any tasks on this file with requested fields. @param fields optional fields to retrieve for this task. @return a list of tasks on this file.
[ "Gets", "a", "list", "of", "any", "tasks", "on", "this", "file", "with", "requested", "fields", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxFile.java#L979-L1000
163,548
box/box-java-sdk
src/main/java/com/box/sdk/BoxFile.java
BoxFile.createMetadata
public Metadata createMetadata(String typeName, Metadata metadata) { String scope = Metadata.scopeBasedOnType(typeName); return this.createMetadata(typeName, scope, metadata); }
java
public Metadata createMetadata(String typeName, Metadata metadata) { String scope = Metadata.scopeBasedOnType(typeName); return this.createMetadata(typeName, scope, metadata); }
[ "public", "Metadata", "createMetadata", "(", "String", "typeName", ",", "Metadata", "metadata", ")", "{", "String", "scope", "=", "Metadata", ".", "scopeBasedOnType", "(", "typeName", ")", ";", "return", "this", ".", "createMetadata", "(", "typeName", ",", "scope", ",", "metadata", ")", ";", "}" ]
Creates metadata on this file in the specified template type. @param typeName the metadata template type name. @param metadata the new metadata values. @return the metadata returned from the server.
[ "Creates", "metadata", "on", "this", "file", "in", "the", "specified", "template", "type", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxFile.java#L1019-L1022
163,549
box/box-java-sdk
src/main/java/com/box/sdk/BoxFile.java
BoxFile.updateClassification
public String updateClassification(String classificationType) { Metadata metadata = new Metadata("enterprise", Metadata.CLASSIFICATION_TEMPLATE_KEY); metadata.add("/Box__Security__Classification__Key", classificationType); Metadata classification = this.updateMetadata(metadata); return classification.getString(Metadata.CLASSIFICATION_KEY); }
java
public String updateClassification(String classificationType) { Metadata metadata = new Metadata("enterprise", Metadata.CLASSIFICATION_TEMPLATE_KEY); metadata.add("/Box__Security__Classification__Key", classificationType); Metadata classification = this.updateMetadata(metadata); return classification.getString(Metadata.CLASSIFICATION_KEY); }
[ "public", "String", "updateClassification", "(", "String", "classificationType", ")", "{", "Metadata", "metadata", "=", "new", "Metadata", "(", "\"enterprise\"", ",", "Metadata", ".", "CLASSIFICATION_TEMPLATE_KEY", ")", ";", "metadata", ".", "add", "(", "\"/Box__Security__Classification__Key\"", ",", "classificationType", ")", ";", "Metadata", "classification", "=", "this", ".", "updateMetadata", "(", "metadata", ")", ";", "return", "classification", ".", "getString", "(", "Metadata", ".", "CLASSIFICATION_KEY", ")", ";", "}" ]
Updates a metadata classification on the specified file. @param classificationType the metadata classification type. @return the new metadata classification type updated on the file.
[ "Updates", "a", "metadata", "classification", "on", "the", "specified", "file", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxFile.java#L1099-L1105
163,550
box/box-java-sdk
src/main/java/com/box/sdk/BoxFile.java
BoxFile.setClassification
public String setClassification(String classificationType) { Metadata metadata = new Metadata().add(Metadata.CLASSIFICATION_KEY, classificationType); Metadata classification = null; try { classification = this.createMetadata(Metadata.CLASSIFICATION_TEMPLATE_KEY, "enterprise", metadata); } catch (BoxAPIException e) { if (e.getResponseCode() == 409) { metadata = new Metadata("enterprise", Metadata.CLASSIFICATION_TEMPLATE_KEY); metadata.replace(Metadata.CLASSIFICATION_KEY, classificationType); classification = this.updateMetadata(metadata); } else { throw e; } } return classification.getString(Metadata.CLASSIFICATION_KEY); }
java
public String setClassification(String classificationType) { Metadata metadata = new Metadata().add(Metadata.CLASSIFICATION_KEY, classificationType); Metadata classification = null; try { classification = this.createMetadata(Metadata.CLASSIFICATION_TEMPLATE_KEY, "enterprise", metadata); } catch (BoxAPIException e) { if (e.getResponseCode() == 409) { metadata = new Metadata("enterprise", Metadata.CLASSIFICATION_TEMPLATE_KEY); metadata.replace(Metadata.CLASSIFICATION_KEY, classificationType); classification = this.updateMetadata(metadata); } else { throw e; } } return classification.getString(Metadata.CLASSIFICATION_KEY); }
[ "public", "String", "setClassification", "(", "String", "classificationType", ")", "{", "Metadata", "metadata", "=", "new", "Metadata", "(", ")", ".", "add", "(", "Metadata", ".", "CLASSIFICATION_KEY", ",", "classificationType", ")", ";", "Metadata", "classification", "=", "null", ";", "try", "{", "classification", "=", "this", ".", "createMetadata", "(", "Metadata", ".", "CLASSIFICATION_TEMPLATE_KEY", ",", "\"enterprise\"", ",", "metadata", ")", ";", "}", "catch", "(", "BoxAPIException", "e", ")", "{", "if", "(", "e", ".", "getResponseCode", "(", ")", "==", "409", ")", "{", "metadata", "=", "new", "Metadata", "(", "\"enterprise\"", ",", "Metadata", ".", "CLASSIFICATION_TEMPLATE_KEY", ")", ";", "metadata", ".", "replace", "(", "Metadata", ".", "CLASSIFICATION_KEY", ",", "classificationType", ")", ";", "classification", "=", "this", ".", "updateMetadata", "(", "metadata", ")", ";", "}", "else", "{", "throw", "e", ";", "}", "}", "return", "classification", ".", "getString", "(", "Metadata", ".", "CLASSIFICATION_KEY", ")", ";", "}" ]
Attempts to add classification to a file. If classification already exists then do update. @param classificationType the metadata classification type. @return the metadata classification type on the file.
[ "Attempts", "to", "add", "classification", "to", "a", "file", ".", "If", "classification", "already", "exists", "then", "do", "update", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxFile.java#L1113-L1130
163,551
box/box-java-sdk
src/main/java/com/box/sdk/BoxFile.java
BoxFile.lock
public BoxLock lock(Date expiresAt, boolean isDownloadPrevented) { String queryString = new QueryStringBuilder().appendParam("fields", "lock").toString(); URL url = FILE_URL_TEMPLATE.buildWithQuery(this.getAPI().getBaseURL(), queryString, this.getID()); BoxAPIRequest request = new BoxAPIRequest(this.getAPI(), url, "PUT"); JsonObject lockConfig = new JsonObject(); lockConfig.add("type", "lock"); if (expiresAt != null) { lockConfig.add("expires_at", BoxDateFormat.format(expiresAt)); } lockConfig.add("is_download_prevented", isDownloadPrevented); JsonObject requestJSON = new JsonObject(); requestJSON.add("lock", lockConfig); request.setBody(requestJSON.toString()); BoxJSONResponse response = (BoxJSONResponse) request.send(); JsonObject responseJSON = JsonObject.readFrom(response.getJSON()); JsonValue lockValue = responseJSON.get("lock"); JsonObject lockJSON = JsonObject.readFrom(lockValue.toString()); return new BoxLock(lockJSON, this.getAPI()); }
java
public BoxLock lock(Date expiresAt, boolean isDownloadPrevented) { String queryString = new QueryStringBuilder().appendParam("fields", "lock").toString(); URL url = FILE_URL_TEMPLATE.buildWithQuery(this.getAPI().getBaseURL(), queryString, this.getID()); BoxAPIRequest request = new BoxAPIRequest(this.getAPI(), url, "PUT"); JsonObject lockConfig = new JsonObject(); lockConfig.add("type", "lock"); if (expiresAt != null) { lockConfig.add("expires_at", BoxDateFormat.format(expiresAt)); } lockConfig.add("is_download_prevented", isDownloadPrevented); JsonObject requestJSON = new JsonObject(); requestJSON.add("lock", lockConfig); request.setBody(requestJSON.toString()); BoxJSONResponse response = (BoxJSONResponse) request.send(); JsonObject responseJSON = JsonObject.readFrom(response.getJSON()); JsonValue lockValue = responseJSON.get("lock"); JsonObject lockJSON = JsonObject.readFrom(lockValue.toString()); return new BoxLock(lockJSON, this.getAPI()); }
[ "public", "BoxLock", "lock", "(", "Date", "expiresAt", ",", "boolean", "isDownloadPrevented", ")", "{", "String", "queryString", "=", "new", "QueryStringBuilder", "(", ")", ".", "appendParam", "(", "\"fields\"", ",", "\"lock\"", ")", ".", "toString", "(", ")", ";", "URL", "url", "=", "FILE_URL_TEMPLATE", ".", "buildWithQuery", "(", "this", ".", "getAPI", "(", ")", ".", "getBaseURL", "(", ")", ",", "queryString", ",", "this", ".", "getID", "(", ")", ")", ";", "BoxAPIRequest", "request", "=", "new", "BoxAPIRequest", "(", "this", ".", "getAPI", "(", ")", ",", "url", ",", "\"PUT\"", ")", ";", "JsonObject", "lockConfig", "=", "new", "JsonObject", "(", ")", ";", "lockConfig", ".", "add", "(", "\"type\"", ",", "\"lock\"", ")", ";", "if", "(", "expiresAt", "!=", "null", ")", "{", "lockConfig", ".", "add", "(", "\"expires_at\"", ",", "BoxDateFormat", ".", "format", "(", "expiresAt", ")", ")", ";", "}", "lockConfig", ".", "add", "(", "\"is_download_prevented\"", ",", "isDownloadPrevented", ")", ";", "JsonObject", "requestJSON", "=", "new", "JsonObject", "(", ")", ";", "requestJSON", ".", "add", "(", "\"lock\"", ",", "lockConfig", ")", ";", "request", ".", "setBody", "(", "requestJSON", ".", "toString", "(", ")", ")", ";", "BoxJSONResponse", "response", "=", "(", "BoxJSONResponse", ")", "request", ".", "send", "(", ")", ";", "JsonObject", "responseJSON", "=", "JsonObject", ".", "readFrom", "(", "response", ".", "getJSON", "(", ")", ")", ";", "JsonValue", "lockValue", "=", "responseJSON", ".", "get", "(", "\"lock\"", ")", ";", "JsonObject", "lockJSON", "=", "JsonObject", ".", "readFrom", "(", "lockValue", ".", "toString", "(", ")", ")", ";", "return", "new", "BoxLock", "(", "lockJSON", ",", "this", ".", "getAPI", "(", ")", ")", ";", "}" ]
Locks a file. @param expiresAt expiration date of the lock. @param isDownloadPrevented is downloading of file prevented when locked. @return the lock returned from the server.
[ "Locks", "a", "file", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxFile.java#L1199-L1222
163,552
box/box-java-sdk
src/main/java/com/box/sdk/BoxFile.java
BoxFile.unlock
public void unlock() { String queryString = new QueryStringBuilder().appendParam("fields", "lock").toString(); URL url = FILE_URL_TEMPLATE.buildWithQuery(this.getAPI().getBaseURL(), queryString, this.getID()); BoxAPIRequest request = new BoxAPIRequest(this.getAPI(), url, "PUT"); JsonObject lockObject = new JsonObject(); lockObject.add("lock", JsonObject.NULL); request.setBody(lockObject.toString()); request.send(); }
java
public void unlock() { String queryString = new QueryStringBuilder().appendParam("fields", "lock").toString(); URL url = FILE_URL_TEMPLATE.buildWithQuery(this.getAPI().getBaseURL(), queryString, this.getID()); BoxAPIRequest request = new BoxAPIRequest(this.getAPI(), url, "PUT"); JsonObject lockObject = new JsonObject(); lockObject.add("lock", JsonObject.NULL); request.setBody(lockObject.toString()); request.send(); }
[ "public", "void", "unlock", "(", ")", "{", "String", "queryString", "=", "new", "QueryStringBuilder", "(", ")", ".", "appendParam", "(", "\"fields\"", ",", "\"lock\"", ")", ".", "toString", "(", ")", ";", "URL", "url", "=", "FILE_URL_TEMPLATE", ".", "buildWithQuery", "(", "this", ".", "getAPI", "(", ")", ".", "getBaseURL", "(", ")", ",", "queryString", ",", "this", ".", "getID", "(", ")", ")", ";", "BoxAPIRequest", "request", "=", "new", "BoxAPIRequest", "(", "this", ".", "getAPI", "(", ")", ",", "url", ",", "\"PUT\"", ")", ";", "JsonObject", "lockObject", "=", "new", "JsonObject", "(", ")", ";", "lockObject", ".", "add", "(", "\"lock\"", ",", "JsonObject", ".", "NULL", ")", ";", "request", ".", "setBody", "(", "lockObject", ".", "toString", "(", ")", ")", ";", "request", ".", "send", "(", ")", ";", "}" ]
Unlocks a file.
[ "Unlocks", "a", "file", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxFile.java#L1227-L1237
163,553
box/box-java-sdk
src/main/java/com/box/sdk/BoxFile.java
BoxFile.updateMetadata
public Metadata updateMetadata(Metadata metadata) { String scope; if (metadata.getScope().equals(Metadata.GLOBAL_METADATA_SCOPE)) { scope = Metadata.GLOBAL_METADATA_SCOPE; } else { scope = Metadata.ENTERPRISE_METADATA_SCOPE; } URL url = METADATA_URL_TEMPLATE.build(this.getAPI().getBaseURL(), this.getID(), scope, metadata.getTemplateName()); BoxAPIRequest request = new BoxAPIRequest(this.getAPI(), url, "PUT"); request.addHeader("Content-Type", "application/json-patch+json"); request.setBody(metadata.getPatch()); BoxJSONResponse response = (BoxJSONResponse) request.send(); return new Metadata(JsonObject.readFrom(response.getJSON())); }
java
public Metadata updateMetadata(Metadata metadata) { String scope; if (metadata.getScope().equals(Metadata.GLOBAL_METADATA_SCOPE)) { scope = Metadata.GLOBAL_METADATA_SCOPE; } else { scope = Metadata.ENTERPRISE_METADATA_SCOPE; } URL url = METADATA_URL_TEMPLATE.build(this.getAPI().getBaseURL(), this.getID(), scope, metadata.getTemplateName()); BoxAPIRequest request = new BoxAPIRequest(this.getAPI(), url, "PUT"); request.addHeader("Content-Type", "application/json-patch+json"); request.setBody(metadata.getPatch()); BoxJSONResponse response = (BoxJSONResponse) request.send(); return new Metadata(JsonObject.readFrom(response.getJSON())); }
[ "public", "Metadata", "updateMetadata", "(", "Metadata", "metadata", ")", "{", "String", "scope", ";", "if", "(", "metadata", ".", "getScope", "(", ")", ".", "equals", "(", "Metadata", ".", "GLOBAL_METADATA_SCOPE", ")", ")", "{", "scope", "=", "Metadata", ".", "GLOBAL_METADATA_SCOPE", ";", "}", "else", "{", "scope", "=", "Metadata", ".", "ENTERPRISE_METADATA_SCOPE", ";", "}", "URL", "url", "=", "METADATA_URL_TEMPLATE", ".", "build", "(", "this", ".", "getAPI", "(", ")", ".", "getBaseURL", "(", ")", ",", "this", ".", "getID", "(", ")", ",", "scope", ",", "metadata", ".", "getTemplateName", "(", ")", ")", ";", "BoxAPIRequest", "request", "=", "new", "BoxAPIRequest", "(", "this", ".", "getAPI", "(", ")", ",", "url", ",", "\"PUT\"", ")", ";", "request", ".", "addHeader", "(", "\"Content-Type\"", ",", "\"application/json-patch+json\"", ")", ";", "request", ".", "setBody", "(", "metadata", ".", "getPatch", "(", ")", ")", ";", "BoxJSONResponse", "response", "=", "(", "BoxJSONResponse", ")", "request", ".", "send", "(", ")", ";", "return", "new", "Metadata", "(", "JsonObject", ".", "readFrom", "(", "response", ".", "getJSON", "(", ")", ")", ")", ";", "}" ]
Updates the file metadata. @param metadata the new metadata values. @return the metadata returned from the server.
[ "Updates", "the", "file", "metadata", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxFile.java#L1289-L1304
163,554
box/box-java-sdk
src/main/java/com/box/sdk/BoxFile.java
BoxFile.createUploadSession
public BoxFileUploadSession.Info createUploadSession(long fileSize) { URL url = UPLOAD_SESSION_URL_TEMPLATE.build(this.getAPI().getBaseUploadURL(), this.getID()); BoxJSONRequest request = new BoxJSONRequest(this.getAPI(), url, "POST"); request.addHeader("Content-Type", "application/json"); JsonObject body = new JsonObject(); body.add("file_size", fileSize); request.setBody(body.toString()); BoxJSONResponse response = (BoxJSONResponse) request.send(); JsonObject jsonObject = JsonObject.readFrom(response.getJSON()); String sessionId = jsonObject.get("id").asString(); BoxFileUploadSession session = new BoxFileUploadSession(this.getAPI(), sessionId); return session.new Info(jsonObject); }
java
public BoxFileUploadSession.Info createUploadSession(long fileSize) { URL url = UPLOAD_SESSION_URL_TEMPLATE.build(this.getAPI().getBaseUploadURL(), this.getID()); BoxJSONRequest request = new BoxJSONRequest(this.getAPI(), url, "POST"); request.addHeader("Content-Type", "application/json"); JsonObject body = new JsonObject(); body.add("file_size", fileSize); request.setBody(body.toString()); BoxJSONResponse response = (BoxJSONResponse) request.send(); JsonObject jsonObject = JsonObject.readFrom(response.getJSON()); String sessionId = jsonObject.get("id").asString(); BoxFileUploadSession session = new BoxFileUploadSession(this.getAPI(), sessionId); return session.new Info(jsonObject); }
[ "public", "BoxFileUploadSession", ".", "Info", "createUploadSession", "(", "long", "fileSize", ")", "{", "URL", "url", "=", "UPLOAD_SESSION_URL_TEMPLATE", ".", "build", "(", "this", ".", "getAPI", "(", ")", ".", "getBaseUploadURL", "(", ")", ",", "this", ".", "getID", "(", ")", ")", ";", "BoxJSONRequest", "request", "=", "new", "BoxJSONRequest", "(", "this", ".", "getAPI", "(", ")", ",", "url", ",", "\"POST\"", ")", ";", "request", ".", "addHeader", "(", "\"Content-Type\"", ",", "\"application/json\"", ")", ";", "JsonObject", "body", "=", "new", "JsonObject", "(", ")", ";", "body", ".", "add", "(", "\"file_size\"", ",", "fileSize", ")", ";", "request", ".", "setBody", "(", "body", ".", "toString", "(", ")", ")", ";", "BoxJSONResponse", "response", "=", "(", "BoxJSONResponse", ")", "request", ".", "send", "(", ")", ";", "JsonObject", "jsonObject", "=", "JsonObject", ".", "readFrom", "(", "response", ".", "getJSON", "(", ")", ")", ";", "String", "sessionId", "=", "jsonObject", ".", "get", "(", "\"id\"", ")", ".", "asString", "(", ")", ";", "BoxFileUploadSession", "session", "=", "new", "BoxFileUploadSession", "(", "this", ".", "getAPI", "(", ")", ",", "sessionId", ")", ";", "return", "session", ".", "new", "Info", "(", "jsonObject", ")", ";", "}" ]
Creates an upload session to create a new version of a file in chunks. This will first verify that the version can be created and then open a session for uploading pieces of the file. @param fileSize the size of the file that will be uploaded. @return the created upload session instance.
[ "Creates", "an", "upload", "session", "to", "create", "a", "new", "version", "of", "a", "file", "in", "chunks", ".", "This", "will", "first", "verify", "that", "the", "version", "can", "be", "created", "and", "then", "open", "a", "session", "for", "uploading", "pieces", "of", "the", "file", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxFile.java#L1392-L1408
163,555
box/box-java-sdk
src/main/java/com/box/sdk/EventLog.java
EventLog.getEnterpriseEvents
public static EventLog getEnterpriseEvents(BoxAPIConnection api, Date after, Date before, BoxEvent.Type... types) { return getEnterpriseEvents(api, null, after, before, ENTERPRISE_LIMIT, types); }
java
public static EventLog getEnterpriseEvents(BoxAPIConnection api, Date after, Date before, BoxEvent.Type... types) { return getEnterpriseEvents(api, null, after, before, ENTERPRISE_LIMIT, types); }
[ "public", "static", "EventLog", "getEnterpriseEvents", "(", "BoxAPIConnection", "api", ",", "Date", "after", ",", "Date", "before", ",", "BoxEvent", ".", "Type", "...", "types", ")", "{", "return", "getEnterpriseEvents", "(", "api", ",", "null", ",", "after", ",", "before", ",", "ENTERPRISE_LIMIT", ",", "types", ")", ";", "}" ]
Gets all the enterprise events that occurred within a specified date range. @param api the API connection to use. @param after the lower bound on the timestamp of the events returned. @param before the upper bound on the timestamp of the events returned. @param types an optional list of event types to filter by. @return a log of all the events that met the given criteria.
[ "Gets", "all", "the", "enterprise", "events", "that", "occurred", "within", "a", "specified", "date", "range", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/EventLog.java#L74-L76
163,556
box/box-java-sdk
src/main/java/com/box/sdk/BoxStoragePolicy.java
BoxStoragePolicy.getInfo
public BoxStoragePolicy.Info getInfo(String... fields) { QueryStringBuilder builder = new QueryStringBuilder(); if (fields.length > 0) { builder.appendParam("fields", fields); } URL url = STORAGE_POLICY_WITH_ID_URL_TEMPLATE.buildWithQuery(this.getAPI().getBaseURL(), builder.toString(), this.getID()); BoxAPIRequest request = new BoxAPIRequest(this.getAPI(), url, "GET"); BoxJSONResponse response = (BoxJSONResponse) request.send(); return new Info(response.getJSON()); }
java
public BoxStoragePolicy.Info getInfo(String... fields) { QueryStringBuilder builder = new QueryStringBuilder(); if (fields.length > 0) { builder.appendParam("fields", fields); } URL url = STORAGE_POLICY_WITH_ID_URL_TEMPLATE.buildWithQuery(this.getAPI().getBaseURL(), builder.toString(), this.getID()); BoxAPIRequest request = new BoxAPIRequest(this.getAPI(), url, "GET"); BoxJSONResponse response = (BoxJSONResponse) request.send(); return new Info(response.getJSON()); }
[ "public", "BoxStoragePolicy", ".", "Info", "getInfo", "(", "String", "...", "fields", ")", "{", "QueryStringBuilder", "builder", "=", "new", "QueryStringBuilder", "(", ")", ";", "if", "(", "fields", ".", "length", ">", "0", ")", "{", "builder", ".", "appendParam", "(", "\"fields\"", ",", "fields", ")", ";", "}", "URL", "url", "=", "STORAGE_POLICY_WITH_ID_URL_TEMPLATE", ".", "buildWithQuery", "(", "this", ".", "getAPI", "(", ")", ".", "getBaseURL", "(", ")", ",", "builder", ".", "toString", "(", ")", ",", "this", ".", "getID", "(", ")", ")", ";", "BoxAPIRequest", "request", "=", "new", "BoxAPIRequest", "(", "this", ".", "getAPI", "(", ")", ",", "url", ",", "\"GET\"", ")", ";", "BoxJSONResponse", "response", "=", "(", "BoxJSONResponse", ")", "request", ".", "send", "(", ")", ";", "return", "new", "Info", "(", "response", ".", "getJSON", "(", ")", ")", ";", "}" ]
Gets information for a Box Storage Policy with optional fields. @param fields the fields to retrieve. @return info about this item containing only the specified fields, including storage policy.
[ "Gets", "information", "for", "a", "Box", "Storage", "Policy", "with", "optional", "fields", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxStoragePolicy.java#L46-L57
163,557
box/box-java-sdk
src/main/java/com/box/sdk/LargeFileUpload.java
LargeFileUpload.upload
public BoxFile.Info upload(BoxAPIConnection boxApi, String folderId, InputStream stream, URL url, String fileName, long fileSize) throws InterruptedException, IOException { //Create a upload session BoxFileUploadSession.Info session = this.createUploadSession(boxApi, folderId, url, fileName, fileSize); return this.uploadHelper(session, stream, fileSize); }
java
public BoxFile.Info upload(BoxAPIConnection boxApi, String folderId, InputStream stream, URL url, String fileName, long fileSize) throws InterruptedException, IOException { //Create a upload session BoxFileUploadSession.Info session = this.createUploadSession(boxApi, folderId, url, fileName, fileSize); return this.uploadHelper(session, stream, fileSize); }
[ "public", "BoxFile", ".", "Info", "upload", "(", "BoxAPIConnection", "boxApi", ",", "String", "folderId", ",", "InputStream", "stream", ",", "URL", "url", ",", "String", "fileName", ",", "long", "fileSize", ")", "throws", "InterruptedException", ",", "IOException", "{", "//Create a upload session", "BoxFileUploadSession", ".", "Info", "session", "=", "this", ".", "createUploadSession", "(", "boxApi", ",", "folderId", ",", "url", ",", "fileName", ",", "fileSize", ")", ";", "return", "this", ".", "uploadHelper", "(", "session", ",", "stream", ",", "fileSize", ")", ";", "}" ]
Uploads a new large file. @param boxApi the API connection to be used by the upload session. @param folderId the id of the folder in which the file will be uploaded. @param stream the input stream that feeds the content of the file. @param url the upload session URL. @param fileName the name of the file to be created. @param fileSize the total size of the file. @return the created file instance. @throws InterruptedException when a thread gets interupted. @throws IOException when reading a stream throws exception.
[ "Uploads", "a", "new", "large", "file", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/LargeFileUpload.java#L91-L96
163,558
box/box-java-sdk
src/main/java/com/box/sdk/LargeFileUpload.java
LargeFileUpload.generateDigest
public String generateDigest(InputStream stream) { MessageDigest digest = null; try { digest = MessageDigest.getInstance(DIGEST_ALGORITHM_SHA1); } catch (NoSuchAlgorithmException ae) { throw new BoxAPIException("Digest algorithm not found", ae); } //Calcuate the digest using the stream. DigestInputStream dis = new DigestInputStream(stream, digest); try { int value = dis.read(); while (value != -1) { value = dis.read(); } } catch (IOException ioe) { throw new BoxAPIException("Reading the stream failed.", ioe); } //Get the calculated digest for the stream byte[] digestBytes = digest.digest(); return Base64.encode(digestBytes); }
java
public String generateDigest(InputStream stream) { MessageDigest digest = null; try { digest = MessageDigest.getInstance(DIGEST_ALGORITHM_SHA1); } catch (NoSuchAlgorithmException ae) { throw new BoxAPIException("Digest algorithm not found", ae); } //Calcuate the digest using the stream. DigestInputStream dis = new DigestInputStream(stream, digest); try { int value = dis.read(); while (value != -1) { value = dis.read(); } } catch (IOException ioe) { throw new BoxAPIException("Reading the stream failed.", ioe); } //Get the calculated digest for the stream byte[] digestBytes = digest.digest(); return Base64.encode(digestBytes); }
[ "public", "String", "generateDigest", "(", "InputStream", "stream", ")", "{", "MessageDigest", "digest", "=", "null", ";", "try", "{", "digest", "=", "MessageDigest", ".", "getInstance", "(", "DIGEST_ALGORITHM_SHA1", ")", ";", "}", "catch", "(", "NoSuchAlgorithmException", "ae", ")", "{", "throw", "new", "BoxAPIException", "(", "\"Digest algorithm not found\"", ",", "ae", ")", ";", "}", "//Calcuate the digest using the stream.", "DigestInputStream", "dis", "=", "new", "DigestInputStream", "(", "stream", ",", "digest", ")", ";", "try", "{", "int", "value", "=", "dis", ".", "read", "(", ")", ";", "while", "(", "value", "!=", "-", "1", ")", "{", "value", "=", "dis", ".", "read", "(", ")", ";", "}", "}", "catch", "(", "IOException", "ioe", ")", "{", "throw", "new", "BoxAPIException", "(", "\"Reading the stream failed.\"", ",", "ioe", ")", ";", "}", "//Get the calculated digest for the stream", "byte", "[", "]", "digestBytes", "=", "digest", ".", "digest", "(", ")", ";", "return", "Base64", ".", "encode", "(", "digestBytes", ")", ";", "}" ]
Generates the Base64 encoded SHA-1 hash for content available in the stream. It can be used to calculate the hash of a file. @param stream the input stream of the file or data. @return the Base64 encoded hash string.
[ "Generates", "the", "Base64", "encoded", "SHA", "-", "1", "hash", "for", "content", "available", "in", "the", "stream", ".", "It", "can", "be", "used", "to", "calculate", "the", "hash", "of", "a", "file", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/LargeFileUpload.java#L220-L242
163,559
box/box-java-sdk
src/main/java/com/box/sdk/BoxSharedLink.java
BoxSharedLink.setPermissions
public void setPermissions(Permissions permissions) { if (this.permissions == permissions) { return; } this.removeChildObject("permissions"); this.permissions = permissions; this.addChildObject("permissions", permissions); }
java
public void setPermissions(Permissions permissions) { if (this.permissions == permissions) { return; } this.removeChildObject("permissions"); this.permissions = permissions; this.addChildObject("permissions", permissions); }
[ "public", "void", "setPermissions", "(", "Permissions", "permissions", ")", "{", "if", "(", "this", ".", "permissions", "==", "permissions", ")", "{", "return", ";", "}", "this", ".", "removeChildObject", "(", "\"permissions\"", ")", ";", "this", ".", "permissions", "=", "permissions", ";", "this", ".", "addChildObject", "(", "\"permissions\"", ",", "permissions", ")", ";", "}" ]
Sets the permissions associated with this shared link. @param permissions the new permissions for this shared link.
[ "Sets", "the", "permissions", "associated", "with", "this", "shared", "link", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxSharedLink.java#L175-L183
163,560
box/box-java-sdk
src/main/java/com/box/sdk/BoxTrash.java
BoxTrash.deleteFolder
public void deleteFolder(String folderID) { URL url = FOLDER_INFO_URL_TEMPLATE.build(this.api.getBaseURL(), folderID); BoxAPIRequest request = new BoxAPIRequest(this.api, url, "DELETE"); BoxAPIResponse response = request.send(); response.disconnect(); }
java
public void deleteFolder(String folderID) { URL url = FOLDER_INFO_URL_TEMPLATE.build(this.api.getBaseURL(), folderID); BoxAPIRequest request = new BoxAPIRequest(this.api, url, "DELETE"); BoxAPIResponse response = request.send(); response.disconnect(); }
[ "public", "void", "deleteFolder", "(", "String", "folderID", ")", "{", "URL", "url", "=", "FOLDER_INFO_URL_TEMPLATE", ".", "build", "(", "this", ".", "api", ".", "getBaseURL", "(", ")", ",", "folderID", ")", ";", "BoxAPIRequest", "request", "=", "new", "BoxAPIRequest", "(", "this", ".", "api", ",", "url", ",", "\"DELETE\"", ")", ";", "BoxAPIResponse", "response", "=", "request", ".", "send", "(", ")", ";", "response", ".", "disconnect", "(", ")", ";", "}" ]
Permanently deletes a trashed folder. @param folderID the ID of the trashed folder to permanently delete.
[ "Permanently", "deletes", "a", "trashed", "folder", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxTrash.java#L53-L58
163,561
box/box-java-sdk
src/main/java/com/box/sdk/BoxTrash.java
BoxTrash.getFolderInfo
public BoxFolder.Info getFolderInfo(String folderID) { URL url = FOLDER_INFO_URL_TEMPLATE.build(this.api.getBaseURL(), folderID); BoxAPIRequest request = new BoxAPIRequest(this.api, url, "GET"); BoxJSONResponse response = (BoxJSONResponse) request.send(); JsonObject jsonObject = JsonObject.readFrom(response.getJSON()); BoxFolder folder = new BoxFolder(this.api, jsonObject.get("id").asString()); return folder.new Info(response.getJSON()); }
java
public BoxFolder.Info getFolderInfo(String folderID) { URL url = FOLDER_INFO_URL_TEMPLATE.build(this.api.getBaseURL(), folderID); BoxAPIRequest request = new BoxAPIRequest(this.api, url, "GET"); BoxJSONResponse response = (BoxJSONResponse) request.send(); JsonObject jsonObject = JsonObject.readFrom(response.getJSON()); BoxFolder folder = new BoxFolder(this.api, jsonObject.get("id").asString()); return folder.new Info(response.getJSON()); }
[ "public", "BoxFolder", ".", "Info", "getFolderInfo", "(", "String", "folderID", ")", "{", "URL", "url", "=", "FOLDER_INFO_URL_TEMPLATE", ".", "build", "(", "this", ".", "api", ".", "getBaseURL", "(", ")", ",", "folderID", ")", ";", "BoxAPIRequest", "request", "=", "new", "BoxAPIRequest", "(", "this", ".", "api", ",", "url", ",", "\"GET\"", ")", ";", "BoxJSONResponse", "response", "=", "(", "BoxJSONResponse", ")", "request", ".", "send", "(", ")", ";", "JsonObject", "jsonObject", "=", "JsonObject", ".", "readFrom", "(", "response", ".", "getJSON", "(", ")", ")", ";", "BoxFolder", "folder", "=", "new", "BoxFolder", "(", "this", ".", "api", ",", "jsonObject", ".", "get", "(", "\"id\"", ")", ".", "asString", "(", ")", ")", ";", "return", "folder", ".", "new", "Info", "(", "response", ".", "getJSON", "(", ")", ")", ";", "}" ]
Gets information about a trashed folder. @param folderID the ID of the trashed folder. @return info about the trashed folder.
[ "Gets", "information", "about", "a", "trashed", "folder", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxTrash.java#L65-L73
163,562
box/box-java-sdk
src/main/java/com/box/sdk/BoxTrash.java
BoxTrash.getFolderInfo
public BoxFolder.Info getFolderInfo(String folderID, String... fields) { String queryString = new QueryStringBuilder().appendParam("fields", fields).toString(); URL url = FOLDER_INFO_URL_TEMPLATE.buildWithQuery(this.api.getBaseURL(), queryString, folderID); BoxAPIRequest request = new BoxAPIRequest(this.api, url, "GET"); BoxJSONResponse response = (BoxJSONResponse) request.send(); JsonObject jsonObject = JsonObject.readFrom(response.getJSON()); BoxFolder folder = new BoxFolder(this.api, jsonObject.get("id").asString()); return folder.new Info(response.getJSON()); }
java
public BoxFolder.Info getFolderInfo(String folderID, String... fields) { String queryString = new QueryStringBuilder().appendParam("fields", fields).toString(); URL url = FOLDER_INFO_URL_TEMPLATE.buildWithQuery(this.api.getBaseURL(), queryString, folderID); BoxAPIRequest request = new BoxAPIRequest(this.api, url, "GET"); BoxJSONResponse response = (BoxJSONResponse) request.send(); JsonObject jsonObject = JsonObject.readFrom(response.getJSON()); BoxFolder folder = new BoxFolder(this.api, jsonObject.get("id").asString()); return folder.new Info(response.getJSON()); }
[ "public", "BoxFolder", ".", "Info", "getFolderInfo", "(", "String", "folderID", ",", "String", "...", "fields", ")", "{", "String", "queryString", "=", "new", "QueryStringBuilder", "(", ")", ".", "appendParam", "(", "\"fields\"", ",", "fields", ")", ".", "toString", "(", ")", ";", "URL", "url", "=", "FOLDER_INFO_URL_TEMPLATE", ".", "buildWithQuery", "(", "this", ".", "api", ".", "getBaseURL", "(", ")", ",", "queryString", ",", "folderID", ")", ";", "BoxAPIRequest", "request", "=", "new", "BoxAPIRequest", "(", "this", ".", "api", ",", "url", ",", "\"GET\"", ")", ";", "BoxJSONResponse", "response", "=", "(", "BoxJSONResponse", ")", "request", ".", "send", "(", ")", ";", "JsonObject", "jsonObject", "=", "JsonObject", ".", "readFrom", "(", "response", ".", "getJSON", "(", ")", ")", ";", "BoxFolder", "folder", "=", "new", "BoxFolder", "(", "this", ".", "api", ",", "jsonObject", ".", "get", "(", "\"id\"", ")", ".", "asString", "(", ")", ")", ";", "return", "folder", ".", "new", "Info", "(", "response", ".", "getJSON", "(", ")", ")", ";", "}" ]
Gets information about a trashed folder that's limited to a list of specified fields. @param folderID the ID of the trashed folder. @param fields the fields to retrieve. @return info about the trashed folder containing only the specified fields.
[ "Gets", "information", "about", "a", "trashed", "folder", "that", "s", "limited", "to", "a", "list", "of", "specified", "fields", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxTrash.java#L81-L90
163,563
box/box-java-sdk
src/main/java/com/box/sdk/BoxTrash.java
BoxTrash.restoreFolder
public BoxFolder.Info restoreFolder(String folderID) { URL url = RESTORE_FOLDER_URL_TEMPLATE.build(this.api.getBaseURL(), folderID); BoxAPIRequest request = new BoxAPIRequest(this.api, url, "POST"); JsonObject requestJSON = new JsonObject() .add("", ""); request.setBody(requestJSON.toString()); BoxJSONResponse response = (BoxJSONResponse) request.send(); JsonObject responseJSON = JsonObject.readFrom(response.getJSON()); BoxFolder restoredFolder = new BoxFolder(this.api, responseJSON.get("id").asString()); return restoredFolder.new Info(responseJSON); }
java
public BoxFolder.Info restoreFolder(String folderID) { URL url = RESTORE_FOLDER_URL_TEMPLATE.build(this.api.getBaseURL(), folderID); BoxAPIRequest request = new BoxAPIRequest(this.api, url, "POST"); JsonObject requestJSON = new JsonObject() .add("", ""); request.setBody(requestJSON.toString()); BoxJSONResponse response = (BoxJSONResponse) request.send(); JsonObject responseJSON = JsonObject.readFrom(response.getJSON()); BoxFolder restoredFolder = new BoxFolder(this.api, responseJSON.get("id").asString()); return restoredFolder.new Info(responseJSON); }
[ "public", "BoxFolder", ".", "Info", "restoreFolder", "(", "String", "folderID", ")", "{", "URL", "url", "=", "RESTORE_FOLDER_URL_TEMPLATE", ".", "build", "(", "this", ".", "api", ".", "getBaseURL", "(", ")", ",", "folderID", ")", ";", "BoxAPIRequest", "request", "=", "new", "BoxAPIRequest", "(", "this", ".", "api", ",", "url", ",", "\"POST\"", ")", ";", "JsonObject", "requestJSON", "=", "new", "JsonObject", "(", ")", ".", "add", "(", "\"\"", ",", "\"\"", ")", ";", "request", ".", "setBody", "(", "requestJSON", ".", "toString", "(", ")", ")", ";", "BoxJSONResponse", "response", "=", "(", "BoxJSONResponse", ")", "request", ".", "send", "(", ")", ";", "JsonObject", "responseJSON", "=", "JsonObject", ".", "readFrom", "(", "response", ".", "getJSON", "(", ")", ")", ";", "BoxFolder", "restoredFolder", "=", "new", "BoxFolder", "(", "this", ".", "api", ",", "responseJSON", ".", "get", "(", "\"id\"", ")", ".", "asString", "(", ")", ")", ";", "return", "restoredFolder", ".", "new", "Info", "(", "responseJSON", ")", ";", "}" ]
Restores a trashed folder back to its original location. @param folderID the ID of the trashed folder. @return info about the restored folder.
[ "Restores", "a", "trashed", "folder", "back", "to", "its", "original", "location", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxTrash.java#L97-L108
163,564
box/box-java-sdk
src/main/java/com/box/sdk/BoxTrash.java
BoxTrash.restoreFolder
public BoxFolder.Info restoreFolder(String folderID, String newName, String newParentID) { JsonObject requestJSON = new JsonObject(); if (newName != null) { requestJSON.add("name", newName); } if (newParentID != null) { JsonObject parent = new JsonObject(); parent.add("id", newParentID); requestJSON.add("parent", parent); } URL url = RESTORE_FOLDER_URL_TEMPLATE.build(this.api.getBaseURL(), folderID); BoxJSONRequest request = new BoxJSONRequest(this.api, url, "POST"); request.setBody(requestJSON.toString()); BoxJSONResponse response = (BoxJSONResponse) request.send(); JsonObject responseJSON = JsonObject.readFrom(response.getJSON()); BoxFolder restoredFolder = new BoxFolder(this.api, responseJSON.get("id").asString()); return restoredFolder.new Info(responseJSON); }
java
public BoxFolder.Info restoreFolder(String folderID, String newName, String newParentID) { JsonObject requestJSON = new JsonObject(); if (newName != null) { requestJSON.add("name", newName); } if (newParentID != null) { JsonObject parent = new JsonObject(); parent.add("id", newParentID); requestJSON.add("parent", parent); } URL url = RESTORE_FOLDER_URL_TEMPLATE.build(this.api.getBaseURL(), folderID); BoxJSONRequest request = new BoxJSONRequest(this.api, url, "POST"); request.setBody(requestJSON.toString()); BoxJSONResponse response = (BoxJSONResponse) request.send(); JsonObject responseJSON = JsonObject.readFrom(response.getJSON()); BoxFolder restoredFolder = new BoxFolder(this.api, responseJSON.get("id").asString()); return restoredFolder.new Info(responseJSON); }
[ "public", "BoxFolder", ".", "Info", "restoreFolder", "(", "String", "folderID", ",", "String", "newName", ",", "String", "newParentID", ")", "{", "JsonObject", "requestJSON", "=", "new", "JsonObject", "(", ")", ";", "if", "(", "newName", "!=", "null", ")", "{", "requestJSON", ".", "add", "(", "\"name\"", ",", "newName", ")", ";", "}", "if", "(", "newParentID", "!=", "null", ")", "{", "JsonObject", "parent", "=", "new", "JsonObject", "(", ")", ";", "parent", ".", "add", "(", "\"id\"", ",", "newParentID", ")", ";", "requestJSON", ".", "add", "(", "\"parent\"", ",", "parent", ")", ";", "}", "URL", "url", "=", "RESTORE_FOLDER_URL_TEMPLATE", ".", "build", "(", "this", ".", "api", ".", "getBaseURL", "(", ")", ",", "folderID", ")", ";", "BoxJSONRequest", "request", "=", "new", "BoxJSONRequest", "(", "this", ".", "api", ",", "url", ",", "\"POST\"", ")", ";", "request", ".", "setBody", "(", "requestJSON", ".", "toString", "(", ")", ")", ";", "BoxJSONResponse", "response", "=", "(", "BoxJSONResponse", ")", "request", ".", "send", "(", ")", ";", "JsonObject", "responseJSON", "=", "JsonObject", ".", "readFrom", "(", "response", ".", "getJSON", "(", ")", ")", ";", "BoxFolder", "restoredFolder", "=", "new", "BoxFolder", "(", "this", ".", "api", ",", "responseJSON", ".", "get", "(", "\"id\"", ")", ".", "asString", "(", ")", ")", ";", "return", "restoredFolder", ".", "new", "Info", "(", "responseJSON", ")", ";", "}" ]
Restores a trashed folder to a new location with a new name. @param folderID the ID of the trashed folder. @param newName an optional new name to give the folder. This can be null to use the folder's original name. @param newParentID an optional new parent ID for the folder. This can be null to use the folder's original parent. @return info about the restored folder.
[ "Restores", "a", "trashed", "folder", "to", "a", "new", "location", "with", "a", "new", "name", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxTrash.java#L118-L139
163,565
box/box-java-sdk
src/main/java/com/box/sdk/BoxTrash.java
BoxTrash.deleteFile
public void deleteFile(String fileID) { URL url = FILE_INFO_URL_TEMPLATE.build(this.api.getBaseURL(), fileID); BoxAPIRequest request = new BoxAPIRequest(this.api, url, "DELETE"); BoxAPIResponse response = request.send(); response.disconnect(); }
java
public void deleteFile(String fileID) { URL url = FILE_INFO_URL_TEMPLATE.build(this.api.getBaseURL(), fileID); BoxAPIRequest request = new BoxAPIRequest(this.api, url, "DELETE"); BoxAPIResponse response = request.send(); response.disconnect(); }
[ "public", "void", "deleteFile", "(", "String", "fileID", ")", "{", "URL", "url", "=", "FILE_INFO_URL_TEMPLATE", ".", "build", "(", "this", ".", "api", ".", "getBaseURL", "(", ")", ",", "fileID", ")", ";", "BoxAPIRequest", "request", "=", "new", "BoxAPIRequest", "(", "this", ".", "api", ",", "url", ",", "\"DELETE\"", ")", ";", "BoxAPIResponse", "response", "=", "request", ".", "send", "(", ")", ";", "response", ".", "disconnect", "(", ")", ";", "}" ]
Permanently deletes a trashed file. @param fileID the ID of the trashed folder to permanently delete.
[ "Permanently", "deletes", "a", "trashed", "file", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxTrash.java#L145-L150
163,566
box/box-java-sdk
src/main/java/com/box/sdk/BoxTrash.java
BoxTrash.getFileInfo
public BoxFile.Info getFileInfo(String fileID) { URL url = FILE_INFO_URL_TEMPLATE.build(this.api.getBaseURL(), fileID); BoxAPIRequest request = new BoxAPIRequest(this.api, url, "GET"); BoxJSONResponse response = (BoxJSONResponse) request.send(); JsonObject jsonObject = JsonObject.readFrom(response.getJSON()); BoxFile file = new BoxFile(this.api, jsonObject.get("id").asString()); return file.new Info(response.getJSON()); }
java
public BoxFile.Info getFileInfo(String fileID) { URL url = FILE_INFO_URL_TEMPLATE.build(this.api.getBaseURL(), fileID); BoxAPIRequest request = new BoxAPIRequest(this.api, url, "GET"); BoxJSONResponse response = (BoxJSONResponse) request.send(); JsonObject jsonObject = JsonObject.readFrom(response.getJSON()); BoxFile file = new BoxFile(this.api, jsonObject.get("id").asString()); return file.new Info(response.getJSON()); }
[ "public", "BoxFile", ".", "Info", "getFileInfo", "(", "String", "fileID", ")", "{", "URL", "url", "=", "FILE_INFO_URL_TEMPLATE", ".", "build", "(", "this", ".", "api", ".", "getBaseURL", "(", ")", ",", "fileID", ")", ";", "BoxAPIRequest", "request", "=", "new", "BoxAPIRequest", "(", "this", ".", "api", ",", "url", ",", "\"GET\"", ")", ";", "BoxJSONResponse", "response", "=", "(", "BoxJSONResponse", ")", "request", ".", "send", "(", ")", ";", "JsonObject", "jsonObject", "=", "JsonObject", ".", "readFrom", "(", "response", ".", "getJSON", "(", ")", ")", ";", "BoxFile", "file", "=", "new", "BoxFile", "(", "this", ".", "api", ",", "jsonObject", ".", "get", "(", "\"id\"", ")", ".", "asString", "(", ")", ")", ";", "return", "file", ".", "new", "Info", "(", "response", ".", "getJSON", "(", ")", ")", ";", "}" ]
Gets information about a trashed file. @param fileID the ID of the trashed file. @return info about the trashed file.
[ "Gets", "information", "about", "a", "trashed", "file", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxTrash.java#L157-L165
163,567
box/box-java-sdk
src/main/java/com/box/sdk/BoxTrash.java
BoxTrash.getFileInfo
public BoxFile.Info getFileInfo(String fileID, String... fields) { String queryString = new QueryStringBuilder().appendParam("fields", fields).toString(); URL url = FILE_INFO_URL_TEMPLATE.buildWithQuery(this.api.getBaseURL(), queryString, fileID); BoxAPIRequest request = new BoxAPIRequest(this.api, url, "GET"); BoxJSONResponse response = (BoxJSONResponse) request.send(); JsonObject jsonObject = JsonObject.readFrom(response.getJSON()); BoxFile file = new BoxFile(this.api, jsonObject.get("id").asString()); return file.new Info(response.getJSON()); }
java
public BoxFile.Info getFileInfo(String fileID, String... fields) { String queryString = new QueryStringBuilder().appendParam("fields", fields).toString(); URL url = FILE_INFO_URL_TEMPLATE.buildWithQuery(this.api.getBaseURL(), queryString, fileID); BoxAPIRequest request = new BoxAPIRequest(this.api, url, "GET"); BoxJSONResponse response = (BoxJSONResponse) request.send(); JsonObject jsonObject = JsonObject.readFrom(response.getJSON()); BoxFile file = new BoxFile(this.api, jsonObject.get("id").asString()); return file.new Info(response.getJSON()); }
[ "public", "BoxFile", ".", "Info", "getFileInfo", "(", "String", "fileID", ",", "String", "...", "fields", ")", "{", "String", "queryString", "=", "new", "QueryStringBuilder", "(", ")", ".", "appendParam", "(", "\"fields\"", ",", "fields", ")", ".", "toString", "(", ")", ";", "URL", "url", "=", "FILE_INFO_URL_TEMPLATE", ".", "buildWithQuery", "(", "this", ".", "api", ".", "getBaseURL", "(", ")", ",", "queryString", ",", "fileID", ")", ";", "BoxAPIRequest", "request", "=", "new", "BoxAPIRequest", "(", "this", ".", "api", ",", "url", ",", "\"GET\"", ")", ";", "BoxJSONResponse", "response", "=", "(", "BoxJSONResponse", ")", "request", ".", "send", "(", ")", ";", "JsonObject", "jsonObject", "=", "JsonObject", ".", "readFrom", "(", "response", ".", "getJSON", "(", ")", ")", ";", "BoxFile", "file", "=", "new", "BoxFile", "(", "this", ".", "api", ",", "jsonObject", ".", "get", "(", "\"id\"", ")", ".", "asString", "(", ")", ")", ";", "return", "file", ".", "new", "Info", "(", "response", ".", "getJSON", "(", ")", ")", ";", "}" ]
Gets information about a trashed file that's limited to a list of specified fields. @param fileID the ID of the trashed file. @param fields the fields to retrieve. @return info about the trashed file containing only the specified fields.
[ "Gets", "information", "about", "a", "trashed", "file", "that", "s", "limited", "to", "a", "list", "of", "specified", "fields", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxTrash.java#L173-L182
163,568
box/box-java-sdk
src/main/java/com/box/sdk/BoxTrash.java
BoxTrash.restoreFile
public BoxFile.Info restoreFile(String fileID) { URL url = RESTORE_FILE_URL_TEMPLATE.build(this.api.getBaseURL(), fileID); BoxAPIRequest request = new BoxAPIRequest(this.api, url, "POST"); JsonObject requestJSON = new JsonObject() .add("", ""); request.setBody(requestJSON.toString()); BoxJSONResponse response = (BoxJSONResponse) request.send(); JsonObject responseJSON = JsonObject.readFrom(response.getJSON()); BoxFile restoredFile = new BoxFile(this.api, responseJSON.get("id").asString()); return restoredFile.new Info(responseJSON); }
java
public BoxFile.Info restoreFile(String fileID) { URL url = RESTORE_FILE_URL_TEMPLATE.build(this.api.getBaseURL(), fileID); BoxAPIRequest request = new BoxAPIRequest(this.api, url, "POST"); JsonObject requestJSON = new JsonObject() .add("", ""); request.setBody(requestJSON.toString()); BoxJSONResponse response = (BoxJSONResponse) request.send(); JsonObject responseJSON = JsonObject.readFrom(response.getJSON()); BoxFile restoredFile = new BoxFile(this.api, responseJSON.get("id").asString()); return restoredFile.new Info(responseJSON); }
[ "public", "BoxFile", ".", "Info", "restoreFile", "(", "String", "fileID", ")", "{", "URL", "url", "=", "RESTORE_FILE_URL_TEMPLATE", ".", "build", "(", "this", ".", "api", ".", "getBaseURL", "(", ")", ",", "fileID", ")", ";", "BoxAPIRequest", "request", "=", "new", "BoxAPIRequest", "(", "this", ".", "api", ",", "url", ",", "\"POST\"", ")", ";", "JsonObject", "requestJSON", "=", "new", "JsonObject", "(", ")", ".", "add", "(", "\"\"", ",", "\"\"", ")", ";", "request", ".", "setBody", "(", "requestJSON", ".", "toString", "(", ")", ")", ";", "BoxJSONResponse", "response", "=", "(", "BoxJSONResponse", ")", "request", ".", "send", "(", ")", ";", "JsonObject", "responseJSON", "=", "JsonObject", ".", "readFrom", "(", "response", ".", "getJSON", "(", ")", ")", ";", "BoxFile", "restoredFile", "=", "new", "BoxFile", "(", "this", ".", "api", ",", "responseJSON", ".", "get", "(", "\"id\"", ")", ".", "asString", "(", ")", ")", ";", "return", "restoredFile", ".", "new", "Info", "(", "responseJSON", ")", ";", "}" ]
Restores a trashed file back to its original location. @param fileID the ID of the trashed file. @return info about the restored file.
[ "Restores", "a", "trashed", "file", "back", "to", "its", "original", "location", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxTrash.java#L189-L200
163,569
box/box-java-sdk
src/main/java/com/box/sdk/BoxTrash.java
BoxTrash.restoreFile
public BoxFile.Info restoreFile(String fileID, String newName, String newParentID) { JsonObject requestJSON = new JsonObject(); if (newName != null) { requestJSON.add("name", newName); } if (newParentID != null) { JsonObject parent = new JsonObject(); parent.add("id", newParentID); requestJSON.add("parent", parent); } URL url = RESTORE_FILE_URL_TEMPLATE.build(this.api.getBaseURL(), fileID); BoxJSONRequest request = new BoxJSONRequest(this.api, url, "POST"); request.setBody(requestJSON.toString()); BoxJSONResponse response = (BoxJSONResponse) request.send(); JsonObject responseJSON = JsonObject.readFrom(response.getJSON()); BoxFile restoredFile = new BoxFile(this.api, responseJSON.get("id").asString()); return restoredFile.new Info(responseJSON); }
java
public BoxFile.Info restoreFile(String fileID, String newName, String newParentID) { JsonObject requestJSON = new JsonObject(); if (newName != null) { requestJSON.add("name", newName); } if (newParentID != null) { JsonObject parent = new JsonObject(); parent.add("id", newParentID); requestJSON.add("parent", parent); } URL url = RESTORE_FILE_URL_TEMPLATE.build(this.api.getBaseURL(), fileID); BoxJSONRequest request = new BoxJSONRequest(this.api, url, "POST"); request.setBody(requestJSON.toString()); BoxJSONResponse response = (BoxJSONResponse) request.send(); JsonObject responseJSON = JsonObject.readFrom(response.getJSON()); BoxFile restoredFile = new BoxFile(this.api, responseJSON.get("id").asString()); return restoredFile.new Info(responseJSON); }
[ "public", "BoxFile", ".", "Info", "restoreFile", "(", "String", "fileID", ",", "String", "newName", ",", "String", "newParentID", ")", "{", "JsonObject", "requestJSON", "=", "new", "JsonObject", "(", ")", ";", "if", "(", "newName", "!=", "null", ")", "{", "requestJSON", ".", "add", "(", "\"name\"", ",", "newName", ")", ";", "}", "if", "(", "newParentID", "!=", "null", ")", "{", "JsonObject", "parent", "=", "new", "JsonObject", "(", ")", ";", "parent", ".", "add", "(", "\"id\"", ",", "newParentID", ")", ";", "requestJSON", ".", "add", "(", "\"parent\"", ",", "parent", ")", ";", "}", "URL", "url", "=", "RESTORE_FILE_URL_TEMPLATE", ".", "build", "(", "this", ".", "api", ".", "getBaseURL", "(", ")", ",", "fileID", ")", ";", "BoxJSONRequest", "request", "=", "new", "BoxJSONRequest", "(", "this", ".", "api", ",", "url", ",", "\"POST\"", ")", ";", "request", ".", "setBody", "(", "requestJSON", ".", "toString", "(", ")", ")", ";", "BoxJSONResponse", "response", "=", "(", "BoxJSONResponse", ")", "request", ".", "send", "(", ")", ";", "JsonObject", "responseJSON", "=", "JsonObject", ".", "readFrom", "(", "response", ".", "getJSON", "(", ")", ")", ";", "BoxFile", "restoredFile", "=", "new", "BoxFile", "(", "this", ".", "api", ",", "responseJSON", ".", "get", "(", "\"id\"", ")", ".", "asString", "(", ")", ")", ";", "return", "restoredFile", ".", "new", "Info", "(", "responseJSON", ")", ";", "}" ]
Restores a trashed file to a new location with a new name. @param fileID the ID of the trashed file. @param newName an optional new name to give the file. This can be null to use the file's original name. @param newParentID an optional new parent ID for the file. This can be null to use the file's original parent. @return info about the restored file.
[ "Restores", "a", "trashed", "file", "to", "a", "new", "location", "with", "a", "new", "name", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxTrash.java#L210-L231
163,570
box/box-java-sdk
src/main/java/com/box/sdk/BoxTrash.java
BoxTrash.iterator
public Iterator<BoxItem.Info> iterator() { URL url = GET_ITEMS_URL.build(this.api.getBaseURL()); return new BoxItemIterator(this.api, url); }
java
public Iterator<BoxItem.Info> iterator() { URL url = GET_ITEMS_URL.build(this.api.getBaseURL()); return new BoxItemIterator(this.api, url); }
[ "public", "Iterator", "<", "BoxItem", ".", "Info", ">", "iterator", "(", ")", "{", "URL", "url", "=", "GET_ITEMS_URL", ".", "build", "(", "this", ".", "api", ".", "getBaseURL", "(", ")", ")", ";", "return", "new", "BoxItemIterator", "(", "this", ".", "api", ",", "url", ")", ";", "}" ]
Returns an iterator over the items in the trash. @return an iterator over the items in the trash.
[ "Returns", "an", "iterator", "over", "the", "items", "in", "the", "trash", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxTrash.java#L237-L240
163,571
box/box-java-sdk
src/main/java/com/box/sdk/MetadataTemplate.java
MetadataTemplate.createMetadataTemplate
public static MetadataTemplate createMetadataTemplate(BoxAPIConnection api, String scope, String templateKey, String displayName, boolean hidden, List<Field> fields) { JsonObject jsonObject = new JsonObject(); jsonObject.add("scope", scope); jsonObject.add("displayName", displayName); jsonObject.add("hidden", hidden); if (templateKey != null) { jsonObject.add("templateKey", templateKey); } JsonArray fieldsArray = new JsonArray(); if (fields != null && !fields.isEmpty()) { for (Field field : fields) { JsonObject fieldObj = getFieldJsonObject(field); fieldsArray.add(fieldObj); } jsonObject.add("fields", fieldsArray); } URL url = METADATA_TEMPLATE_SCHEMA_URL_TEMPLATE.build(api.getBaseURL()); BoxJSONRequest request = new BoxJSONRequest(api, url, "POST"); request.setBody(jsonObject.toString()); BoxJSONResponse response = (BoxJSONResponse) request.send(); JsonObject responseJSON = JsonObject.readFrom(response.getJSON()); return new MetadataTemplate(responseJSON); }
java
public static MetadataTemplate createMetadataTemplate(BoxAPIConnection api, String scope, String templateKey, String displayName, boolean hidden, List<Field> fields) { JsonObject jsonObject = new JsonObject(); jsonObject.add("scope", scope); jsonObject.add("displayName", displayName); jsonObject.add("hidden", hidden); if (templateKey != null) { jsonObject.add("templateKey", templateKey); } JsonArray fieldsArray = new JsonArray(); if (fields != null && !fields.isEmpty()) { for (Field field : fields) { JsonObject fieldObj = getFieldJsonObject(field); fieldsArray.add(fieldObj); } jsonObject.add("fields", fieldsArray); } URL url = METADATA_TEMPLATE_SCHEMA_URL_TEMPLATE.build(api.getBaseURL()); BoxJSONRequest request = new BoxJSONRequest(api, url, "POST"); request.setBody(jsonObject.toString()); BoxJSONResponse response = (BoxJSONResponse) request.send(); JsonObject responseJSON = JsonObject.readFrom(response.getJSON()); return new MetadataTemplate(responseJSON); }
[ "public", "static", "MetadataTemplate", "createMetadataTemplate", "(", "BoxAPIConnection", "api", ",", "String", "scope", ",", "String", "templateKey", ",", "String", "displayName", ",", "boolean", "hidden", ",", "List", "<", "Field", ">", "fields", ")", "{", "JsonObject", "jsonObject", "=", "new", "JsonObject", "(", ")", ";", "jsonObject", ".", "add", "(", "\"scope\"", ",", "scope", ")", ";", "jsonObject", ".", "add", "(", "\"displayName\"", ",", "displayName", ")", ";", "jsonObject", ".", "add", "(", "\"hidden\"", ",", "hidden", ")", ";", "if", "(", "templateKey", "!=", "null", ")", "{", "jsonObject", ".", "add", "(", "\"templateKey\"", ",", "templateKey", ")", ";", "}", "JsonArray", "fieldsArray", "=", "new", "JsonArray", "(", ")", ";", "if", "(", "fields", "!=", "null", "&&", "!", "fields", ".", "isEmpty", "(", ")", ")", "{", "for", "(", "Field", "field", ":", "fields", ")", "{", "JsonObject", "fieldObj", "=", "getFieldJsonObject", "(", "field", ")", ";", "fieldsArray", ".", "add", "(", "fieldObj", ")", ";", "}", "jsonObject", ".", "add", "(", "\"fields\"", ",", "fieldsArray", ")", ";", "}", "URL", "url", "=", "METADATA_TEMPLATE_SCHEMA_URL_TEMPLATE", ".", "build", "(", "api", ".", "getBaseURL", "(", ")", ")", ";", "BoxJSONRequest", "request", "=", "new", "BoxJSONRequest", "(", "api", ",", "url", ",", "\"POST\"", ")", ";", "request", ".", "setBody", "(", "jsonObject", ".", "toString", "(", ")", ")", ";", "BoxJSONResponse", "response", "=", "(", "BoxJSONResponse", ")", "request", ".", "send", "(", ")", ";", "JsonObject", "responseJSON", "=", "JsonObject", ".", "readFrom", "(", "response", ".", "getJSON", "(", ")", ")", ";", "return", "new", "MetadataTemplate", "(", "responseJSON", ")", ";", "}" ]
Creates new metadata template. @param api the API connection to be used. @param scope the scope of the object. @param templateKey a unique identifier for the template. @param displayName the display name of the field. @param hidden whether this template is hidden in the UI. @param fields the ordered set of fields for the template @return the metadata template returned from the server.
[ "Creates", "new", "metadata", "template", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/MetadataTemplate.java#L198-L229
163,572
box/box-java-sdk
src/main/java/com/box/sdk/MetadataTemplate.java
MetadataTemplate.getFieldJsonObject
private static JsonObject getFieldJsonObject(Field field) { JsonObject fieldObj = new JsonObject(); fieldObj.add("type", field.getType()); fieldObj.add("key", field.getKey()); fieldObj.add("displayName", field.getDisplayName()); String fieldDesc = field.getDescription(); if (fieldDesc != null) { fieldObj.add("description", field.getDescription()); } Boolean fieldIsHidden = field.getIsHidden(); if (fieldIsHidden != null) { fieldObj.add("hidden", field.getIsHidden()); } JsonArray array = new JsonArray(); List<String> options = field.getOptions(); if (options != null && !options.isEmpty()) { for (String option : options) { JsonObject optionObj = new JsonObject(); optionObj.add("key", option); array.add(optionObj); } fieldObj.add("options", array); } return fieldObj; }
java
private static JsonObject getFieldJsonObject(Field field) { JsonObject fieldObj = new JsonObject(); fieldObj.add("type", field.getType()); fieldObj.add("key", field.getKey()); fieldObj.add("displayName", field.getDisplayName()); String fieldDesc = field.getDescription(); if (fieldDesc != null) { fieldObj.add("description", field.getDescription()); } Boolean fieldIsHidden = field.getIsHidden(); if (fieldIsHidden != null) { fieldObj.add("hidden", field.getIsHidden()); } JsonArray array = new JsonArray(); List<String> options = field.getOptions(); if (options != null && !options.isEmpty()) { for (String option : options) { JsonObject optionObj = new JsonObject(); optionObj.add("key", option); array.add(optionObj); } fieldObj.add("options", array); } return fieldObj; }
[ "private", "static", "JsonObject", "getFieldJsonObject", "(", "Field", "field", ")", "{", "JsonObject", "fieldObj", "=", "new", "JsonObject", "(", ")", ";", "fieldObj", ".", "add", "(", "\"type\"", ",", "field", ".", "getType", "(", ")", ")", ";", "fieldObj", ".", "add", "(", "\"key\"", ",", "field", ".", "getKey", "(", ")", ")", ";", "fieldObj", ".", "add", "(", "\"displayName\"", ",", "field", ".", "getDisplayName", "(", ")", ")", ";", "String", "fieldDesc", "=", "field", ".", "getDescription", "(", ")", ";", "if", "(", "fieldDesc", "!=", "null", ")", "{", "fieldObj", ".", "add", "(", "\"description\"", ",", "field", ".", "getDescription", "(", ")", ")", ";", "}", "Boolean", "fieldIsHidden", "=", "field", ".", "getIsHidden", "(", ")", ";", "if", "(", "fieldIsHidden", "!=", "null", ")", "{", "fieldObj", ".", "add", "(", "\"hidden\"", ",", "field", ".", "getIsHidden", "(", ")", ")", ";", "}", "JsonArray", "array", "=", "new", "JsonArray", "(", ")", ";", "List", "<", "String", ">", "options", "=", "field", ".", "getOptions", "(", ")", ";", "if", "(", "options", "!=", "null", "&&", "!", "options", ".", "isEmpty", "(", ")", ")", "{", "for", "(", "String", "option", ":", "options", ")", "{", "JsonObject", "optionObj", "=", "new", "JsonObject", "(", ")", ";", "optionObj", ".", "add", "(", "\"key\"", ",", "option", ")", ";", "array", ".", "add", "(", "optionObj", ")", ";", "}", "fieldObj", ".", "add", "(", "\"options\"", ",", "array", ")", ";", "}", "return", "fieldObj", ";", "}" ]
Gets the JsonObject representation of the given field object. @param field represents a template field @return the json object
[ "Gets", "the", "JsonObject", "representation", "of", "the", "given", "field", "object", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/MetadataTemplate.java#L236-L265
163,573
box/box-java-sdk
src/main/java/com/box/sdk/MetadataTemplate.java
MetadataTemplate.updateMetadataTemplate
public static MetadataTemplate updateMetadataTemplate(BoxAPIConnection api, String scope, String template, List<FieldOperation> fieldOperations) { JsonArray array = new JsonArray(); for (FieldOperation fieldOperation : fieldOperations) { JsonObject jsonObject = getFieldOperationJsonObject(fieldOperation); array.add(jsonObject); } QueryStringBuilder builder = new QueryStringBuilder(); URL url = METADATA_TEMPLATE_URL_TEMPLATE.build(api.getBaseURL(), scope, template); BoxJSONRequest request = new BoxJSONRequest(api, url, "PUT"); request.setBody(array.toString()); BoxJSONResponse response = (BoxJSONResponse) request.send(); JsonObject responseJson = JsonObject.readFrom(response.getJSON()); return new MetadataTemplate(responseJson); }
java
public static MetadataTemplate updateMetadataTemplate(BoxAPIConnection api, String scope, String template, List<FieldOperation> fieldOperations) { JsonArray array = new JsonArray(); for (FieldOperation fieldOperation : fieldOperations) { JsonObject jsonObject = getFieldOperationJsonObject(fieldOperation); array.add(jsonObject); } QueryStringBuilder builder = new QueryStringBuilder(); URL url = METADATA_TEMPLATE_URL_TEMPLATE.build(api.getBaseURL(), scope, template); BoxJSONRequest request = new BoxJSONRequest(api, url, "PUT"); request.setBody(array.toString()); BoxJSONResponse response = (BoxJSONResponse) request.send(); JsonObject responseJson = JsonObject.readFrom(response.getJSON()); return new MetadataTemplate(responseJson); }
[ "public", "static", "MetadataTemplate", "updateMetadataTemplate", "(", "BoxAPIConnection", "api", ",", "String", "scope", ",", "String", "template", ",", "List", "<", "FieldOperation", ">", "fieldOperations", ")", "{", "JsonArray", "array", "=", "new", "JsonArray", "(", ")", ";", "for", "(", "FieldOperation", "fieldOperation", ":", "fieldOperations", ")", "{", "JsonObject", "jsonObject", "=", "getFieldOperationJsonObject", "(", "fieldOperation", ")", ";", "array", ".", "add", "(", "jsonObject", ")", ";", "}", "QueryStringBuilder", "builder", "=", "new", "QueryStringBuilder", "(", ")", ";", "URL", "url", "=", "METADATA_TEMPLATE_URL_TEMPLATE", ".", "build", "(", "api", ".", "getBaseURL", "(", ")", ",", "scope", ",", "template", ")", ";", "BoxJSONRequest", "request", "=", "new", "BoxJSONRequest", "(", "api", ",", "url", ",", "\"PUT\"", ")", ";", "request", ".", "setBody", "(", "array", ".", "toString", "(", ")", ")", ";", "BoxJSONResponse", "response", "=", "(", "BoxJSONResponse", ")", "request", ".", "send", "(", ")", ";", "JsonObject", "responseJson", "=", "JsonObject", ".", "readFrom", "(", "response", ".", "getJSON", "(", ")", ")", ";", "return", "new", "MetadataTemplate", "(", "responseJson", ")", ";", "}" ]
Updates the schema of an existing metadata template. @param api the API connection to be used @param scope the scope of the object @param template Unique identifier of the template @param fieldOperations the fields that needs to be updated / added in the template @return the updated metadata template
[ "Updates", "the", "schema", "of", "an", "existing", "metadata", "template", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/MetadataTemplate.java#L276-L295
163,574
box/box-java-sdk
src/main/java/com/box/sdk/MetadataTemplate.java
MetadataTemplate.deleteMetadataTemplate
public static void deleteMetadataTemplate(BoxAPIConnection api, String scope, String template) { URL url = METADATA_TEMPLATE_URL_TEMPLATE.build(api.getBaseURL(), scope, template); BoxJSONRequest request = new BoxJSONRequest(api, url, "DELETE"); request.send(); }
java
public static void deleteMetadataTemplate(BoxAPIConnection api, String scope, String template) { URL url = METADATA_TEMPLATE_URL_TEMPLATE.build(api.getBaseURL(), scope, template); BoxJSONRequest request = new BoxJSONRequest(api, url, "DELETE"); request.send(); }
[ "public", "static", "void", "deleteMetadataTemplate", "(", "BoxAPIConnection", "api", ",", "String", "scope", ",", "String", "template", ")", "{", "URL", "url", "=", "METADATA_TEMPLATE_URL_TEMPLATE", ".", "build", "(", "api", ".", "getBaseURL", "(", ")", ",", "scope", ",", "template", ")", ";", "BoxJSONRequest", "request", "=", "new", "BoxJSONRequest", "(", "api", ",", "url", ",", "\"DELETE\"", ")", ";", "request", ".", "send", "(", ")", ";", "}" ]
Deletes the schema of an existing metadata template. @param api the API connection to be used @param scope the scope of the object @param template Unique identifier of the template
[ "Deletes", "the", "schema", "of", "an", "existing", "metadata", "template", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/MetadataTemplate.java#L304-L310
163,575
box/box-java-sdk
src/main/java/com/box/sdk/MetadataTemplate.java
MetadataTemplate.getFieldOperationJsonObject
private static JsonObject getFieldOperationJsonObject(FieldOperation fieldOperation) { JsonObject jsonObject = new JsonObject(); jsonObject.add("op", fieldOperation.getOp().toString()); String fieldKey = fieldOperation.getFieldKey(); if (fieldKey != null) { jsonObject.add("fieldKey", fieldKey); } Field field = fieldOperation.getData(); if (field != null) { JsonObject fieldObj = new JsonObject(); String type = field.getType(); if (type != null) { fieldObj.add("type", type); } String key = field.getKey(); if (key != null) { fieldObj.add("key", key); } String displayName = field.getDisplayName(); if (displayName != null) { fieldObj.add("displayName", displayName); } String description = field.getDescription(); if (description != null) { fieldObj.add("description", description); } Boolean hidden = field.getIsHidden(); if (hidden != null) { fieldObj.add("hidden", hidden); } List<String> options = field.getOptions(); if (options != null) { JsonArray array = new JsonArray(); for (String option: options) { JsonObject optionObj = new JsonObject(); optionObj.add("key", option); array.add(optionObj); } fieldObj.add("options", array); } jsonObject.add("data", fieldObj); } List<String> fieldKeys = fieldOperation.getFieldKeys(); if (fieldKeys != null) { jsonObject.add("fieldKeys", getJsonArray(fieldKeys)); } List<String> enumOptionKeys = fieldOperation.getEnumOptionKeys(); if (enumOptionKeys != null) { jsonObject.add("enumOptionKeys", getJsonArray(enumOptionKeys)); } String enumOptionKey = fieldOperation.getEnumOptionKey(); if (enumOptionKey != null) { jsonObject.add("enumOptionKey", enumOptionKey); } String multiSelectOptionKey = fieldOperation.getMultiSelectOptionKey(); if (multiSelectOptionKey != null) { jsonObject.add("multiSelectOptionKey", multiSelectOptionKey); } List<String> multiSelectOptionKeys = fieldOperation.getMultiSelectOptionKeys(); if (multiSelectOptionKeys != null) { jsonObject.add("multiSelectOptionKeys", getJsonArray(multiSelectOptionKeys)); } return jsonObject; }
java
private static JsonObject getFieldOperationJsonObject(FieldOperation fieldOperation) { JsonObject jsonObject = new JsonObject(); jsonObject.add("op", fieldOperation.getOp().toString()); String fieldKey = fieldOperation.getFieldKey(); if (fieldKey != null) { jsonObject.add("fieldKey", fieldKey); } Field field = fieldOperation.getData(); if (field != null) { JsonObject fieldObj = new JsonObject(); String type = field.getType(); if (type != null) { fieldObj.add("type", type); } String key = field.getKey(); if (key != null) { fieldObj.add("key", key); } String displayName = field.getDisplayName(); if (displayName != null) { fieldObj.add("displayName", displayName); } String description = field.getDescription(); if (description != null) { fieldObj.add("description", description); } Boolean hidden = field.getIsHidden(); if (hidden != null) { fieldObj.add("hidden", hidden); } List<String> options = field.getOptions(); if (options != null) { JsonArray array = new JsonArray(); for (String option: options) { JsonObject optionObj = new JsonObject(); optionObj.add("key", option); array.add(optionObj); } fieldObj.add("options", array); } jsonObject.add("data", fieldObj); } List<String> fieldKeys = fieldOperation.getFieldKeys(); if (fieldKeys != null) { jsonObject.add("fieldKeys", getJsonArray(fieldKeys)); } List<String> enumOptionKeys = fieldOperation.getEnumOptionKeys(); if (enumOptionKeys != null) { jsonObject.add("enumOptionKeys", getJsonArray(enumOptionKeys)); } String enumOptionKey = fieldOperation.getEnumOptionKey(); if (enumOptionKey != null) { jsonObject.add("enumOptionKey", enumOptionKey); } String multiSelectOptionKey = fieldOperation.getMultiSelectOptionKey(); if (multiSelectOptionKey != null) { jsonObject.add("multiSelectOptionKey", multiSelectOptionKey); } List<String> multiSelectOptionKeys = fieldOperation.getMultiSelectOptionKeys(); if (multiSelectOptionKeys != null) { jsonObject.add("multiSelectOptionKeys", getJsonArray(multiSelectOptionKeys)); } return jsonObject; }
[ "private", "static", "JsonObject", "getFieldOperationJsonObject", "(", "FieldOperation", "fieldOperation", ")", "{", "JsonObject", "jsonObject", "=", "new", "JsonObject", "(", ")", ";", "jsonObject", ".", "add", "(", "\"op\"", ",", "fieldOperation", ".", "getOp", "(", ")", ".", "toString", "(", ")", ")", ";", "String", "fieldKey", "=", "fieldOperation", ".", "getFieldKey", "(", ")", ";", "if", "(", "fieldKey", "!=", "null", ")", "{", "jsonObject", ".", "add", "(", "\"fieldKey\"", ",", "fieldKey", ")", ";", "}", "Field", "field", "=", "fieldOperation", ".", "getData", "(", ")", ";", "if", "(", "field", "!=", "null", ")", "{", "JsonObject", "fieldObj", "=", "new", "JsonObject", "(", ")", ";", "String", "type", "=", "field", ".", "getType", "(", ")", ";", "if", "(", "type", "!=", "null", ")", "{", "fieldObj", ".", "add", "(", "\"type\"", ",", "type", ")", ";", "}", "String", "key", "=", "field", ".", "getKey", "(", ")", ";", "if", "(", "key", "!=", "null", ")", "{", "fieldObj", ".", "add", "(", "\"key\"", ",", "key", ")", ";", "}", "String", "displayName", "=", "field", ".", "getDisplayName", "(", ")", ";", "if", "(", "displayName", "!=", "null", ")", "{", "fieldObj", ".", "add", "(", "\"displayName\"", ",", "displayName", ")", ";", "}", "String", "description", "=", "field", ".", "getDescription", "(", ")", ";", "if", "(", "description", "!=", "null", ")", "{", "fieldObj", ".", "add", "(", "\"description\"", ",", "description", ")", ";", "}", "Boolean", "hidden", "=", "field", ".", "getIsHidden", "(", ")", ";", "if", "(", "hidden", "!=", "null", ")", "{", "fieldObj", ".", "add", "(", "\"hidden\"", ",", "hidden", ")", ";", "}", "List", "<", "String", ">", "options", "=", "field", ".", "getOptions", "(", ")", ";", "if", "(", "options", "!=", "null", ")", "{", "JsonArray", "array", "=", "new", "JsonArray", "(", ")", ";", "for", "(", "String", "option", ":", "options", ")", "{", "JsonObject", "optionObj", "=", "new", "JsonObject", "(", ")", ";", "optionObj", ".", "add", "(", "\"key\"", ",", "option", ")", ";", "array", ".", "add", "(", "optionObj", ")", ";", "}", "fieldObj", ".", "add", "(", "\"options\"", ",", "array", ")", ";", "}", "jsonObject", ".", "add", "(", "\"data\"", ",", "fieldObj", ")", ";", "}", "List", "<", "String", ">", "fieldKeys", "=", "fieldOperation", ".", "getFieldKeys", "(", ")", ";", "if", "(", "fieldKeys", "!=", "null", ")", "{", "jsonObject", ".", "add", "(", "\"fieldKeys\"", ",", "getJsonArray", "(", "fieldKeys", ")", ")", ";", "}", "List", "<", "String", ">", "enumOptionKeys", "=", "fieldOperation", ".", "getEnumOptionKeys", "(", ")", ";", "if", "(", "enumOptionKeys", "!=", "null", ")", "{", "jsonObject", ".", "add", "(", "\"enumOptionKeys\"", ",", "getJsonArray", "(", "enumOptionKeys", ")", ")", ";", "}", "String", "enumOptionKey", "=", "fieldOperation", ".", "getEnumOptionKey", "(", ")", ";", "if", "(", "enumOptionKey", "!=", "null", ")", "{", "jsonObject", ".", "add", "(", "\"enumOptionKey\"", ",", "enumOptionKey", ")", ";", "}", "String", "multiSelectOptionKey", "=", "fieldOperation", ".", "getMultiSelectOptionKey", "(", ")", ";", "if", "(", "multiSelectOptionKey", "!=", "null", ")", "{", "jsonObject", ".", "add", "(", "\"multiSelectOptionKey\"", ",", "multiSelectOptionKey", ")", ";", "}", "List", "<", "String", ">", "multiSelectOptionKeys", "=", "fieldOperation", ".", "getMultiSelectOptionKeys", "(", ")", ";", "if", "(", "multiSelectOptionKeys", "!=", "null", ")", "{", "jsonObject", ".", "add", "(", "\"multiSelectOptionKeys\"", ",", "getJsonArray", "(", "multiSelectOptionKeys", ")", ")", ";", "}", "return", "jsonObject", ";", "}" ]
Gets the JsonObject representation of the Field Operation. @param fieldOperation represents the template update operation @return the json object
[ "Gets", "the", "JsonObject", "representation", "of", "the", "Field", "Operation", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/MetadataTemplate.java#L317-L397
163,576
box/box-java-sdk
src/main/java/com/box/sdk/MetadataTemplate.java
MetadataTemplate.getJsonArray
private static JsonArray getJsonArray(List<String> keys) { JsonArray array = new JsonArray(); for (String key : keys) { array.add(key); } return array; }
java
private static JsonArray getJsonArray(List<String> keys) { JsonArray array = new JsonArray(); for (String key : keys) { array.add(key); } return array; }
[ "private", "static", "JsonArray", "getJsonArray", "(", "List", "<", "String", ">", "keys", ")", "{", "JsonArray", "array", "=", "new", "JsonArray", "(", ")", ";", "for", "(", "String", "key", ":", "keys", ")", "{", "array", ".", "add", "(", "key", ")", ";", "}", "return", "array", ";", "}" ]
Gets the Json Array representation of the given list of strings. @param keys List of strings @return the JsonArray represents the list of keys
[ "Gets", "the", "Json", "Array", "representation", "of", "the", "given", "list", "of", "strings", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/MetadataTemplate.java#L404-L411
163,577
box/box-java-sdk
src/main/java/com/box/sdk/MetadataTemplate.java
MetadataTemplate.getMetadataTemplateByID
public static MetadataTemplate getMetadataTemplateByID(BoxAPIConnection api, String templateID) { URL url = METADATA_TEMPLATE_BY_ID_URL_TEMPLATE.build(api.getBaseURL(), templateID); BoxAPIRequest request = new BoxAPIRequest(api, url, "GET"); BoxJSONResponse response = (BoxJSONResponse) request.send(); return new MetadataTemplate(response.getJSON()); }
java
public static MetadataTemplate getMetadataTemplateByID(BoxAPIConnection api, String templateID) { URL url = METADATA_TEMPLATE_BY_ID_URL_TEMPLATE.build(api.getBaseURL(), templateID); BoxAPIRequest request = new BoxAPIRequest(api, url, "GET"); BoxJSONResponse response = (BoxJSONResponse) request.send(); return new MetadataTemplate(response.getJSON()); }
[ "public", "static", "MetadataTemplate", "getMetadataTemplateByID", "(", "BoxAPIConnection", "api", ",", "String", "templateID", ")", "{", "URL", "url", "=", "METADATA_TEMPLATE_BY_ID_URL_TEMPLATE", ".", "build", "(", "api", ".", "getBaseURL", "(", ")", ",", "templateID", ")", ";", "BoxAPIRequest", "request", "=", "new", "BoxAPIRequest", "(", "api", ",", "url", ",", "\"GET\"", ")", ";", "BoxJSONResponse", "response", "=", "(", "BoxJSONResponse", ")", "request", ".", "send", "(", ")", ";", "return", "new", "MetadataTemplate", "(", "response", ".", "getJSON", "(", ")", ")", ";", "}" ]
Geta the specified metadata template by its ID. @param api the API connection to be used. @param templateID the ID of the template to get. @return the metadata template object.
[ "Geta", "the", "specified", "metadata", "template", "by", "its", "ID", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/MetadataTemplate.java#L460-L466
163,578
box/box-java-sdk
src/main/java/com/box/sdk/BoxSearchParameters.java
BoxSearchParameters.clearParameters
public boolean clearParameters() { this.query = null; this.fields = null; this.scope = null; this.fileExtensions = null; this.createdRange = null; this.updatedRange = null; this.sizeRange = null; this.ownerUserIds = null; this.ancestorFolderIds = null; this.contentTypes = null; this.type = null; this.trashContent = null; this.metadataFilter = null; this.sort = null; this.direction = null; return true; }
java
public boolean clearParameters() { this.query = null; this.fields = null; this.scope = null; this.fileExtensions = null; this.createdRange = null; this.updatedRange = null; this.sizeRange = null; this.ownerUserIds = null; this.ancestorFolderIds = null; this.contentTypes = null; this.type = null; this.trashContent = null; this.metadataFilter = null; this.sort = null; this.direction = null; return true; }
[ "public", "boolean", "clearParameters", "(", ")", "{", "this", ".", "query", "=", "null", ";", "this", ".", "fields", "=", "null", ";", "this", ".", "scope", "=", "null", ";", "this", ".", "fileExtensions", "=", "null", ";", "this", ".", "createdRange", "=", "null", ";", "this", ".", "updatedRange", "=", "null", ";", "this", ".", "sizeRange", "=", "null", ";", "this", ".", "ownerUserIds", "=", "null", ";", "this", ".", "ancestorFolderIds", "=", "null", ";", "this", ".", "contentTypes", "=", "null", ";", "this", ".", "type", "=", "null", ";", "this", ".", "trashContent", "=", "null", ";", "this", ".", "metadataFilter", "=", "null", ";", "this", ".", "sort", "=", "null", ";", "this", ".", "direction", "=", "null", ";", "return", "true", ";", "}" ]
Clears the Parameters before performing a new search. @return this.true;
[ "Clears", "the", "Parameters", "before", "performing", "a", "new", "search", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxSearchParameters.java#L47-L64
163,579
box/box-java-sdk
src/main/java/com/box/sdk/BoxSearchParameters.java
BoxSearchParameters.isNullOrEmpty
private boolean isNullOrEmpty(Object paramValue) { boolean isNullOrEmpty = false; if (paramValue == null) { isNullOrEmpty = true; } if (paramValue instanceof String) { if (((String) paramValue).trim().equalsIgnoreCase("")) { isNullOrEmpty = true; } } else if (paramValue instanceof List) { return ((List) paramValue).isEmpty(); } return isNullOrEmpty; }
java
private boolean isNullOrEmpty(Object paramValue) { boolean isNullOrEmpty = false; if (paramValue == null) { isNullOrEmpty = true; } if (paramValue instanceof String) { if (((String) paramValue).trim().equalsIgnoreCase("")) { isNullOrEmpty = true; } } else if (paramValue instanceof List) { return ((List) paramValue).isEmpty(); } return isNullOrEmpty; }
[ "private", "boolean", "isNullOrEmpty", "(", "Object", "paramValue", ")", "{", "boolean", "isNullOrEmpty", "=", "false", ";", "if", "(", "paramValue", "==", "null", ")", "{", "isNullOrEmpty", "=", "true", ";", "}", "if", "(", "paramValue", "instanceof", "String", ")", "{", "if", "(", "(", "(", "String", ")", "paramValue", ")", ".", "trim", "(", ")", ".", "equalsIgnoreCase", "(", "\"\"", ")", ")", "{", "isNullOrEmpty", "=", "true", ";", "}", "}", "else", "if", "(", "paramValue", "instanceof", "List", ")", "{", "return", "(", "(", "List", ")", "paramValue", ")", ".", "isEmpty", "(", ")", ";", "}", "return", "isNullOrEmpty", ";", "}" ]
Checks String to see if the parameter is null. @param paramValue Object that will be checked if null. @return this.true if the parameter that is being checked is not null
[ "Checks", "String", "to", "see", "if", "the", "parameter", "is", "null", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxSearchParameters.java#L285-L298
163,580
box/box-java-sdk
src/main/java/com/box/sdk/BoxSearchParameters.java
BoxSearchParameters.formatBoxMetadataFilterRequest
private JsonArray formatBoxMetadataFilterRequest() { JsonArray boxMetadataFilterRequestArray = new JsonArray(); JsonObject boxMetadataFilter = new JsonObject() .add("templateKey", this.metadataFilter.getTemplateKey()) .add("scope", this.metadataFilter.getScope()) .add("filters", this.metadataFilter.getFiltersList()); boxMetadataFilterRequestArray.add(boxMetadataFilter); return boxMetadataFilterRequestArray; }
java
private JsonArray formatBoxMetadataFilterRequest() { JsonArray boxMetadataFilterRequestArray = new JsonArray(); JsonObject boxMetadataFilter = new JsonObject() .add("templateKey", this.metadataFilter.getTemplateKey()) .add("scope", this.metadataFilter.getScope()) .add("filters", this.metadataFilter.getFiltersList()); boxMetadataFilterRequestArray.add(boxMetadataFilter); return boxMetadataFilterRequestArray; }
[ "private", "JsonArray", "formatBoxMetadataFilterRequest", "(", ")", "{", "JsonArray", "boxMetadataFilterRequestArray", "=", "new", "JsonArray", "(", ")", ";", "JsonObject", "boxMetadataFilter", "=", "new", "JsonObject", "(", ")", ".", "add", "(", "\"templateKey\"", ",", "this", ".", "metadataFilter", ".", "getTemplateKey", "(", ")", ")", ".", "add", "(", "\"scope\"", ",", "this", ".", "metadataFilter", ".", "getScope", "(", ")", ")", ".", "add", "(", "\"filters\"", ",", "this", ".", "metadataFilter", ".", "getFiltersList", "(", ")", ")", ";", "boxMetadataFilterRequestArray", ".", "add", "(", "boxMetadataFilter", ")", ";", "return", "boxMetadataFilterRequestArray", ";", "}" ]
Add BoxMetaDataFilter to the JsonArray boxMetadataFilterRequestArray. @param @param bmf accepts a filter that has templateKey, scope, and filters populated. @return JsonArray that is formated Json request
[ "Add", "BoxMetaDataFilter", "to", "the", "JsonArray", "boxMetadataFilterRequestArray", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxSearchParameters.java#L304-L314
163,581
box/box-java-sdk
src/main/java/com/box/sdk/BoxSearchParameters.java
BoxSearchParameters.listToCSV
private String listToCSV(List<String> list) { String csvStr = ""; for (String item : list) { csvStr += "," + item; } return csvStr.length() > 1 ? csvStr.substring(1) : csvStr; }
java
private String listToCSV(List<String> list) { String csvStr = ""; for (String item : list) { csvStr += "," + item; } return csvStr.length() > 1 ? csvStr.substring(1) : csvStr; }
[ "private", "String", "listToCSV", "(", "List", "<", "String", ">", "list", ")", "{", "String", "csvStr", "=", "\"\"", ";", "for", "(", "String", "item", ":", "list", ")", "{", "csvStr", "+=", "\",\"", "+", "item", ";", "}", "return", "csvStr", ".", "length", "(", ")", ">", "1", "?", "csvStr", ".", "substring", "(", "1", ")", ":", "csvStr", ";", "}" ]
Concat a List into a CSV String. @param list list to concat @return csv string
[ "Concat", "a", "List", "into", "a", "CSV", "String", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxSearchParameters.java#L321-L328
163,582
box/box-java-sdk
src/main/java/com/box/sdk/BoxSearchParameters.java
BoxSearchParameters.getQueryParameters
public QueryStringBuilder getQueryParameters() { QueryStringBuilder builder = new QueryStringBuilder(); if (this.isNullOrEmpty(this.query) && this.metadataFilter == null) { throw new BoxAPIException( "BoxSearchParameters requires either a search query or Metadata filter to be set." ); } //Set the query of the search if (!this.isNullOrEmpty(this.query)) { builder.appendParam("query", this.query); } //Set the scope of the search if (!this.isNullOrEmpty(this.scope)) { builder.appendParam("scope", this.scope); } //Acceptable Value: "jpg,png" if (!this.isNullOrEmpty(this.fileExtensions)) { builder.appendParam("file_extensions", this.listToCSV(this.fileExtensions)); } //Created Date Range: From Date - To Date if ((this.createdRange != null)) { builder.appendParam("created_at_range", this.createdRange.buildRangeString()); } //Updated Date Range: From Date - To Date if ((this.updatedRange != null)) { builder.appendParam("updated_at_range", this.updatedRange.buildRangeString()); } //Filesize Range if ((this.sizeRange != null)) { builder.appendParam("size_range", this.sizeRange.buildRangeString()); } //Owner Id's if (!this.isNullOrEmpty(this.ownerUserIds)) { builder.appendParam("owner_user_ids", this.listToCSV(this.ownerUserIds)); } //Ancestor ID's if (!this.isNullOrEmpty(this.ancestorFolderIds)) { builder.appendParam("ancestor_folder_ids", this.listToCSV(this.ancestorFolderIds)); } //Content Types: "name, description" if (!this.isNullOrEmpty(this.contentTypes)) { builder.appendParam("content_types", this.listToCSV(this.contentTypes)); } //Type of File: "file,folder,web_link" if (this.type != null) { builder.appendParam("type", this.type); } //Trash Content if (!this.isNullOrEmpty(this.trashContent)) { builder.appendParam("trash_content", this.trashContent); } //Metadata filters if (this.metadataFilter != null) { builder.appendParam("mdfilters", this.formatBoxMetadataFilterRequest().toString()); } //Fields if (!this.isNullOrEmpty(this.fields)) { builder.appendParam("fields", this.listToCSV(this.fields)); } //Sort if (!this.isNullOrEmpty(this.sort)) { builder.appendParam("sort", this.sort); } //Direction if (!this.isNullOrEmpty(this.direction)) { builder.appendParam("direction", this.direction); } return builder; }
java
public QueryStringBuilder getQueryParameters() { QueryStringBuilder builder = new QueryStringBuilder(); if (this.isNullOrEmpty(this.query) && this.metadataFilter == null) { throw new BoxAPIException( "BoxSearchParameters requires either a search query or Metadata filter to be set." ); } //Set the query of the search if (!this.isNullOrEmpty(this.query)) { builder.appendParam("query", this.query); } //Set the scope of the search if (!this.isNullOrEmpty(this.scope)) { builder.appendParam("scope", this.scope); } //Acceptable Value: "jpg,png" if (!this.isNullOrEmpty(this.fileExtensions)) { builder.appendParam("file_extensions", this.listToCSV(this.fileExtensions)); } //Created Date Range: From Date - To Date if ((this.createdRange != null)) { builder.appendParam("created_at_range", this.createdRange.buildRangeString()); } //Updated Date Range: From Date - To Date if ((this.updatedRange != null)) { builder.appendParam("updated_at_range", this.updatedRange.buildRangeString()); } //Filesize Range if ((this.sizeRange != null)) { builder.appendParam("size_range", this.sizeRange.buildRangeString()); } //Owner Id's if (!this.isNullOrEmpty(this.ownerUserIds)) { builder.appendParam("owner_user_ids", this.listToCSV(this.ownerUserIds)); } //Ancestor ID's if (!this.isNullOrEmpty(this.ancestorFolderIds)) { builder.appendParam("ancestor_folder_ids", this.listToCSV(this.ancestorFolderIds)); } //Content Types: "name, description" if (!this.isNullOrEmpty(this.contentTypes)) { builder.appendParam("content_types", this.listToCSV(this.contentTypes)); } //Type of File: "file,folder,web_link" if (this.type != null) { builder.appendParam("type", this.type); } //Trash Content if (!this.isNullOrEmpty(this.trashContent)) { builder.appendParam("trash_content", this.trashContent); } //Metadata filters if (this.metadataFilter != null) { builder.appendParam("mdfilters", this.formatBoxMetadataFilterRequest().toString()); } //Fields if (!this.isNullOrEmpty(this.fields)) { builder.appendParam("fields", this.listToCSV(this.fields)); } //Sort if (!this.isNullOrEmpty(this.sort)) { builder.appendParam("sort", this.sort); } //Direction if (!this.isNullOrEmpty(this.direction)) { builder.appendParam("direction", this.direction); } return builder; }
[ "public", "QueryStringBuilder", "getQueryParameters", "(", ")", "{", "QueryStringBuilder", "builder", "=", "new", "QueryStringBuilder", "(", ")", ";", "if", "(", "this", ".", "isNullOrEmpty", "(", "this", ".", "query", ")", "&&", "this", ".", "metadataFilter", "==", "null", ")", "{", "throw", "new", "BoxAPIException", "(", "\"BoxSearchParameters requires either a search query or Metadata filter to be set.\"", ")", ";", "}", "//Set the query of the search", "if", "(", "!", "this", ".", "isNullOrEmpty", "(", "this", ".", "query", ")", ")", "{", "builder", ".", "appendParam", "(", "\"query\"", ",", "this", ".", "query", ")", ";", "}", "//Set the scope of the search", "if", "(", "!", "this", ".", "isNullOrEmpty", "(", "this", ".", "scope", ")", ")", "{", "builder", ".", "appendParam", "(", "\"scope\"", ",", "this", ".", "scope", ")", ";", "}", "//Acceptable Value: \"jpg,png\"", "if", "(", "!", "this", ".", "isNullOrEmpty", "(", "this", ".", "fileExtensions", ")", ")", "{", "builder", ".", "appendParam", "(", "\"file_extensions\"", ",", "this", ".", "listToCSV", "(", "this", ".", "fileExtensions", ")", ")", ";", "}", "//Created Date Range: From Date - To Date", "if", "(", "(", "this", ".", "createdRange", "!=", "null", ")", ")", "{", "builder", ".", "appendParam", "(", "\"created_at_range\"", ",", "this", ".", "createdRange", ".", "buildRangeString", "(", ")", ")", ";", "}", "//Updated Date Range: From Date - To Date", "if", "(", "(", "this", ".", "updatedRange", "!=", "null", ")", ")", "{", "builder", ".", "appendParam", "(", "\"updated_at_range\"", ",", "this", ".", "updatedRange", ".", "buildRangeString", "(", ")", ")", ";", "}", "//Filesize Range", "if", "(", "(", "this", ".", "sizeRange", "!=", "null", ")", ")", "{", "builder", ".", "appendParam", "(", "\"size_range\"", ",", "this", ".", "sizeRange", ".", "buildRangeString", "(", ")", ")", ";", "}", "//Owner Id's", "if", "(", "!", "this", ".", "isNullOrEmpty", "(", "this", ".", "ownerUserIds", ")", ")", "{", "builder", ".", "appendParam", "(", "\"owner_user_ids\"", ",", "this", ".", "listToCSV", "(", "this", ".", "ownerUserIds", ")", ")", ";", "}", "//Ancestor ID's", "if", "(", "!", "this", ".", "isNullOrEmpty", "(", "this", ".", "ancestorFolderIds", ")", ")", "{", "builder", ".", "appendParam", "(", "\"ancestor_folder_ids\"", ",", "this", ".", "listToCSV", "(", "this", ".", "ancestorFolderIds", ")", ")", ";", "}", "//Content Types: \"name, description\"", "if", "(", "!", "this", ".", "isNullOrEmpty", "(", "this", ".", "contentTypes", ")", ")", "{", "builder", ".", "appendParam", "(", "\"content_types\"", ",", "this", ".", "listToCSV", "(", "this", ".", "contentTypes", ")", ")", ";", "}", "//Type of File: \"file,folder,web_link\"", "if", "(", "this", ".", "type", "!=", "null", ")", "{", "builder", ".", "appendParam", "(", "\"type\"", ",", "this", ".", "type", ")", ";", "}", "//Trash Content", "if", "(", "!", "this", ".", "isNullOrEmpty", "(", "this", ".", "trashContent", ")", ")", "{", "builder", ".", "appendParam", "(", "\"trash_content\"", ",", "this", ".", "trashContent", ")", ";", "}", "//Metadata filters", "if", "(", "this", ".", "metadataFilter", "!=", "null", ")", "{", "builder", ".", "appendParam", "(", "\"mdfilters\"", ",", "this", ".", "formatBoxMetadataFilterRequest", "(", ")", ".", "toString", "(", ")", ")", ";", "}", "//Fields", "if", "(", "!", "this", ".", "isNullOrEmpty", "(", "this", ".", "fields", ")", ")", "{", "builder", ".", "appendParam", "(", "\"fields\"", ",", "this", ".", "listToCSV", "(", "this", ".", "fields", ")", ")", ";", "}", "//Sort", "if", "(", "!", "this", ".", "isNullOrEmpty", "(", "this", ".", "sort", ")", ")", "{", "builder", ".", "appendParam", "(", "\"sort\"", ",", "this", ".", "sort", ")", ";", "}", "//Direction", "if", "(", "!", "this", ".", "isNullOrEmpty", "(", "this", ".", "direction", ")", ")", "{", "builder", ".", "appendParam", "(", "\"direction\"", ",", "this", ".", "direction", ")", ";", "}", "return", "builder", ";", "}" ]
Get the Query Paramaters to be used for search request. @return this.QueryStringBuilder.
[ "Get", "the", "Query", "Paramaters", "to", "be", "used", "for", "search", "request", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxSearchParameters.java#L333-L403
163,583
box/box-java-sdk
src/main/java/com/box/sdk/MetadataFieldFilter.java
MetadataFieldFilter.getJsonObject
public JsonObject getJsonObject() { JsonObject obj = new JsonObject(); obj.add("field", this.field); obj.add("value", this.value); return obj; }
java
public JsonObject getJsonObject() { JsonObject obj = new JsonObject(); obj.add("field", this.field); obj.add("value", this.value); return obj; }
[ "public", "JsonObject", "getJsonObject", "(", ")", "{", "JsonObject", "obj", "=", "new", "JsonObject", "(", ")", ";", "obj", ".", "add", "(", "\"field\"", ",", "this", ".", "field", ")", ";", "obj", ".", "add", "(", "\"value\"", ",", "this", ".", "value", ")", ";", "return", "obj", ";", "}" ]
Get the JSON representation of the metadata field filter. @return the JSON object representing the filter.
[ "Get", "the", "JSON", "representation", "of", "the", "metadata", "field", "filter", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/MetadataFieldFilter.java#L40-L48
163,584
box/box-java-sdk
src/main/java/com/box/sdk/BoxAPIConnection.java
BoxAPIConnection.restore
public static BoxAPIConnection restore(String clientID, String clientSecret, String state) { BoxAPIConnection api = new BoxAPIConnection(clientID, clientSecret); api.restore(state); return api; }
java
public static BoxAPIConnection restore(String clientID, String clientSecret, String state) { BoxAPIConnection api = new BoxAPIConnection(clientID, clientSecret); api.restore(state); return api; }
[ "public", "static", "BoxAPIConnection", "restore", "(", "String", "clientID", ",", "String", "clientSecret", ",", "String", "state", ")", "{", "BoxAPIConnection", "api", "=", "new", "BoxAPIConnection", "(", "clientID", ",", "clientSecret", ")", ";", "api", ".", "restore", "(", "state", ")", ";", "return", "api", ";", "}" ]
Restores a BoxAPIConnection from a saved state. @see #save @param clientID the client ID to use with the connection. @param clientSecret the client secret to use with the connection. @param state the saved state that was created with {@link #save}. @return a restored API connection.
[ "Restores", "a", "BoxAPIConnection", "from", "a", "saved", "state", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxAPIConnection.java#L146-L150
163,585
box/box-java-sdk
src/main/java/com/box/sdk/BoxAPIConnection.java
BoxAPIConnection.getAuthorizationURL
public static URL getAuthorizationURL(String clientID, URI redirectUri, String state, List<String> scopes) { URLTemplate template = new URLTemplate(AUTHORIZATION_URL); QueryStringBuilder queryBuilder = new QueryStringBuilder().appendParam("client_id", clientID) .appendParam("response_type", "code") .appendParam("redirect_uri", redirectUri.toString()) .appendParam("state", state); if (scopes != null && !scopes.isEmpty()) { StringBuilder builder = new StringBuilder(); int size = scopes.size() - 1; int i = 0; while (i < size) { builder.append(scopes.get(i)); builder.append(" "); i++; } builder.append(scopes.get(i)); queryBuilder.appendParam("scope", builder.toString()); } return template.buildWithQuery("", queryBuilder.toString()); }
java
public static URL getAuthorizationURL(String clientID, URI redirectUri, String state, List<String> scopes) { URLTemplate template = new URLTemplate(AUTHORIZATION_URL); QueryStringBuilder queryBuilder = new QueryStringBuilder().appendParam("client_id", clientID) .appendParam("response_type", "code") .appendParam("redirect_uri", redirectUri.toString()) .appendParam("state", state); if (scopes != null && !scopes.isEmpty()) { StringBuilder builder = new StringBuilder(); int size = scopes.size() - 1; int i = 0; while (i < size) { builder.append(scopes.get(i)); builder.append(" "); i++; } builder.append(scopes.get(i)); queryBuilder.appendParam("scope", builder.toString()); } return template.buildWithQuery("", queryBuilder.toString()); }
[ "public", "static", "URL", "getAuthorizationURL", "(", "String", "clientID", ",", "URI", "redirectUri", ",", "String", "state", ",", "List", "<", "String", ">", "scopes", ")", "{", "URLTemplate", "template", "=", "new", "URLTemplate", "(", "AUTHORIZATION_URL", ")", ";", "QueryStringBuilder", "queryBuilder", "=", "new", "QueryStringBuilder", "(", ")", ".", "appendParam", "(", "\"client_id\"", ",", "clientID", ")", ".", "appendParam", "(", "\"response_type\"", ",", "\"code\"", ")", ".", "appendParam", "(", "\"redirect_uri\"", ",", "redirectUri", ".", "toString", "(", ")", ")", ".", "appendParam", "(", "\"state\"", ",", "state", ")", ";", "if", "(", "scopes", "!=", "null", "&&", "!", "scopes", ".", "isEmpty", "(", ")", ")", "{", "StringBuilder", "builder", "=", "new", "StringBuilder", "(", ")", ";", "int", "size", "=", "scopes", ".", "size", "(", ")", "-", "1", ";", "int", "i", "=", "0", ";", "while", "(", "i", "<", "size", ")", "{", "builder", ".", "append", "(", "scopes", ".", "get", "(", "i", ")", ")", ";", "builder", ".", "append", "(", "\" \"", ")", ";", "i", "++", ";", "}", "builder", ".", "append", "(", "scopes", ".", "get", "(", "i", ")", ")", ";", "queryBuilder", ".", "appendParam", "(", "\"scope\"", ",", "builder", ".", "toString", "(", ")", ")", ";", "}", "return", "template", ".", "buildWithQuery", "(", "\"\"", ",", "queryBuilder", ".", "toString", "(", ")", ")", ";", "}" ]
Return the authorization URL which is used to perform the authorization_code based OAuth2 flow. @param clientID the client ID to use with the connection. @param redirectUri the URL to which Box redirects the browser when authentication completes. @param state the text string that you choose. Box sends the same string to your redirect URL when authentication is complete. @param scopes this optional parameter identifies the Box scopes available to the application once it's authenticated. @return the authorization URL
[ "Return", "the", "authorization", "URL", "which", "is", "used", "to", "perform", "the", "authorization_code", "based", "OAuth2", "flow", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxAPIConnection.java#L162-L184
163,586
box/box-java-sdk
src/main/java/com/box/sdk/BoxAPIConnection.java
BoxAPIConnection.authenticate
public void authenticate(String authCode) { URL url = null; try { url = new URL(this.tokenURL); } catch (MalformedURLException e) { assert false : "An invalid token URL indicates a bug in the SDK."; throw new RuntimeException("An invalid token URL indicates a bug in the SDK.", e); } String urlParameters = String.format("grant_type=authorization_code&code=%s&client_id=%s&client_secret=%s", authCode, this.clientID, this.clientSecret); BoxAPIRequest request = new BoxAPIRequest(this, url, "POST"); request.shouldAuthenticate(false); request.setBody(urlParameters); BoxJSONResponse response = (BoxJSONResponse) request.send(); String json = response.getJSON(); JsonObject jsonObject = JsonObject.readFrom(json); this.accessToken = jsonObject.get("access_token").asString(); this.refreshToken = jsonObject.get("refresh_token").asString(); this.lastRefresh = System.currentTimeMillis(); this.expires = jsonObject.get("expires_in").asLong() * 1000; }
java
public void authenticate(String authCode) { URL url = null; try { url = new URL(this.tokenURL); } catch (MalformedURLException e) { assert false : "An invalid token URL indicates a bug in the SDK."; throw new RuntimeException("An invalid token URL indicates a bug in the SDK.", e); } String urlParameters = String.format("grant_type=authorization_code&code=%s&client_id=%s&client_secret=%s", authCode, this.clientID, this.clientSecret); BoxAPIRequest request = new BoxAPIRequest(this, url, "POST"); request.shouldAuthenticate(false); request.setBody(urlParameters); BoxJSONResponse response = (BoxJSONResponse) request.send(); String json = response.getJSON(); JsonObject jsonObject = JsonObject.readFrom(json); this.accessToken = jsonObject.get("access_token").asString(); this.refreshToken = jsonObject.get("refresh_token").asString(); this.lastRefresh = System.currentTimeMillis(); this.expires = jsonObject.get("expires_in").asLong() * 1000; }
[ "public", "void", "authenticate", "(", "String", "authCode", ")", "{", "URL", "url", "=", "null", ";", "try", "{", "url", "=", "new", "URL", "(", "this", ".", "tokenURL", ")", ";", "}", "catch", "(", "MalformedURLException", "e", ")", "{", "assert", "false", ":", "\"An invalid token URL indicates a bug in the SDK.\"", ";", "throw", "new", "RuntimeException", "(", "\"An invalid token URL indicates a bug in the SDK.\"", ",", "e", ")", ";", "}", "String", "urlParameters", "=", "String", ".", "format", "(", "\"grant_type=authorization_code&code=%s&client_id=%s&client_secret=%s\"", ",", "authCode", ",", "this", ".", "clientID", ",", "this", ".", "clientSecret", ")", ";", "BoxAPIRequest", "request", "=", "new", "BoxAPIRequest", "(", "this", ",", "url", ",", "\"POST\"", ")", ";", "request", ".", "shouldAuthenticate", "(", "false", ")", ";", "request", ".", "setBody", "(", "urlParameters", ")", ";", "BoxJSONResponse", "response", "=", "(", "BoxJSONResponse", ")", "request", ".", "send", "(", ")", ";", "String", "json", "=", "response", ".", "getJSON", "(", ")", ";", "JsonObject", "jsonObject", "=", "JsonObject", ".", "readFrom", "(", "json", ")", ";", "this", ".", "accessToken", "=", "jsonObject", ".", "get", "(", "\"access_token\"", ")", ".", "asString", "(", ")", ";", "this", ".", "refreshToken", "=", "jsonObject", ".", "get", "(", "\"refresh_token\"", ")", ".", "asString", "(", ")", ";", "this", ".", "lastRefresh", "=", "System", ".", "currentTimeMillis", "(", ")", ";", "this", ".", "expires", "=", "jsonObject", ".", "get", "(", "\"expires_in\"", ")", ".", "asLong", "(", ")", "*", "1000", ";", "}" ]
Authenticates the API connection by obtaining access and refresh tokens using the auth code that was obtained from the first half of OAuth. @param authCode the auth code obtained from the first half of the OAuth process.
[ "Authenticates", "the", "API", "connection", "by", "obtaining", "access", "and", "refresh", "tokens", "using", "the", "auth", "code", "that", "was", "obtained", "from", "the", "first", "half", "of", "OAuth", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxAPIConnection.java#L191-L215
163,587
box/box-java-sdk
src/main/java/com/box/sdk/BoxAPIConnection.java
BoxAPIConnection.needsRefresh
public boolean needsRefresh() { boolean needsRefresh; this.refreshLock.readLock().lock(); long now = System.currentTimeMillis(); long tokenDuration = (now - this.lastRefresh); needsRefresh = (tokenDuration >= this.expires - REFRESH_EPSILON); this.refreshLock.readLock().unlock(); return needsRefresh; }
java
public boolean needsRefresh() { boolean needsRefresh; this.refreshLock.readLock().lock(); long now = System.currentTimeMillis(); long tokenDuration = (now - this.lastRefresh); needsRefresh = (tokenDuration >= this.expires - REFRESH_EPSILON); this.refreshLock.readLock().unlock(); return needsRefresh; }
[ "public", "boolean", "needsRefresh", "(", ")", "{", "boolean", "needsRefresh", ";", "this", ".", "refreshLock", ".", "readLock", "(", ")", ".", "lock", "(", ")", ";", "long", "now", "=", "System", ".", "currentTimeMillis", "(", ")", ";", "long", "tokenDuration", "=", "(", "now", "-", "this", ".", "lastRefresh", ")", ";", "needsRefresh", "=", "(", "tokenDuration", ">=", "this", ".", "expires", "-", "REFRESH_EPSILON", ")", ";", "this", ".", "refreshLock", ".", "readLock", "(", ")", ".", "unlock", "(", ")", ";", "return", "needsRefresh", ";", "}" ]
Determines if this connection's access token has expired and needs to be refreshed. @return true if the access token needs to be refreshed; otherwise false.
[ "Determines", "if", "this", "connection", "s", "access", "token", "has", "expired", "and", "needs", "to", "be", "refreshed", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxAPIConnection.java#L530-L540
163,588
box/box-java-sdk
src/main/java/com/box/sdk/BoxAPIConnection.java
BoxAPIConnection.refresh
public void refresh() { this.refreshLock.writeLock().lock(); if (!this.canRefresh()) { this.refreshLock.writeLock().unlock(); throw new IllegalStateException("The BoxAPIConnection cannot be refreshed because it doesn't have a " + "refresh token."); } URL url = null; try { url = new URL(this.tokenURL); } catch (MalformedURLException e) { this.refreshLock.writeLock().unlock(); assert false : "An invalid refresh URL indicates a bug in the SDK."; throw new RuntimeException("An invalid refresh URL indicates a bug in the SDK.", e); } String urlParameters = String.format("grant_type=refresh_token&refresh_token=%s&client_id=%s&client_secret=%s", this.refreshToken, this.clientID, this.clientSecret); BoxAPIRequest request = new BoxAPIRequest(this, url, "POST"); request.shouldAuthenticate(false); request.setBody(urlParameters); String json; try { BoxJSONResponse response = (BoxJSONResponse) request.send(); json = response.getJSON(); } catch (BoxAPIException e) { this.notifyError(e); this.refreshLock.writeLock().unlock(); throw e; } JsonObject jsonObject = JsonObject.readFrom(json); this.accessToken = jsonObject.get("access_token").asString(); this.refreshToken = jsonObject.get("refresh_token").asString(); this.lastRefresh = System.currentTimeMillis(); this.expires = jsonObject.get("expires_in").asLong() * 1000; this.notifyRefresh(); this.refreshLock.writeLock().unlock(); }
java
public void refresh() { this.refreshLock.writeLock().lock(); if (!this.canRefresh()) { this.refreshLock.writeLock().unlock(); throw new IllegalStateException("The BoxAPIConnection cannot be refreshed because it doesn't have a " + "refresh token."); } URL url = null; try { url = new URL(this.tokenURL); } catch (MalformedURLException e) { this.refreshLock.writeLock().unlock(); assert false : "An invalid refresh URL indicates a bug in the SDK."; throw new RuntimeException("An invalid refresh URL indicates a bug in the SDK.", e); } String urlParameters = String.format("grant_type=refresh_token&refresh_token=%s&client_id=%s&client_secret=%s", this.refreshToken, this.clientID, this.clientSecret); BoxAPIRequest request = new BoxAPIRequest(this, url, "POST"); request.shouldAuthenticate(false); request.setBody(urlParameters); String json; try { BoxJSONResponse response = (BoxJSONResponse) request.send(); json = response.getJSON(); } catch (BoxAPIException e) { this.notifyError(e); this.refreshLock.writeLock().unlock(); throw e; } JsonObject jsonObject = JsonObject.readFrom(json); this.accessToken = jsonObject.get("access_token").asString(); this.refreshToken = jsonObject.get("refresh_token").asString(); this.lastRefresh = System.currentTimeMillis(); this.expires = jsonObject.get("expires_in").asLong() * 1000; this.notifyRefresh(); this.refreshLock.writeLock().unlock(); }
[ "public", "void", "refresh", "(", ")", "{", "this", ".", "refreshLock", ".", "writeLock", "(", ")", ".", "lock", "(", ")", ";", "if", "(", "!", "this", ".", "canRefresh", "(", ")", ")", "{", "this", ".", "refreshLock", ".", "writeLock", "(", ")", ".", "unlock", "(", ")", ";", "throw", "new", "IllegalStateException", "(", "\"The BoxAPIConnection cannot be refreshed because it doesn't have a \"", "+", "\"refresh token.\"", ")", ";", "}", "URL", "url", "=", "null", ";", "try", "{", "url", "=", "new", "URL", "(", "this", ".", "tokenURL", ")", ";", "}", "catch", "(", "MalformedURLException", "e", ")", "{", "this", ".", "refreshLock", ".", "writeLock", "(", ")", ".", "unlock", "(", ")", ";", "assert", "false", ":", "\"An invalid refresh URL indicates a bug in the SDK.\"", ";", "throw", "new", "RuntimeException", "(", "\"An invalid refresh URL indicates a bug in the SDK.\"", ",", "e", ")", ";", "}", "String", "urlParameters", "=", "String", ".", "format", "(", "\"grant_type=refresh_token&refresh_token=%s&client_id=%s&client_secret=%s\"", ",", "this", ".", "refreshToken", ",", "this", ".", "clientID", ",", "this", ".", "clientSecret", ")", ";", "BoxAPIRequest", "request", "=", "new", "BoxAPIRequest", "(", "this", ",", "url", ",", "\"POST\"", ")", ";", "request", ".", "shouldAuthenticate", "(", "false", ")", ";", "request", ".", "setBody", "(", "urlParameters", ")", ";", "String", "json", ";", "try", "{", "BoxJSONResponse", "response", "=", "(", "BoxJSONResponse", ")", "request", ".", "send", "(", ")", ";", "json", "=", "response", ".", "getJSON", "(", ")", ";", "}", "catch", "(", "BoxAPIException", "e", ")", "{", "this", ".", "notifyError", "(", "e", ")", ";", "this", ".", "refreshLock", ".", "writeLock", "(", ")", ".", "unlock", "(", ")", ";", "throw", "e", ";", "}", "JsonObject", "jsonObject", "=", "JsonObject", ".", "readFrom", "(", "json", ")", ";", "this", ".", "accessToken", "=", "jsonObject", ".", "get", "(", "\"access_token\"", ")", ".", "asString", "(", ")", ";", "this", ".", "refreshToken", "=", "jsonObject", ".", "get", "(", "\"refresh_token\"", ")", ".", "asString", "(", ")", ";", "this", ".", "lastRefresh", "=", "System", ".", "currentTimeMillis", "(", ")", ";", "this", ".", "expires", "=", "jsonObject", ".", "get", "(", "\"expires_in\"", ")", ".", "asLong", "(", ")", "*", "1000", ";", "this", ".", "notifyRefresh", "(", ")", ";", "this", ".", "refreshLock", ".", "writeLock", "(", ")", ".", "unlock", "(", ")", ";", "}" ]
Refresh's this connection's access token using its refresh token. @throws IllegalStateException if this connection's access token cannot be refreshed.
[ "Refresh", "s", "this", "connection", "s", "access", "token", "using", "its", "refresh", "token", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxAPIConnection.java#L546-L590
163,589
box/box-java-sdk
src/main/java/com/box/sdk/BoxAPIConnection.java
BoxAPIConnection.restore
public void restore(String state) { JsonObject json = JsonObject.readFrom(state); String accessToken = json.get("accessToken").asString(); String refreshToken = json.get("refreshToken").asString(); long lastRefresh = json.get("lastRefresh").asLong(); long expires = json.get("expires").asLong(); String userAgent = json.get("userAgent").asString(); String tokenURL = json.get("tokenURL").asString(); String baseURL = json.get("baseURL").asString(); String baseUploadURL = json.get("baseUploadURL").asString(); boolean autoRefresh = json.get("autoRefresh").asBoolean(); int maxRequestAttempts = json.get("maxRequestAttempts").asInt(); this.accessToken = accessToken; this.refreshToken = refreshToken; this.lastRefresh = lastRefresh; this.expires = expires; this.userAgent = userAgent; this.tokenURL = tokenURL; this.baseURL = baseURL; this.baseUploadURL = baseUploadURL; this.autoRefresh = autoRefresh; this.maxRequestAttempts = maxRequestAttempts; }
java
public void restore(String state) { JsonObject json = JsonObject.readFrom(state); String accessToken = json.get("accessToken").asString(); String refreshToken = json.get("refreshToken").asString(); long lastRefresh = json.get("lastRefresh").asLong(); long expires = json.get("expires").asLong(); String userAgent = json.get("userAgent").asString(); String tokenURL = json.get("tokenURL").asString(); String baseURL = json.get("baseURL").asString(); String baseUploadURL = json.get("baseUploadURL").asString(); boolean autoRefresh = json.get("autoRefresh").asBoolean(); int maxRequestAttempts = json.get("maxRequestAttempts").asInt(); this.accessToken = accessToken; this.refreshToken = refreshToken; this.lastRefresh = lastRefresh; this.expires = expires; this.userAgent = userAgent; this.tokenURL = tokenURL; this.baseURL = baseURL; this.baseUploadURL = baseUploadURL; this.autoRefresh = autoRefresh; this.maxRequestAttempts = maxRequestAttempts; }
[ "public", "void", "restore", "(", "String", "state", ")", "{", "JsonObject", "json", "=", "JsonObject", ".", "readFrom", "(", "state", ")", ";", "String", "accessToken", "=", "json", ".", "get", "(", "\"accessToken\"", ")", ".", "asString", "(", ")", ";", "String", "refreshToken", "=", "json", ".", "get", "(", "\"refreshToken\"", ")", ".", "asString", "(", ")", ";", "long", "lastRefresh", "=", "json", ".", "get", "(", "\"lastRefresh\"", ")", ".", "asLong", "(", ")", ";", "long", "expires", "=", "json", ".", "get", "(", "\"expires\"", ")", ".", "asLong", "(", ")", ";", "String", "userAgent", "=", "json", ".", "get", "(", "\"userAgent\"", ")", ".", "asString", "(", ")", ";", "String", "tokenURL", "=", "json", ".", "get", "(", "\"tokenURL\"", ")", ".", "asString", "(", ")", ";", "String", "baseURL", "=", "json", ".", "get", "(", "\"baseURL\"", ")", ".", "asString", "(", ")", ";", "String", "baseUploadURL", "=", "json", ".", "get", "(", "\"baseUploadURL\"", ")", ".", "asString", "(", ")", ";", "boolean", "autoRefresh", "=", "json", ".", "get", "(", "\"autoRefresh\"", ")", ".", "asBoolean", "(", ")", ";", "int", "maxRequestAttempts", "=", "json", ".", "get", "(", "\"maxRequestAttempts\"", ")", ".", "asInt", "(", ")", ";", "this", ".", "accessToken", "=", "accessToken", ";", "this", ".", "refreshToken", "=", "refreshToken", ";", "this", ".", "lastRefresh", "=", "lastRefresh", ";", "this", ".", "expires", "=", "expires", ";", "this", ".", "userAgent", "=", "userAgent", ";", "this", ".", "tokenURL", "=", "tokenURL", ";", "this", ".", "baseURL", "=", "baseURL", ";", "this", ".", "baseUploadURL", "=", "baseUploadURL", ";", "this", ".", "autoRefresh", "=", "autoRefresh", ";", "this", ".", "maxRequestAttempts", "=", "maxRequestAttempts", ";", "}" ]
Restores a saved connection state into this BoxAPIConnection. @see #save @param state the saved state that was created with {@link #save}.
[ "Restores", "a", "saved", "connection", "state", "into", "this", "BoxAPIConnection", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxAPIConnection.java#L598-L621
163,590
box/box-java-sdk
src/main/java/com/box/sdk/BoxAPIConnection.java
BoxAPIConnection.getLowerScopedToken
public ScopedToken getLowerScopedToken(List<String> scopes, String resource) { assert (scopes != null); assert (scopes.size() > 0); URL url = null; try { url = new URL(this.getTokenURL()); } catch (MalformedURLException e) { assert false : "An invalid refresh URL indicates a bug in the SDK."; throw new RuntimeException("An invalid refresh URL indicates a bug in the SDK.", e); } StringBuilder spaceSeparatedScopes = new StringBuilder(); for (int i = 0; i < scopes.size(); i++) { spaceSeparatedScopes.append(scopes.get(i)); if (i < scopes.size() - 1) { spaceSeparatedScopes.append(" "); } } String urlParameters = null; if (resource != null) { //this.getAccessToken() ensures we have a valid access token urlParameters = String.format("grant_type=urn:ietf:params:oauth:grant-type:token-exchange" + "&subject_token_type=urn:ietf:params:oauth:token-type:access_token&subject_token=%s" + "&scope=%s&resource=%s", this.getAccessToken(), spaceSeparatedScopes, resource); } else { //this.getAccessToken() ensures we have a valid access token urlParameters = String.format("grant_type=urn:ietf:params:oauth:grant-type:token-exchange" + "&subject_token_type=urn:ietf:params:oauth:token-type:access_token&subject_token=%s" + "&scope=%s", this.getAccessToken(), spaceSeparatedScopes); } BoxAPIRequest request = new BoxAPIRequest(this, url, "POST"); request.shouldAuthenticate(false); request.setBody(urlParameters); String json; try { BoxJSONResponse response = (BoxJSONResponse) request.send(); json = response.getJSON(); } catch (BoxAPIException e) { this.notifyError(e); throw e; } JsonObject jsonObject = JsonObject.readFrom(json); ScopedToken token = new ScopedToken(jsonObject); token.setObtainedAt(System.currentTimeMillis()); token.setExpiresIn(jsonObject.get("expires_in").asLong() * 1000); return token; }
java
public ScopedToken getLowerScopedToken(List<String> scopes, String resource) { assert (scopes != null); assert (scopes.size() > 0); URL url = null; try { url = new URL(this.getTokenURL()); } catch (MalformedURLException e) { assert false : "An invalid refresh URL indicates a bug in the SDK."; throw new RuntimeException("An invalid refresh URL indicates a bug in the SDK.", e); } StringBuilder spaceSeparatedScopes = new StringBuilder(); for (int i = 0; i < scopes.size(); i++) { spaceSeparatedScopes.append(scopes.get(i)); if (i < scopes.size() - 1) { spaceSeparatedScopes.append(" "); } } String urlParameters = null; if (resource != null) { //this.getAccessToken() ensures we have a valid access token urlParameters = String.format("grant_type=urn:ietf:params:oauth:grant-type:token-exchange" + "&subject_token_type=urn:ietf:params:oauth:token-type:access_token&subject_token=%s" + "&scope=%s&resource=%s", this.getAccessToken(), spaceSeparatedScopes, resource); } else { //this.getAccessToken() ensures we have a valid access token urlParameters = String.format("grant_type=urn:ietf:params:oauth:grant-type:token-exchange" + "&subject_token_type=urn:ietf:params:oauth:token-type:access_token&subject_token=%s" + "&scope=%s", this.getAccessToken(), spaceSeparatedScopes); } BoxAPIRequest request = new BoxAPIRequest(this, url, "POST"); request.shouldAuthenticate(false); request.setBody(urlParameters); String json; try { BoxJSONResponse response = (BoxJSONResponse) request.send(); json = response.getJSON(); } catch (BoxAPIException e) { this.notifyError(e); throw e; } JsonObject jsonObject = JsonObject.readFrom(json); ScopedToken token = new ScopedToken(jsonObject); token.setObtainedAt(System.currentTimeMillis()); token.setExpiresIn(jsonObject.get("expires_in").asLong() * 1000); return token; }
[ "public", "ScopedToken", "getLowerScopedToken", "(", "List", "<", "String", ">", "scopes", ",", "String", "resource", ")", "{", "assert", "(", "scopes", "!=", "null", ")", ";", "assert", "(", "scopes", ".", "size", "(", ")", ">", "0", ")", ";", "URL", "url", "=", "null", ";", "try", "{", "url", "=", "new", "URL", "(", "this", ".", "getTokenURL", "(", ")", ")", ";", "}", "catch", "(", "MalformedURLException", "e", ")", "{", "assert", "false", ":", "\"An invalid refresh URL indicates a bug in the SDK.\"", ";", "throw", "new", "RuntimeException", "(", "\"An invalid refresh URL indicates a bug in the SDK.\"", ",", "e", ")", ";", "}", "StringBuilder", "spaceSeparatedScopes", "=", "new", "StringBuilder", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "scopes", ".", "size", "(", ")", ";", "i", "++", ")", "{", "spaceSeparatedScopes", ".", "append", "(", "scopes", ".", "get", "(", "i", ")", ")", ";", "if", "(", "i", "<", "scopes", ".", "size", "(", ")", "-", "1", ")", "{", "spaceSeparatedScopes", ".", "append", "(", "\" \"", ")", ";", "}", "}", "String", "urlParameters", "=", "null", ";", "if", "(", "resource", "!=", "null", ")", "{", "//this.getAccessToken() ensures we have a valid access token", "urlParameters", "=", "String", ".", "format", "(", "\"grant_type=urn:ietf:params:oauth:grant-type:token-exchange\"", "+", "\"&subject_token_type=urn:ietf:params:oauth:token-type:access_token&subject_token=%s\"", "+", "\"&scope=%s&resource=%s\"", ",", "this", ".", "getAccessToken", "(", ")", ",", "spaceSeparatedScopes", ",", "resource", ")", ";", "}", "else", "{", "//this.getAccessToken() ensures we have a valid access token", "urlParameters", "=", "String", ".", "format", "(", "\"grant_type=urn:ietf:params:oauth:grant-type:token-exchange\"", "+", "\"&subject_token_type=urn:ietf:params:oauth:token-type:access_token&subject_token=%s\"", "+", "\"&scope=%s\"", ",", "this", ".", "getAccessToken", "(", ")", ",", "spaceSeparatedScopes", ")", ";", "}", "BoxAPIRequest", "request", "=", "new", "BoxAPIRequest", "(", "this", ",", "url", ",", "\"POST\"", ")", ";", "request", ".", "shouldAuthenticate", "(", "false", ")", ";", "request", ".", "setBody", "(", "urlParameters", ")", ";", "String", "json", ";", "try", "{", "BoxJSONResponse", "response", "=", "(", "BoxJSONResponse", ")", "request", ".", "send", "(", ")", ";", "json", "=", "response", ".", "getJSON", "(", ")", ";", "}", "catch", "(", "BoxAPIException", "e", ")", "{", "this", ".", "notifyError", "(", "e", ")", ";", "throw", "e", ";", "}", "JsonObject", "jsonObject", "=", "JsonObject", ".", "readFrom", "(", "json", ")", ";", "ScopedToken", "token", "=", "new", "ScopedToken", "(", "jsonObject", ")", ";", "token", ".", "setObtainedAt", "(", "System", ".", "currentTimeMillis", "(", ")", ")", ";", "token", ".", "setExpiresIn", "(", "jsonObject", ".", "get", "(", "\"expires_in\"", ")", ".", "asLong", "(", ")", "*", "1000", ")", ";", "return", "token", ";", "}" ]
Get a lower-scoped token restricted to a resource for the list of scopes that are passed. @param scopes the list of scopes to which the new token should be restricted for @param resource the resource for which the new token has to be obtained @return scopedToken which has access token and other details
[ "Get", "a", "lower", "-", "scoped", "token", "restricted", "to", "a", "resource", "for", "the", "list", "of", "scopes", "that", "are", "passed", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxAPIConnection.java#L680-L733
163,591
box/box-java-sdk
src/main/java/com/box/sdk/BoxAPIConnection.java
BoxAPIConnection.save
public String save() { JsonObject state = new JsonObject() .add("accessToken", this.accessToken) .add("refreshToken", this.refreshToken) .add("lastRefresh", this.lastRefresh) .add("expires", this.expires) .add("userAgent", this.userAgent) .add("tokenURL", this.tokenURL) .add("baseURL", this.baseURL) .add("baseUploadURL", this.baseUploadURL) .add("autoRefresh", this.autoRefresh) .add("maxRequestAttempts", this.maxRequestAttempts); return state.toString(); }
java
public String save() { JsonObject state = new JsonObject() .add("accessToken", this.accessToken) .add("refreshToken", this.refreshToken) .add("lastRefresh", this.lastRefresh) .add("expires", this.expires) .add("userAgent", this.userAgent) .add("tokenURL", this.tokenURL) .add("baseURL", this.baseURL) .add("baseUploadURL", this.baseUploadURL) .add("autoRefresh", this.autoRefresh) .add("maxRequestAttempts", this.maxRequestAttempts); return state.toString(); }
[ "public", "String", "save", "(", ")", "{", "JsonObject", "state", "=", "new", "JsonObject", "(", ")", ".", "add", "(", "\"accessToken\"", ",", "this", ".", "accessToken", ")", ".", "add", "(", "\"refreshToken\"", ",", "this", ".", "refreshToken", ")", ".", "add", "(", "\"lastRefresh\"", ",", "this", ".", "lastRefresh", ")", ".", "add", "(", "\"expires\"", ",", "this", ".", "expires", ")", ".", "add", "(", "\"userAgent\"", ",", "this", ".", "userAgent", ")", ".", "add", "(", "\"tokenURL\"", ",", "this", ".", "tokenURL", ")", ".", "add", "(", "\"baseURL\"", ",", "this", ".", "baseURL", ")", ".", "add", "(", "\"baseUploadURL\"", ",", "this", ".", "baseUploadURL", ")", ".", "add", "(", "\"autoRefresh\"", ",", "this", ".", "autoRefresh", ")", ".", "add", "(", "\"maxRequestAttempts\"", ",", "this", ".", "maxRequestAttempts", ")", ";", "return", "state", ".", "toString", "(", ")", ";", "}" ]
Saves the state of this connection to a string so that it can be persisted and restored at a later time. <p>Note that proxy settings aren't automatically saved or restored. This is mainly due to security concerns around persisting proxy authentication details to the state string. If your connection uses a proxy, you will have to manually configure it again after restoring the connection.</p> @see #restore @return the state of this connection.
[ "Saves", "the", "state", "of", "this", "connection", "to", "a", "string", "so", "that", "it", "can", "be", "persisted", "and", "restored", "at", "a", "later", "time", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxAPIConnection.java#L773-L786
163,592
box/box-java-sdk
src/main/java/com/box/sdk/BoxDevicePin.java
BoxDevicePin.getInfo
public Info getInfo(String ... fields) { QueryStringBuilder builder = new QueryStringBuilder(); if (fields.length > 0) { builder.appendParam("fields", fields); } URL url = DEVICE_PIN_URL_TEMPLATE.buildWithQuery(this.getAPI().getBaseURL(), builder.toString(), this.getID()); BoxAPIRequest request = new BoxAPIRequest(this.getAPI(), url, "GET"); BoxJSONResponse response = (BoxJSONResponse) request.send(); JsonObject responseJSON = JsonObject.readFrom(response.getJSON()); return new Info(responseJSON); }
java
public Info getInfo(String ... fields) { QueryStringBuilder builder = new QueryStringBuilder(); if (fields.length > 0) { builder.appendParam("fields", fields); } URL url = DEVICE_PIN_URL_TEMPLATE.buildWithQuery(this.getAPI().getBaseURL(), builder.toString(), this.getID()); BoxAPIRequest request = new BoxAPIRequest(this.getAPI(), url, "GET"); BoxJSONResponse response = (BoxJSONResponse) request.send(); JsonObject responseJSON = JsonObject.readFrom(response.getJSON()); return new Info(responseJSON); }
[ "public", "Info", "getInfo", "(", "String", "...", "fields", ")", "{", "QueryStringBuilder", "builder", "=", "new", "QueryStringBuilder", "(", ")", ";", "if", "(", "fields", ".", "length", ">", "0", ")", "{", "builder", ".", "appendParam", "(", "\"fields\"", ",", "fields", ")", ";", "}", "URL", "url", "=", "DEVICE_PIN_URL_TEMPLATE", ".", "buildWithQuery", "(", "this", ".", "getAPI", "(", ")", ".", "getBaseURL", "(", ")", ",", "builder", ".", "toString", "(", ")", ",", "this", ".", "getID", "(", ")", ")", ";", "BoxAPIRequest", "request", "=", "new", "BoxAPIRequest", "(", "this", ".", "getAPI", "(", ")", ",", "url", ",", "\"GET\"", ")", ";", "BoxJSONResponse", "response", "=", "(", "BoxJSONResponse", ")", "request", ".", "send", "(", ")", ";", "JsonObject", "responseJSON", "=", "JsonObject", ".", "readFrom", "(", "response", ".", "getJSON", "(", ")", ")", ";", "return", "new", "Info", "(", "responseJSON", ")", ";", "}" ]
Gets information about the device pin. @param fields the fields to retrieve. @return info about the device pin.
[ "Gets", "information", "about", "the", "device", "pin", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxDevicePin.java#L50-L60
163,593
box/box-java-sdk
src/main/java/com/box/sdk/BoxDevicePin.java
BoxDevicePin.delete
public void delete() { URL url = DEVICE_PIN_URL_TEMPLATE.build(this.getAPI().getBaseURL(), this.getID()); BoxAPIRequest request = new BoxAPIRequest(this.getAPI(), url, "DELETE"); BoxAPIResponse response = request.send(); response.disconnect(); }
java
public void delete() { URL url = DEVICE_PIN_URL_TEMPLATE.build(this.getAPI().getBaseURL(), this.getID()); BoxAPIRequest request = new BoxAPIRequest(this.getAPI(), url, "DELETE"); BoxAPIResponse response = request.send(); response.disconnect(); }
[ "public", "void", "delete", "(", ")", "{", "URL", "url", "=", "DEVICE_PIN_URL_TEMPLATE", ".", "build", "(", "this", ".", "getAPI", "(", ")", ".", "getBaseURL", "(", ")", ",", "this", ".", "getID", "(", ")", ")", ";", "BoxAPIRequest", "request", "=", "new", "BoxAPIRequest", "(", "this", ".", "getAPI", "(", ")", ",", "url", ",", "\"DELETE\"", ")", ";", "BoxAPIResponse", "response", "=", "request", ".", "send", "(", ")", ";", "response", ".", "disconnect", "(", ")", ";", "}" ]
Deletes the device pin.
[ "Deletes", "the", "device", "pin", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxDevicePin.java#L105-L110
163,594
box/box-java-sdk
src/main/java/com/box/sdk/BoxMetadataCascadePolicy.java
BoxMetadataCascadePolicy.forceApply
public void forceApply(String conflictResolution) { URL url = FORCE_METADATA_CASCADE_POLICIES_URL_TEMPLATE.build(this.getAPI().getBaseURL(), this.getID()); BoxJSONRequest request = new BoxJSONRequest(this.getAPI(), url, "POST"); JsonObject requestJSON = new JsonObject() .add("conflict_resolution", conflictResolution); request.setBody(requestJSON.toString()); request.send(); }
java
public void forceApply(String conflictResolution) { URL url = FORCE_METADATA_CASCADE_POLICIES_URL_TEMPLATE.build(this.getAPI().getBaseURL(), this.getID()); BoxJSONRequest request = new BoxJSONRequest(this.getAPI(), url, "POST"); JsonObject requestJSON = new JsonObject() .add("conflict_resolution", conflictResolution); request.setBody(requestJSON.toString()); request.send(); }
[ "public", "void", "forceApply", "(", "String", "conflictResolution", ")", "{", "URL", "url", "=", "FORCE_METADATA_CASCADE_POLICIES_URL_TEMPLATE", ".", "build", "(", "this", ".", "getAPI", "(", ")", ".", "getBaseURL", "(", ")", ",", "this", ".", "getID", "(", ")", ")", ";", "BoxJSONRequest", "request", "=", "new", "BoxJSONRequest", "(", "this", ".", "getAPI", "(", ")", ",", "url", ",", "\"POST\"", ")", ";", "JsonObject", "requestJSON", "=", "new", "JsonObject", "(", ")", ".", "add", "(", "\"conflict_resolution\"", ",", "conflictResolution", ")", ";", "request", ".", "setBody", "(", "requestJSON", ".", "toString", "(", ")", ")", ";", "request", ".", "send", "(", ")", ";", "}" ]
If a policy already exists on a folder, this will apply that policy to all existing files and sub folders within the target folder. @param conflictResolution the desired behavior for conflict-resolution. Set to either none or overwrite.
[ "If", "a", "policy", "already", "exists", "on", "a", "folder", "this", "will", "apply", "that", "policy", "to", "all", "existing", "files", "and", "sub", "folders", "within", "the", "target", "folder", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxMetadataCascadePolicy.java#L141-L149
163,595
box/box-java-sdk
src/main/java/com/box/sdk/BoxTask.java
BoxTask.addAssignment
public BoxTaskAssignment.Info addAssignment(BoxUser assignTo) { JsonObject taskJSON = new JsonObject(); taskJSON.add("type", "task"); taskJSON.add("id", this.getID()); JsonObject assignToJSON = new JsonObject(); assignToJSON.add("id", assignTo.getID()); JsonObject requestJSON = new JsonObject(); requestJSON.add("task", taskJSON); requestJSON.add("assign_to", assignToJSON); URL url = ADD_TASK_ASSIGNMENT_URL_TEMPLATE.build(this.getAPI().getBaseURL()); BoxJSONRequest request = new BoxJSONRequest(this.getAPI(), url, "POST"); request.setBody(requestJSON.toString()); BoxJSONResponse response = (BoxJSONResponse) request.send(); JsonObject responseJSON = JsonObject.readFrom(response.getJSON()); BoxTaskAssignment addedAssignment = new BoxTaskAssignment(this.getAPI(), responseJSON.get("id").asString()); return addedAssignment.new Info(responseJSON); }
java
public BoxTaskAssignment.Info addAssignment(BoxUser assignTo) { JsonObject taskJSON = new JsonObject(); taskJSON.add("type", "task"); taskJSON.add("id", this.getID()); JsonObject assignToJSON = new JsonObject(); assignToJSON.add("id", assignTo.getID()); JsonObject requestJSON = new JsonObject(); requestJSON.add("task", taskJSON); requestJSON.add("assign_to", assignToJSON); URL url = ADD_TASK_ASSIGNMENT_URL_TEMPLATE.build(this.getAPI().getBaseURL()); BoxJSONRequest request = new BoxJSONRequest(this.getAPI(), url, "POST"); request.setBody(requestJSON.toString()); BoxJSONResponse response = (BoxJSONResponse) request.send(); JsonObject responseJSON = JsonObject.readFrom(response.getJSON()); BoxTaskAssignment addedAssignment = new BoxTaskAssignment(this.getAPI(), responseJSON.get("id").asString()); return addedAssignment.new Info(responseJSON); }
[ "public", "BoxTaskAssignment", ".", "Info", "addAssignment", "(", "BoxUser", "assignTo", ")", "{", "JsonObject", "taskJSON", "=", "new", "JsonObject", "(", ")", ";", "taskJSON", ".", "add", "(", "\"type\"", ",", "\"task\"", ")", ";", "taskJSON", ".", "add", "(", "\"id\"", ",", "this", ".", "getID", "(", ")", ")", ";", "JsonObject", "assignToJSON", "=", "new", "JsonObject", "(", ")", ";", "assignToJSON", ".", "add", "(", "\"id\"", ",", "assignTo", ".", "getID", "(", ")", ")", ";", "JsonObject", "requestJSON", "=", "new", "JsonObject", "(", ")", ";", "requestJSON", ".", "add", "(", "\"task\"", ",", "taskJSON", ")", ";", "requestJSON", ".", "add", "(", "\"assign_to\"", ",", "assignToJSON", ")", ";", "URL", "url", "=", "ADD_TASK_ASSIGNMENT_URL_TEMPLATE", ".", "build", "(", "this", ".", "getAPI", "(", ")", ".", "getBaseURL", "(", ")", ")", ";", "BoxJSONRequest", "request", "=", "new", "BoxJSONRequest", "(", "this", ".", "getAPI", "(", ")", ",", "url", ",", "\"POST\"", ")", ";", "request", ".", "setBody", "(", "requestJSON", ".", "toString", "(", ")", ")", ";", "BoxJSONResponse", "response", "=", "(", "BoxJSONResponse", ")", "request", ".", "send", "(", ")", ";", "JsonObject", "responseJSON", "=", "JsonObject", ".", "readFrom", "(", "response", ".", "getJSON", "(", ")", ")", ";", "BoxTaskAssignment", "addedAssignment", "=", "new", "BoxTaskAssignment", "(", "this", ".", "getAPI", "(", ")", ",", "responseJSON", ".", "get", "(", "\"id\"", ")", ".", "asString", "(", ")", ")", ";", "return", "addedAssignment", ".", "new", "Info", "(", "responseJSON", ")", ";", "}" ]
Adds a new assignment to this task. @param assignTo the user to assign the assignment to. @return information about the newly added task assignment.
[ "Adds", "a", "new", "assignment", "to", "this", "task", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxTask.java#L57-L77
163,596
box/box-java-sdk
src/main/java/com/box/sdk/BoxTask.java
BoxTask.getAssignments
public List<BoxTaskAssignment.Info> getAssignments() { URL url = GET_ASSIGNMENTS_URL_TEMPLATE.build(this.getAPI().getBaseURL(), this.getID()); BoxAPIRequest request = new BoxAPIRequest(this.getAPI(), url, "GET"); BoxJSONResponse response = (BoxJSONResponse) request.send(); JsonObject responseJSON = JsonObject.readFrom(response.getJSON()); int totalCount = responseJSON.get("total_count").asInt(); List<BoxTaskAssignment.Info> assignments = new ArrayList<BoxTaskAssignment.Info>(totalCount); JsonArray entries = responseJSON.get("entries").asArray(); for (JsonValue value : entries) { JsonObject assignmentJSON = value.asObject(); BoxTaskAssignment assignment = new BoxTaskAssignment(this.getAPI(), assignmentJSON.get("id").asString()); BoxTaskAssignment.Info info = assignment.new Info(assignmentJSON); assignments.add(info); } return assignments; }
java
public List<BoxTaskAssignment.Info> getAssignments() { URL url = GET_ASSIGNMENTS_URL_TEMPLATE.build(this.getAPI().getBaseURL(), this.getID()); BoxAPIRequest request = new BoxAPIRequest(this.getAPI(), url, "GET"); BoxJSONResponse response = (BoxJSONResponse) request.send(); JsonObject responseJSON = JsonObject.readFrom(response.getJSON()); int totalCount = responseJSON.get("total_count").asInt(); List<BoxTaskAssignment.Info> assignments = new ArrayList<BoxTaskAssignment.Info>(totalCount); JsonArray entries = responseJSON.get("entries").asArray(); for (JsonValue value : entries) { JsonObject assignmentJSON = value.asObject(); BoxTaskAssignment assignment = new BoxTaskAssignment(this.getAPI(), assignmentJSON.get("id").asString()); BoxTaskAssignment.Info info = assignment.new Info(assignmentJSON); assignments.add(info); } return assignments; }
[ "public", "List", "<", "BoxTaskAssignment", ".", "Info", ">", "getAssignments", "(", ")", "{", "URL", "url", "=", "GET_ASSIGNMENTS_URL_TEMPLATE", ".", "build", "(", "this", ".", "getAPI", "(", ")", ".", "getBaseURL", "(", ")", ",", "this", ".", "getID", "(", ")", ")", ";", "BoxAPIRequest", "request", "=", "new", "BoxAPIRequest", "(", "this", ".", "getAPI", "(", ")", ",", "url", ",", "\"GET\"", ")", ";", "BoxJSONResponse", "response", "=", "(", "BoxJSONResponse", ")", "request", ".", "send", "(", ")", ";", "JsonObject", "responseJSON", "=", "JsonObject", ".", "readFrom", "(", "response", ".", "getJSON", "(", ")", ")", ";", "int", "totalCount", "=", "responseJSON", ".", "get", "(", "\"total_count\"", ")", ".", "asInt", "(", ")", ";", "List", "<", "BoxTaskAssignment", ".", "Info", ">", "assignments", "=", "new", "ArrayList", "<", "BoxTaskAssignment", ".", "Info", ">", "(", "totalCount", ")", ";", "JsonArray", "entries", "=", "responseJSON", ".", "get", "(", "\"entries\"", ")", ".", "asArray", "(", ")", ";", "for", "(", "JsonValue", "value", ":", "entries", ")", "{", "JsonObject", "assignmentJSON", "=", "value", ".", "asObject", "(", ")", ";", "BoxTaskAssignment", "assignment", "=", "new", "BoxTaskAssignment", "(", "this", ".", "getAPI", "(", ")", ",", "assignmentJSON", ".", "get", "(", "\"id\"", ")", ".", "asString", "(", ")", ")", ";", "BoxTaskAssignment", ".", "Info", "info", "=", "assignment", ".", "new", "Info", "(", "assignmentJSON", ")", ";", "assignments", ".", "add", "(", "info", ")", ";", "}", "return", "assignments", ";", "}" ]
Gets any assignments for this task. @return a list of assignments for this task.
[ "Gets", "any", "assignments", "for", "this", "task", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxTask.java#L110-L127
163,597
box/box-java-sdk
src/main/java/com/box/sdk/BoxTask.java
BoxTask.getAllAssignments
public Iterable<BoxTaskAssignment.Info> getAllAssignments(String ... fields) { final QueryStringBuilder builder = new QueryStringBuilder(); if (fields.length > 0) { builder.appendParam("fields", fields); } return new Iterable<BoxTaskAssignment.Info>() { public Iterator<BoxTaskAssignment.Info> iterator() { URL url = GET_ASSIGNMENTS_URL_TEMPLATE.buildWithQuery( BoxTask.this.getAPI().getBaseURL(), builder.toString(), BoxTask.this.getID()); return new BoxTaskAssignmentIterator(BoxTask.this.getAPI(), url); } }; }
java
public Iterable<BoxTaskAssignment.Info> getAllAssignments(String ... fields) { final QueryStringBuilder builder = new QueryStringBuilder(); if (fields.length > 0) { builder.appendParam("fields", fields); } return new Iterable<BoxTaskAssignment.Info>() { public Iterator<BoxTaskAssignment.Info> iterator() { URL url = GET_ASSIGNMENTS_URL_TEMPLATE.buildWithQuery( BoxTask.this.getAPI().getBaseURL(), builder.toString(), BoxTask.this.getID()); return new BoxTaskAssignmentIterator(BoxTask.this.getAPI(), url); } }; }
[ "public", "Iterable", "<", "BoxTaskAssignment", ".", "Info", ">", "getAllAssignments", "(", "String", "...", "fields", ")", "{", "final", "QueryStringBuilder", "builder", "=", "new", "QueryStringBuilder", "(", ")", ";", "if", "(", "fields", ".", "length", ">", "0", ")", "{", "builder", ".", "appendParam", "(", "\"fields\"", ",", "fields", ")", ";", "}", "return", "new", "Iterable", "<", "BoxTaskAssignment", ".", "Info", ">", "(", ")", "{", "public", "Iterator", "<", "BoxTaskAssignment", ".", "Info", ">", "iterator", "(", ")", "{", "URL", "url", "=", "GET_ASSIGNMENTS_URL_TEMPLATE", ".", "buildWithQuery", "(", "BoxTask", ".", "this", ".", "getAPI", "(", ")", ".", "getBaseURL", "(", ")", ",", "builder", ".", "toString", "(", ")", ",", "BoxTask", ".", "this", ".", "getID", "(", ")", ")", ";", "return", "new", "BoxTaskAssignmentIterator", "(", "BoxTask", ".", "this", ".", "getAPI", "(", ")", ",", "url", ")", ";", "}", "}", ";", "}" ]
Gets an iterable of all the assignments of this task. @param fields the fields to retrieve. @return an iterable containing info about all the assignments.
[ "Gets", "an", "iterable", "of", "all", "the", "assignments", "of", "this", "task", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxTask.java#L134-L146
163,598
box/box-java-sdk
src/main/java/com/box/sdk/BoxJSONObject.java
BoxJSONObject.getPendingChanges
public String getPendingChanges() { JsonObject jsonObject = this.getPendingJSONObject(); if (jsonObject == null) { return null; } return jsonObject.toString(); }
java
public String getPendingChanges() { JsonObject jsonObject = this.getPendingJSONObject(); if (jsonObject == null) { return null; } return jsonObject.toString(); }
[ "public", "String", "getPendingChanges", "(", ")", "{", "JsonObject", "jsonObject", "=", "this", ".", "getPendingJSONObject", "(", ")", ";", "if", "(", "jsonObject", "==", "null", ")", "{", "return", "null", ";", "}", "return", "jsonObject", ".", "toString", "(", ")", ";", "}" ]
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.
[ "Gets", "a", "JSON", "string", "containing", "any", "pending", "changes", "to", "this", "object", "that", "can", "be", "sent", "back", "to", "the", "Box", "API", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxJSONObject.java#L66-L73
163,599
box/box-java-sdk
src/main/java/com/box/sdk/BoxJSONObject.java
BoxJSONObject.update
void update(JsonObject jsonObject) { for (JsonObject.Member member : jsonObject) { if (member.getValue().isNull()) { continue; } this.parseJSONMember(member); } this.clearPendingChanges(); }
java
void update(JsonObject jsonObject) { for (JsonObject.Member member : jsonObject) { if (member.getValue().isNull()) { continue; } this.parseJSONMember(member); } this.clearPendingChanges(); }
[ "void", "update", "(", "JsonObject", "jsonObject", ")", "{", "for", "(", "JsonObject", ".", "Member", "member", ":", "jsonObject", ")", "{", "if", "(", "member", ".", "getValue", "(", ")", ".", "isNull", "(", ")", ")", "{", "continue", ";", "}", "this", ".", "parseJSONMember", "(", "member", ")", ";", "}", "this", ".", "clearPendingChanges", "(", ")", ";", "}" ]
Updates this BoxJSONObject using the information in a JSON object. @param jsonObject the JSON object containing updated information.
[ "Updates", "this", "BoxJSONObject", "using", "the", "information", "in", "a", "JSON", "object", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxJSONObject.java#L187-L197