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 list | docstring stringlengths 3 16k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 105 339 | partition stringclasses 1 value |
|---|---|---|---|---|---|---|---|---|---|---|---|
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",
"(",
")",... | 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 | train |
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",
".",
"build... | 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 | train |
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",
... | 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 | train |
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",
".",
... | 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",
"uploa... | 35b4ba69417f9d6a002c19dfaab57527750ef349 | https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxFile.java#L1392-L1408 | train |
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",
... | 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 | train |
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",
".",
"appen... | 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 | train |
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",
",",
"IOExceptio... | 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 | train |
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",
"(",
"NoSuchAlgorithm... | 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 | train |
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",
".",
"permi... | 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 | train |
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",
"Bo... | 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 | train |
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"... | 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 | train |
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",
")",
".",
"to... | 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 | train |
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",
"reque... | 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 | train |
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",
")",
... | 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 | train |
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",
"BoxAPIRequ... | 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 | train |
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",
"=",
... | 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 | train |
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... | 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 | train |
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",
"="... | 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 | train |
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",
")",
"{",
... | 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 | train |
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",
".",
... | 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 | train |
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",
")",
"{",
"J... | 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 | train |
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",
"(",
")",
")",
";",
"fieldOb... | 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 | train |
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",
... | 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 | train |
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",
"(",
")",
",",
... | 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 | train |
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",
... | 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 | train |
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",
")... | 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 | train |
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",
"(",
")",
",",
"template... | 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 | train |
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"... | 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 | train |
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",
"Stri... | 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 | train |
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\"",
... | 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 | train |
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",
".",
... | 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 | train |
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",
... | 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 | train |
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",
".",
"va... | 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 | train |
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",
".",
... | 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 | train |
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",
... | 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 | train |
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",
... | 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 | train |
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",
"tokenDu... | 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 | train |
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",
"(",
")",
... | 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 | train |
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",
"(",
")",
";"... | 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 | train |
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",
... | 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 | train |
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",
")",
".... | 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 | train |
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\"... | 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 | train |
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",
"=",
... | 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 | train |
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",
"(",
... | 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 | train |
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",
... | 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 | train |
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",
... | 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 | train |
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",
">",... | 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 | train |
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 | train |
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",
";",
"}",
"thi... | 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 | train |
box/box-java-sdk | src/main/java/com/box/sdk/BoxJSONObject.java | BoxJSONObject.getPendingJSONObject | private JsonObject getPendingJSONObject() {
for (Map.Entry<String, BoxJSONObject> entry : this.children.entrySet()) {
BoxJSONObject child = entry.getValue();
JsonObject jsonObject = child.getPendingJSONObject();
if (jsonObject != null) {
if (this.pendingChanges == null) {
this.pendingChanges = new JsonObject();
}
this.pendingChanges.set(entry.getKey(), jsonObject);
}
}
return this.pendingChanges;
} | java | private JsonObject getPendingJSONObject() {
for (Map.Entry<String, BoxJSONObject> entry : this.children.entrySet()) {
BoxJSONObject child = entry.getValue();
JsonObject jsonObject = child.getPendingJSONObject();
if (jsonObject != null) {
if (this.pendingChanges == null) {
this.pendingChanges = new JsonObject();
}
this.pendingChanges.set(entry.getKey(), jsonObject);
}
}
return this.pendingChanges;
} | [
"private",
"JsonObject",
"getPendingJSONObject",
"(",
")",
"{",
"for",
"(",
"Map",
".",
"Entry",
"<",
"String",
",",
"BoxJSONObject",
">",
"entry",
":",
"this",
".",
"children",
".",
"entrySet",
"(",
")",
")",
"{",
"BoxJSONObject",
"child",
"=",
"entry",
... | Gets a JsonObject containing any pending changes to this object that can be sent back to the Box API.
@return a JsonObject containing the pending changes. | [
"Gets",
"a",
"JsonObject",
"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#L203-L216 | train |
box/box-java-sdk | src/main/java/com/box/sdk/BoxAPIRequest.java | BoxAPIRequest.addHeader | public void addHeader(String key, String value) {
if (key.equals("As-User")) {
for (int i = 0; i < this.headers.size(); i++) {
if (this.headers.get(i).getKey().equals("As-User")) {
this.headers.remove(i);
}
}
}
if (key.equals("X-Box-UA")) {
throw new IllegalArgumentException("Altering the X-Box-UA header is not permitted");
}
this.headers.add(new RequestHeader(key, value));
} | java | public void addHeader(String key, String value) {
if (key.equals("As-User")) {
for (int i = 0; i < this.headers.size(); i++) {
if (this.headers.get(i).getKey().equals("As-User")) {
this.headers.remove(i);
}
}
}
if (key.equals("X-Box-UA")) {
throw new IllegalArgumentException("Altering the X-Box-UA header is not permitted");
}
this.headers.add(new RequestHeader(key, value));
} | [
"public",
"void",
"addHeader",
"(",
"String",
"key",
",",
"String",
"value",
")",
"{",
"if",
"(",
"key",
".",
"equals",
"(",
"\"As-User\"",
")",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"this",
".",
"headers",
".",
"size",
"(",
... | Adds an HTTP header to this request.
@param key the header key.
@param value the header value. | [
"Adds",
"an",
"HTTP",
"header",
"to",
"this",
"request",
"."
] | 35b4ba69417f9d6a002c19dfaab57527750ef349 | https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxAPIRequest.java#L178-L190 | train |
box/box-java-sdk | src/main/java/com/box/sdk/BoxAPIRequest.java | BoxAPIRequest.setBody | public void setBody(String body) {
byte[] bytes = body.getBytes(StandardCharsets.UTF_8);
this.bodyLength = bytes.length;
this.body = new ByteArrayInputStream(bytes);
} | java | public void setBody(String body) {
byte[] bytes = body.getBytes(StandardCharsets.UTF_8);
this.bodyLength = bytes.length;
this.body = new ByteArrayInputStream(bytes);
} | [
"public",
"void",
"setBody",
"(",
"String",
"body",
")",
"{",
"byte",
"[",
"]",
"bytes",
"=",
"body",
".",
"getBytes",
"(",
"StandardCharsets",
".",
"UTF_8",
")",
";",
"this",
".",
"bodyLength",
"=",
"bytes",
".",
"length",
";",
"this",
".",
"body",
... | Sets the request body to the contents of a String.
<p>If the contents of the body are large, then it may be more efficient to use an {@link InputStream} instead of
a String. Using a String requires that the entire body be in memory before sending the request.</p>
@param body a String containing the contents of the body. | [
"Sets",
"the",
"request",
"body",
"to",
"the",
"contents",
"of",
"a",
"String",
"."
] | 35b4ba69417f9d6a002c19dfaab57527750ef349 | https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxAPIRequest.java#L280-L284 | train |
box/box-java-sdk | src/main/java/com/box/sdk/BoxAPIRequest.java | BoxAPIRequest.send | public BoxAPIResponse send(ProgressListener listener) {
if (this.api == null) {
this.backoffCounter.reset(BoxGlobalSettings.getMaxRequestAttempts());
} else {
this.backoffCounter.reset(this.api.getMaxRequestAttempts());
}
while (this.backoffCounter.getAttemptsRemaining() > 0) {
try {
return this.trySend(listener);
} catch (BoxAPIException apiException) {
if (!this.backoffCounter.decrement() || !isResponseRetryable(apiException.getResponseCode())) {
throw apiException;
}
try {
this.resetBody();
} catch (IOException ioException) {
throw apiException;
}
try {
this.backoffCounter.waitBackoff();
} catch (InterruptedException interruptedException) {
Thread.currentThread().interrupt();
throw apiException;
}
}
}
throw new RuntimeException();
} | java | public BoxAPIResponse send(ProgressListener listener) {
if (this.api == null) {
this.backoffCounter.reset(BoxGlobalSettings.getMaxRequestAttempts());
} else {
this.backoffCounter.reset(this.api.getMaxRequestAttempts());
}
while (this.backoffCounter.getAttemptsRemaining() > 0) {
try {
return this.trySend(listener);
} catch (BoxAPIException apiException) {
if (!this.backoffCounter.decrement() || !isResponseRetryable(apiException.getResponseCode())) {
throw apiException;
}
try {
this.resetBody();
} catch (IOException ioException) {
throw apiException;
}
try {
this.backoffCounter.waitBackoff();
} catch (InterruptedException interruptedException) {
Thread.currentThread().interrupt();
throw apiException;
}
}
}
throw new RuntimeException();
} | [
"public",
"BoxAPIResponse",
"send",
"(",
"ProgressListener",
"listener",
")",
"{",
"if",
"(",
"this",
".",
"api",
"==",
"null",
")",
"{",
"this",
".",
"backoffCounter",
".",
"reset",
"(",
"BoxGlobalSettings",
".",
"getMaxRequestAttempts",
"(",
")",
")",
";",... | Sends this request while monitoring its progress and returns a BoxAPIResponse containing the server's response.
<p>A ProgressListener is generally only useful when the size of the request is known beforehand. If the size is
unknown, then the ProgressListener will be updated for each byte sent, but the total number of bytes will be
reported as 0.</p>
<p> See {@link #send} for more information on sending requests.</p>
@param listener a listener for monitoring the progress of the request.
@throws BoxAPIException if the server returns an error code or if a network error occurs.
@return a {@link BoxAPIResponse} containing the server's response. | [
"Sends",
"this",
"request",
"while",
"monitoring",
"its",
"progress",
"and",
"returns",
"a",
"BoxAPIResponse",
"containing",
"the",
"server",
"s",
"response",
"."
] | 35b4ba69417f9d6a002c19dfaab57527750ef349 | https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxAPIRequest.java#L345-L376 | train |
box/box-java-sdk | src/main/java/com/box/sdk/BoxAPIRequest.java | BoxAPIRequest.writeBody | protected void writeBody(HttpURLConnection connection, ProgressListener listener) {
if (this.body == null) {
return;
}
connection.setDoOutput(true);
try {
OutputStream output = connection.getOutputStream();
if (listener != null) {
output = new ProgressOutputStream(output, listener, this.bodyLength);
}
int b = this.body.read();
while (b != -1) {
output.write(b);
b = this.body.read();
}
output.close();
} catch (IOException e) {
throw new BoxAPIException("Couldn't connect to the Box API due to a network error.", e);
}
} | java | protected void writeBody(HttpURLConnection connection, ProgressListener listener) {
if (this.body == null) {
return;
}
connection.setDoOutput(true);
try {
OutputStream output = connection.getOutputStream();
if (listener != null) {
output = new ProgressOutputStream(output, listener, this.bodyLength);
}
int b = this.body.read();
while (b != -1) {
output.write(b);
b = this.body.read();
}
output.close();
} catch (IOException e) {
throw new BoxAPIException("Couldn't connect to the Box API due to a network error.", e);
}
} | [
"protected",
"void",
"writeBody",
"(",
"HttpURLConnection",
"connection",
",",
"ProgressListener",
"listener",
")",
"{",
"if",
"(",
"this",
".",
"body",
"==",
"null",
")",
"{",
"return",
";",
"}",
"connection",
".",
"setDoOutput",
"(",
"true",
")",
";",
"t... | Writes the body of this request to an HttpURLConnection.
<p>Subclasses overriding this method must remember to close the connection's OutputStream after writing.</p>
@param connection the connection to which the body should be written.
@param listener an optional listener for monitoring the write progress.
@throws BoxAPIException if an error occurs while writing to the connection. | [
"Writes",
"the",
"body",
"of",
"this",
"request",
"to",
"an",
"HttpURLConnection",
"."
] | 35b4ba69417f9d6a002c19dfaab57527750ef349 | https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxAPIRequest.java#L450-L470 | train |
box/box-java-sdk | src/main/java/com/box/sdk/BoxLegalHoldPolicy.java | BoxLegalHoldPolicy.createOngoing | public static BoxLegalHoldPolicy.Info createOngoing(BoxAPIConnection api, String name, String description) {
URL url = ALL_LEGAL_HOLD_URL_TEMPLATE.build(api.getBaseURL());
BoxJSONRequest request = new BoxJSONRequest(api, url, "POST");
JsonObject requestJSON = new JsonObject()
.add("policy_name", name)
.add("is_ongoing", true);
if (description != null) {
requestJSON.add("description", description);
}
request.setBody(requestJSON.toString());
BoxJSONResponse response = (BoxJSONResponse) request.send();
JsonObject responseJSON = JsonObject.readFrom(response.getJSON());
BoxLegalHoldPolicy createdPolicy = new BoxLegalHoldPolicy(api, responseJSON.get("id").asString());
return createdPolicy.new Info(responseJSON);
} | java | public static BoxLegalHoldPolicy.Info createOngoing(BoxAPIConnection api, String name, String description) {
URL url = ALL_LEGAL_HOLD_URL_TEMPLATE.build(api.getBaseURL());
BoxJSONRequest request = new BoxJSONRequest(api, url, "POST");
JsonObject requestJSON = new JsonObject()
.add("policy_name", name)
.add("is_ongoing", true);
if (description != null) {
requestJSON.add("description", description);
}
request.setBody(requestJSON.toString());
BoxJSONResponse response = (BoxJSONResponse) request.send();
JsonObject responseJSON = JsonObject.readFrom(response.getJSON());
BoxLegalHoldPolicy createdPolicy = new BoxLegalHoldPolicy(api, responseJSON.get("id").asString());
return createdPolicy.new Info(responseJSON);
} | [
"public",
"static",
"BoxLegalHoldPolicy",
".",
"Info",
"createOngoing",
"(",
"BoxAPIConnection",
"api",
",",
"String",
"name",
",",
"String",
"description",
")",
"{",
"URL",
"url",
"=",
"ALL_LEGAL_HOLD_URL_TEMPLATE",
".",
"build",
"(",
"api",
".",
"getBaseURL",
... | Creates a new ongoing Legal Hold Policy.
@param api the API connection to be used by the resource.
@param name the name of Legal Hold Policy.
@param description the description of Legal Hold Policy.
@return information about the Legal Hold Policy created. | [
"Creates",
"a",
"new",
"ongoing",
"Legal",
"Hold",
"Policy",
"."
] | 35b4ba69417f9d6a002c19dfaab57527750ef349 | https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxLegalHoldPolicy.java#L116-L130 | train |
box/box-java-sdk | src/main/java/com/box/sdk/BoxLegalHoldPolicy.java | BoxLegalHoldPolicy.getAssignments | public Iterable<BoxLegalHoldAssignment.Info> getAssignments(String ... fields) {
return this.getAssignments(null, null, DEFAULT_LIMIT, fields);
} | java | public Iterable<BoxLegalHoldAssignment.Info> getAssignments(String ... fields) {
return this.getAssignments(null, null, DEFAULT_LIMIT, fields);
} | [
"public",
"Iterable",
"<",
"BoxLegalHoldAssignment",
".",
"Info",
">",
"getAssignments",
"(",
"String",
"...",
"fields",
")",
"{",
"return",
"this",
".",
"getAssignments",
"(",
"null",
",",
"null",
",",
"DEFAULT_LIMIT",
",",
"fields",
")",
";",
"}"
] | Returns iterable containing assignments for this single legal hold policy.
@param fields the fields to retrieve.
@return an iterable containing assignments for this single legal hold policy. | [
"Returns",
"iterable",
"containing",
"assignments",
"for",
"this",
"single",
"legal",
"hold",
"policy",
"."
] | 35b4ba69417f9d6a002c19dfaab57527750ef349 | https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxLegalHoldPolicy.java#L210-L212 | train |
box/box-java-sdk | src/main/java/com/box/sdk/BoxLegalHoldPolicy.java | BoxLegalHoldPolicy.getAssignments | public Iterable<BoxLegalHoldAssignment.Info> getAssignments(String type, String id, int limit, String ... fields) {
QueryStringBuilder builder = new QueryStringBuilder();
if (type != null) {
builder.appendParam("assign_to_type", type);
}
if (id != null) {
builder.appendParam("assign_to_id", id);
}
if (fields.length > 0) {
builder.appendParam("fields", fields);
}
return new BoxResourceIterable<BoxLegalHoldAssignment.Info>(
this.getAPI(), LEGAL_HOLD_ASSIGNMENTS_URL_TEMPLATE.buildWithQuery(
this.getAPI().getBaseURL(), builder.toString(), this.getID()), limit) {
@Override
protected BoxLegalHoldAssignment.Info factory(JsonObject jsonObject) {
BoxLegalHoldAssignment assignment = new BoxLegalHoldAssignment(
BoxLegalHoldPolicy.this.getAPI(), jsonObject.get("id").asString());
return assignment.new Info(jsonObject);
}
};
} | java | public Iterable<BoxLegalHoldAssignment.Info> getAssignments(String type, String id, int limit, String ... fields) {
QueryStringBuilder builder = new QueryStringBuilder();
if (type != null) {
builder.appendParam("assign_to_type", type);
}
if (id != null) {
builder.appendParam("assign_to_id", id);
}
if (fields.length > 0) {
builder.appendParam("fields", fields);
}
return new BoxResourceIterable<BoxLegalHoldAssignment.Info>(
this.getAPI(), LEGAL_HOLD_ASSIGNMENTS_URL_TEMPLATE.buildWithQuery(
this.getAPI().getBaseURL(), builder.toString(), this.getID()), limit) {
@Override
protected BoxLegalHoldAssignment.Info factory(JsonObject jsonObject) {
BoxLegalHoldAssignment assignment = new BoxLegalHoldAssignment(
BoxLegalHoldPolicy.this.getAPI(), jsonObject.get("id").asString());
return assignment.new Info(jsonObject);
}
};
} | [
"public",
"Iterable",
"<",
"BoxLegalHoldAssignment",
".",
"Info",
">",
"getAssignments",
"(",
"String",
"type",
",",
"String",
"id",
",",
"int",
"limit",
",",
"String",
"...",
"fields",
")",
"{",
"QueryStringBuilder",
"builder",
"=",
"new",
"QueryStringBuilder",... | Returns iterable containing assignments for this single legal hold policy.
Parameters can be used to filter retrieved assignments.
@param type filter assignments of this type only.
Can be "file_version", "file", "folder", "user" or null if no type filter is necessary.
@param id filter assignments to this ID only. Can be null if no id filter is necessary.
@param limit the limit of entries per page. Default limit is 100.
@param fields the fields to retrieve.
@return an iterable containing assignments for this single legal hold policy. | [
"Returns",
"iterable",
"containing",
"assignments",
"for",
"this",
"single",
"legal",
"hold",
"policy",
".",
"Parameters",
"can",
"be",
"used",
"to",
"filter",
"retrieved",
"assignments",
"."
] | 35b4ba69417f9d6a002c19dfaab57527750ef349 | https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxLegalHoldPolicy.java#L224-L246 | train |
box/box-java-sdk | src/main/java/com/box/sdk/BoxLegalHoldPolicy.java | BoxLegalHoldPolicy.getFileVersionHolds | public Iterable<BoxFileVersionLegalHold.Info> getFileVersionHolds(int limit, String ... fields) {
QueryStringBuilder queryString = new QueryStringBuilder().appendParam("policy_id", this.getID());
if (fields.length > 0) {
queryString.appendParam("fields", fields);
}
URL url = LIST_OF_FILE_VERSION_HOLDS_URL_TEMPLATE.buildWithQuery(getAPI().getBaseURL(), queryString.toString());
return new BoxResourceIterable<BoxFileVersionLegalHold.Info>(getAPI(), url, limit) {
@Override
protected BoxFileVersionLegalHold.Info factory(JsonObject jsonObject) {
BoxFileVersionLegalHold assignment
= new BoxFileVersionLegalHold(getAPI(), jsonObject.get("id").asString());
return assignment.new Info(jsonObject);
}
};
} | java | public Iterable<BoxFileVersionLegalHold.Info> getFileVersionHolds(int limit, String ... fields) {
QueryStringBuilder queryString = new QueryStringBuilder().appendParam("policy_id", this.getID());
if (fields.length > 0) {
queryString.appendParam("fields", fields);
}
URL url = LIST_OF_FILE_VERSION_HOLDS_URL_TEMPLATE.buildWithQuery(getAPI().getBaseURL(), queryString.toString());
return new BoxResourceIterable<BoxFileVersionLegalHold.Info>(getAPI(), url, limit) {
@Override
protected BoxFileVersionLegalHold.Info factory(JsonObject jsonObject) {
BoxFileVersionLegalHold assignment
= new BoxFileVersionLegalHold(getAPI(), jsonObject.get("id").asString());
return assignment.new Info(jsonObject);
}
};
} | [
"public",
"Iterable",
"<",
"BoxFileVersionLegalHold",
".",
"Info",
">",
"getFileVersionHolds",
"(",
"int",
"limit",
",",
"String",
"...",
"fields",
")",
"{",
"QueryStringBuilder",
"queryString",
"=",
"new",
"QueryStringBuilder",
"(",
")",
".",
"appendParam",
"(",
... | Returns iterable with all non-deleted file version legal holds for this legal hold policy.
@param limit the limit of entries per response. The default value is 100.
@param fields the fields to retrieve.
@return an iterable containing file version legal holds info. | [
"Returns",
"iterable",
"with",
"all",
"non",
"-",
"deleted",
"file",
"version",
"legal",
"holds",
"for",
"this",
"legal",
"hold",
"policy",
"."
] | 35b4ba69417f9d6a002c19dfaab57527750ef349 | https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxLegalHoldPolicy.java#L263-L279 | train |
box/box-java-sdk | src/main/java/com/box/sdk/BoxFileVersionRetention.java | BoxFileVersionRetention.getAll | public static Iterable<BoxFileVersionRetention.Info> getAll(BoxAPIConnection api, String ... fields) {
return getRetentions(api, new QueryFilter(), fields);
} | java | public static Iterable<BoxFileVersionRetention.Info> getAll(BoxAPIConnection api, String ... fields) {
return getRetentions(api, new QueryFilter(), fields);
} | [
"public",
"static",
"Iterable",
"<",
"BoxFileVersionRetention",
".",
"Info",
">",
"getAll",
"(",
"BoxAPIConnection",
"api",
",",
"String",
"...",
"fields",
")",
"{",
"return",
"getRetentions",
"(",
"api",
",",
"new",
"QueryFilter",
"(",
")",
",",
"fields",
"... | Retrieves all file version retentions.
@param api the API connection to be used by the resource.
@param fields the fields to retrieve.
@return an iterable contains information about all file version retentions. | [
"Retrieves",
"all",
"file",
"version",
"retentions",
"."
] | 35b4ba69417f9d6a002c19dfaab57527750ef349 | https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxFileVersionRetention.java#L72-L74 | train |
box/box-java-sdk | src/main/java/com/box/sdk/BoxFileVersionRetention.java | BoxFileVersionRetention.getRetentions | public static Iterable<BoxFileVersionRetention.Info> getRetentions(
final BoxAPIConnection api, QueryFilter filter, String ... fields) {
filter.addFields(fields);
return new BoxResourceIterable<BoxFileVersionRetention.Info>(api,
ALL_RETENTIONS_URL_TEMPLATE.buildWithQuery(api.getBaseURL(), filter.toString()),
DEFAULT_LIMIT) {
@Override
protected BoxFileVersionRetention.Info factory(JsonObject jsonObject) {
BoxFileVersionRetention retention = new BoxFileVersionRetention(api, jsonObject.get("id").asString());
return retention.new Info(jsonObject);
}
};
} | java | public static Iterable<BoxFileVersionRetention.Info> getRetentions(
final BoxAPIConnection api, QueryFilter filter, String ... fields) {
filter.addFields(fields);
return new BoxResourceIterable<BoxFileVersionRetention.Info>(api,
ALL_RETENTIONS_URL_TEMPLATE.buildWithQuery(api.getBaseURL(), filter.toString()),
DEFAULT_LIMIT) {
@Override
protected BoxFileVersionRetention.Info factory(JsonObject jsonObject) {
BoxFileVersionRetention retention = new BoxFileVersionRetention(api, jsonObject.get("id").asString());
return retention.new Info(jsonObject);
}
};
} | [
"public",
"static",
"Iterable",
"<",
"BoxFileVersionRetention",
".",
"Info",
">",
"getRetentions",
"(",
"final",
"BoxAPIConnection",
"api",
",",
"QueryFilter",
"filter",
",",
"String",
"...",
"fields",
")",
"{",
"filter",
".",
"addFields",
"(",
"fields",
")",
... | Retrieves all file version retentions matching given filters as an Iterable.
@param api the API connection to be used by the resource.
@param filter filters for the query stored in QueryFilter object.
@param fields the fields to retrieve.
@return an iterable contains information about all file version retentions matching given filter. | [
"Retrieves",
"all",
"file",
"version",
"retentions",
"matching",
"given",
"filters",
"as",
"an",
"Iterable",
"."
] | 35b4ba69417f9d6a002c19dfaab57527750ef349 | https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxFileVersionRetention.java#L83-L96 | train |
box/box-java-sdk | src/main/java/com/box/sdk/BoxWebHookSignatureVerifier.java | BoxWebHookSignatureVerifier.verify | public boolean verify(String signatureVersion, String signatureAlgorithm, String primarySignature,
String secondarySignature, String webHookPayload, String deliveryTimestamp) {
// enforce versions supported by this implementation
if (!SUPPORTED_VERSIONS.contains(signatureVersion)) {
return false;
}
// enforce algorithms supported by this implementation
BoxSignatureAlgorithm algorithm = BoxSignatureAlgorithm.byName(signatureAlgorithm);
if (!SUPPORTED_ALGORITHMS.contains(algorithm)) {
return false;
}
// check primary key signature if primary key exists
if (this.primarySignatureKey != null && this.verify(this.primarySignatureKey, algorithm, primarySignature,
webHookPayload, deliveryTimestamp)) {
return true;
}
// check secondary key signature if secondary key exists
if (this.secondarySignatureKey != null && this.verify(this.secondarySignatureKey, algorithm, secondarySignature,
webHookPayload, deliveryTimestamp)) {
return true;
}
// default strategy is false, to minimize security issues
return false;
} | java | public boolean verify(String signatureVersion, String signatureAlgorithm, String primarySignature,
String secondarySignature, String webHookPayload, String deliveryTimestamp) {
// enforce versions supported by this implementation
if (!SUPPORTED_VERSIONS.contains(signatureVersion)) {
return false;
}
// enforce algorithms supported by this implementation
BoxSignatureAlgorithm algorithm = BoxSignatureAlgorithm.byName(signatureAlgorithm);
if (!SUPPORTED_ALGORITHMS.contains(algorithm)) {
return false;
}
// check primary key signature if primary key exists
if (this.primarySignatureKey != null && this.verify(this.primarySignatureKey, algorithm, primarySignature,
webHookPayload, deliveryTimestamp)) {
return true;
}
// check secondary key signature if secondary key exists
if (this.secondarySignatureKey != null && this.verify(this.secondarySignatureKey, algorithm, secondarySignature,
webHookPayload, deliveryTimestamp)) {
return true;
}
// default strategy is false, to minimize security issues
return false;
} | [
"public",
"boolean",
"verify",
"(",
"String",
"signatureVersion",
",",
"String",
"signatureAlgorithm",
",",
"String",
"primarySignature",
",",
"String",
"secondarySignature",
",",
"String",
"webHookPayload",
",",
"String",
"deliveryTimestamp",
")",
"{",
"// enforce vers... | Verifies given web-hook information.
@param signatureVersion
signature version received from web-hook
@param signatureAlgorithm
signature algorithm received from web-hook
@param primarySignature
primary signature received from web-hook
@param secondarySignature
secondary signature received from web-hook
@param webHookPayload
payload of web-hook
@param deliveryTimestamp
devilery timestamp received from web-hook
@return true, if given payload is successfully verified against primary and secondary signatures, false otherwise | [
"Verifies",
"given",
"web",
"-",
"hook",
"information",
"."
] | 35b4ba69417f9d6a002c19dfaab57527750ef349 | https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxWebHookSignatureVerifier.java#L93-L121 | train |
box/box-java-sdk | src/main/java/com/box/sdk/BoxWebHookSignatureVerifier.java | BoxWebHookSignatureVerifier.verify | private boolean verify(String key, BoxSignatureAlgorithm actualAlgorithm, String actualSignature,
String webHookPayload, String deliveryTimestamp) {
if (actualSignature == null) {
return false;
}
byte[] actual = Base64.decode(actualSignature);
byte[] expected = this.signRaw(actualAlgorithm, key, webHookPayload, deliveryTimestamp);
return Arrays.equals(expected, actual);
} | java | private boolean verify(String key, BoxSignatureAlgorithm actualAlgorithm, String actualSignature,
String webHookPayload, String deliveryTimestamp) {
if (actualSignature == null) {
return false;
}
byte[] actual = Base64.decode(actualSignature);
byte[] expected = this.signRaw(actualAlgorithm, key, webHookPayload, deliveryTimestamp);
return Arrays.equals(expected, actual);
} | [
"private",
"boolean",
"verify",
"(",
"String",
"key",
",",
"BoxSignatureAlgorithm",
"actualAlgorithm",
",",
"String",
"actualSignature",
",",
"String",
"webHookPayload",
",",
"String",
"deliveryTimestamp",
")",
"{",
"if",
"(",
"actualSignature",
"==",
"null",
")",
... | Verifies a provided signature.
@param key
for which signature key
@param actualAlgorithm
current signature algorithm
@param actualSignature
current signature
@param webHookPayload
for signing
@param deliveryTimestamp
for signing
@return true if verification passed | [
"Verifies",
"a",
"provided",
"signature",
"."
] | 35b4ba69417f9d6a002c19dfaab57527750ef349 | https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxWebHookSignatureVerifier.java#L138-L148 | train |
box/box-java-sdk | src/main/java/com/box/sdk/BoxSearch.java | BoxSearch.searchRange | public PartialCollection<BoxItem.Info> searchRange(long offset, long limit, final BoxSearchParameters bsp) {
QueryStringBuilder builder = bsp.getQueryParameters()
.appendParam("limit", limit)
.appendParam("offset", offset);
URL url = SEARCH_URL_TEMPLATE.buildWithQuery(this.getAPI().getBaseURL(), builder.toString());
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> results = new PartialCollection<BoxItem.Info>(offset, limit, fullSize);
JsonArray jsonArray = responseJSON.get("entries").asArray();
for (JsonValue value : jsonArray) {
JsonObject jsonObject = value.asObject();
BoxItem.Info parsedItemInfo = (BoxItem.Info) BoxResource.parseInfo(this.getAPI(), jsonObject);
if (parsedItemInfo != null) {
results.add(parsedItemInfo);
}
}
return results;
} | java | public PartialCollection<BoxItem.Info> searchRange(long offset, long limit, final BoxSearchParameters bsp) {
QueryStringBuilder builder = bsp.getQueryParameters()
.appendParam("limit", limit)
.appendParam("offset", offset);
URL url = SEARCH_URL_TEMPLATE.buildWithQuery(this.getAPI().getBaseURL(), builder.toString());
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> results = new PartialCollection<BoxItem.Info>(offset, limit, fullSize);
JsonArray jsonArray = responseJSON.get("entries").asArray();
for (JsonValue value : jsonArray) {
JsonObject jsonObject = value.asObject();
BoxItem.Info parsedItemInfo = (BoxItem.Info) BoxResource.parseInfo(this.getAPI(), jsonObject);
if (parsedItemInfo != null) {
results.add(parsedItemInfo);
}
}
return results;
} | [
"public",
"PartialCollection",
"<",
"BoxItem",
".",
"Info",
">",
"searchRange",
"(",
"long",
"offset",
",",
"long",
"limit",
",",
"final",
"BoxSearchParameters",
"bsp",
")",
"{",
"QueryStringBuilder",
"builder",
"=",
"bsp",
".",
"getQueryParameters",
"(",
")",
... | Searches all descendant folders using a given query and query parameters.
@param offset is the starting position.
@param limit the maximum number of items to return. The default is 30 and the maximum is 200.
@param bsp containing query and advanced search capabilities.
@return a PartialCollection containing the search results. | [
"Searches",
"all",
"descendant",
"folders",
"using",
"a",
"given",
"query",
"and",
"query",
"parameters",
"."
] | 35b4ba69417f9d6a002c19dfaab57527750ef349 | https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxSearch.java#L38-L58 | train |
box/box-java-sdk | src/main/java/com/box/sdk/BoxTransactionalAPIConnection.java | BoxTransactionalAPIConnection.getTransactionConnection | public static BoxAPIConnection getTransactionConnection(String accessToken, String scope) {
return BoxTransactionalAPIConnection.getTransactionConnection(accessToken, scope, null);
} | java | public static BoxAPIConnection getTransactionConnection(String accessToken, String scope) {
return BoxTransactionalAPIConnection.getTransactionConnection(accessToken, scope, null);
} | [
"public",
"static",
"BoxAPIConnection",
"getTransactionConnection",
"(",
"String",
"accessToken",
",",
"String",
"scope",
")",
"{",
"return",
"BoxTransactionalAPIConnection",
".",
"getTransactionConnection",
"(",
"accessToken",
",",
"scope",
",",
"null",
")",
";",
"}"... | Request a scoped transactional token.
@param accessToken application access token.
@param scope scope of transactional token.
@return a BoxAPIConnection which can be used to perform transactional requests. | [
"Request",
"a",
"scoped",
"transactional",
"token",
"."
] | 35b4ba69417f9d6a002c19dfaab57527750ef349 | https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxTransactionalAPIConnection.java#L35-L37 | train |
box/box-java-sdk | src/main/java/com/box/sdk/BoxTransactionalAPIConnection.java | BoxTransactionalAPIConnection.getTransactionConnection | public static BoxAPIConnection getTransactionConnection(String accessToken, String scope, String resource) {
BoxAPIConnection apiConnection = new BoxAPIConnection(accessToken);
URL url;
try {
url = new URL(apiConnection.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 urlParameters;
try {
urlParameters = String.format("grant_type=%s&subject_token=%s&subject_token_type=%s&scope=%s", GRANT_TYPE,
URLEncoder.encode(accessToken, "UTF-8"), SUBJECT_TOKEN_TYPE, URLEncoder.encode(scope, "UTF-8"));
if (resource != null) {
urlParameters += "&resource=" + URLEncoder.encode(resource, "UTF-8");
}
} catch (UnsupportedEncodingException e) {
throw new BoxAPIException(
"An error occurred while attempting to encode url parameters for a transactional token request"
);
}
BoxAPIRequest request = new BoxAPIRequest(apiConnection, url, "POST");
request.shouldAuthenticate(false);
request.setBody(urlParameters);
BoxJSONResponse response = (BoxJSONResponse) request.send();
JsonObject responseJSON = JsonObject.readFrom(response.getJSON());
final String fileToken = responseJSON.get("access_token").asString();
BoxTransactionalAPIConnection transactionConnection = new BoxTransactionalAPIConnection(fileToken);
transactionConnection.setExpires(responseJSON.get("expires_in").asLong() * 1000);
return transactionConnection;
} | java | public static BoxAPIConnection getTransactionConnection(String accessToken, String scope, String resource) {
BoxAPIConnection apiConnection = new BoxAPIConnection(accessToken);
URL url;
try {
url = new URL(apiConnection.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 urlParameters;
try {
urlParameters = String.format("grant_type=%s&subject_token=%s&subject_token_type=%s&scope=%s", GRANT_TYPE,
URLEncoder.encode(accessToken, "UTF-8"), SUBJECT_TOKEN_TYPE, URLEncoder.encode(scope, "UTF-8"));
if (resource != null) {
urlParameters += "&resource=" + URLEncoder.encode(resource, "UTF-8");
}
} catch (UnsupportedEncodingException e) {
throw new BoxAPIException(
"An error occurred while attempting to encode url parameters for a transactional token request"
);
}
BoxAPIRequest request = new BoxAPIRequest(apiConnection, url, "POST");
request.shouldAuthenticate(false);
request.setBody(urlParameters);
BoxJSONResponse response = (BoxJSONResponse) request.send();
JsonObject responseJSON = JsonObject.readFrom(response.getJSON());
final String fileToken = responseJSON.get("access_token").asString();
BoxTransactionalAPIConnection transactionConnection = new BoxTransactionalAPIConnection(fileToken);
transactionConnection.setExpires(responseJSON.get("expires_in").asLong() * 1000);
return transactionConnection;
} | [
"public",
"static",
"BoxAPIConnection",
"getTransactionConnection",
"(",
"String",
"accessToken",
",",
"String",
"scope",
",",
"String",
"resource",
")",
"{",
"BoxAPIConnection",
"apiConnection",
"=",
"new",
"BoxAPIConnection",
"(",
"accessToken",
")",
";",
"URL",
"... | Request a scoped transactional token for a particular resource.
@param accessToken application access token.
@param scope scope of transactional token.
@param resource resource transactional token has access to.
@return a BoxAPIConnection which can be used to perform transactional requests. | [
"Request",
"a",
"scoped",
"transactional",
"token",
"for",
"a",
"particular",
"resource",
"."
] | 35b4ba69417f9d6a002c19dfaab57527750ef349 | https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxTransactionalAPIConnection.java#L46-L83 | train |
box/box-java-sdk | src/main/java/com/box/sdk/BoxItem.java | BoxItem.getSharedItem | public static BoxItem.Info getSharedItem(BoxAPIConnection api, String sharedLink) {
return getSharedItem(api, sharedLink, null);
} | java | public static BoxItem.Info getSharedItem(BoxAPIConnection api, String sharedLink) {
return getSharedItem(api, sharedLink, null);
} | [
"public",
"static",
"BoxItem",
".",
"Info",
"getSharedItem",
"(",
"BoxAPIConnection",
"api",
",",
"String",
"sharedLink",
")",
"{",
"return",
"getSharedItem",
"(",
"api",
",",
"sharedLink",
",",
"null",
")",
";",
"}"
] | Gets an item that was shared with a shared link.
@param api the API connection to be used by the shared item.
@param sharedLink the shared link to the item.
@return info about the shared item. | [
"Gets",
"an",
"item",
"that",
"was",
"shared",
"with",
"a",
"shared",
"link",
"."
] | 35b4ba69417f9d6a002c19dfaab57527750ef349 | https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxItem.java#L60-L62 | train |
box/box-java-sdk | src/main/java/com/box/sdk/BoxItem.java | BoxItem.getSharedItem | public static BoxItem.Info getSharedItem(BoxAPIConnection api, String sharedLink, String password) {
BoxAPIConnection newAPI = new SharedLinkAPIConnection(api, sharedLink, password);
URL url = SHARED_ITEM_URL_TEMPLATE.build(newAPI.getBaseURL());
BoxAPIRequest request = new BoxAPIRequest(newAPI, url, "GET");
BoxJSONResponse response = (BoxJSONResponse) request.send();
JsonObject json = JsonObject.readFrom(response.getJSON());
return (BoxItem.Info) BoxResource.parseInfo(newAPI, json);
} | java | public static BoxItem.Info getSharedItem(BoxAPIConnection api, String sharedLink, String password) {
BoxAPIConnection newAPI = new SharedLinkAPIConnection(api, sharedLink, password);
URL url = SHARED_ITEM_URL_TEMPLATE.build(newAPI.getBaseURL());
BoxAPIRequest request = new BoxAPIRequest(newAPI, url, "GET");
BoxJSONResponse response = (BoxJSONResponse) request.send();
JsonObject json = JsonObject.readFrom(response.getJSON());
return (BoxItem.Info) BoxResource.parseInfo(newAPI, json);
} | [
"public",
"static",
"BoxItem",
".",
"Info",
"getSharedItem",
"(",
"BoxAPIConnection",
"api",
",",
"String",
"sharedLink",
",",
"String",
"password",
")",
"{",
"BoxAPIConnection",
"newAPI",
"=",
"new",
"SharedLinkAPIConnection",
"(",
"api",
",",
"sharedLink",
",",
... | Gets an item that was shared with a password-protected shared link.
@param api the API connection to be used by the shared item.
@param sharedLink the shared link to the item.
@param password the password for the shared link.
@return info about the shared item. | [
"Gets",
"an",
"item",
"that",
"was",
"shared",
"with",
"a",
"password",
"-",
"protected",
"shared",
"link",
"."
] | 35b4ba69417f9d6a002c19dfaab57527750ef349 | https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxItem.java#L71-L78 | train |
box/box-java-sdk | src/main/java/com/box/sdk/BoxItem.java | BoxItem.getWatermark | protected BoxWatermark getWatermark(URLTemplate itemUrl, String... fields) {
URL watermarkUrl = itemUrl.build(this.getAPI().getBaseURL(), this.getID());
QueryStringBuilder builder = new QueryStringBuilder();
if (fields.length > 0) {
builder.appendParam("fields", fields);
}
URL url = WATERMARK_URL_TEMPLATE.buildWithQuery(watermarkUrl.toString(), builder.toString());
BoxAPIRequest request = new BoxAPIRequest(this.getAPI(), url, "GET");
BoxJSONResponse response = (BoxJSONResponse) request.send();
return new BoxWatermark(response.getJSON());
} | java | protected BoxWatermark getWatermark(URLTemplate itemUrl, String... fields) {
URL watermarkUrl = itemUrl.build(this.getAPI().getBaseURL(), this.getID());
QueryStringBuilder builder = new QueryStringBuilder();
if (fields.length > 0) {
builder.appendParam("fields", fields);
}
URL url = WATERMARK_URL_TEMPLATE.buildWithQuery(watermarkUrl.toString(), builder.toString());
BoxAPIRequest request = new BoxAPIRequest(this.getAPI(), url, "GET");
BoxJSONResponse response = (BoxJSONResponse) request.send();
return new BoxWatermark(response.getJSON());
} | [
"protected",
"BoxWatermark",
"getWatermark",
"(",
"URLTemplate",
"itemUrl",
",",
"String",
"...",
"fields",
")",
"{",
"URL",
"watermarkUrl",
"=",
"itemUrl",
".",
"build",
"(",
"this",
".",
"getAPI",
"(",
")",
".",
"getBaseURL",
"(",
")",
",",
"this",
".",
... | Used to retrieve the watermark for the item.
If the item does not have a watermark applied to it, a 404 Not Found will be returned by API.
@param itemUrl url template for the item.
@param fields the fields to retrieve.
@return the watermark associated with the item. | [
"Used",
"to",
"retrieve",
"the",
"watermark",
"for",
"the",
"item",
".",
"If",
"the",
"item",
"does",
"not",
"have",
"a",
"watermark",
"applied",
"to",
"it",
"a",
"404",
"Not",
"Found",
"will",
"be",
"returned",
"by",
"API",
"."
] | 35b4ba69417f9d6a002c19dfaab57527750ef349 | https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxItem.java#L87-L97 | train |
box/box-java-sdk | src/main/java/com/box/sdk/BoxItem.java | BoxItem.applyWatermark | protected BoxWatermark applyWatermark(URLTemplate itemUrl, String imprint) {
URL watermarkUrl = itemUrl.build(this.getAPI().getBaseURL(), this.getID());
URL url = WATERMARK_URL_TEMPLATE.build(watermarkUrl.toString());
BoxJSONRequest request = new BoxJSONRequest(this.getAPI(), url, "PUT");
JsonObject body = new JsonObject()
.add(BoxWatermark.WATERMARK_JSON_KEY, new JsonObject()
.add(BoxWatermark.WATERMARK_IMPRINT_JSON_KEY, imprint));
request.setBody(body.toString());
BoxJSONResponse response = (BoxJSONResponse) request.send();
return new BoxWatermark(response.getJSON());
} | java | protected BoxWatermark applyWatermark(URLTemplate itemUrl, String imprint) {
URL watermarkUrl = itemUrl.build(this.getAPI().getBaseURL(), this.getID());
URL url = WATERMARK_URL_TEMPLATE.build(watermarkUrl.toString());
BoxJSONRequest request = new BoxJSONRequest(this.getAPI(), url, "PUT");
JsonObject body = new JsonObject()
.add(BoxWatermark.WATERMARK_JSON_KEY, new JsonObject()
.add(BoxWatermark.WATERMARK_IMPRINT_JSON_KEY, imprint));
request.setBody(body.toString());
BoxJSONResponse response = (BoxJSONResponse) request.send();
return new BoxWatermark(response.getJSON());
} | [
"protected",
"BoxWatermark",
"applyWatermark",
"(",
"URLTemplate",
"itemUrl",
",",
"String",
"imprint",
")",
"{",
"URL",
"watermarkUrl",
"=",
"itemUrl",
".",
"build",
"(",
"this",
".",
"getAPI",
"(",
")",
".",
"getBaseURL",
"(",
")",
",",
"this",
".",
"get... | Used to apply or update the watermark for the item.
@param itemUrl url template for the item.
@param imprint the value must be "default", as custom watermarks is not yet supported.
@return the watermark associated with the item. | [
"Used",
"to",
"apply",
"or",
"update",
"the",
"watermark",
"for",
"the",
"item",
"."
] | 35b4ba69417f9d6a002c19dfaab57527750ef349 | https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxItem.java#L105-L115 | train |
box/box-java-sdk | src/main/java/com/box/sdk/BoxItem.java | BoxItem.removeWatermark | protected void removeWatermark(URLTemplate itemUrl) {
URL watermarkUrl = itemUrl.build(this.getAPI().getBaseURL(), this.getID());
URL url = WATERMARK_URL_TEMPLATE.build(watermarkUrl.toString());
BoxAPIRequest request = new BoxAPIRequest(this.getAPI(), url, "DELETE");
BoxAPIResponse response = request.send();
response.disconnect();
} | java | protected void removeWatermark(URLTemplate itemUrl) {
URL watermarkUrl = itemUrl.build(this.getAPI().getBaseURL(), this.getID());
URL url = WATERMARK_URL_TEMPLATE.build(watermarkUrl.toString());
BoxAPIRequest request = new BoxAPIRequest(this.getAPI(), url, "DELETE");
BoxAPIResponse response = request.send();
response.disconnect();
} | [
"protected",
"void",
"removeWatermark",
"(",
"URLTemplate",
"itemUrl",
")",
"{",
"URL",
"watermarkUrl",
"=",
"itemUrl",
".",
"build",
"(",
"this",
".",
"getAPI",
"(",
")",
".",
"getBaseURL",
"(",
")",
",",
"this",
".",
"getID",
"(",
")",
")",
";",
"URL... | Removes a watermark from the item.
If the item did not have a watermark applied to it, a 404 Not Found will be returned by API.
@param itemUrl url template for the item. | [
"Removes",
"a",
"watermark",
"from",
"the",
"item",
".",
"If",
"the",
"item",
"did",
"not",
"have",
"a",
"watermark",
"applied",
"to",
"it",
"a",
"404",
"Not",
"Found",
"will",
"be",
"returned",
"by",
"API",
"."
] | 35b4ba69417f9d6a002c19dfaab57527750ef349 | https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxItem.java#L122-L128 | train |
box/box-java-sdk | src/main/java/com/box/sdk/BoxFileVersion.java | BoxFileVersion.parseJSON | private void parseJSON(JsonObject jsonObject) {
for (JsonObject.Member member : jsonObject) {
JsonValue value = member.getValue();
if (value.isNull()) {
continue;
}
try {
String memberName = member.getName();
if (memberName.equals("id")) {
this.versionID = value.asString();
} else if (memberName.equals("sha1")) {
this.sha1 = value.asString();
} else if (memberName.equals("name")) {
this.name = value.asString();
} else if (memberName.equals("size")) {
this.size = Double.valueOf(value.toString()).longValue();
} else if (memberName.equals("created_at")) {
this.createdAt = BoxDateFormat.parse(value.asString());
} else if (memberName.equals("modified_at")) {
this.modifiedAt = BoxDateFormat.parse(value.asString());
} else if (memberName.equals("trashed_at")) {
this.trashedAt = BoxDateFormat.parse(value.asString());
} else if (memberName.equals("modified_by")) {
JsonObject userJSON = value.asObject();
String userID = userJSON.get("id").asString();
BoxUser user = new BoxUser(getAPI(), userID);
this.modifiedBy = user.new Info(userJSON);
}
} catch (ParseException e) {
assert false : "A ParseException indicates a bug in the SDK.";
}
}
} | java | private void parseJSON(JsonObject jsonObject) {
for (JsonObject.Member member : jsonObject) {
JsonValue value = member.getValue();
if (value.isNull()) {
continue;
}
try {
String memberName = member.getName();
if (memberName.equals("id")) {
this.versionID = value.asString();
} else if (memberName.equals("sha1")) {
this.sha1 = value.asString();
} else if (memberName.equals("name")) {
this.name = value.asString();
} else if (memberName.equals("size")) {
this.size = Double.valueOf(value.toString()).longValue();
} else if (memberName.equals("created_at")) {
this.createdAt = BoxDateFormat.parse(value.asString());
} else if (memberName.equals("modified_at")) {
this.modifiedAt = BoxDateFormat.parse(value.asString());
} else if (memberName.equals("trashed_at")) {
this.trashedAt = BoxDateFormat.parse(value.asString());
} else if (memberName.equals("modified_by")) {
JsonObject userJSON = value.asObject();
String userID = userJSON.get("id").asString();
BoxUser user = new BoxUser(getAPI(), userID);
this.modifiedBy = user.new Info(userJSON);
}
} catch (ParseException e) {
assert false : "A ParseException indicates a bug in the SDK.";
}
}
} | [
"private",
"void",
"parseJSON",
"(",
"JsonObject",
"jsonObject",
")",
"{",
"for",
"(",
"JsonObject",
".",
"Member",
"member",
":",
"jsonObject",
")",
"{",
"JsonValue",
"value",
"=",
"member",
".",
"getValue",
"(",
")",
";",
"if",
"(",
"value",
".",
"isNu... | Method used to update fields with values received from API.
@param jsonObject JSON-encoded info about File Version object. | [
"Method",
"used",
"to",
"update",
"fields",
"with",
"values",
"received",
"from",
"API",
"."
] | 35b4ba69417f9d6a002c19dfaab57527750ef349 | https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxFileVersion.java#L60-L93 | train |
box/box-java-sdk | src/main/java/com/box/sdk/BoxFileVersion.java | BoxFileVersion.download | public void download(OutputStream output, ProgressListener listener) {
URL url = CONTENT_URL_TEMPLATE.build(this.getAPI().getBaseURL(), this.fileID, this.getID());
BoxAPIRequest request = new BoxAPIRequest(this.getAPI(), url, "GET");
BoxAPIResponse response = request.send();
InputStream input = response.getBody(listener);
long totalRead = 0;
byte[] buffer = new byte[BUFFER_SIZE];
try {
int n = input.read(buffer);
totalRead += n;
while (n != -1) {
output.write(buffer, 0, n);
n = input.read(buffer);
totalRead += n;
}
} catch (IOException e) {
throw new BoxAPIException("Couldn't connect to the Box API due to a network error.", e);
}
response.disconnect();
} | java | public void download(OutputStream output, ProgressListener listener) {
URL url = CONTENT_URL_TEMPLATE.build(this.getAPI().getBaseURL(), this.fileID, this.getID());
BoxAPIRequest request = new BoxAPIRequest(this.getAPI(), url, "GET");
BoxAPIResponse response = request.send();
InputStream input = response.getBody(listener);
long totalRead = 0;
byte[] buffer = new byte[BUFFER_SIZE];
try {
int n = input.read(buffer);
totalRead += n;
while (n != -1) {
output.write(buffer, 0, n);
n = input.read(buffer);
totalRead += n;
}
} catch (IOException e) {
throw new BoxAPIException("Couldn't connect to the Box API due to a network error.", e);
}
response.disconnect();
} | [
"public",
"void",
"download",
"(",
"OutputStream",
"output",
",",
"ProgressListener",
"listener",
")",
"{",
"URL",
"url",
"=",
"CONTENT_URL_TEMPLATE",
".",
"build",
"(",
"this",
".",
"getAPI",
"(",
")",
".",
"getBaseURL",
"(",
")",
",",
"this",
".",
"fileI... | Downloads this version of the file to a given OutputStream while reporting the progress to a ProgressListener.
@param output the stream to where the file will be written.
@param listener a listener for monitoring the download's progress. | [
"Downloads",
"this",
"version",
"of",
"the",
"file",
"to",
"a",
"given",
"OutputStream",
"while",
"reporting",
"the",
"progress",
"to",
"a",
"ProgressListener",
"."
] | 35b4ba69417f9d6a002c19dfaab57527750ef349 | https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxFileVersion.java#L197-L218 | train |
box/box-java-sdk | src/main/java/com/box/sdk/BoxFileVersion.java | BoxFileVersion.promote | public void promote() {
URL url = VERSION_URL_TEMPLATE.build(this.getAPI().getBaseURL(), this.fileID, "current");
JsonObject jsonObject = new JsonObject();
jsonObject.add("type", "file_version");
jsonObject.add("id", this.getID());
BoxJSONRequest request = new BoxJSONRequest(this.getAPI(), url, "POST");
request.setBody(jsonObject.toString());
BoxJSONResponse response = (BoxJSONResponse) request.send();
this.parseJSON(JsonObject.readFrom(response.getJSON()));
} | java | public void promote() {
URL url = VERSION_URL_TEMPLATE.build(this.getAPI().getBaseURL(), this.fileID, "current");
JsonObject jsonObject = new JsonObject();
jsonObject.add("type", "file_version");
jsonObject.add("id", this.getID());
BoxJSONRequest request = new BoxJSONRequest(this.getAPI(), url, "POST");
request.setBody(jsonObject.toString());
BoxJSONResponse response = (BoxJSONResponse) request.send();
this.parseJSON(JsonObject.readFrom(response.getJSON()));
} | [
"public",
"void",
"promote",
"(",
")",
"{",
"URL",
"url",
"=",
"VERSION_URL_TEMPLATE",
".",
"build",
"(",
"this",
".",
"getAPI",
"(",
")",
".",
"getBaseURL",
"(",
")",
",",
"this",
".",
"fileID",
",",
"\"current\"",
")",
";",
"JsonObject",
"jsonObject",
... | Promotes this version of the file to be the latest version. | [
"Promotes",
"this",
"version",
"of",
"the",
"file",
"to",
"be",
"the",
"latest",
"version",
"."
] | 35b4ba69417f9d6a002c19dfaab57527750ef349 | https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxFileVersion.java#L223-L234 | train |
box/box-java-sdk | src/main/java/com/box/sdk/BoxUser.java | BoxUser.createAppUser | public static BoxUser.Info createAppUser(BoxAPIConnection api, String name) {
return createAppUser(api, name, new CreateUserParams());
} | java | public static BoxUser.Info createAppUser(BoxAPIConnection api, String name) {
return createAppUser(api, name, new CreateUserParams());
} | [
"public",
"static",
"BoxUser",
".",
"Info",
"createAppUser",
"(",
"BoxAPIConnection",
"api",
",",
"String",
"name",
")",
"{",
"return",
"createAppUser",
"(",
"api",
",",
"name",
",",
"new",
"CreateUserParams",
"(",
")",
")",
";",
"}"
] | Provisions a new app user in an enterprise using Box Developer Edition.
@param api the API connection to be used by the created user.
@param name the name of the user.
@return the created user's info. | [
"Provisions",
"a",
"new",
"app",
"user",
"in",
"an",
"enterprise",
"using",
"Box",
"Developer",
"Edition",
"."
] | 35b4ba69417f9d6a002c19dfaab57527750ef349 | https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxUser.java#L83-L85 | train |
box/box-java-sdk | src/main/java/com/box/sdk/BoxUser.java | BoxUser.createAppUser | public static BoxUser.Info createAppUser(BoxAPIConnection api, String name,
CreateUserParams params) {
params.setIsPlatformAccessOnly(true);
return createEnterpriseUser(api, null, name, params);
} | java | public static BoxUser.Info createAppUser(BoxAPIConnection api, String name,
CreateUserParams params) {
params.setIsPlatformAccessOnly(true);
return createEnterpriseUser(api, null, name, params);
} | [
"public",
"static",
"BoxUser",
".",
"Info",
"createAppUser",
"(",
"BoxAPIConnection",
"api",
",",
"String",
"name",
",",
"CreateUserParams",
"params",
")",
"{",
"params",
".",
"setIsPlatformAccessOnly",
"(",
"true",
")",
";",
"return",
"createEnterpriseUser",
"(",... | Provisions a new app user in an enterprise with additional user information using Box Developer Edition.
@param api the API connection to be used by the created user.
@param name the name of the user.
@param params additional user information.
@return the created user's info. | [
"Provisions",
"a",
"new",
"app",
"user",
"in",
"an",
"enterprise",
"with",
"additional",
"user",
"information",
"using",
"Box",
"Developer",
"Edition",
"."
] | 35b4ba69417f9d6a002c19dfaab57527750ef349 | https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxUser.java#L94-L99 | train |
box/box-java-sdk | src/main/java/com/box/sdk/BoxUser.java | BoxUser.createEnterpriseUser | public static BoxUser.Info createEnterpriseUser(BoxAPIConnection api, String login, String name) {
return createEnterpriseUser(api, login, name, null);
} | java | public static BoxUser.Info createEnterpriseUser(BoxAPIConnection api, String login, String name) {
return createEnterpriseUser(api, login, name, null);
} | [
"public",
"static",
"BoxUser",
".",
"Info",
"createEnterpriseUser",
"(",
"BoxAPIConnection",
"api",
",",
"String",
"login",
",",
"String",
"name",
")",
"{",
"return",
"createEnterpriseUser",
"(",
"api",
",",
"login",
",",
"name",
",",
"null",
")",
";",
"}"
] | Provisions a new user in an enterprise.
@param api the API connection to be used by the created user.
@param login the email address the user will use to login.
@param name the name of the user.
@return the created user's info. | [
"Provisions",
"a",
"new",
"user",
"in",
"an",
"enterprise",
"."
] | 35b4ba69417f9d6a002c19dfaab57527750ef349 | https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxUser.java#L108-L110 | train |
box/box-java-sdk | src/main/java/com/box/sdk/BoxUser.java | BoxUser.createEnterpriseUser | public static BoxUser.Info createEnterpriseUser(BoxAPIConnection api, String login, String name,
CreateUserParams params) {
JsonObject requestJSON = new JsonObject();
requestJSON.add("login", login);
requestJSON.add("name", name);
if (params != null) {
if (params.getRole() != null) {
requestJSON.add("role", params.getRole().toJSONValue());
}
if (params.getStatus() != null) {
requestJSON.add("status", params.getStatus().toJSONValue());
}
requestJSON.add("language", params.getLanguage());
requestJSON.add("is_sync_enabled", params.getIsSyncEnabled());
requestJSON.add("job_title", params.getJobTitle());
requestJSON.add("phone", params.getPhone());
requestJSON.add("address", params.getAddress());
requestJSON.add("space_amount", params.getSpaceAmount());
requestJSON.add("can_see_managed_users", params.getCanSeeManagedUsers());
requestJSON.add("timezone", params.getTimezone());
requestJSON.add("is_exempt_from_device_limits", params.getIsExemptFromDeviceLimits());
requestJSON.add("is_exempt_from_login_verification", params.getIsExemptFromLoginVerification());
requestJSON.add("is_platform_access_only", params.getIsPlatformAccessOnly());
requestJSON.add("external_app_user_id", params.getExternalAppUserId());
}
URL url = USERS_URL_TEMPLATE.build(api.getBaseURL());
BoxJSONRequest request = new BoxJSONRequest(api, url, "POST");
request.setBody(requestJSON.toString());
BoxJSONResponse response = (BoxJSONResponse) request.send();
JsonObject responseJSON = JsonObject.readFrom(response.getJSON());
BoxUser createdUser = new BoxUser(api, responseJSON.get("id").asString());
return createdUser.new Info(responseJSON);
} | java | public static BoxUser.Info createEnterpriseUser(BoxAPIConnection api, String login, String name,
CreateUserParams params) {
JsonObject requestJSON = new JsonObject();
requestJSON.add("login", login);
requestJSON.add("name", name);
if (params != null) {
if (params.getRole() != null) {
requestJSON.add("role", params.getRole().toJSONValue());
}
if (params.getStatus() != null) {
requestJSON.add("status", params.getStatus().toJSONValue());
}
requestJSON.add("language", params.getLanguage());
requestJSON.add("is_sync_enabled", params.getIsSyncEnabled());
requestJSON.add("job_title", params.getJobTitle());
requestJSON.add("phone", params.getPhone());
requestJSON.add("address", params.getAddress());
requestJSON.add("space_amount", params.getSpaceAmount());
requestJSON.add("can_see_managed_users", params.getCanSeeManagedUsers());
requestJSON.add("timezone", params.getTimezone());
requestJSON.add("is_exempt_from_device_limits", params.getIsExemptFromDeviceLimits());
requestJSON.add("is_exempt_from_login_verification", params.getIsExemptFromLoginVerification());
requestJSON.add("is_platform_access_only", params.getIsPlatformAccessOnly());
requestJSON.add("external_app_user_id", params.getExternalAppUserId());
}
URL url = USERS_URL_TEMPLATE.build(api.getBaseURL());
BoxJSONRequest request = new BoxJSONRequest(api, url, "POST");
request.setBody(requestJSON.toString());
BoxJSONResponse response = (BoxJSONResponse) request.send();
JsonObject responseJSON = JsonObject.readFrom(response.getJSON());
BoxUser createdUser = new BoxUser(api, responseJSON.get("id").asString());
return createdUser.new Info(responseJSON);
} | [
"public",
"static",
"BoxUser",
".",
"Info",
"createEnterpriseUser",
"(",
"BoxAPIConnection",
"api",
",",
"String",
"login",
",",
"String",
"name",
",",
"CreateUserParams",
"params",
")",
"{",
"JsonObject",
"requestJSON",
"=",
"new",
"JsonObject",
"(",
")",
";",
... | Provisions a new user in an enterprise with additional user information.
@param api the API connection to be used by the created user.
@param login the email address the user will use to login.
@param name the name of the user.
@param params additional user information.
@return the created user's info. | [
"Provisions",
"a",
"new",
"user",
"in",
"an",
"enterprise",
"with",
"additional",
"user",
"information",
"."
] | 35b4ba69417f9d6a002c19dfaab57527750ef349 | https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxUser.java#L120-L158 | train |
box/box-java-sdk | src/main/java/com/box/sdk/BoxUser.java | BoxUser.getCurrentUser | public static BoxUser getCurrentUser(BoxAPIConnection api) {
URL url = GET_ME_URL.build(api.getBaseURL());
BoxAPIRequest request = new BoxAPIRequest(api, url, "GET");
BoxJSONResponse response = (BoxJSONResponse) request.send();
JsonObject jsonObject = JsonObject.readFrom(response.getJSON());
return new BoxUser(api, jsonObject.get("id").asString());
} | java | public static BoxUser getCurrentUser(BoxAPIConnection api) {
URL url = GET_ME_URL.build(api.getBaseURL());
BoxAPIRequest request = new BoxAPIRequest(api, url, "GET");
BoxJSONResponse response = (BoxJSONResponse) request.send();
JsonObject jsonObject = JsonObject.readFrom(response.getJSON());
return new BoxUser(api, jsonObject.get("id").asString());
} | [
"public",
"static",
"BoxUser",
"getCurrentUser",
"(",
"BoxAPIConnection",
"api",
")",
"{",
"URL",
"url",
"=",
"GET_ME_URL",
".",
"build",
"(",
"api",
".",
"getBaseURL",
"(",
")",
")",
";",
"BoxAPIRequest",
"request",
"=",
"new",
"BoxAPIRequest",
"(",
"api",
... | Gets the current user.
@param api the API connection of the current user.
@return the current user. | [
"Gets",
"the",
"current",
"user",
"."
] | 35b4ba69417f9d6a002c19dfaab57527750ef349 | https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxUser.java#L165-L171 | train |
box/box-java-sdk | src/main/java/com/box/sdk/BoxUser.java | BoxUser.getAllEnterpriseUsers | public static Iterable<BoxUser.Info> getAllEnterpriseUsers(final BoxAPIConnection api, final String filterTerm,
final String... fields) {
return getUsersInfoForType(api, filterTerm, null, null, fields);
} | java | public static Iterable<BoxUser.Info> getAllEnterpriseUsers(final BoxAPIConnection api, final String filterTerm,
final String... fields) {
return getUsersInfoForType(api, filterTerm, null, null, fields);
} | [
"public",
"static",
"Iterable",
"<",
"BoxUser",
".",
"Info",
">",
"getAllEnterpriseUsers",
"(",
"final",
"BoxAPIConnection",
"api",
",",
"final",
"String",
"filterTerm",
",",
"final",
"String",
"...",
"fields",
")",
"{",
"return",
"getUsersInfoForType",
"(",
"ap... | Returns an iterable containing all the enterprise users that matches the filter and specifies which child fields
to retrieve from the API.
@param api the API connection to be used when retrieving the users.
@param filterTerm used to filter the results to only users starting with this string in either the name or the
login. Can be null to not filter the results.
@param fields the fields to retrieve. Leave this out for the standard fields.
@return an iterable containing all the enterprise users that matches the filter. | [
"Returns",
"an",
"iterable",
"containing",
"all",
"the",
"enterprise",
"users",
"that",
"matches",
"the",
"filter",
"and",
"specifies",
"which",
"child",
"fields",
"to",
"retrieve",
"from",
"the",
"API",
"."
] | 35b4ba69417f9d6a002c19dfaab57527750ef349 | https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxUser.java#L191-L194 | train |
box/box-java-sdk | src/main/java/com/box/sdk/BoxUser.java | BoxUser.getAppUsersByExternalAppUserID | public static Iterable<BoxUser.Info> getAppUsersByExternalAppUserID(final BoxAPIConnection api,
final String externalAppUserId, final String... fields) {
return getUsersInfoForType(api, null, null, externalAppUserId, fields);
} | java | public static Iterable<BoxUser.Info> getAppUsersByExternalAppUserID(final BoxAPIConnection api,
final String externalAppUserId, final String... fields) {
return getUsersInfoForType(api, null, null, externalAppUserId, fields);
} | [
"public",
"static",
"Iterable",
"<",
"BoxUser",
".",
"Info",
">",
"getAppUsersByExternalAppUserID",
"(",
"final",
"BoxAPIConnection",
"api",
",",
"final",
"String",
"externalAppUserId",
",",
"final",
"String",
"...",
"fields",
")",
"{",
"return",
"getUsersInfoForTyp... | Gets any app users that has an exact match with the externalAppUserId term.
@param api the API connection to be used when retrieving the users.
@param externalAppUserId the external app user id that has been set for app user
@param fields the fields to retrieve. Leave this out for the standard fields.
@return an iterable containing users matching the given email | [
"Gets",
"any",
"app",
"users",
"that",
"has",
"an",
"exact",
"match",
"with",
"the",
"externalAppUserId",
"term",
"."
] | 35b4ba69417f9d6a002c19dfaab57527750ef349 | https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxUser.java#L235-L238 | train |
box/box-java-sdk | src/main/java/com/box/sdk/BoxUser.java | BoxUser.getUsersInfoForType | private static Iterable<BoxUser.Info> getUsersInfoForType(final BoxAPIConnection api,
final String filterTerm, final String userType, final String externalAppUserId, final String... fields) {
return new Iterable<BoxUser.Info>() {
public Iterator<BoxUser.Info> iterator() {
QueryStringBuilder builder = new QueryStringBuilder();
if (filterTerm != null) {
builder.appendParam("filter_term", filterTerm);
}
if (userType != null) {
builder.appendParam("user_type", userType);
}
if (externalAppUserId != null) {
builder.appendParam("external_app_user_id", externalAppUserId);
}
if (fields.length > 0) {
builder.appendParam("fields", fields);
}
URL url = USERS_URL_TEMPLATE.buildWithQuery(api.getBaseURL(), builder.toString());
return new BoxUserIterator(api, url);
}
};
} | java | private static Iterable<BoxUser.Info> getUsersInfoForType(final BoxAPIConnection api,
final String filterTerm, final String userType, final String externalAppUserId, final String... fields) {
return new Iterable<BoxUser.Info>() {
public Iterator<BoxUser.Info> iterator() {
QueryStringBuilder builder = new QueryStringBuilder();
if (filterTerm != null) {
builder.appendParam("filter_term", filterTerm);
}
if (userType != null) {
builder.appendParam("user_type", userType);
}
if (externalAppUserId != null) {
builder.appendParam("external_app_user_id", externalAppUserId);
}
if (fields.length > 0) {
builder.appendParam("fields", fields);
}
URL url = USERS_URL_TEMPLATE.buildWithQuery(api.getBaseURL(), builder.toString());
return new BoxUserIterator(api, url);
}
};
} | [
"private",
"static",
"Iterable",
"<",
"BoxUser",
".",
"Info",
">",
"getUsersInfoForType",
"(",
"final",
"BoxAPIConnection",
"api",
",",
"final",
"String",
"filterTerm",
",",
"final",
"String",
"userType",
",",
"final",
"String",
"externalAppUserId",
",",
"final",
... | Helper method to abstract out the common logic from the various users methods.
@param api the API connection to be used when retrieving the users.
@param filterTerm The filter term to lookup users by (login for external, login or name for managed)
@param userType The type of users we want to search with this request.
Valid values are 'managed' (enterprise users), 'external' or 'all'
@param externalAppUserId the external app user id that has been set for an app user
@param fields the fields to retrieve. Leave this out for the standard fields.
@return An iterator over the selected users. | [
"Helper",
"method",
"to",
"abstract",
"out",
"the",
"common",
"logic",
"from",
"the",
"various",
"users",
"methods",
"."
] | 35b4ba69417f9d6a002c19dfaab57527750ef349 | https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxUser.java#L251-L272 | train |
box/box-java-sdk | src/main/java/com/box/sdk/BoxUser.java | BoxUser.getInfo | public BoxUser.Info getInfo(String... fields) {
URL url;
if (fields.length > 0) {
String queryString = new QueryStringBuilder().appendParam("fields", fields).toString();
url = USER_URL_TEMPLATE.buildWithQuery(this.getAPI().getBaseURL(), queryString, this.getID());
} else {
url = USER_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());
return new Info(jsonObject);
} | java | public BoxUser.Info getInfo(String... fields) {
URL url;
if (fields.length > 0) {
String queryString = new QueryStringBuilder().appendParam("fields", fields).toString();
url = USER_URL_TEMPLATE.buildWithQuery(this.getAPI().getBaseURL(), queryString, this.getID());
} else {
url = USER_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());
return new Info(jsonObject);
} | [
"public",
"BoxUser",
".",
"Info",
"getInfo",
"(",
"String",
"...",
"fields",
")",
"{",
"URL",
"url",
";",
"if",
"(",
"fields",
".",
"length",
">",
"0",
")",
"{",
"String",
"queryString",
"=",
"new",
"QueryStringBuilder",
"(",
")",
".",
"appendParam",
"... | Gets information about this user.
@param fields the optional fields to retrieve.
@return info about this user. | [
"Gets",
"information",
"about",
"this",
"user",
"."
] | 35b4ba69417f9d6a002c19dfaab57527750ef349 | https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxUser.java#L279-L291 | train |
box/box-java-sdk | src/main/java/com/box/sdk/BoxUser.java | BoxUser.getMemberships | public Collection<BoxGroupMembership.Info> getMemberships() {
BoxAPIConnection api = this.getAPI();
URL url = USER_MEMBERSHIPS_URL_TEMPLATE.build(this.getAPI().getBaseURL(), this.getID());
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<BoxGroupMembership.Info> memberships = new ArrayList<BoxGroupMembership.Info>(entriesCount);
JsonArray entries = responseJSON.get("entries").asArray();
for (JsonValue entry : entries) {
JsonObject entryObject = entry.asObject();
BoxGroupMembership membership = new BoxGroupMembership(api, entryObject.get("id").asString());
BoxGroupMembership.Info info = membership.new Info(entryObject);
memberships.add(info);
}
return memberships;
} | java | public Collection<BoxGroupMembership.Info> getMemberships() {
BoxAPIConnection api = this.getAPI();
URL url = USER_MEMBERSHIPS_URL_TEMPLATE.build(this.getAPI().getBaseURL(), this.getID());
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<BoxGroupMembership.Info> memberships = new ArrayList<BoxGroupMembership.Info>(entriesCount);
JsonArray entries = responseJSON.get("entries").asArray();
for (JsonValue entry : entries) {
JsonObject entryObject = entry.asObject();
BoxGroupMembership membership = new BoxGroupMembership(api, entryObject.get("id").asString());
BoxGroupMembership.Info info = membership.new Info(entryObject);
memberships.add(info);
}
return memberships;
} | [
"public",
"Collection",
"<",
"BoxGroupMembership",
".",
"Info",
">",
"getMemberships",
"(",
")",
"{",
"BoxAPIConnection",
"api",
"=",
"this",
".",
"getAPI",
"(",
")",
";",
"URL",
"url",
"=",
"USER_MEMBERSHIPS_URL_TEMPLATE",
".",
"build",
"(",
"this",
".",
"g... | Gets information about all of the group memberships for this user.
Does not support paging.
<p>Note: This method is only available to enterprise admins.</p>
@return a collection of information about the group memberships for this user. | [
"Gets",
"information",
"about",
"all",
"of",
"the",
"group",
"memberships",
"for",
"this",
"user",
".",
"Does",
"not",
"support",
"paging",
"."
] | 35b4ba69417f9d6a002c19dfaab57527750ef349 | https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxUser.java#L301-L320 | train |
box/box-java-sdk | src/main/java/com/box/sdk/BoxUser.java | BoxUser.getAllMemberships | public Iterable<BoxGroupMembership.Info> getAllMemberships(String ... fields) {
final QueryStringBuilder builder = new QueryStringBuilder();
if (fields.length > 0) {
builder.appendParam("fields", fields);
}
return new Iterable<BoxGroupMembership.Info>() {
public Iterator<BoxGroupMembership.Info> iterator() {
URL url = USER_MEMBERSHIPS_URL_TEMPLATE.buildWithQuery(
BoxUser.this.getAPI().getBaseURL(), builder.toString(), BoxUser.this.getID());
return new BoxGroupMembershipIterator(BoxUser.this.getAPI(), url);
}
};
} | java | public Iterable<BoxGroupMembership.Info> getAllMemberships(String ... fields) {
final QueryStringBuilder builder = new QueryStringBuilder();
if (fields.length > 0) {
builder.appendParam("fields", fields);
}
return new Iterable<BoxGroupMembership.Info>() {
public Iterator<BoxGroupMembership.Info> iterator() {
URL url = USER_MEMBERSHIPS_URL_TEMPLATE.buildWithQuery(
BoxUser.this.getAPI().getBaseURL(), builder.toString(), BoxUser.this.getID());
return new BoxGroupMembershipIterator(BoxUser.this.getAPI(), url);
}
};
} | [
"public",
"Iterable",
"<",
"BoxGroupMembership",
".",
"Info",
">",
"getAllMemberships",
"(",
"String",
"...",
"fields",
")",
"{",
"final",
"QueryStringBuilder",
"builder",
"=",
"new",
"QueryStringBuilder",
"(",
")",
";",
"if",
"(",
"fields",
".",
"length",
">"... | Gets information about all of the group memberships for this user as iterable with paging support.
@param fields the fields to retrieve.
@return an iterable with information about the group memberships for this user. | [
"Gets",
"information",
"about",
"all",
"of",
"the",
"group",
"memberships",
"for",
"this",
"user",
"as",
"iterable",
"with",
"paging",
"support",
"."
] | 35b4ba69417f9d6a002c19dfaab57527750ef349 | https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxUser.java#L327-L339 | train |
box/box-java-sdk | src/main/java/com/box/sdk/BoxUser.java | BoxUser.addEmailAlias | public EmailAlias addEmailAlias(String email, boolean isConfirmed) {
URL url = EMAIL_ALIASES_URL_TEMPLATE.build(this.getAPI().getBaseURL(), this.getID());
BoxJSONRequest request = new BoxJSONRequest(this.getAPI(), url, "POST");
JsonObject requestJSON = new JsonObject()
.add("email", email);
if (isConfirmed) {
requestJSON.add("is_confirmed", isConfirmed);
}
request.setBody(requestJSON.toString());
BoxJSONResponse response = (BoxJSONResponse) request.send();
JsonObject responseJSON = JsonObject.readFrom(response.getJSON());
return new EmailAlias(responseJSON);
} | java | public EmailAlias addEmailAlias(String email, boolean isConfirmed) {
URL url = EMAIL_ALIASES_URL_TEMPLATE.build(this.getAPI().getBaseURL(), this.getID());
BoxJSONRequest request = new BoxJSONRequest(this.getAPI(), url, "POST");
JsonObject requestJSON = new JsonObject()
.add("email", email);
if (isConfirmed) {
requestJSON.add("is_confirmed", isConfirmed);
}
request.setBody(requestJSON.toString());
BoxJSONResponse response = (BoxJSONResponse) request.send();
JsonObject responseJSON = JsonObject.readFrom(response.getJSON());
return new EmailAlias(responseJSON);
} | [
"public",
"EmailAlias",
"addEmailAlias",
"(",
"String",
"email",
",",
"boolean",
"isConfirmed",
")",
"{",
"URL",
"url",
"=",
"EMAIL_ALIASES_URL_TEMPLATE",
".",
"build",
"(",
"this",
".",
"getAPI",
"(",
")",
".",
"getBaseURL",
"(",
")",
",",
"this",
".",
"g... | Adds a new email alias to this user's account and confirms it without user interaction.
This functionality is only available for enterprise admins.
@param email the email address to add as an alias.
@param isConfirmed whether or not the email alias should be automatically confirmed.
@return the newly created email alias. | [
"Adds",
"a",
"new",
"email",
"alias",
"to",
"this",
"user",
"s",
"account",
"and",
"confirms",
"it",
"without",
"user",
"interaction",
".",
"This",
"functionality",
"is",
"only",
"available",
"for",
"enterprise",
"admins",
"."
] | 35b4ba69417f9d6a002c19dfaab57527750ef349 | https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxUser.java#L357-L372 | train |
box/box-java-sdk | src/main/java/com/box/sdk/BoxUser.java | BoxUser.deleteEmailAlias | public void deleteEmailAlias(String emailAliasID) {
URL url = EMAIL_ALIAS_URL_TEMPLATE.build(this.getAPI().getBaseURL(), this.getID(), emailAliasID);
BoxAPIRequest request = new BoxAPIRequest(this.getAPI(), url, "DELETE");
BoxAPIResponse response = request.send();
response.disconnect();
} | java | public void deleteEmailAlias(String emailAliasID) {
URL url = EMAIL_ALIAS_URL_TEMPLATE.build(this.getAPI().getBaseURL(), this.getID(), emailAliasID);
BoxAPIRequest request = new BoxAPIRequest(this.getAPI(), url, "DELETE");
BoxAPIResponse response = request.send();
response.disconnect();
} | [
"public",
"void",
"deleteEmailAlias",
"(",
"String",
"emailAliasID",
")",
"{",
"URL",
"url",
"=",
"EMAIL_ALIAS_URL_TEMPLATE",
".",
"build",
"(",
"this",
".",
"getAPI",
"(",
")",
".",
"getBaseURL",
"(",
")",
",",
"this",
".",
"getID",
"(",
")",
",",
"emai... | Deletes an email alias from this user's account.
<p>The IDs of the user's email aliases can be found by calling {@link #getEmailAliases}.</p>
@param emailAliasID the ID of the email alias to delete. | [
"Deletes",
"an",
"email",
"alias",
"from",
"this",
"user",
"s",
"account",
"."
] | 35b4ba69417f9d6a002c19dfaab57527750ef349 | https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxUser.java#L381-L386 | train |
box/box-java-sdk | src/main/java/com/box/sdk/BoxUser.java | BoxUser.getEmailAliases | public Collection<EmailAlias> getEmailAliases() {
URL url = EMAIL_ALIASES_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();
Collection<EmailAlias> emailAliases = new ArrayList<EmailAlias>(totalCount);
JsonArray entries = responseJSON.get("entries").asArray();
for (JsonValue value : entries) {
JsonObject emailAliasJSON = value.asObject();
emailAliases.add(new EmailAlias(emailAliasJSON));
}
return emailAliases;
} | java | public Collection<EmailAlias> getEmailAliases() {
URL url = EMAIL_ALIASES_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();
Collection<EmailAlias> emailAliases = new ArrayList<EmailAlias>(totalCount);
JsonArray entries = responseJSON.get("entries").asArray();
for (JsonValue value : entries) {
JsonObject emailAliasJSON = value.asObject();
emailAliases.add(new EmailAlias(emailAliasJSON));
}
return emailAliases;
} | [
"public",
"Collection",
"<",
"EmailAlias",
">",
"getEmailAliases",
"(",
")",
"{",
"URL",
"url",
"=",
"EMAIL_ALIASES_URL_TEMPLATE",
".",
"build",
"(",
"this",
".",
"getAPI",
"(",
")",
".",
"getBaseURL",
"(",
")",
",",
"this",
".",
"getID",
"(",
")",
")",
... | Gets a collection of all the email aliases for this user.
<p>Note that the user's primary login email is not included in the collection of email aliases.</p>
@return a collection of all the email aliases for this user. | [
"Gets",
"a",
"collection",
"of",
"all",
"the",
"email",
"aliases",
"for",
"this",
"user",
"."
] | 35b4ba69417f9d6a002c19dfaab57527750ef349 | https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxUser.java#L395-L410 | train |
box/box-java-sdk | src/main/java/com/box/sdk/BoxUser.java | BoxUser.delete | public void delete(boolean notifyUser, boolean force) {
String queryString = new QueryStringBuilder()
.appendParam("notify", String.valueOf(notifyUser))
.appendParam("force", String.valueOf(force))
.toString();
URL url = USER_URL_TEMPLATE.buildWithQuery(this.getAPI().getBaseURL(), queryString, this.getID());
BoxAPIRequest request = new BoxAPIRequest(this.getAPI(), url, "DELETE");
BoxAPIResponse response = request.send();
response.disconnect();
} | java | public void delete(boolean notifyUser, boolean force) {
String queryString = new QueryStringBuilder()
.appendParam("notify", String.valueOf(notifyUser))
.appendParam("force", String.valueOf(force))
.toString();
URL url = USER_URL_TEMPLATE.buildWithQuery(this.getAPI().getBaseURL(), queryString, this.getID());
BoxAPIRequest request = new BoxAPIRequest(this.getAPI(), url, "DELETE");
BoxAPIResponse response = request.send();
response.disconnect();
} | [
"public",
"void",
"delete",
"(",
"boolean",
"notifyUser",
",",
"boolean",
"force",
")",
"{",
"String",
"queryString",
"=",
"new",
"QueryStringBuilder",
"(",
")",
".",
"appendParam",
"(",
"\"notify\"",
",",
"String",
".",
"valueOf",
"(",
"notifyUser",
")",
")... | Deletes a user from an enterprise account.
@param notifyUser whether or not to send an email notification to the user that their account has been deleted.
@param force whether or not this user should be deleted even if they still own files. | [
"Deletes",
"a",
"user",
"from",
"an",
"enterprise",
"account",
"."
] | 35b4ba69417f9d6a002c19dfaab57527750ef349 | https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxUser.java#L417-L427 | train |
box/box-java-sdk | src/main/java/com/box/sdk/BoxUser.java | BoxUser.getAvatar | public InputStream getAvatar() {
URL url = USER_AVATAR_TEMPLATE.build(this.getAPI().getBaseURL(), this.getID());
BoxAPIRequest request = new BoxAPIRequest(this.getAPI(), url, "GET");
BoxAPIResponse response = request.send();
return response.getBody();
} | java | public InputStream getAvatar() {
URL url = USER_AVATAR_TEMPLATE.build(this.getAPI().getBaseURL(), this.getID());
BoxAPIRequest request = new BoxAPIRequest(this.getAPI(), url, "GET");
BoxAPIResponse response = request.send();
return response.getBody();
} | [
"public",
"InputStream",
"getAvatar",
"(",
")",
"{",
"URL",
"url",
"=",
"USER_AVATAR_TEMPLATE",
".",
"build",
"(",
"this",
".",
"getAPI",
"(",
")",
".",
"getBaseURL",
"(",
")",
",",
"this",
".",
"getID",
"(",
")",
")",
";",
"BoxAPIRequest",
"request",
... | Retrieves the avatar of a user as an InputStream.
@return InputStream representing the user avater. | [
"Retrieves",
"the",
"avatar",
"of",
"a",
"user",
"as",
"an",
"InputStream",
"."
] | 35b4ba69417f9d6a002c19dfaab57527750ef349 | https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxUser.java#L508-L514 | train |
box/box-java-sdk | src/main/java/com/box/sdk/BoxInvite.java | BoxInvite.inviteUserToEnterprise | public static Info inviteUserToEnterprise(BoxAPIConnection api, String userLogin, String enterpriseID) {
URL url = INVITE_CREATION_URL_TEMPLATE.build(api.getBaseURL());
BoxJSONRequest request = new BoxJSONRequest(api, url, "POST");
JsonObject body = new JsonObject();
JsonObject enterprise = new JsonObject();
enterprise.add("id", enterpriseID);
body.add("enterprise", enterprise);
JsonObject actionableBy = new JsonObject();
actionableBy.add("login", userLogin);
body.add("actionable_by", actionableBy);
request.setBody(body);
BoxJSONResponse response = (BoxJSONResponse) request.send();
JsonObject responseJSON = JsonObject.readFrom(response.getJSON());
BoxInvite invite = new BoxInvite(api, responseJSON.get("id").asString());
return invite.new Info(responseJSON);
} | java | public static Info inviteUserToEnterprise(BoxAPIConnection api, String userLogin, String enterpriseID) {
URL url = INVITE_CREATION_URL_TEMPLATE.build(api.getBaseURL());
BoxJSONRequest request = new BoxJSONRequest(api, url, "POST");
JsonObject body = new JsonObject();
JsonObject enterprise = new JsonObject();
enterprise.add("id", enterpriseID);
body.add("enterprise", enterprise);
JsonObject actionableBy = new JsonObject();
actionableBy.add("login", userLogin);
body.add("actionable_by", actionableBy);
request.setBody(body);
BoxJSONResponse response = (BoxJSONResponse) request.send();
JsonObject responseJSON = JsonObject.readFrom(response.getJSON());
BoxInvite invite = new BoxInvite(api, responseJSON.get("id").asString());
return invite.new Info(responseJSON);
} | [
"public",
"static",
"Info",
"inviteUserToEnterprise",
"(",
"BoxAPIConnection",
"api",
",",
"String",
"userLogin",
",",
"String",
"enterpriseID",
")",
"{",
"URL",
"url",
"=",
"INVITE_CREATION_URL_TEMPLATE",
".",
"build",
"(",
"api",
".",
"getBaseURL",
"(",
")",
"... | Invite a user to an enterprise.
@param api the API connection to use for the request.
@param userLogin the login of the user to invite.
@param enterpriseID the ID of the enterprise to invite the user to.
@return the invite info. | [
"Invite",
"a",
"user",
"to",
"an",
"enterprise",
"."
] | 35b4ba69417f9d6a002c19dfaab57527750ef349 | https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxInvite.java#L61-L82 | train |
box/box-java-sdk | src/main/java/com/box/sdk/BoxWebHook.java | BoxWebHook.toJsonArray | private static JsonArray toJsonArray(Collection<String> values) {
JsonArray array = new JsonArray();
for (String value : values) {
array.add(value);
}
return array;
} | java | private static JsonArray toJsonArray(Collection<String> values) {
JsonArray array = new JsonArray();
for (String value : values) {
array.add(value);
}
return array;
} | [
"private",
"static",
"JsonArray",
"toJsonArray",
"(",
"Collection",
"<",
"String",
">",
"values",
")",
"{",
"JsonArray",
"array",
"=",
"new",
"JsonArray",
"(",
")",
";",
"for",
"(",
"String",
"value",
":",
"values",
")",
"{",
"array",
".",
"add",
"(",
... | Helper function to create JsonArray from collection.
@param values collection of values to convert to JsonArray
@return JsonArray with collection values | [
"Helper",
"function",
"to",
"create",
"JsonArray",
"from",
"collection",
"."
] | 35b4ba69417f9d6a002c19dfaab57527750ef349 | https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxWebHook.java#L170-L177 | train |
box/box-java-sdk | src/main/java/com/box/sdk/BoxJSONRequest.java | BoxJSONRequest.setBody | @Override
public void setBody(String body) {
super.setBody(body);
this.jsonValue = JsonValue.readFrom(body);
} | java | @Override
public void setBody(String body) {
super.setBody(body);
this.jsonValue = JsonValue.readFrom(body);
} | [
"@",
"Override",
"public",
"void",
"setBody",
"(",
"String",
"body",
")",
"{",
"super",
".",
"setBody",
"(",
"body",
")",
";",
"this",
".",
"jsonValue",
"=",
"JsonValue",
".",
"readFrom",
"(",
"body",
")",
";",
"}"
] | Sets the body of this request to a given JSON string.
@param body the JSON string to use as the body. | [
"Sets",
"the",
"body",
"of",
"this",
"request",
"to",
"a",
"given",
"JSON",
"string",
"."
] | 35b4ba69417f9d6a002c19dfaab57527750ef349 | https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxJSONRequest.java#L54-L58 | train |
box/box-java-sdk | src/main/java/com/box/sdk/BoxComment.java | BoxComment.changeMessage | public Info changeMessage(String newMessage) {
Info newInfo = new Info();
newInfo.setMessage(newMessage);
URL url = COMMENT_URL_TEMPLATE.build(this.getAPI().getBaseURL(), this.getID());
BoxJSONRequest request = new BoxJSONRequest(this.getAPI(), url, "PUT");
request.setBody(newInfo.getPendingChanges());
BoxJSONResponse response = (BoxJSONResponse) request.send();
JsonObject jsonResponse = JsonObject.readFrom(response.getJSON());
return new Info(jsonResponse);
} | java | public Info changeMessage(String newMessage) {
Info newInfo = new Info();
newInfo.setMessage(newMessage);
URL url = COMMENT_URL_TEMPLATE.build(this.getAPI().getBaseURL(), this.getID());
BoxJSONRequest request = new BoxJSONRequest(this.getAPI(), url, "PUT");
request.setBody(newInfo.getPendingChanges());
BoxJSONResponse response = (BoxJSONResponse) request.send();
JsonObject jsonResponse = JsonObject.readFrom(response.getJSON());
return new Info(jsonResponse);
} | [
"public",
"Info",
"changeMessage",
"(",
"String",
"newMessage",
")",
"{",
"Info",
"newInfo",
"=",
"new",
"Info",
"(",
")",
";",
"newInfo",
".",
"setMessage",
"(",
"newMessage",
")",
";",
"URL",
"url",
"=",
"COMMENT_URL_TEMPLATE",
".",
"build",
"(",
"this",... | Changes the message of this comment.
@param newMessage the new message for this comment.
@return updated info about this comment. | [
"Changes",
"the",
"message",
"of",
"this",
"comment",
"."
] | 35b4ba69417f9d6a002c19dfaab57527750ef349 | https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxComment.java#L69-L80 | train |
box/box-java-sdk | src/main/java/com/box/sdk/BoxComment.java | BoxComment.reply | public BoxComment.Info reply(String message) {
JsonObject itemJSON = new JsonObject();
itemJSON.add("type", "comment");
itemJSON.add("id", this.getID());
JsonObject requestJSON = new JsonObject();
requestJSON.add("item", itemJSON);
if (BoxComment.messageContainsMention(message)) {
requestJSON.add("tagged_message", message);
} else {
requestJSON.add("message", message);
}
URL url = ADD_COMMENT_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());
BoxComment addedComment = new BoxComment(this.getAPI(), responseJSON.get("id").asString());
return addedComment.new Info(responseJSON);
} | java | public BoxComment.Info reply(String message) {
JsonObject itemJSON = new JsonObject();
itemJSON.add("type", "comment");
itemJSON.add("id", this.getID());
JsonObject requestJSON = new JsonObject();
requestJSON.add("item", itemJSON);
if (BoxComment.messageContainsMention(message)) {
requestJSON.add("tagged_message", message);
} else {
requestJSON.add("message", message);
}
URL url = ADD_COMMENT_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());
BoxComment addedComment = new BoxComment(this.getAPI(), responseJSON.get("id").asString());
return addedComment.new Info(responseJSON);
} | [
"public",
"BoxComment",
".",
"Info",
"reply",
"(",
"String",
"message",
")",
"{",
"JsonObject",
"itemJSON",
"=",
"new",
"JsonObject",
"(",
")",
";",
"itemJSON",
".",
"add",
"(",
"\"type\"",
",",
"\"comment\"",
")",
";",
"itemJSON",
".",
"add",
"(",
"\"id... | Replies to this comment with another message.
@param message the message for the reply.
@return info about the newly created reply comment. | [
"Replies",
"to",
"this",
"comment",
"with",
"another",
"message",
"."
] | 35b4ba69417f9d6a002c19dfaab57527750ef349 | https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxComment.java#L87-L108 | train |
box/box-java-sdk | src/main/java/com/box/sdk/InMemoryLRUAccessTokenCache.java | InMemoryLRUAccessTokenCache.put | public void put(String key, String value) {
synchronized (this.cache) {
this.cache.put(key, value);
}
} | java | public void put(String key, String value) {
synchronized (this.cache) {
this.cache.put(key, value);
}
} | [
"public",
"void",
"put",
"(",
"String",
"key",
",",
"String",
"value",
")",
"{",
"synchronized",
"(",
"this",
".",
"cache",
")",
"{",
"this",
".",
"cache",
".",
"put",
"(",
"key",
",",
"value",
")",
";",
"}",
"}"
] | Add an entry to the cache.
@param key key to use.
@param value access token information to store. | [
"Add",
"an",
"entry",
"to",
"the",
"cache",
"."
] | 35b4ba69417f9d6a002c19dfaab57527750ef349 | https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/InMemoryLRUAccessTokenCache.java#L33-L37 | train |
box/box-java-sdk | src/main/java/com/box/sdk/URLTemplate.java | URLTemplate.buildWithQuery | public URL buildWithQuery(String base, String queryString, Object... values) {
String urlString = String.format(base + this.template, values) + queryString;
URL url = null;
try {
url = new URL(urlString);
} catch (MalformedURLException e) {
assert false : "An invalid URL template indicates a bug in the SDK.";
}
return url;
} | java | public URL buildWithQuery(String base, String queryString, Object... values) {
String urlString = String.format(base + this.template, values) + queryString;
URL url = null;
try {
url = new URL(urlString);
} catch (MalformedURLException e) {
assert false : "An invalid URL template indicates a bug in the SDK.";
}
return url;
} | [
"public",
"URL",
"buildWithQuery",
"(",
"String",
"base",
",",
"String",
"queryString",
",",
"Object",
"...",
"values",
")",
"{",
"String",
"urlString",
"=",
"String",
".",
"format",
"(",
"base",
"+",
"this",
".",
"template",
",",
"values",
")",
"+",
"qu... | Build a URL with Query String and URL Parameters.
@param base base URL
@param queryString query string
@param values URL Parameters
@return URL | [
"Build",
"a",
"URL",
"with",
"Query",
"String",
"and",
"URL",
"Parameters",
"."
] | 35b4ba69417f9d6a002c19dfaab57527750ef349 | https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/URLTemplate.java#L46-L56 | train |
box/box-java-sdk | src/main/java/com/box/sdk/BoxFileUploadSession.java | BoxFileUploadSession.uploadPart | public BoxFileUploadSessionPart uploadPart(InputStream stream, long offset, int partSize,
long totalSizeOfFile) {
URL uploadPartURL = this.sessionInfo.getSessionEndpoints().getUploadPartEndpoint();
BoxAPIRequest request = new BoxAPIRequest(this.getAPI(), uploadPartURL, HttpMethod.PUT);
request.addHeader(HttpHeaders.CONTENT_TYPE, ContentType.APPLICATION_OCTET_STREAM);
//Read the partSize bytes from the stream
byte[] bytes = new byte[partSize];
try {
stream.read(bytes);
} catch (IOException ioe) {
throw new BoxAPIException("Reading data from stream failed.", ioe);
}
return this.uploadPart(bytes, offset, partSize, totalSizeOfFile);
} | java | public BoxFileUploadSessionPart uploadPart(InputStream stream, long offset, int partSize,
long totalSizeOfFile) {
URL uploadPartURL = this.sessionInfo.getSessionEndpoints().getUploadPartEndpoint();
BoxAPIRequest request = new BoxAPIRequest(this.getAPI(), uploadPartURL, HttpMethod.PUT);
request.addHeader(HttpHeaders.CONTENT_TYPE, ContentType.APPLICATION_OCTET_STREAM);
//Read the partSize bytes from the stream
byte[] bytes = new byte[partSize];
try {
stream.read(bytes);
} catch (IOException ioe) {
throw new BoxAPIException("Reading data from stream failed.", ioe);
}
return this.uploadPart(bytes, offset, partSize, totalSizeOfFile);
} | [
"public",
"BoxFileUploadSessionPart",
"uploadPart",
"(",
"InputStream",
"stream",
",",
"long",
"offset",
",",
"int",
"partSize",
",",
"long",
"totalSizeOfFile",
")",
"{",
"URL",
"uploadPartURL",
"=",
"this",
".",
"sessionInfo",
".",
"getSessionEndpoints",
"(",
")"... | Uploads chunk of a stream to an open upload session.
@param stream the stream that is used to read the chunck using the offset and part size.
@param offset the byte position where the chunk begins in the file.
@param partSize the part size returned as part of the upload session instance creation.
Only the last chunk can have a lesser value.
@param totalSizeOfFile The total size of the file being uploaded.
@return the part instance that contains the part id, offset and part size. | [
"Uploads",
"chunk",
"of",
"a",
"stream",
"to",
"an",
"open",
"upload",
"session",
"."
] | 35b4ba69417f9d6a002c19dfaab57527750ef349 | https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxFileUploadSession.java#L241-L258 | train |
box/box-java-sdk | src/main/java/com/box/sdk/BoxFileUploadSession.java | BoxFileUploadSession.uploadPart | public BoxFileUploadSessionPart uploadPart(byte[] data, long offset, int partSize,
long totalSizeOfFile) {
URL uploadPartURL = this.sessionInfo.getSessionEndpoints().getUploadPartEndpoint();
BoxAPIRequest request = new BoxAPIRequest(this.getAPI(), uploadPartURL, HttpMethod.PUT);
request.addHeader(HttpHeaders.CONTENT_TYPE, ContentType.APPLICATION_OCTET_STREAM);
MessageDigest digestInstance = null;
try {
digestInstance = MessageDigest.getInstance(DIGEST_ALGORITHM_SHA1);
} catch (NoSuchAlgorithmException ae) {
throw new BoxAPIException("Digest algorithm not found", ae);
}
//Creates the digest using SHA1 algorithm. Then encodes the bytes using Base64.
byte[] digestBytes = digestInstance.digest(data);
String digest = Base64.encode(digestBytes);
request.addHeader(HttpHeaders.DIGEST, DIGEST_HEADER_PREFIX_SHA + digest);
//Content-Range: bytes offset-part/totalSize
request.addHeader(HttpHeaders.CONTENT_RANGE,
"bytes " + offset + "-" + (offset + partSize - 1) + "/" + totalSizeOfFile);
//Creates the body
request.setBody(new ByteArrayInputStream(data));
BoxJSONResponse response = (BoxJSONResponse) request.send();
JsonObject jsonObject = JsonObject.readFrom(response.getJSON());
BoxFileUploadSessionPart part = new BoxFileUploadSessionPart((JsonObject) jsonObject.get("part"));
return part;
} | java | public BoxFileUploadSessionPart uploadPart(byte[] data, long offset, int partSize,
long totalSizeOfFile) {
URL uploadPartURL = this.sessionInfo.getSessionEndpoints().getUploadPartEndpoint();
BoxAPIRequest request = new BoxAPIRequest(this.getAPI(), uploadPartURL, HttpMethod.PUT);
request.addHeader(HttpHeaders.CONTENT_TYPE, ContentType.APPLICATION_OCTET_STREAM);
MessageDigest digestInstance = null;
try {
digestInstance = MessageDigest.getInstance(DIGEST_ALGORITHM_SHA1);
} catch (NoSuchAlgorithmException ae) {
throw new BoxAPIException("Digest algorithm not found", ae);
}
//Creates the digest using SHA1 algorithm. Then encodes the bytes using Base64.
byte[] digestBytes = digestInstance.digest(data);
String digest = Base64.encode(digestBytes);
request.addHeader(HttpHeaders.DIGEST, DIGEST_HEADER_PREFIX_SHA + digest);
//Content-Range: bytes offset-part/totalSize
request.addHeader(HttpHeaders.CONTENT_RANGE,
"bytes " + offset + "-" + (offset + partSize - 1) + "/" + totalSizeOfFile);
//Creates the body
request.setBody(new ByteArrayInputStream(data));
BoxJSONResponse response = (BoxJSONResponse) request.send();
JsonObject jsonObject = JsonObject.readFrom(response.getJSON());
BoxFileUploadSessionPart part = new BoxFileUploadSessionPart((JsonObject) jsonObject.get("part"));
return part;
} | [
"public",
"BoxFileUploadSessionPart",
"uploadPart",
"(",
"byte",
"[",
"]",
"data",
",",
"long",
"offset",
",",
"int",
"partSize",
",",
"long",
"totalSizeOfFile",
")",
"{",
"URL",
"uploadPartURL",
"=",
"this",
".",
"sessionInfo",
".",
"getSessionEndpoints",
"(",
... | Uploads bytes to an open upload session.
@param data data
@param offset the byte position where the chunk begins in the file.
@param partSize the part size returned as part of the upload session instance creation.
Only the last chunk can have a lesser value.
@param totalSizeOfFile The total size of the file being uploaded.
@return the part instance that contains the part id, offset and part size. | [
"Uploads",
"bytes",
"to",
"an",
"open",
"upload",
"session",
"."
] | 35b4ba69417f9d6a002c19dfaab57527750ef349 | https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxFileUploadSession.java#L269-L297 | train |
box/box-java-sdk | src/main/java/com/box/sdk/BoxFileUploadSession.java | BoxFileUploadSession.listParts | public BoxFileUploadSessionPartList listParts(int offset, int limit) {
URL listPartsURL = this.sessionInfo.getSessionEndpoints().getListPartsEndpoint();
URLTemplate template = new URLTemplate(listPartsURL.toString());
QueryStringBuilder builder = new QueryStringBuilder();
builder.appendParam(OFFSET_QUERY_STRING, offset);
String queryString = builder.appendParam(LIMIT_QUERY_STRING, limit).toString();
//Template is initalized with the full URL. So empty string for the path.
URL url = template.buildWithQuery("", queryString);
BoxJSONRequest request = new BoxJSONRequest(this.getAPI(), url, HttpMethod.GET);
BoxJSONResponse response = (BoxJSONResponse) request.send();
JsonObject jsonObject = JsonObject.readFrom(response.getJSON());
return new BoxFileUploadSessionPartList(jsonObject);
} | java | public BoxFileUploadSessionPartList listParts(int offset, int limit) {
URL listPartsURL = this.sessionInfo.getSessionEndpoints().getListPartsEndpoint();
URLTemplate template = new URLTemplate(listPartsURL.toString());
QueryStringBuilder builder = new QueryStringBuilder();
builder.appendParam(OFFSET_QUERY_STRING, offset);
String queryString = builder.appendParam(LIMIT_QUERY_STRING, limit).toString();
//Template is initalized with the full URL. So empty string for the path.
URL url = template.buildWithQuery("", queryString);
BoxJSONRequest request = new BoxJSONRequest(this.getAPI(), url, HttpMethod.GET);
BoxJSONResponse response = (BoxJSONResponse) request.send();
JsonObject jsonObject = JsonObject.readFrom(response.getJSON());
return new BoxFileUploadSessionPartList(jsonObject);
} | [
"public",
"BoxFileUploadSessionPartList",
"listParts",
"(",
"int",
"offset",
",",
"int",
"limit",
")",
"{",
"URL",
"listPartsURL",
"=",
"this",
".",
"sessionInfo",
".",
"getSessionEndpoints",
"(",
")",
".",
"getListPartsEndpoint",
"(",
")",
";",
"URLTemplate",
"... | Returns a list of all parts that have been uploaded to an upload session.
@param offset paging marker for the list of parts.
@param limit maximum number of parts to return.
@return the list of parts. | [
"Returns",
"a",
"list",
"of",
"all",
"parts",
"that",
"have",
"been",
"uploaded",
"to",
"an",
"upload",
"session",
"."
] | 35b4ba69417f9d6a002c19dfaab57527750ef349 | https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxFileUploadSession.java#L305-L321 | train |
box/box-java-sdk | src/main/java/com/box/sdk/BoxFileUploadSession.java | BoxFileUploadSession.commit | public BoxFile.Info commit(String digest, List<BoxFileUploadSessionPart> parts,
Map<String, String> attributes, String ifMatch, String ifNoneMatch) {
URL commitURL = this.sessionInfo.getSessionEndpoints().getCommitEndpoint();
BoxJSONRequest request = new BoxJSONRequest(this.getAPI(), commitURL, HttpMethod.POST);
request.addHeader(HttpHeaders.DIGEST, DIGEST_HEADER_PREFIX_SHA + digest);
request.addHeader(HttpHeaders.CONTENT_TYPE, ContentType.APPLICATION_JSON);
if (ifMatch != null) {
request.addHeader(HttpHeaders.IF_MATCH, ifMatch);
}
if (ifNoneMatch != null) {
request.addHeader(HttpHeaders.IF_NONE_MATCH, ifNoneMatch);
}
//Creates the body of the request
String body = this.getCommitBody(parts, attributes);
request.setBody(body);
BoxAPIResponse response = request.send();
//Retry the commit operation after the given number of seconds if the HTTP response code is 202.
if (response.getResponseCode() == 202) {
String retryInterval = response.getHeaderField("retry-after");
if (retryInterval != null) {
try {
Thread.sleep(new Integer(retryInterval) * 1000);
} catch (InterruptedException ie) {
throw new BoxAPIException("Commit retry failed. ", ie);
}
return this.commit(digest, parts, attributes, ifMatch, ifNoneMatch);
}
}
if (response instanceof BoxJSONResponse) {
//Create the file instance from the response
return this.getFile((BoxJSONResponse) response);
} else {
throw new BoxAPIException("Commit response content type is not application/json. The response code : "
+ response.getResponseCode());
}
} | java | public BoxFile.Info commit(String digest, List<BoxFileUploadSessionPart> parts,
Map<String, String> attributes, String ifMatch, String ifNoneMatch) {
URL commitURL = this.sessionInfo.getSessionEndpoints().getCommitEndpoint();
BoxJSONRequest request = new BoxJSONRequest(this.getAPI(), commitURL, HttpMethod.POST);
request.addHeader(HttpHeaders.DIGEST, DIGEST_HEADER_PREFIX_SHA + digest);
request.addHeader(HttpHeaders.CONTENT_TYPE, ContentType.APPLICATION_JSON);
if (ifMatch != null) {
request.addHeader(HttpHeaders.IF_MATCH, ifMatch);
}
if (ifNoneMatch != null) {
request.addHeader(HttpHeaders.IF_NONE_MATCH, ifNoneMatch);
}
//Creates the body of the request
String body = this.getCommitBody(parts, attributes);
request.setBody(body);
BoxAPIResponse response = request.send();
//Retry the commit operation after the given number of seconds if the HTTP response code is 202.
if (response.getResponseCode() == 202) {
String retryInterval = response.getHeaderField("retry-after");
if (retryInterval != null) {
try {
Thread.sleep(new Integer(retryInterval) * 1000);
} catch (InterruptedException ie) {
throw new BoxAPIException("Commit retry failed. ", ie);
}
return this.commit(digest, parts, attributes, ifMatch, ifNoneMatch);
}
}
if (response instanceof BoxJSONResponse) {
//Create the file instance from the response
return this.getFile((BoxJSONResponse) response);
} else {
throw new BoxAPIException("Commit response content type is not application/json. The response code : "
+ response.getResponseCode());
}
} | [
"public",
"BoxFile",
".",
"Info",
"commit",
"(",
"String",
"digest",
",",
"List",
"<",
"BoxFileUploadSessionPart",
">",
"parts",
",",
"Map",
"<",
"String",
",",
"String",
">",
"attributes",
",",
"String",
"ifMatch",
",",
"String",
"ifNoneMatch",
")",
"{",
... | Commit an upload session after all parts have been uploaded, creating the new file or the version.
@param digest the base64-encoded SHA-1 hash of the file being uploaded.
@param parts the list of uploaded parts to be committed.
@param attributes the key value pairs of attributes from the file instance.
@param ifMatch ensures that your app only alters files/folders on Box if you have the current version.
@param ifNoneMatch ensure that it retrieve unnecessary data if the most current version of file is on-hand.
@return the created file instance. | [
"Commit",
"an",
"upload",
"session",
"after",
"all",
"parts",
"have",
"been",
"uploaded",
"creating",
"the",
"new",
"file",
"or",
"the",
"version",
"."
] | 35b4ba69417f9d6a002c19dfaab57527750ef349 | https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxFileUploadSession.java#L332-L374 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.