id
int32 0
165k
| repo
stringlengths 7
58
| path
stringlengths 12
218
| func_name
stringlengths 3
140
| original_string
stringlengths 73
34.1k
| language
stringclasses 1
value | code
stringlengths 73
34.1k
| code_tokens
sequence | docstring
stringlengths 3
16k
| docstring_tokens
sequence | sha
stringlengths 40
40
| url
stringlengths 105
339
|
---|---|---|---|---|---|---|---|---|---|---|---|
163,600 | 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",
".",
"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",
";",
"}"
] | 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 |
163,601 | 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",
"(",
")",
";",
"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",
")",
")",
";",
"}"
] | 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 |
163,602 | 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",
"=",
"new",
"ByteArrayInputStream",
"(",
"bytes",
")",
";",
"}"
] | 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 |
163,603 | 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",
"(",
")",
")",
";",
"}",
"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",
"(",
")",
";",
"}"
] | 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 |
163,604 | 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",
")",
";",
"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",
")",
";",
"}",
"}"
] | 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 |
163,605 | 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",
"(",
")",
")",
";",
"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",
")",
";",
"}"
] | 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 |
163,606 | 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 |
163,607 | 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",
"(",
")",
";",
"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",
")",
";",
"}",
"}",
";",
"}"
] | 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 |
163,608 | 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",
"(",
"\"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",
")",
";",
"}",
"}",
";",
"}"
] | 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 |
163,609 | 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 |
163,610 | 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",
")",
";",
"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",
")",
";",
"}",
"}",
";",
"}"
] | 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 |
163,611 | 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 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",
";",
"}"
] | 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 |
163,612 | 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",
")",
"{",
"return",
"false",
";",
"}",
"byte",
"[",
"]",
"actual",
"=",
"Base64",
".",
"decode",
"(",
"actualSignature",
")",
";",
"byte",
"[",
"]",
"expected",
"=",
"this",
".",
"signRaw",
"(",
"actualAlgorithm",
",",
"key",
",",
"webHookPayload",
",",
"deliveryTimestamp",
")",
";",
"return",
"Arrays",
".",
"equals",
"(",
"expected",
",",
"actual",
")",
";",
"}"
] | 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 |
163,613 | 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",
"(",
")",
".",
"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",
";",
"}"
] | 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 |
163,614 | 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 |
163,615 | 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",
"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",
";",
"}"
] | 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 |
163,616 | 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 |
163,617 | 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",
",",
"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",
")",
";",
"}"
] | 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 |
163,618 | 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",
".",
"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",
"(",
")",
")",
";",
"}"
] | 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 |
163,619 | 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",
".",
"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",
"(",
")",
")",
";",
"}"
] | 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 |
163,620 | 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",
"url",
"=",
"WATERMARK_URL_TEMPLATE",
".",
"build",
"(",
"watermarkUrl",
".",
"toString",
"(",
")",
")",
";",
"BoxAPIRequest",
"request",
"=",
"new",
"BoxAPIRequest",
"(",
"this",
".",
"getAPI",
"(",
")",
",",
"url",
",",
"\"DELETE\"",
")",
";",
"BoxAPIResponse",
"response",
"=",
"request",
".",
"send",
"(",
")",
";",
"response",
".",
"disconnect",
"(",
")",
";",
"}"
] | 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 |
163,621 | 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",
".",
"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.\"",
";",
"}",
"}",
"}"
] | 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 |
163,622 | 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",
".",
"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",
"(",
")",
";",
"}"
] | 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 |
163,623 | 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",
"=",
"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",
"(",
")",
")",
")",
";",
"}"
] | 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 |
163,624 | 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 |
163,625 | 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",
"(",
"api",
",",
"null",
",",
"name",
",",
"params",
")",
";",
"}"
] | 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 |
163,626 | 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 |
163,627 | 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",
"(",
")",
";",
"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",
")",
";",
"}"
] | 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 |
163,628 | 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",
",",
"url",
",",
"\"GET\"",
")",
";",
"BoxJSONResponse",
"response",
"=",
"(",
"BoxJSONResponse",
")",
"request",
".",
"send",
"(",
")",
";",
"JsonObject",
"jsonObject",
"=",
"JsonObject",
".",
"readFrom",
"(",
"response",
".",
"getJSON",
"(",
")",
")",
";",
"return",
"new",
"BoxUser",
"(",
"api",
",",
"jsonObject",
".",
"get",
"(",
"\"id\"",
")",
".",
"asString",
"(",
")",
")",
";",
"}"
] | 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 |
163,629 | 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",
"(",
"api",
",",
"filterTerm",
",",
"null",
",",
"null",
",",
"fields",
")",
";",
"}"
] | 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 |
163,630 | 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",
"getUsersInfoForType",
"(",
"api",
",",
"null",
",",
"null",
",",
"externalAppUserId",
",",
"fields",
")",
";",
"}"
] | 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 |
163,631 | 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",
"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",
")",
";",
"}",
"}",
";",
"}"
] | 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 |
163,632 | 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",
"(",
"\"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",
")",
";",
"}"
] | 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 |
163,633 | 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",
".",
"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",
";",
"}"
] | 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 |
163,634 | 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",
">",
"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",
")",
";",
"}",
"}",
";",
"}"
] | 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 |
163,635 | 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",
".",
"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",
")",
";",
"}"
] | 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 |
163,636 | 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",
"(",
")",
",",
"emailAliasID",
")",
";",
"BoxAPIRequest",
"request",
"=",
"new",
"BoxAPIRequest",
"(",
"this",
".",
"getAPI",
"(",
")",
",",
"url",
",",
"\"DELETE\"",
")",
";",
"BoxAPIResponse",
"response",
"=",
"request",
".",
"send",
"(",
")",
";",
"response",
".",
"disconnect",
"(",
")",
";",
"}"
] | 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 |
163,637 | 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",
"(",
")",
")",
";",
"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",
";",
"}"
] | 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 |
163,638 | 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",
")",
")",
".",
"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",
"(",
")",
";",
"}"
] | 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 |
163,639 | 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",
"=",
"new",
"BoxAPIRequest",
"(",
"this",
".",
"getAPI",
"(",
")",
",",
"url",
",",
"\"GET\"",
")",
";",
"BoxAPIResponse",
"response",
"=",
"request",
".",
"send",
"(",
")",
";",
"return",
"response",
".",
"getBody",
"(",
")",
";",
"}"
] | 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 |
163,640 | 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",
"(",
")",
")",
";",
"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",
")",
";",
"}"
] | 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 |
163,641 | 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",
"(",
"value",
")",
";",
"}",
"return",
"array",
";",
"}"
] | 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 |
163,642 | 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 |
163,643 | 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",
".",
"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",
")",
";",
"}"
] | 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 |
163,644 | 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\"",
",",
"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",
")",
";",
"}"
] | 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 |
163,645 | 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 |
163,646 | 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",
")",
"+",
"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",
";",
"}"
] | 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 |
163,647 | 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",
"(",
")",
".",
"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",
")",
";",
"}"
] | 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 |
163,648 | 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",
"(",
")",
".",
"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",
";",
"}"
] | 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 |
163,649 | 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",
"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",
")",
";",
"}"
] | 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 |
163,650 | 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",
")",
"{",
"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",
"(",
")",
")",
";",
"}",
"}"
] | 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 |
163,651 | box/box-java-sdk | src/main/java/com/box/sdk/BoxFileUploadSession.java | BoxFileUploadSession.getStatus | public BoxFileUploadSession.Info getStatus() {
URL statusURL = this.sessionInfo.getSessionEndpoints().getStatusEndpoint();
BoxJSONRequest request = new BoxJSONRequest(this.getAPI(), statusURL, HttpMethod.GET);
BoxJSONResponse response = (BoxJSONResponse) request.send();
JsonObject jsonObject = JsonObject.readFrom(response.getJSON());
this.sessionInfo.update(jsonObject);
return this.sessionInfo;
} | java | public BoxFileUploadSession.Info getStatus() {
URL statusURL = this.sessionInfo.getSessionEndpoints().getStatusEndpoint();
BoxJSONRequest request = new BoxJSONRequest(this.getAPI(), statusURL, HttpMethod.GET);
BoxJSONResponse response = (BoxJSONResponse) request.send();
JsonObject jsonObject = JsonObject.readFrom(response.getJSON());
this.sessionInfo.update(jsonObject);
return this.sessionInfo;
} | [
"public",
"BoxFileUploadSession",
".",
"Info",
"getStatus",
"(",
")",
"{",
"URL",
"statusURL",
"=",
"this",
".",
"sessionInfo",
".",
"getSessionEndpoints",
"(",
")",
".",
"getStatusEndpoint",
"(",
")",
";",
"BoxJSONRequest",
"request",
"=",
"new",
"BoxJSONRequest",
"(",
"this",
".",
"getAPI",
"(",
")",
",",
"statusURL",
",",
"HttpMethod",
".",
"GET",
")",
";",
"BoxJSONResponse",
"response",
"=",
"(",
"BoxJSONResponse",
")",
"request",
".",
"send",
"(",
")",
";",
"JsonObject",
"jsonObject",
"=",
"JsonObject",
".",
"readFrom",
"(",
"response",
".",
"getJSON",
"(",
")",
")",
";",
"this",
".",
"sessionInfo",
".",
"update",
"(",
"jsonObject",
")",
";",
"return",
"this",
".",
"sessionInfo",
";",
"}"
] | Get the status of the upload session. It contains the number of parts that are processed so far,
the total number of parts required for the commit and expiration date and time of the upload session.
@return the status. | [
"Get",
"the",
"status",
"of",
"the",
"upload",
"session",
".",
"It",
"contains",
"the",
"number",
"of",
"parts",
"that",
"are",
"processed",
"so",
"far",
"the",
"total",
"number",
"of",
"parts",
"required",
"for",
"the",
"commit",
"and",
"expiration",
"date",
"and",
"time",
"of",
"the",
"upload",
"session",
"."
] | 35b4ba69417f9d6a002c19dfaab57527750ef349 | https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxFileUploadSession.java#L423-L432 |
163,652 | box/box-java-sdk | src/main/java/com/box/sdk/BoxFileUploadSession.java | BoxFileUploadSession.abort | public void abort() {
URL abortURL = this.sessionInfo.getSessionEndpoints().getAbortEndpoint();
BoxJSONRequest request = new BoxJSONRequest(this.getAPI(), abortURL, HttpMethod.DELETE);
request.send();
} | java | public void abort() {
URL abortURL = this.sessionInfo.getSessionEndpoints().getAbortEndpoint();
BoxJSONRequest request = new BoxJSONRequest(this.getAPI(), abortURL, HttpMethod.DELETE);
request.send();
} | [
"public",
"void",
"abort",
"(",
")",
"{",
"URL",
"abortURL",
"=",
"this",
".",
"sessionInfo",
".",
"getSessionEndpoints",
"(",
")",
".",
"getAbortEndpoint",
"(",
")",
";",
"BoxJSONRequest",
"request",
"=",
"new",
"BoxJSONRequest",
"(",
"this",
".",
"getAPI",
"(",
")",
",",
"abortURL",
",",
"HttpMethod",
".",
"DELETE",
")",
";",
"request",
".",
"send",
"(",
")",
";",
"}"
] | Abort an upload session, discarding any chunks that were uploaded to it. | [
"Abort",
"an",
"upload",
"session",
"discarding",
"any",
"chunks",
"that",
"were",
"uploaded",
"to",
"it",
"."
] | 35b4ba69417f9d6a002c19dfaab57527750ef349 | https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxFileUploadSession.java#L437-L441 |
163,653 | box/box-java-sdk | src/main/java/com/box/sdk/BoxAPIResponse.java | BoxAPIResponse.getHeaderField | public String getHeaderField(String fieldName) {
// headers map is null for all regular response calls except when made as a batch request
if (this.headers == null) {
if (this.connection != null) {
return this.connection.getHeaderField(fieldName);
} else {
return null;
}
} else {
return this.headers.get(fieldName);
}
} | java | public String getHeaderField(String fieldName) {
// headers map is null for all regular response calls except when made as a batch request
if (this.headers == null) {
if (this.connection != null) {
return this.connection.getHeaderField(fieldName);
} else {
return null;
}
} else {
return this.headers.get(fieldName);
}
} | [
"public",
"String",
"getHeaderField",
"(",
"String",
"fieldName",
")",
"{",
"// headers map is null for all regular response calls except when made as a batch request",
"if",
"(",
"this",
".",
"headers",
"==",
"null",
")",
"{",
"if",
"(",
"this",
".",
"connection",
"!=",
"null",
")",
"{",
"return",
"this",
".",
"connection",
".",
"getHeaderField",
"(",
"fieldName",
")",
";",
"}",
"else",
"{",
"return",
"null",
";",
"}",
"}",
"else",
"{",
"return",
"this",
".",
"headers",
".",
"get",
"(",
"fieldName",
")",
";",
"}",
"}"
] | Gets the value of the given header field.
@param fieldName name of the header field.
@return value of the header. | [
"Gets",
"the",
"value",
"of",
"the",
"given",
"header",
"field",
"."
] | 35b4ba69417f9d6a002c19dfaab57527750ef349 | https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxAPIResponse.java#L119-L130 |
163,654 | box/box-java-sdk | src/main/java/com/box/sdk/BoxAPIResponse.java | BoxAPIResponse.getErrorStream | private InputStream getErrorStream() {
InputStream errorStream = this.connection.getErrorStream();
if (errorStream != null) {
final String contentEncoding = this.connection.getContentEncoding();
if (contentEncoding != null && contentEncoding.equalsIgnoreCase("gzip")) {
try {
errorStream = new GZIPInputStream(errorStream);
} catch (IOException e) {
// just return the error stream as is
}
}
}
return errorStream;
} | java | private InputStream getErrorStream() {
InputStream errorStream = this.connection.getErrorStream();
if (errorStream != null) {
final String contentEncoding = this.connection.getContentEncoding();
if (contentEncoding != null && contentEncoding.equalsIgnoreCase("gzip")) {
try {
errorStream = new GZIPInputStream(errorStream);
} catch (IOException e) {
// just return the error stream as is
}
}
}
return errorStream;
} | [
"private",
"InputStream",
"getErrorStream",
"(",
")",
"{",
"InputStream",
"errorStream",
"=",
"this",
".",
"connection",
".",
"getErrorStream",
"(",
")",
";",
"if",
"(",
"errorStream",
"!=",
"null",
")",
"{",
"final",
"String",
"contentEncoding",
"=",
"this",
".",
"connection",
".",
"getContentEncoding",
"(",
")",
";",
"if",
"(",
"contentEncoding",
"!=",
"null",
"&&",
"contentEncoding",
".",
"equalsIgnoreCase",
"(",
"\"gzip\"",
")",
")",
"{",
"try",
"{",
"errorStream",
"=",
"new",
"GZIPInputStream",
"(",
"errorStream",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"// just return the error stream as is",
"}",
"}",
"}",
"return",
"errorStream",
";",
"}"
] | Returns the response error stream, handling the case when it contains gzipped data.
@return gzip decoded (if needed) error stream or null | [
"Returns",
"the",
"response",
"error",
"stream",
"handling",
"the",
"case",
"when",
"it",
"contains",
"gzipped",
"data",
"."
] | 35b4ba69417f9d6a002c19dfaab57527750ef349 | https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxAPIResponse.java#L281-L295 |
163,655 | box/box-java-sdk | src/main/java/com/box/sdk/BoxWebLink.java | BoxWebLink.updateInfo | public void updateInfo(BoxWebLink.Info info) {
URL url = WEB_LINK_URL_TEMPLATE.build(this.getAPI().getBaseURL(), this.getID());
BoxJSONRequest request = new BoxJSONRequest(this.getAPI(), url, "PUT");
request.setBody(info.getPendingChanges());
String body = info.getPendingChanges();
BoxJSONResponse response = (BoxJSONResponse) request.send();
JsonObject jsonObject = JsonObject.readFrom(response.getJSON());
info.update(jsonObject);
} | java | public void updateInfo(BoxWebLink.Info info) {
URL url = WEB_LINK_URL_TEMPLATE.build(this.getAPI().getBaseURL(), this.getID());
BoxJSONRequest request = new BoxJSONRequest(this.getAPI(), url, "PUT");
request.setBody(info.getPendingChanges());
String body = info.getPendingChanges();
BoxJSONResponse response = (BoxJSONResponse) request.send();
JsonObject jsonObject = JsonObject.readFrom(response.getJSON());
info.update(jsonObject);
} | [
"public",
"void",
"updateInfo",
"(",
"BoxWebLink",
".",
"Info",
"info",
")",
"{",
"URL",
"url",
"=",
"WEB_LINK_URL_TEMPLATE",
".",
"build",
"(",
"this",
".",
"getAPI",
"(",
")",
".",
"getBaseURL",
"(",
")",
",",
"this",
".",
"getID",
"(",
")",
")",
";",
"BoxJSONRequest",
"request",
"=",
"new",
"BoxJSONRequest",
"(",
"this",
".",
"getAPI",
"(",
")",
",",
"url",
",",
"\"PUT\"",
")",
";",
"request",
".",
"setBody",
"(",
"info",
".",
"getPendingChanges",
"(",
")",
")",
";",
"String",
"body",
"=",
"info",
".",
"getPendingChanges",
"(",
")",
";",
"BoxJSONResponse",
"response",
"=",
"(",
"BoxJSONResponse",
")",
"request",
".",
"send",
"(",
")",
";",
"JsonObject",
"jsonObject",
"=",
"JsonObject",
".",
"readFrom",
"(",
"response",
".",
"getJSON",
"(",
")",
")",
";",
"info",
".",
"update",
"(",
"jsonObject",
")",
";",
"}"
] | Updates the information about this weblink with any info fields that have been modified locally.
<p>The only fields that will be updated are the ones that have been modified locally. For example, the following
code won't update any information (or even send a network request) since none of the info's fields were
changed:</p>
<pre>BoxWebLink webLink = new BoxWebLink(api, id);
BoxWebLink.Info info = webLink.getInfo();
webLink.updateInfo(info);</pre>
@param info the updated info. | [
"Updates",
"the",
"information",
"about",
"this",
"weblink",
"with",
"any",
"info",
"fields",
"that",
"have",
"been",
"modified",
"locally",
"."
] | 35b4ba69417f9d6a002c19dfaab57527750ef349 | https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxWebLink.java#L188-L196 |
163,656 | box/box-java-sdk | src/main/java/com/box/sdk/BoxStoragePolicyAssignment.java | BoxStoragePolicyAssignment.create | public static BoxStoragePolicyAssignment.Info create(BoxAPIConnection api, String policyID, String userID) {
URL url = STORAGE_POLICY_ASSIGNMENT_URL_TEMPLATE.build(api.getBaseURL());
BoxJSONRequest request = new BoxJSONRequest(api, url, HttpMethod.POST);
JsonObject requestJSON = new JsonObject()
.add("storage_policy", new JsonObject()
.add("type", "storage_policy")
.add("id", policyID))
.add("assigned_to", new JsonObject()
.add("type", "user")
.add("id", userID));
request.setBody(requestJSON.toString());
BoxJSONResponse response = (BoxJSONResponse) request.send();
JsonObject responseJSON = JsonObject.readFrom(response.getJSON());
BoxStoragePolicyAssignment storagePolicyAssignment = new BoxStoragePolicyAssignment(api,
responseJSON.get("id").asString());
return storagePolicyAssignment.new Info(responseJSON);
} | java | public static BoxStoragePolicyAssignment.Info create(BoxAPIConnection api, String policyID, String userID) {
URL url = STORAGE_POLICY_ASSIGNMENT_URL_TEMPLATE.build(api.getBaseURL());
BoxJSONRequest request = new BoxJSONRequest(api, url, HttpMethod.POST);
JsonObject requestJSON = new JsonObject()
.add("storage_policy", new JsonObject()
.add("type", "storage_policy")
.add("id", policyID))
.add("assigned_to", new JsonObject()
.add("type", "user")
.add("id", userID));
request.setBody(requestJSON.toString());
BoxJSONResponse response = (BoxJSONResponse) request.send();
JsonObject responseJSON = JsonObject.readFrom(response.getJSON());
BoxStoragePolicyAssignment storagePolicyAssignment = new BoxStoragePolicyAssignment(api,
responseJSON.get("id").asString());
return storagePolicyAssignment.new Info(responseJSON);
} | [
"public",
"static",
"BoxStoragePolicyAssignment",
".",
"Info",
"create",
"(",
"BoxAPIConnection",
"api",
",",
"String",
"policyID",
",",
"String",
"userID",
")",
"{",
"URL",
"url",
"=",
"STORAGE_POLICY_ASSIGNMENT_URL_TEMPLATE",
".",
"build",
"(",
"api",
".",
"getBaseURL",
"(",
")",
")",
";",
"BoxJSONRequest",
"request",
"=",
"new",
"BoxJSONRequest",
"(",
"api",
",",
"url",
",",
"HttpMethod",
".",
"POST",
")",
";",
"JsonObject",
"requestJSON",
"=",
"new",
"JsonObject",
"(",
")",
".",
"add",
"(",
"\"storage_policy\"",
",",
"new",
"JsonObject",
"(",
")",
".",
"add",
"(",
"\"type\"",
",",
"\"storage_policy\"",
")",
".",
"add",
"(",
"\"id\"",
",",
"policyID",
")",
")",
".",
"add",
"(",
"\"assigned_to\"",
",",
"new",
"JsonObject",
"(",
")",
".",
"add",
"(",
"\"type\"",
",",
"\"user\"",
")",
".",
"add",
"(",
"\"id\"",
",",
"userID",
")",
")",
";",
"request",
".",
"setBody",
"(",
"requestJSON",
".",
"toString",
"(",
")",
")",
";",
"BoxJSONResponse",
"response",
"=",
"(",
"BoxJSONResponse",
")",
"request",
".",
"send",
"(",
")",
";",
"JsonObject",
"responseJSON",
"=",
"JsonObject",
".",
"readFrom",
"(",
"response",
".",
"getJSON",
"(",
")",
")",
";",
"BoxStoragePolicyAssignment",
"storagePolicyAssignment",
"=",
"new",
"BoxStoragePolicyAssignment",
"(",
"api",
",",
"responseJSON",
".",
"get",
"(",
"\"id\"",
")",
".",
"asString",
"(",
")",
")",
";",
"return",
"storagePolicyAssignment",
".",
"new",
"Info",
"(",
"responseJSON",
")",
";",
"}"
] | Create a BoxStoragePolicyAssignment for a BoxStoragePolicy.
@param api the API connection to be used by the resource.
@param policyID the policy ID of the BoxStoragePolicy.
@param userID the user ID of the to assign the BoxStoragePolicy to.
@return the information about the BoxStoragePolicyAssignment created. | [
"Create",
"a",
"BoxStoragePolicyAssignment",
"for",
"a",
"BoxStoragePolicy",
"."
] | 35b4ba69417f9d6a002c19dfaab57527750ef349 | https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxStoragePolicyAssignment.java#L45-L64 |
163,657 | box/box-java-sdk | src/main/java/com/box/sdk/BoxStoragePolicyAssignment.java | BoxStoragePolicyAssignment.getAssignmentForTarget | public static BoxStoragePolicyAssignment.Info getAssignmentForTarget(final BoxAPIConnection api,
String resolvedForType, String resolvedForID) {
QueryStringBuilder builder = new QueryStringBuilder();
builder.appendParam("resolved_for_type", resolvedForType)
.appendParam("resolved_for_id", resolvedForID);
URL url = STORAGE_POLICY_ASSIGNMENT_URL_TEMPLATE.buildWithQuery(api.getBaseURL(), builder.toString());
BoxAPIRequest request = new BoxAPIRequest(api, url, HttpMethod.GET);
BoxJSONResponse response = (BoxJSONResponse) request.send();
BoxStoragePolicyAssignment storagePolicyAssignment = new BoxStoragePolicyAssignment(api,
response.getJsonObject().get("entries").asArray().get(0).asObject().get("id").asString());
BoxStoragePolicyAssignment.Info info = storagePolicyAssignment.new
Info(response.getJsonObject().get("entries").asArray().get(0).asObject());
return info;
} | java | public static BoxStoragePolicyAssignment.Info getAssignmentForTarget(final BoxAPIConnection api,
String resolvedForType, String resolvedForID) {
QueryStringBuilder builder = new QueryStringBuilder();
builder.appendParam("resolved_for_type", resolvedForType)
.appendParam("resolved_for_id", resolvedForID);
URL url = STORAGE_POLICY_ASSIGNMENT_URL_TEMPLATE.buildWithQuery(api.getBaseURL(), builder.toString());
BoxAPIRequest request = new BoxAPIRequest(api, url, HttpMethod.GET);
BoxJSONResponse response = (BoxJSONResponse) request.send();
BoxStoragePolicyAssignment storagePolicyAssignment = new BoxStoragePolicyAssignment(api,
response.getJsonObject().get("entries").asArray().get(0).asObject().get("id").asString());
BoxStoragePolicyAssignment.Info info = storagePolicyAssignment.new
Info(response.getJsonObject().get("entries").asArray().get(0).asObject());
return info;
} | [
"public",
"static",
"BoxStoragePolicyAssignment",
".",
"Info",
"getAssignmentForTarget",
"(",
"final",
"BoxAPIConnection",
"api",
",",
"String",
"resolvedForType",
",",
"String",
"resolvedForID",
")",
"{",
"QueryStringBuilder",
"builder",
"=",
"new",
"QueryStringBuilder",
"(",
")",
";",
"builder",
".",
"appendParam",
"(",
"\"resolved_for_type\"",
",",
"resolvedForType",
")",
".",
"appendParam",
"(",
"\"resolved_for_id\"",
",",
"resolvedForID",
")",
";",
"URL",
"url",
"=",
"STORAGE_POLICY_ASSIGNMENT_URL_TEMPLATE",
".",
"buildWithQuery",
"(",
"api",
".",
"getBaseURL",
"(",
")",
",",
"builder",
".",
"toString",
"(",
")",
")",
";",
"BoxAPIRequest",
"request",
"=",
"new",
"BoxAPIRequest",
"(",
"api",
",",
"url",
",",
"HttpMethod",
".",
"GET",
")",
";",
"BoxJSONResponse",
"response",
"=",
"(",
"BoxJSONResponse",
")",
"request",
".",
"send",
"(",
")",
";",
"BoxStoragePolicyAssignment",
"storagePolicyAssignment",
"=",
"new",
"BoxStoragePolicyAssignment",
"(",
"api",
",",
"response",
".",
"getJsonObject",
"(",
")",
".",
"get",
"(",
"\"entries\"",
")",
".",
"asArray",
"(",
")",
".",
"get",
"(",
"0",
")",
".",
"asObject",
"(",
")",
".",
"get",
"(",
"\"id\"",
")",
".",
"asString",
"(",
")",
")",
";",
"BoxStoragePolicyAssignment",
".",
"Info",
"info",
"=",
"storagePolicyAssignment",
".",
"new",
"Info",
"(",
"response",
".",
"getJsonObject",
"(",
")",
".",
"get",
"(",
"\"entries\"",
")",
".",
"asArray",
"(",
")",
".",
"get",
"(",
"0",
")",
".",
"asObject",
"(",
")",
")",
";",
"return",
"info",
";",
"}"
] | Returns a BoxStoragePolicyAssignment information.
@param api the API connection to be used by the resource.
@param resolvedForType the assigned entity type for the storage policy.
@param resolvedForID the assigned entity id for the storage policy.
@return information about this {@link BoxStoragePolicyAssignment}. | [
"Returns",
"a",
"BoxStoragePolicyAssignment",
"information",
"."
] | 35b4ba69417f9d6a002c19dfaab57527750ef349 | https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxStoragePolicyAssignment.java#L88-L103 |
163,658 | box/box-java-sdk | src/main/java/com/box/sdk/BoxStoragePolicyAssignment.java | BoxStoragePolicyAssignment.delete | public void delete() {
URL url = STORAGE_POLICY_ASSIGNMENT_WITH_ID_URL_TEMPLATE.build(this.getAPI().getBaseURL(), this.getID());
BoxAPIRequest request = new BoxAPIRequest(this.getAPI(), url, HttpMethod.DELETE);
request.send();
} | java | public void delete() {
URL url = STORAGE_POLICY_ASSIGNMENT_WITH_ID_URL_TEMPLATE.build(this.getAPI().getBaseURL(), this.getID());
BoxAPIRequest request = new BoxAPIRequest(this.getAPI(), url, HttpMethod.DELETE);
request.send();
} | [
"public",
"void",
"delete",
"(",
")",
"{",
"URL",
"url",
"=",
"STORAGE_POLICY_ASSIGNMENT_WITH_ID_URL_TEMPLATE",
".",
"build",
"(",
"this",
".",
"getAPI",
"(",
")",
".",
"getBaseURL",
"(",
")",
",",
"this",
".",
"getID",
"(",
")",
")",
";",
"BoxAPIRequest",
"request",
"=",
"new",
"BoxAPIRequest",
"(",
"this",
".",
"getAPI",
"(",
")",
",",
"url",
",",
"HttpMethod",
".",
"DELETE",
")",
";",
"request",
".",
"send",
"(",
")",
";",
"}"
] | Deletes this BoxStoragePolicyAssignment. | [
"Deletes",
"this",
"BoxStoragePolicyAssignment",
"."
] | 35b4ba69417f9d6a002c19dfaab57527750ef349 | https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxStoragePolicyAssignment.java#L119-L124 |
163,659 | box/box-java-sdk | src/main/java/com/box/sdk/BoxGroup.java | BoxGroup.getAllGroupsByName | public static Iterable<BoxGroup.Info> getAllGroupsByName(final BoxAPIConnection api, String name) {
final QueryStringBuilder builder = new QueryStringBuilder();
if (name == null || name.trim().isEmpty()) {
throw new BoxAPIException("Searching groups by name requires a non NULL or non empty name");
} else {
builder.appendParam("name", name);
}
return new Iterable<BoxGroup.Info>() {
public Iterator<BoxGroup.Info> iterator() {
URL url = GROUPS_URL_TEMPLATE.buildWithQuery(api.getBaseURL(), builder.toString());
return new BoxGroupIterator(api, url);
}
};
} | java | public static Iterable<BoxGroup.Info> getAllGroupsByName(final BoxAPIConnection api, String name) {
final QueryStringBuilder builder = new QueryStringBuilder();
if (name == null || name.trim().isEmpty()) {
throw new BoxAPIException("Searching groups by name requires a non NULL or non empty name");
} else {
builder.appendParam("name", name);
}
return new Iterable<BoxGroup.Info>() {
public Iterator<BoxGroup.Info> iterator() {
URL url = GROUPS_URL_TEMPLATE.buildWithQuery(api.getBaseURL(), builder.toString());
return new BoxGroupIterator(api, url);
}
};
} | [
"public",
"static",
"Iterable",
"<",
"BoxGroup",
".",
"Info",
">",
"getAllGroupsByName",
"(",
"final",
"BoxAPIConnection",
"api",
",",
"String",
"name",
")",
"{",
"final",
"QueryStringBuilder",
"builder",
"=",
"new",
"QueryStringBuilder",
"(",
")",
";",
"if",
"(",
"name",
"==",
"null",
"||",
"name",
".",
"trim",
"(",
")",
".",
"isEmpty",
"(",
")",
")",
"{",
"throw",
"new",
"BoxAPIException",
"(",
"\"Searching groups by name requires a non NULL or non empty name\"",
")",
";",
"}",
"else",
"{",
"builder",
".",
"appendParam",
"(",
"\"name\"",
",",
"name",
")",
";",
"}",
"return",
"new",
"Iterable",
"<",
"BoxGroup",
".",
"Info",
">",
"(",
")",
"{",
"public",
"Iterator",
"<",
"BoxGroup",
".",
"Info",
">",
"iterator",
"(",
")",
"{",
"URL",
"url",
"=",
"GROUPS_URL_TEMPLATE",
".",
"buildWithQuery",
"(",
"api",
".",
"getBaseURL",
"(",
")",
",",
"builder",
".",
"toString",
"(",
")",
")",
";",
"return",
"new",
"BoxGroupIterator",
"(",
"api",
",",
"url",
")",
";",
"}",
"}",
";",
"}"
] | Gets an iterable of all the groups in the enterprise that are starting with the given name string.
@param api the API connection to be used when retrieving the groups.
@param name the name prefix of the groups. If the groups need to searched by full name that has spaces,
then the parameter string should have been wrapped with "".
@return an iterable containing info about all the groups. | [
"Gets",
"an",
"iterable",
"of",
"all",
"the",
"groups",
"in",
"the",
"enterprise",
"that",
"are",
"starting",
"with",
"the",
"given",
"name",
"string",
"."
] | 35b4ba69417f9d6a002c19dfaab57527750ef349 | https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxGroup.java#L150-L164 |
163,660 | box/box-java-sdk | src/main/java/com/box/sdk/BoxGroup.java | BoxGroup.getMemberships | public Collection<BoxGroupMembership.Info> getMemberships() {
final BoxAPIConnection api = this.getAPI();
final String groupID = this.getID();
Iterable<BoxGroupMembership.Info> iter = new Iterable<BoxGroupMembership.Info>() {
public Iterator<BoxGroupMembership.Info> iterator() {
URL url = MEMBERSHIPS_URL_TEMPLATE.build(api.getBaseURL(), groupID);
return new BoxGroupMembershipIterator(api, url);
}
};
// We need to iterate all results because this method must return a Collection. This logic should be removed in
// the next major version, and instead return the Iterable directly.
Collection<BoxGroupMembership.Info> memberships = new ArrayList<BoxGroupMembership.Info>();
for (BoxGroupMembership.Info membership : iter) {
memberships.add(membership);
}
return memberships;
} | java | public Collection<BoxGroupMembership.Info> getMemberships() {
final BoxAPIConnection api = this.getAPI();
final String groupID = this.getID();
Iterable<BoxGroupMembership.Info> iter = new Iterable<BoxGroupMembership.Info>() {
public Iterator<BoxGroupMembership.Info> iterator() {
URL url = MEMBERSHIPS_URL_TEMPLATE.build(api.getBaseURL(), groupID);
return new BoxGroupMembershipIterator(api, url);
}
};
// We need to iterate all results because this method must return a Collection. This logic should be removed in
// the next major version, and instead return the Iterable directly.
Collection<BoxGroupMembership.Info> memberships = new ArrayList<BoxGroupMembership.Info>();
for (BoxGroupMembership.Info membership : iter) {
memberships.add(membership);
}
return memberships;
} | [
"public",
"Collection",
"<",
"BoxGroupMembership",
".",
"Info",
">",
"getMemberships",
"(",
")",
"{",
"final",
"BoxAPIConnection",
"api",
"=",
"this",
".",
"getAPI",
"(",
")",
";",
"final",
"String",
"groupID",
"=",
"this",
".",
"getID",
"(",
")",
";",
"Iterable",
"<",
"BoxGroupMembership",
".",
"Info",
">",
"iter",
"=",
"new",
"Iterable",
"<",
"BoxGroupMembership",
".",
"Info",
">",
"(",
")",
"{",
"public",
"Iterator",
"<",
"BoxGroupMembership",
".",
"Info",
">",
"iterator",
"(",
")",
"{",
"URL",
"url",
"=",
"MEMBERSHIPS_URL_TEMPLATE",
".",
"build",
"(",
"api",
".",
"getBaseURL",
"(",
")",
",",
"groupID",
")",
";",
"return",
"new",
"BoxGroupMembershipIterator",
"(",
"api",
",",
"url",
")",
";",
"}",
"}",
";",
"// We need to iterate all results because this method must return a Collection. This logic should be removed in",
"// the next major version, and instead return the Iterable directly.",
"Collection",
"<",
"BoxGroupMembership",
".",
"Info",
">",
"memberships",
"=",
"new",
"ArrayList",
"<",
"BoxGroupMembership",
".",
"Info",
">",
"(",
")",
";",
"for",
"(",
"BoxGroupMembership",
".",
"Info",
"membership",
":",
"iter",
")",
"{",
"memberships",
".",
"add",
"(",
"membership",
")",
";",
"}",
"return",
"memberships",
";",
"}"
] | Gets information about all of the group memberships for this group.
Does not support paging.
@return a collection of information about the group memberships for this group. | [
"Gets",
"information",
"about",
"all",
"of",
"the",
"group",
"memberships",
"for",
"this",
"group",
".",
"Does",
"not",
"support",
"paging",
"."
] | 35b4ba69417f9d6a002c19dfaab57527750ef349 | https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxGroup.java#L200-L218 |
163,661 | box/box-java-sdk | src/main/java/com/box/sdk/BoxGroup.java | BoxGroup.addMembership | public BoxGroupMembership.Info addMembership(BoxUser user, Role role) {
BoxAPIConnection api = this.getAPI();
JsonObject requestJSON = new JsonObject();
requestJSON.add("user", new JsonObject().add("id", user.getID()));
requestJSON.add("group", new JsonObject().add("id", this.getID()));
if (role != null) {
requestJSON.add("role", role.toJSONString());
}
URL url = ADD_MEMBERSHIP_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());
BoxGroupMembership membership = new BoxGroupMembership(api, responseJSON.get("id").asString());
return membership.new Info(responseJSON);
} | java | public BoxGroupMembership.Info addMembership(BoxUser user, Role role) {
BoxAPIConnection api = this.getAPI();
JsonObject requestJSON = new JsonObject();
requestJSON.add("user", new JsonObject().add("id", user.getID()));
requestJSON.add("group", new JsonObject().add("id", this.getID()));
if (role != null) {
requestJSON.add("role", role.toJSONString());
}
URL url = ADD_MEMBERSHIP_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());
BoxGroupMembership membership = new BoxGroupMembership(api, responseJSON.get("id").asString());
return membership.new Info(responseJSON);
} | [
"public",
"BoxGroupMembership",
".",
"Info",
"addMembership",
"(",
"BoxUser",
"user",
",",
"Role",
"role",
")",
"{",
"BoxAPIConnection",
"api",
"=",
"this",
".",
"getAPI",
"(",
")",
";",
"JsonObject",
"requestJSON",
"=",
"new",
"JsonObject",
"(",
")",
";",
"requestJSON",
".",
"add",
"(",
"\"user\"",
",",
"new",
"JsonObject",
"(",
")",
".",
"add",
"(",
"\"id\"",
",",
"user",
".",
"getID",
"(",
")",
")",
")",
";",
"requestJSON",
".",
"add",
"(",
"\"group\"",
",",
"new",
"JsonObject",
"(",
")",
".",
"add",
"(",
"\"id\"",
",",
"this",
".",
"getID",
"(",
")",
")",
")",
";",
"if",
"(",
"role",
"!=",
"null",
")",
"{",
"requestJSON",
".",
"add",
"(",
"\"role\"",
",",
"role",
".",
"toJSONString",
"(",
")",
")",
";",
"}",
"URL",
"url",
"=",
"ADD_MEMBERSHIP_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",
"(",
")",
")",
";",
"BoxGroupMembership",
"membership",
"=",
"new",
"BoxGroupMembership",
"(",
"api",
",",
"responseJSON",
".",
"get",
"(",
"\"id\"",
")",
".",
"asString",
"(",
")",
")",
";",
"return",
"membership",
".",
"new",
"Info",
"(",
"responseJSON",
")",
";",
"}"
] | Adds a member to this group with the specified role.
@param user the member to be added to this group.
@param role the role of the user in this group. Can be null to assign the default role.
@return info about the new group membership. | [
"Adds",
"a",
"member",
"to",
"this",
"group",
"with",
"the",
"specified",
"role",
"."
] | 35b4ba69417f9d6a002c19dfaab57527750ef349 | https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxGroup.java#L254-L272 |
163,662 | box/box-java-sdk | src/main/java/com/box/sdk/BoxTermsOfService.java | BoxTermsOfService.create | public static BoxTermsOfService.Info create(BoxAPIConnection api,
BoxTermsOfService.TermsOfServiceStatus termsOfServiceStatus,
BoxTermsOfService.TermsOfServiceType termsOfServiceType, String text) {
URL url = ALL_TERMS_OF_SERVICES_URL_TEMPLATE.build(api.getBaseURL());
BoxJSONRequest request = new BoxJSONRequest(api, url, "POST");
JsonObject requestJSON = new JsonObject()
.add("status", termsOfServiceStatus.toString())
.add("tos_type", termsOfServiceType.toString())
.add("text", text);
request.setBody(requestJSON.toString());
BoxJSONResponse response = (BoxJSONResponse) request.send();
JsonObject responseJSON = JsonObject.readFrom(response.getJSON());
BoxTermsOfService createdTermsOfServices = new BoxTermsOfService(api, responseJSON.get("id").asString());
return createdTermsOfServices.new Info(responseJSON);
} | java | public static BoxTermsOfService.Info create(BoxAPIConnection api,
BoxTermsOfService.TermsOfServiceStatus termsOfServiceStatus,
BoxTermsOfService.TermsOfServiceType termsOfServiceType, String text) {
URL url = ALL_TERMS_OF_SERVICES_URL_TEMPLATE.build(api.getBaseURL());
BoxJSONRequest request = new BoxJSONRequest(api, url, "POST");
JsonObject requestJSON = new JsonObject()
.add("status", termsOfServiceStatus.toString())
.add("tos_type", termsOfServiceType.toString())
.add("text", text);
request.setBody(requestJSON.toString());
BoxJSONResponse response = (BoxJSONResponse) request.send();
JsonObject responseJSON = JsonObject.readFrom(response.getJSON());
BoxTermsOfService createdTermsOfServices = new BoxTermsOfService(api, responseJSON.get("id").asString());
return createdTermsOfServices.new Info(responseJSON);
} | [
"public",
"static",
"BoxTermsOfService",
".",
"Info",
"create",
"(",
"BoxAPIConnection",
"api",
",",
"BoxTermsOfService",
".",
"TermsOfServiceStatus",
"termsOfServiceStatus",
",",
"BoxTermsOfService",
".",
"TermsOfServiceType",
"termsOfServiceType",
",",
"String",
"text",
")",
"{",
"URL",
"url",
"=",
"ALL_TERMS_OF_SERVICES_URL_TEMPLATE",
".",
"build",
"(",
"api",
".",
"getBaseURL",
"(",
")",
")",
";",
"BoxJSONRequest",
"request",
"=",
"new",
"BoxJSONRequest",
"(",
"api",
",",
"url",
",",
"\"POST\"",
")",
";",
"JsonObject",
"requestJSON",
"=",
"new",
"JsonObject",
"(",
")",
".",
"add",
"(",
"\"status\"",
",",
"termsOfServiceStatus",
".",
"toString",
"(",
")",
")",
".",
"add",
"(",
"\"tos_type\"",
",",
"termsOfServiceType",
".",
"toString",
"(",
")",
")",
".",
"add",
"(",
"\"text\"",
",",
"text",
")",
";",
"request",
".",
"setBody",
"(",
"requestJSON",
".",
"toString",
"(",
")",
")",
";",
"BoxJSONResponse",
"response",
"=",
"(",
"BoxJSONResponse",
")",
"request",
".",
"send",
"(",
")",
";",
"JsonObject",
"responseJSON",
"=",
"JsonObject",
".",
"readFrom",
"(",
"response",
".",
"getJSON",
"(",
")",
")",
";",
"BoxTermsOfService",
"createdTermsOfServices",
"=",
"new",
"BoxTermsOfService",
"(",
"api",
",",
"responseJSON",
".",
"get",
"(",
"\"id\"",
")",
".",
"asString",
"(",
")",
")",
";",
"return",
"createdTermsOfServices",
".",
"new",
"Info",
"(",
"responseJSON",
")",
";",
"}"
] | Creates a new Terms of Services.
@param api the API connection to be used by the resource.
@param termsOfServiceStatus the current status of the terms of services. Set to "enabled" or "disabled".
@param termsOfServiceType the scope of terms of service. Set to "external" or "managed".
@param text the text field of terms of service containing terms of service agreement info.
@return information about the Terms of Service created. | [
"Creates",
"a",
"new",
"Terms",
"of",
"Services",
"."
] | 35b4ba69417f9d6a002c19dfaab57527750ef349 | https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxTermsOfService.java#L44-L60 |
163,663 | box/box-java-sdk | src/main/java/com/box/sdk/BoxTermsOfService.java | BoxTermsOfService.getAllTermsOfServices | public static List<BoxTermsOfService.Info> getAllTermsOfServices(final BoxAPIConnection api,
BoxTermsOfService.TermsOfServiceType
termsOfServiceType) {
QueryStringBuilder builder = new QueryStringBuilder();
if (termsOfServiceType != null) {
builder.appendParam("tos_type", termsOfServiceType.toString());
}
URL url = ALL_TERMS_OF_SERVICES_URL_TEMPLATE.buildWithQuery(api.getBaseURL(), builder.toString());
BoxAPIRequest request = new BoxAPIRequest(api, url, "GET");
BoxJSONResponse response = (BoxJSONResponse) request.send();
JsonObject responseJSON = JsonObject.readFrom(response.getJSON());
int totalCount = responseJSON.get("total_count").asInt();
List<BoxTermsOfService.Info> termsOfServices = new ArrayList<BoxTermsOfService.Info>(totalCount);
JsonArray entries = responseJSON.get("entries").asArray();
for (JsonValue value : entries) {
JsonObject termsOfServiceJSON = value.asObject();
BoxTermsOfService termsOfService = new BoxTermsOfService(api, termsOfServiceJSON.get("id").asString());
BoxTermsOfService.Info info = termsOfService.new Info(termsOfServiceJSON);
termsOfServices.add(info);
}
return termsOfServices;
} | java | public static List<BoxTermsOfService.Info> getAllTermsOfServices(final BoxAPIConnection api,
BoxTermsOfService.TermsOfServiceType
termsOfServiceType) {
QueryStringBuilder builder = new QueryStringBuilder();
if (termsOfServiceType != null) {
builder.appendParam("tos_type", termsOfServiceType.toString());
}
URL url = ALL_TERMS_OF_SERVICES_URL_TEMPLATE.buildWithQuery(api.getBaseURL(), builder.toString());
BoxAPIRequest request = new BoxAPIRequest(api, url, "GET");
BoxJSONResponse response = (BoxJSONResponse) request.send();
JsonObject responseJSON = JsonObject.readFrom(response.getJSON());
int totalCount = responseJSON.get("total_count").asInt();
List<BoxTermsOfService.Info> termsOfServices = new ArrayList<BoxTermsOfService.Info>(totalCount);
JsonArray entries = responseJSON.get("entries").asArray();
for (JsonValue value : entries) {
JsonObject termsOfServiceJSON = value.asObject();
BoxTermsOfService termsOfService = new BoxTermsOfService(api, termsOfServiceJSON.get("id").asString());
BoxTermsOfService.Info info = termsOfService.new Info(termsOfServiceJSON);
termsOfServices.add(info);
}
return termsOfServices;
} | [
"public",
"static",
"List",
"<",
"BoxTermsOfService",
".",
"Info",
">",
"getAllTermsOfServices",
"(",
"final",
"BoxAPIConnection",
"api",
",",
"BoxTermsOfService",
".",
"TermsOfServiceType",
"termsOfServiceType",
")",
"{",
"QueryStringBuilder",
"builder",
"=",
"new",
"QueryStringBuilder",
"(",
")",
";",
"if",
"(",
"termsOfServiceType",
"!=",
"null",
")",
"{",
"builder",
".",
"appendParam",
"(",
"\"tos_type\"",
",",
"termsOfServiceType",
".",
"toString",
"(",
")",
")",
";",
"}",
"URL",
"url",
"=",
"ALL_TERMS_OF_SERVICES_URL_TEMPLATE",
".",
"buildWithQuery",
"(",
"api",
".",
"getBaseURL",
"(",
")",
",",
"builder",
".",
"toString",
"(",
")",
")",
";",
"BoxAPIRequest",
"request",
"=",
"new",
"BoxAPIRequest",
"(",
"api",
",",
"url",
",",
"\"GET\"",
")",
";",
"BoxJSONResponse",
"response",
"=",
"(",
"BoxJSONResponse",
")",
"request",
".",
"send",
"(",
")",
";",
"JsonObject",
"responseJSON",
"=",
"JsonObject",
".",
"readFrom",
"(",
"response",
".",
"getJSON",
"(",
")",
")",
";",
"int",
"totalCount",
"=",
"responseJSON",
".",
"get",
"(",
"\"total_count\"",
")",
".",
"asInt",
"(",
")",
";",
"List",
"<",
"BoxTermsOfService",
".",
"Info",
">",
"termsOfServices",
"=",
"new",
"ArrayList",
"<",
"BoxTermsOfService",
".",
"Info",
">",
"(",
"totalCount",
")",
";",
"JsonArray",
"entries",
"=",
"responseJSON",
".",
"get",
"(",
"\"entries\"",
")",
".",
"asArray",
"(",
")",
";",
"for",
"(",
"JsonValue",
"value",
":",
"entries",
")",
"{",
"JsonObject",
"termsOfServiceJSON",
"=",
"value",
".",
"asObject",
"(",
")",
";",
"BoxTermsOfService",
"termsOfService",
"=",
"new",
"BoxTermsOfService",
"(",
"api",
",",
"termsOfServiceJSON",
".",
"get",
"(",
"\"id\"",
")",
".",
"asString",
"(",
")",
")",
";",
"BoxTermsOfService",
".",
"Info",
"info",
"=",
"termsOfService",
".",
"new",
"Info",
"(",
"termsOfServiceJSON",
")",
";",
"termsOfServices",
".",
"add",
"(",
"info",
")",
";",
"}",
"return",
"termsOfServices",
";",
"}"
] | Retrieves a list of Terms of Service that belong to your Enterprise as an Iterable.
@param api api the API connection to be used by the resource.
@param termsOfServiceType the type of terms of service to be retrieved. Can be set to "managed" or "external"
@return the Iterable of Terms of Service in an Enterprise that match the filter parameters. | [
"Retrieves",
"a",
"list",
"of",
"Terms",
"of",
"Service",
"that",
"belong",
"to",
"your",
"Enterprise",
"as",
"an",
"Iterable",
"."
] | 35b4ba69417f9d6a002c19dfaab57527750ef349 | https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxTermsOfService.java#L102-L126 |
163,664 | box/box-java-sdk | src/main/java/com/box/sdk/internal/utils/Parsers.java | Parsers.parseAndPopulateMetadataMap | public static Map<String, Map<String, Metadata>> parseAndPopulateMetadataMap(JsonObject jsonObject) {
Map<String, Map<String, Metadata>> metadataMap = new HashMap<String, Map<String, Metadata>>();
//Parse all templates
for (JsonObject.Member templateMember : jsonObject) {
if (templateMember.getValue().isNull()) {
continue;
} else {
String templateName = templateMember.getName();
Map<String, Metadata> scopeMap = metadataMap.get(templateName);
//If templateName doesn't yet exist then create an entry with empty scope map
if (scopeMap == null) {
scopeMap = new HashMap<String, Metadata>();
metadataMap.put(templateName, scopeMap);
}
//Parse all scopes in a template
for (JsonObject.Member scopeMember : templateMember.getValue().asObject()) {
String scope = scopeMember.getName();
Metadata metadataObject = new Metadata(scopeMember.getValue().asObject());
scopeMap.put(scope, metadataObject);
}
}
}
return metadataMap;
} | java | public static Map<String, Map<String, Metadata>> parseAndPopulateMetadataMap(JsonObject jsonObject) {
Map<String, Map<String, Metadata>> metadataMap = new HashMap<String, Map<String, Metadata>>();
//Parse all templates
for (JsonObject.Member templateMember : jsonObject) {
if (templateMember.getValue().isNull()) {
continue;
} else {
String templateName = templateMember.getName();
Map<String, Metadata> scopeMap = metadataMap.get(templateName);
//If templateName doesn't yet exist then create an entry with empty scope map
if (scopeMap == null) {
scopeMap = new HashMap<String, Metadata>();
metadataMap.put(templateName, scopeMap);
}
//Parse all scopes in a template
for (JsonObject.Member scopeMember : templateMember.getValue().asObject()) {
String scope = scopeMember.getName();
Metadata metadataObject = new Metadata(scopeMember.getValue().asObject());
scopeMap.put(scope, metadataObject);
}
}
}
return metadataMap;
} | [
"public",
"static",
"Map",
"<",
"String",
",",
"Map",
"<",
"String",
",",
"Metadata",
">",
">",
"parseAndPopulateMetadataMap",
"(",
"JsonObject",
"jsonObject",
")",
"{",
"Map",
"<",
"String",
",",
"Map",
"<",
"String",
",",
"Metadata",
">",
">",
"metadataMap",
"=",
"new",
"HashMap",
"<",
"String",
",",
"Map",
"<",
"String",
",",
"Metadata",
">",
">",
"(",
")",
";",
"//Parse all templates",
"for",
"(",
"JsonObject",
".",
"Member",
"templateMember",
":",
"jsonObject",
")",
"{",
"if",
"(",
"templateMember",
".",
"getValue",
"(",
")",
".",
"isNull",
"(",
")",
")",
"{",
"continue",
";",
"}",
"else",
"{",
"String",
"templateName",
"=",
"templateMember",
".",
"getName",
"(",
")",
";",
"Map",
"<",
"String",
",",
"Metadata",
">",
"scopeMap",
"=",
"metadataMap",
".",
"get",
"(",
"templateName",
")",
";",
"//If templateName doesn't yet exist then create an entry with empty scope map",
"if",
"(",
"scopeMap",
"==",
"null",
")",
"{",
"scopeMap",
"=",
"new",
"HashMap",
"<",
"String",
",",
"Metadata",
">",
"(",
")",
";",
"metadataMap",
".",
"put",
"(",
"templateName",
",",
"scopeMap",
")",
";",
"}",
"//Parse all scopes in a template",
"for",
"(",
"JsonObject",
".",
"Member",
"scopeMember",
":",
"templateMember",
".",
"getValue",
"(",
")",
".",
"asObject",
"(",
")",
")",
"{",
"String",
"scope",
"=",
"scopeMember",
".",
"getName",
"(",
")",
";",
"Metadata",
"metadataObject",
"=",
"new",
"Metadata",
"(",
"scopeMember",
".",
"getValue",
"(",
")",
".",
"asObject",
"(",
")",
")",
";",
"scopeMap",
".",
"put",
"(",
"scope",
",",
"metadataObject",
")",
";",
"}",
"}",
"}",
"return",
"metadataMap",
";",
"}"
] | Creates a map of metadata from json.
@param jsonObject metadata json object for metadata field in get /files?fileds=,etadata.scope.template response
@return Map of String as key a value another Map with a String key and Metadata value | [
"Creates",
"a",
"map",
"of",
"metadata",
"from",
"json",
"."
] | 35b4ba69417f9d6a002c19dfaab57527750ef349 | https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/internal/utils/Parsers.java#L29-L53 |
163,665 | box/box-java-sdk | src/main/java/com/box/sdk/internal/utils/Parsers.java | Parsers.parseRepresentations | public static List<Representation> parseRepresentations(JsonObject jsonObject) {
List<Representation> representations = new ArrayList<Representation>();
for (JsonValue representationJson : jsonObject.get("entries").asArray()) {
Representation representation = new Representation(representationJson.asObject());
representations.add(representation);
}
return representations;
} | java | public static List<Representation> parseRepresentations(JsonObject jsonObject) {
List<Representation> representations = new ArrayList<Representation>();
for (JsonValue representationJson : jsonObject.get("entries").asArray()) {
Representation representation = new Representation(representationJson.asObject());
representations.add(representation);
}
return representations;
} | [
"public",
"static",
"List",
"<",
"Representation",
">",
"parseRepresentations",
"(",
"JsonObject",
"jsonObject",
")",
"{",
"List",
"<",
"Representation",
">",
"representations",
"=",
"new",
"ArrayList",
"<",
"Representation",
">",
"(",
")",
";",
"for",
"(",
"JsonValue",
"representationJson",
":",
"jsonObject",
".",
"get",
"(",
"\"entries\"",
")",
".",
"asArray",
"(",
")",
")",
"{",
"Representation",
"representation",
"=",
"new",
"Representation",
"(",
"representationJson",
".",
"asObject",
"(",
")",
")",
";",
"representations",
".",
"add",
"(",
"representation",
")",
";",
"}",
"return",
"representations",
";",
"}"
] | Parse representations from a file object response.
@param jsonObject representations json object in get response for /files/file-id?fields=representations
@return list of representations | [
"Parse",
"representations",
"from",
"a",
"file",
"object",
"response",
"."
] | 35b4ba69417f9d6a002c19dfaab57527750ef349 | https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/internal/utils/Parsers.java#L60-L67 |
163,666 | box/box-java-sdk | src/main/java/com/box/sdk/BoxTermsOfServiceUserStatus.java | BoxTermsOfServiceUserStatus.updateInfo | public void updateInfo(BoxTermsOfServiceUserStatus.Info info) {
URL url = TERMS_OF_SERVICE_USER_STATUSES_TEMPLATE.build(this.getAPI().getBaseURL(), this.getID());
BoxJSONRequest request = new BoxJSONRequest(this.getAPI(), url, "PUT");
request.setBody(info.getPendingChanges());
BoxJSONResponse response = (BoxJSONResponse) request.send();
JsonObject responseJSON = JsonObject.readFrom(response.getJSON());
info.update(responseJSON);
} | java | public void updateInfo(BoxTermsOfServiceUserStatus.Info info) {
URL url = TERMS_OF_SERVICE_USER_STATUSES_TEMPLATE.build(this.getAPI().getBaseURL(), this.getID());
BoxJSONRequest request = new BoxJSONRequest(this.getAPI(), url, "PUT");
request.setBody(info.getPendingChanges());
BoxJSONResponse response = (BoxJSONResponse) request.send();
JsonObject responseJSON = JsonObject.readFrom(response.getJSON());
info.update(responseJSON);
} | [
"public",
"void",
"updateInfo",
"(",
"BoxTermsOfServiceUserStatus",
".",
"Info",
"info",
")",
"{",
"URL",
"url",
"=",
"TERMS_OF_SERVICE_USER_STATUSES_TEMPLATE",
".",
"build",
"(",
"this",
".",
"getAPI",
"(",
")",
".",
"getBaseURL",
"(",
")",
",",
"this",
".",
"getID",
"(",
")",
")",
";",
"BoxJSONRequest",
"request",
"=",
"new",
"BoxJSONRequest",
"(",
"this",
".",
"getAPI",
"(",
")",
",",
"url",
",",
"\"PUT\"",
")",
";",
"request",
".",
"setBody",
"(",
"info",
".",
"getPendingChanges",
"(",
")",
")",
";",
"BoxJSONResponse",
"response",
"=",
"(",
"BoxJSONResponse",
")",
"request",
".",
"send",
"(",
")",
";",
"JsonObject",
"responseJSON",
"=",
"JsonObject",
".",
"readFrom",
"(",
"response",
".",
"getJSON",
"(",
")",
")",
";",
"info",
".",
"update",
"(",
"responseJSON",
")",
";",
"}"
] | Updates the information about the user status for this terms of service with any info fields that have
been modified locally.
@param info the updated info. | [
"Updates",
"the",
"information",
"about",
"the",
"user",
"status",
"for",
"this",
"terms",
"of",
"service",
"with",
"any",
"info",
"fields",
"that",
"have",
"been",
"modified",
"locally",
"."
] | 35b4ba69417f9d6a002c19dfaab57527750ef349 | https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxTermsOfServiceUserStatus.java#L133-L141 |
163,667 | box/box-java-sdk | src/main/java/com/box/sdk/BatchAPIRequest.java | BatchAPIRequest.execute | public List<BoxAPIResponse> execute(List<BoxAPIRequest> requests) {
this.prepareRequest(requests);
BoxJSONResponse batchResponse = (BoxJSONResponse) send();
return this.parseResponse(batchResponse);
} | java | public List<BoxAPIResponse> execute(List<BoxAPIRequest> requests) {
this.prepareRequest(requests);
BoxJSONResponse batchResponse = (BoxJSONResponse) send();
return this.parseResponse(batchResponse);
} | [
"public",
"List",
"<",
"BoxAPIResponse",
">",
"execute",
"(",
"List",
"<",
"BoxAPIRequest",
">",
"requests",
")",
"{",
"this",
".",
"prepareRequest",
"(",
"requests",
")",
";",
"BoxJSONResponse",
"batchResponse",
"=",
"(",
"BoxJSONResponse",
")",
"send",
"(",
")",
";",
"return",
"this",
".",
"parseResponse",
"(",
"batchResponse",
")",
";",
"}"
] | Execute a set of API calls as batch request.
@param requests list of api requests that has to be executed in batch.
@return list of BoxAPIResponses | [
"Execute",
"a",
"set",
"of",
"API",
"calls",
"as",
"batch",
"request",
"."
] | 35b4ba69417f9d6a002c19dfaab57527750ef349 | https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BatchAPIRequest.java#L44-L48 |
163,668 | box/box-java-sdk | src/main/java/com/box/sdk/BatchAPIRequest.java | BatchAPIRequest.prepareRequest | protected void prepareRequest(List<BoxAPIRequest> requests) {
JsonObject body = new JsonObject();
JsonArray requestsJSONArray = new JsonArray();
for (BoxAPIRequest request: requests) {
JsonObject batchRequest = new JsonObject();
batchRequest.add("method", request.getMethod());
batchRequest.add("relative_url", request.getUrl().toString().substring(this.api.getBaseURL().length() - 1));
//If the actual request has a JSON body then add it to vatch request
if (request instanceof BoxJSONRequest) {
BoxJSONRequest jsonRequest = (BoxJSONRequest) request;
batchRequest.add("body", jsonRequest.getBodyAsJsonValue());
}
//Add any headers that are in the request, except Authorization
if (request.getHeaders() != null) {
JsonObject batchRequestHeaders = new JsonObject();
for (RequestHeader header: request.getHeaders()) {
if (header.getKey() != null && !header.getKey().isEmpty()
&& !HttpHeaders.AUTHORIZATION.equals(header.getKey())) {
batchRequestHeaders.add(header.getKey(), header.getValue());
}
}
batchRequest.add("headers", batchRequestHeaders);
}
//Add the request to array
requestsJSONArray.add(batchRequest);
}
//Add the requests array to body
body.add("requests", requestsJSONArray);
super.setBody(body);
} | java | protected void prepareRequest(List<BoxAPIRequest> requests) {
JsonObject body = new JsonObject();
JsonArray requestsJSONArray = new JsonArray();
for (BoxAPIRequest request: requests) {
JsonObject batchRequest = new JsonObject();
batchRequest.add("method", request.getMethod());
batchRequest.add("relative_url", request.getUrl().toString().substring(this.api.getBaseURL().length() - 1));
//If the actual request has a JSON body then add it to vatch request
if (request instanceof BoxJSONRequest) {
BoxJSONRequest jsonRequest = (BoxJSONRequest) request;
batchRequest.add("body", jsonRequest.getBodyAsJsonValue());
}
//Add any headers that are in the request, except Authorization
if (request.getHeaders() != null) {
JsonObject batchRequestHeaders = new JsonObject();
for (RequestHeader header: request.getHeaders()) {
if (header.getKey() != null && !header.getKey().isEmpty()
&& !HttpHeaders.AUTHORIZATION.equals(header.getKey())) {
batchRequestHeaders.add(header.getKey(), header.getValue());
}
}
batchRequest.add("headers", batchRequestHeaders);
}
//Add the request to array
requestsJSONArray.add(batchRequest);
}
//Add the requests array to body
body.add("requests", requestsJSONArray);
super.setBody(body);
} | [
"protected",
"void",
"prepareRequest",
"(",
"List",
"<",
"BoxAPIRequest",
">",
"requests",
")",
"{",
"JsonObject",
"body",
"=",
"new",
"JsonObject",
"(",
")",
";",
"JsonArray",
"requestsJSONArray",
"=",
"new",
"JsonArray",
"(",
")",
";",
"for",
"(",
"BoxAPIRequest",
"request",
":",
"requests",
")",
"{",
"JsonObject",
"batchRequest",
"=",
"new",
"JsonObject",
"(",
")",
";",
"batchRequest",
".",
"add",
"(",
"\"method\"",
",",
"request",
".",
"getMethod",
"(",
")",
")",
";",
"batchRequest",
".",
"add",
"(",
"\"relative_url\"",
",",
"request",
".",
"getUrl",
"(",
")",
".",
"toString",
"(",
")",
".",
"substring",
"(",
"this",
".",
"api",
".",
"getBaseURL",
"(",
")",
".",
"length",
"(",
")",
"-",
"1",
")",
")",
";",
"//If the actual request has a JSON body then add it to vatch request",
"if",
"(",
"request",
"instanceof",
"BoxJSONRequest",
")",
"{",
"BoxJSONRequest",
"jsonRequest",
"=",
"(",
"BoxJSONRequest",
")",
"request",
";",
"batchRequest",
".",
"add",
"(",
"\"body\"",
",",
"jsonRequest",
".",
"getBodyAsJsonValue",
"(",
")",
")",
";",
"}",
"//Add any headers that are in the request, except Authorization",
"if",
"(",
"request",
".",
"getHeaders",
"(",
")",
"!=",
"null",
")",
"{",
"JsonObject",
"batchRequestHeaders",
"=",
"new",
"JsonObject",
"(",
")",
";",
"for",
"(",
"RequestHeader",
"header",
":",
"request",
".",
"getHeaders",
"(",
")",
")",
"{",
"if",
"(",
"header",
".",
"getKey",
"(",
")",
"!=",
"null",
"&&",
"!",
"header",
".",
"getKey",
"(",
")",
".",
"isEmpty",
"(",
")",
"&&",
"!",
"HttpHeaders",
".",
"AUTHORIZATION",
".",
"equals",
"(",
"header",
".",
"getKey",
"(",
")",
")",
")",
"{",
"batchRequestHeaders",
".",
"add",
"(",
"header",
".",
"getKey",
"(",
")",
",",
"header",
".",
"getValue",
"(",
")",
")",
";",
"}",
"}",
"batchRequest",
".",
"add",
"(",
"\"headers\"",
",",
"batchRequestHeaders",
")",
";",
"}",
"//Add the request to array",
"requestsJSONArray",
".",
"add",
"(",
"batchRequest",
")",
";",
"}",
"//Add the requests array to body",
"body",
".",
"add",
"(",
"\"requests\"",
",",
"requestsJSONArray",
")",
";",
"super",
".",
"setBody",
"(",
"body",
")",
";",
"}"
] | Prepare a batch api request using list of individual reuests.
@param requests list of api requests that has to be executed in batch. | [
"Prepare",
"a",
"batch",
"api",
"request",
"using",
"list",
"of",
"individual",
"reuests",
"."
] | 35b4ba69417f9d6a002c19dfaab57527750ef349 | https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BatchAPIRequest.java#L54-L84 |
163,669 | box/box-java-sdk | src/main/java/com/box/sdk/BatchAPIRequest.java | BatchAPIRequest.parseResponse | protected List<BoxAPIResponse> parseResponse(BoxJSONResponse batchResponse) {
JsonObject responseJSON = JsonObject.readFrom(batchResponse.getJSON());
List<BoxAPIResponse> responses = new ArrayList<BoxAPIResponse>();
Iterator<JsonValue> responseIterator = responseJSON.get("responses").asArray().iterator();
while (responseIterator.hasNext()) {
JsonObject jsonResponse = responseIterator.next().asObject();
BoxAPIResponse response = null;
//Gather headers
Map<String, String> responseHeaders = new HashMap<String, String>();
if (jsonResponse.get("headers") != null) {
JsonObject batchResponseHeadersObject = jsonResponse.get("headers").asObject();
for (JsonObject.Member member : batchResponseHeadersObject) {
String headerName = member.getName();
String headerValue = member.getValue().asString();
responseHeaders.put(headerName, headerValue);
}
}
// Construct a BoxAPIResponse when response is null, or a BoxJSONResponse when there's a response
// (not anticipating any other response as per current APIs.
// Ideally we should do it based on response header)
if (jsonResponse.get("response") == null || jsonResponse.get("response").isNull()) {
response =
new BoxAPIResponse(jsonResponse.get("status").asInt(), responseHeaders);
} else {
response =
new BoxJSONResponse(jsonResponse.get("status").asInt(), responseHeaders,
jsonResponse.get("response").asObject());
}
responses.add(response);
}
return responses;
} | java | protected List<BoxAPIResponse> parseResponse(BoxJSONResponse batchResponse) {
JsonObject responseJSON = JsonObject.readFrom(batchResponse.getJSON());
List<BoxAPIResponse> responses = new ArrayList<BoxAPIResponse>();
Iterator<JsonValue> responseIterator = responseJSON.get("responses").asArray().iterator();
while (responseIterator.hasNext()) {
JsonObject jsonResponse = responseIterator.next().asObject();
BoxAPIResponse response = null;
//Gather headers
Map<String, String> responseHeaders = new HashMap<String, String>();
if (jsonResponse.get("headers") != null) {
JsonObject batchResponseHeadersObject = jsonResponse.get("headers").asObject();
for (JsonObject.Member member : batchResponseHeadersObject) {
String headerName = member.getName();
String headerValue = member.getValue().asString();
responseHeaders.put(headerName, headerValue);
}
}
// Construct a BoxAPIResponse when response is null, or a BoxJSONResponse when there's a response
// (not anticipating any other response as per current APIs.
// Ideally we should do it based on response header)
if (jsonResponse.get("response") == null || jsonResponse.get("response").isNull()) {
response =
new BoxAPIResponse(jsonResponse.get("status").asInt(), responseHeaders);
} else {
response =
new BoxJSONResponse(jsonResponse.get("status").asInt(), responseHeaders,
jsonResponse.get("response").asObject());
}
responses.add(response);
}
return responses;
} | [
"protected",
"List",
"<",
"BoxAPIResponse",
">",
"parseResponse",
"(",
"BoxJSONResponse",
"batchResponse",
")",
"{",
"JsonObject",
"responseJSON",
"=",
"JsonObject",
".",
"readFrom",
"(",
"batchResponse",
".",
"getJSON",
"(",
")",
")",
";",
"List",
"<",
"BoxAPIResponse",
">",
"responses",
"=",
"new",
"ArrayList",
"<",
"BoxAPIResponse",
">",
"(",
")",
";",
"Iterator",
"<",
"JsonValue",
">",
"responseIterator",
"=",
"responseJSON",
".",
"get",
"(",
"\"responses\"",
")",
".",
"asArray",
"(",
")",
".",
"iterator",
"(",
")",
";",
"while",
"(",
"responseIterator",
".",
"hasNext",
"(",
")",
")",
"{",
"JsonObject",
"jsonResponse",
"=",
"responseIterator",
".",
"next",
"(",
")",
".",
"asObject",
"(",
")",
";",
"BoxAPIResponse",
"response",
"=",
"null",
";",
"//Gather headers",
"Map",
"<",
"String",
",",
"String",
">",
"responseHeaders",
"=",
"new",
"HashMap",
"<",
"String",
",",
"String",
">",
"(",
")",
";",
"if",
"(",
"jsonResponse",
".",
"get",
"(",
"\"headers\"",
")",
"!=",
"null",
")",
"{",
"JsonObject",
"batchResponseHeadersObject",
"=",
"jsonResponse",
".",
"get",
"(",
"\"headers\"",
")",
".",
"asObject",
"(",
")",
";",
"for",
"(",
"JsonObject",
".",
"Member",
"member",
":",
"batchResponseHeadersObject",
")",
"{",
"String",
"headerName",
"=",
"member",
".",
"getName",
"(",
")",
";",
"String",
"headerValue",
"=",
"member",
".",
"getValue",
"(",
")",
".",
"asString",
"(",
")",
";",
"responseHeaders",
".",
"put",
"(",
"headerName",
",",
"headerValue",
")",
";",
"}",
"}",
"// Construct a BoxAPIResponse when response is null, or a BoxJSONResponse when there's a response",
"// (not anticipating any other response as per current APIs.",
"// Ideally we should do it based on response header)",
"if",
"(",
"jsonResponse",
".",
"get",
"(",
"\"response\"",
")",
"==",
"null",
"||",
"jsonResponse",
".",
"get",
"(",
"\"response\"",
")",
".",
"isNull",
"(",
")",
")",
"{",
"response",
"=",
"new",
"BoxAPIResponse",
"(",
"jsonResponse",
".",
"get",
"(",
"\"status\"",
")",
".",
"asInt",
"(",
")",
",",
"responseHeaders",
")",
";",
"}",
"else",
"{",
"response",
"=",
"new",
"BoxJSONResponse",
"(",
"jsonResponse",
".",
"get",
"(",
"\"status\"",
")",
".",
"asInt",
"(",
")",
",",
"responseHeaders",
",",
"jsonResponse",
".",
"get",
"(",
"\"response\"",
")",
".",
"asObject",
"(",
")",
")",
";",
"}",
"responses",
".",
"add",
"(",
"response",
")",
";",
"}",
"return",
"responses",
";",
"}"
] | Parses btch api response to create a list of BoxAPIResponse objects.
@param batchResponse response of a batch api request
@return list of BoxAPIResponses | [
"Parses",
"btch",
"api",
"response",
"to",
"create",
"a",
"list",
"of",
"BoxAPIResponse",
"objects",
"."
] | 35b4ba69417f9d6a002c19dfaab57527750ef349 | https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BatchAPIRequest.java#L91-L125 |
163,670 | apache/fluo | modules/core/src/main/java/org/apache/fluo/core/util/ScanUtil.java | ScanUtil.generateJson | private static void generateJson(CellScanner cellScanner, Function<Bytes, String> encoder,
PrintStream out) throws JsonIOException {
Gson gson = new GsonBuilder().serializeNulls().setDateFormat(DateFormat.LONG)
.setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES).setVersion(1.0)
.create();
Map<String, String> json = new LinkedHashMap<>();
for (RowColumnValue rcv : cellScanner) {
json.put(FLUO_ROW, encoder.apply(rcv.getRow()));
json.put(FLUO_COLUMN_FAMILY, encoder.apply(rcv.getColumn().getFamily()));
json.put(FLUO_COLUMN_QUALIFIER, encoder.apply(rcv.getColumn().getQualifier()));
json.put(FLUO_COLUMN_VISIBILITY, encoder.apply(rcv.getColumn().getVisibility()));
json.put(FLUO_VALUE, encoder.apply(rcv.getValue()));
gson.toJson(json, out);
out.append("\n");
if (out.checkError()) {
break;
}
}
out.flush();
} | java | private static void generateJson(CellScanner cellScanner, Function<Bytes, String> encoder,
PrintStream out) throws JsonIOException {
Gson gson = new GsonBuilder().serializeNulls().setDateFormat(DateFormat.LONG)
.setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES).setVersion(1.0)
.create();
Map<String, String> json = new LinkedHashMap<>();
for (RowColumnValue rcv : cellScanner) {
json.put(FLUO_ROW, encoder.apply(rcv.getRow()));
json.put(FLUO_COLUMN_FAMILY, encoder.apply(rcv.getColumn().getFamily()));
json.put(FLUO_COLUMN_QUALIFIER, encoder.apply(rcv.getColumn().getQualifier()));
json.put(FLUO_COLUMN_VISIBILITY, encoder.apply(rcv.getColumn().getVisibility()));
json.put(FLUO_VALUE, encoder.apply(rcv.getValue()));
gson.toJson(json, out);
out.append("\n");
if (out.checkError()) {
break;
}
}
out.flush();
} | [
"private",
"static",
"void",
"generateJson",
"(",
"CellScanner",
"cellScanner",
",",
"Function",
"<",
"Bytes",
",",
"String",
">",
"encoder",
",",
"PrintStream",
"out",
")",
"throws",
"JsonIOException",
"{",
"Gson",
"gson",
"=",
"new",
"GsonBuilder",
"(",
")",
".",
"serializeNulls",
"(",
")",
".",
"setDateFormat",
"(",
"DateFormat",
".",
"LONG",
")",
".",
"setFieldNamingPolicy",
"(",
"FieldNamingPolicy",
".",
"LOWER_CASE_WITH_UNDERSCORES",
")",
".",
"setVersion",
"(",
"1.0",
")",
".",
"create",
"(",
")",
";",
"Map",
"<",
"String",
",",
"String",
">",
"json",
"=",
"new",
"LinkedHashMap",
"<>",
"(",
")",
";",
"for",
"(",
"RowColumnValue",
"rcv",
":",
"cellScanner",
")",
"{",
"json",
".",
"put",
"(",
"FLUO_ROW",
",",
"encoder",
".",
"apply",
"(",
"rcv",
".",
"getRow",
"(",
")",
")",
")",
";",
"json",
".",
"put",
"(",
"FLUO_COLUMN_FAMILY",
",",
"encoder",
".",
"apply",
"(",
"rcv",
".",
"getColumn",
"(",
")",
".",
"getFamily",
"(",
")",
")",
")",
";",
"json",
".",
"put",
"(",
"FLUO_COLUMN_QUALIFIER",
",",
"encoder",
".",
"apply",
"(",
"rcv",
".",
"getColumn",
"(",
")",
".",
"getQualifier",
"(",
")",
")",
")",
";",
"json",
".",
"put",
"(",
"FLUO_COLUMN_VISIBILITY",
",",
"encoder",
".",
"apply",
"(",
"rcv",
".",
"getColumn",
"(",
")",
".",
"getVisibility",
"(",
")",
")",
")",
";",
"json",
".",
"put",
"(",
"FLUO_VALUE",
",",
"encoder",
".",
"apply",
"(",
"rcv",
".",
"getValue",
"(",
")",
")",
")",
";",
"gson",
".",
"toJson",
"(",
"json",
",",
"out",
")",
";",
"out",
".",
"append",
"(",
"\"\\n\"",
")",
";",
"if",
"(",
"out",
".",
"checkError",
"(",
")",
")",
"{",
"break",
";",
"}",
"}",
"out",
".",
"flush",
"(",
")",
";",
"}"
] | Generate JSON format as result of the scan.
@since 1.2 | [
"Generate",
"JSON",
"format",
"as",
"result",
"of",
"the",
"scan",
"."
] | 8e06204d4167651e2d3b5219b8c1397644e6ba6e | https://github.com/apache/fluo/blob/8e06204d4167651e2d3b5219b8c1397644e6ba6e/modules/core/src/main/java/org/apache/fluo/core/util/ScanUtil.java#L181-L202 |
163,671 | apache/fluo | modules/core/src/main/java/org/apache/fluo/core/impl/TxInfo.java | TxInfo.getTransactionInfo | public static TxInfo getTransactionInfo(Environment env, Bytes prow, Column pcol, long startTs) {
// TODO ensure primary is visible
IteratorSetting is = new IteratorSetting(10, RollbackCheckIterator.class);
RollbackCheckIterator.setLocktime(is, startTs);
Entry<Key, Value> entry = ColumnUtil.checkColumn(env, is, prow, pcol);
TxInfo txInfo = new TxInfo();
if (entry == null) {
txInfo.status = TxStatus.UNKNOWN;
return txInfo;
}
ColumnType colType = ColumnType.from(entry.getKey());
long ts = entry.getKey().getTimestamp() & ColumnConstants.TIMESTAMP_MASK;
switch (colType) {
case LOCK: {
if (ts == startTs) {
txInfo.status = TxStatus.LOCKED;
txInfo.lockValue = entry.getValue().get();
} else {
txInfo.status = TxStatus.UNKNOWN; // locked by another tx
}
break;
}
case DEL_LOCK: {
DelLockValue dlv = new DelLockValue(entry.getValue().get());
if (ts != startTs) {
// expect this to always be false, must be a bug in the iterator
throw new IllegalStateException(prow + " " + pcol + " (" + ts + " != " + startTs + ") ");
}
if (dlv.isRollback()) {
txInfo.status = TxStatus.ROLLED_BACK;
} else {
txInfo.status = TxStatus.COMMITTED;
txInfo.commitTs = dlv.getCommitTimestamp();
}
break;
}
case WRITE: {
long timePtr = WriteValue.getTimestamp(entry.getValue().get());
if (timePtr != startTs) {
// expect this to always be false, must be a bug in the iterator
throw new IllegalStateException(
prow + " " + pcol + " (" + timePtr + " != " + startTs + ") ");
}
txInfo.status = TxStatus.COMMITTED;
txInfo.commitTs = ts;
break;
}
default:
throw new IllegalStateException("unexpected col type returned " + colType);
}
return txInfo;
} | java | public static TxInfo getTransactionInfo(Environment env, Bytes prow, Column pcol, long startTs) {
// TODO ensure primary is visible
IteratorSetting is = new IteratorSetting(10, RollbackCheckIterator.class);
RollbackCheckIterator.setLocktime(is, startTs);
Entry<Key, Value> entry = ColumnUtil.checkColumn(env, is, prow, pcol);
TxInfo txInfo = new TxInfo();
if (entry == null) {
txInfo.status = TxStatus.UNKNOWN;
return txInfo;
}
ColumnType colType = ColumnType.from(entry.getKey());
long ts = entry.getKey().getTimestamp() & ColumnConstants.TIMESTAMP_MASK;
switch (colType) {
case LOCK: {
if (ts == startTs) {
txInfo.status = TxStatus.LOCKED;
txInfo.lockValue = entry.getValue().get();
} else {
txInfo.status = TxStatus.UNKNOWN; // locked by another tx
}
break;
}
case DEL_LOCK: {
DelLockValue dlv = new DelLockValue(entry.getValue().get());
if (ts != startTs) {
// expect this to always be false, must be a bug in the iterator
throw new IllegalStateException(prow + " " + pcol + " (" + ts + " != " + startTs + ") ");
}
if (dlv.isRollback()) {
txInfo.status = TxStatus.ROLLED_BACK;
} else {
txInfo.status = TxStatus.COMMITTED;
txInfo.commitTs = dlv.getCommitTimestamp();
}
break;
}
case WRITE: {
long timePtr = WriteValue.getTimestamp(entry.getValue().get());
if (timePtr != startTs) {
// expect this to always be false, must be a bug in the iterator
throw new IllegalStateException(
prow + " " + pcol + " (" + timePtr + " != " + startTs + ") ");
}
txInfo.status = TxStatus.COMMITTED;
txInfo.commitTs = ts;
break;
}
default:
throw new IllegalStateException("unexpected col type returned " + colType);
}
return txInfo;
} | [
"public",
"static",
"TxInfo",
"getTransactionInfo",
"(",
"Environment",
"env",
",",
"Bytes",
"prow",
",",
"Column",
"pcol",
",",
"long",
"startTs",
")",
"{",
"// TODO ensure primary is visible",
"IteratorSetting",
"is",
"=",
"new",
"IteratorSetting",
"(",
"10",
",",
"RollbackCheckIterator",
".",
"class",
")",
";",
"RollbackCheckIterator",
".",
"setLocktime",
"(",
"is",
",",
"startTs",
")",
";",
"Entry",
"<",
"Key",
",",
"Value",
">",
"entry",
"=",
"ColumnUtil",
".",
"checkColumn",
"(",
"env",
",",
"is",
",",
"prow",
",",
"pcol",
")",
";",
"TxInfo",
"txInfo",
"=",
"new",
"TxInfo",
"(",
")",
";",
"if",
"(",
"entry",
"==",
"null",
")",
"{",
"txInfo",
".",
"status",
"=",
"TxStatus",
".",
"UNKNOWN",
";",
"return",
"txInfo",
";",
"}",
"ColumnType",
"colType",
"=",
"ColumnType",
".",
"from",
"(",
"entry",
".",
"getKey",
"(",
")",
")",
";",
"long",
"ts",
"=",
"entry",
".",
"getKey",
"(",
")",
".",
"getTimestamp",
"(",
")",
"&",
"ColumnConstants",
".",
"TIMESTAMP_MASK",
";",
"switch",
"(",
"colType",
")",
"{",
"case",
"LOCK",
":",
"{",
"if",
"(",
"ts",
"==",
"startTs",
")",
"{",
"txInfo",
".",
"status",
"=",
"TxStatus",
".",
"LOCKED",
";",
"txInfo",
".",
"lockValue",
"=",
"entry",
".",
"getValue",
"(",
")",
".",
"get",
"(",
")",
";",
"}",
"else",
"{",
"txInfo",
".",
"status",
"=",
"TxStatus",
".",
"UNKNOWN",
";",
"// locked by another tx",
"}",
"break",
";",
"}",
"case",
"DEL_LOCK",
":",
"{",
"DelLockValue",
"dlv",
"=",
"new",
"DelLockValue",
"(",
"entry",
".",
"getValue",
"(",
")",
".",
"get",
"(",
")",
")",
";",
"if",
"(",
"ts",
"!=",
"startTs",
")",
"{",
"// expect this to always be false, must be a bug in the iterator",
"throw",
"new",
"IllegalStateException",
"(",
"prow",
"+",
"\" \"",
"+",
"pcol",
"+",
"\" (\"",
"+",
"ts",
"+",
"\" != \"",
"+",
"startTs",
"+",
"\") \"",
")",
";",
"}",
"if",
"(",
"dlv",
".",
"isRollback",
"(",
")",
")",
"{",
"txInfo",
".",
"status",
"=",
"TxStatus",
".",
"ROLLED_BACK",
";",
"}",
"else",
"{",
"txInfo",
".",
"status",
"=",
"TxStatus",
".",
"COMMITTED",
";",
"txInfo",
".",
"commitTs",
"=",
"dlv",
".",
"getCommitTimestamp",
"(",
")",
";",
"}",
"break",
";",
"}",
"case",
"WRITE",
":",
"{",
"long",
"timePtr",
"=",
"WriteValue",
".",
"getTimestamp",
"(",
"entry",
".",
"getValue",
"(",
")",
".",
"get",
"(",
")",
")",
";",
"if",
"(",
"timePtr",
"!=",
"startTs",
")",
"{",
"// expect this to always be false, must be a bug in the iterator",
"throw",
"new",
"IllegalStateException",
"(",
"prow",
"+",
"\" \"",
"+",
"pcol",
"+",
"\" (\"",
"+",
"timePtr",
"+",
"\" != \"",
"+",
"startTs",
"+",
"\") \"",
")",
";",
"}",
"txInfo",
".",
"status",
"=",
"TxStatus",
".",
"COMMITTED",
";",
"txInfo",
".",
"commitTs",
"=",
"ts",
";",
"break",
";",
"}",
"default",
":",
"throw",
"new",
"IllegalStateException",
"(",
"\"unexpected col type returned \"",
"+",
"colType",
")",
";",
"}",
"return",
"txInfo",
";",
"}"
] | determine the what state a transaction is in by inspecting the primary column | [
"determine",
"the",
"what",
"state",
"a",
"transaction",
"is",
"in",
"by",
"inspecting",
"the",
"primary",
"column"
] | 8e06204d4167651e2d3b5219b8c1397644e6ba6e | https://github.com/apache/fluo/blob/8e06204d4167651e2d3b5219b8c1397644e6ba6e/modules/core/src/main/java/org/apache/fluo/core/impl/TxInfo.java#L40-L102 |
163,672 | apache/fluo | modules/core/src/main/java/org/apache/fluo/core/util/OracleServerUtils.java | OracleServerUtils.oracleExists | public static boolean oracleExists(CuratorFramework curator) {
boolean exists = false;
try {
exists = curator.checkExists().forPath(ZookeeperPath.ORACLE_SERVER) != null
&& !curator.getChildren().forPath(ZookeeperPath.ORACLE_SERVER).isEmpty();
} catch (Exception nne) {
if (nne instanceof KeeperException.NoNodeException) {
// you'll do nothing
} else {
throw new RuntimeException(nne);
}
}
return exists;
} | java | public static boolean oracleExists(CuratorFramework curator) {
boolean exists = false;
try {
exists = curator.checkExists().forPath(ZookeeperPath.ORACLE_SERVER) != null
&& !curator.getChildren().forPath(ZookeeperPath.ORACLE_SERVER).isEmpty();
} catch (Exception nne) {
if (nne instanceof KeeperException.NoNodeException) {
// you'll do nothing
} else {
throw new RuntimeException(nne);
}
}
return exists;
} | [
"public",
"static",
"boolean",
"oracleExists",
"(",
"CuratorFramework",
"curator",
")",
"{",
"boolean",
"exists",
"=",
"false",
";",
"try",
"{",
"exists",
"=",
"curator",
".",
"checkExists",
"(",
")",
".",
"forPath",
"(",
"ZookeeperPath",
".",
"ORACLE_SERVER",
")",
"!=",
"null",
"&&",
"!",
"curator",
".",
"getChildren",
"(",
")",
".",
"forPath",
"(",
"ZookeeperPath",
".",
"ORACLE_SERVER",
")",
".",
"isEmpty",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"nne",
")",
"{",
"if",
"(",
"nne",
"instanceof",
"KeeperException",
".",
"NoNodeException",
")",
"{",
"// you'll do nothing",
"}",
"else",
"{",
"throw",
"new",
"RuntimeException",
"(",
"nne",
")",
";",
"}",
"}",
"return",
"exists",
";",
"}"
] | Checks to see if an Oracle Server exists.
@param curator It is the responsibility of the caller to ensure the curator is started
@return boolean if the server exists in zookeeper | [
"Checks",
"to",
"see",
"if",
"an",
"Oracle",
"Server",
"exists",
"."
] | 8e06204d4167651e2d3b5219b8c1397644e6ba6e | https://github.com/apache/fluo/blob/8e06204d4167651e2d3b5219b8c1397644e6ba6e/modules/core/src/main/java/org/apache/fluo/core/util/OracleServerUtils.java#L32-L45 |
163,673 | apache/fluo | modules/core/src/main/java/org/apache/fluo/core/impl/SharedBatchWriter.java | SharedBatchWriter.waitForAsyncFlush | public void waitForAsyncFlush() {
long numAdded = asyncBatchesAdded.get();
synchronized (this) {
while (numAdded > asyncBatchesProcessed) {
try {
wait();
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
}
}
} | java | public void waitForAsyncFlush() {
long numAdded = asyncBatchesAdded.get();
synchronized (this) {
while (numAdded > asyncBatchesProcessed) {
try {
wait();
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
}
}
} | [
"public",
"void",
"waitForAsyncFlush",
"(",
")",
"{",
"long",
"numAdded",
"=",
"asyncBatchesAdded",
".",
"get",
"(",
")",
";",
"synchronized",
"(",
"this",
")",
"{",
"while",
"(",
"numAdded",
">",
"asyncBatchesProcessed",
")",
"{",
"try",
"{",
"wait",
"(",
")",
";",
"}",
"catch",
"(",
"InterruptedException",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"e",
")",
";",
"}",
"}",
"}",
"}"
] | waits for all async mutations that were added before this was called to be flushed. Does not
wait for async mutations added after call. | [
"waits",
"for",
"all",
"async",
"mutations",
"that",
"were",
"added",
"before",
"this",
"was",
"called",
"to",
"be",
"flushed",
".",
"Does",
"not",
"wait",
"for",
"async",
"mutations",
"added",
"after",
"call",
"."
] | 8e06204d4167651e2d3b5219b8c1397644e6ba6e | https://github.com/apache/fluo/blob/8e06204d4167651e2d3b5219b8c1397644e6ba6e/modules/core/src/main/java/org/apache/fluo/core/impl/SharedBatchWriter.java#L216-L228 |
163,674 | apache/fluo | modules/api/src/main/java/org/apache/fluo/api/data/Span.java | Span.exact | public static Span exact(Bytes row) {
Objects.requireNonNull(row);
return new Span(row, true, row, true);
} | java | public static Span exact(Bytes row) {
Objects.requireNonNull(row);
return new Span(row, true, row, true);
} | [
"public",
"static",
"Span",
"exact",
"(",
"Bytes",
"row",
")",
"{",
"Objects",
".",
"requireNonNull",
"(",
"row",
")",
";",
"return",
"new",
"Span",
"(",
"row",
",",
"true",
",",
"row",
",",
"true",
")",
";",
"}"
] | Creates a span that covers an exact row | [
"Creates",
"a",
"span",
"that",
"covers",
"an",
"exact",
"row"
] | 8e06204d4167651e2d3b5219b8c1397644e6ba6e | https://github.com/apache/fluo/blob/8e06204d4167651e2d3b5219b8c1397644e6ba6e/modules/api/src/main/java/org/apache/fluo/api/data/Span.java#L206-L209 |
163,675 | apache/fluo | modules/api/src/main/java/org/apache/fluo/api/data/Span.java | Span.exact | public static Span exact(CharSequence row) {
Objects.requireNonNull(row);
return exact(Bytes.of(row));
} | java | public static Span exact(CharSequence row) {
Objects.requireNonNull(row);
return exact(Bytes.of(row));
} | [
"public",
"static",
"Span",
"exact",
"(",
"CharSequence",
"row",
")",
"{",
"Objects",
".",
"requireNonNull",
"(",
"row",
")",
";",
"return",
"exact",
"(",
"Bytes",
".",
"of",
"(",
"row",
")",
")",
";",
"}"
] | Creates a Span that covers an exact row. String parameters will be encoded as UTF-8 | [
"Creates",
"a",
"Span",
"that",
"covers",
"an",
"exact",
"row",
".",
"String",
"parameters",
"will",
"be",
"encoded",
"as",
"UTF",
"-",
"8"
] | 8e06204d4167651e2d3b5219b8c1397644e6ba6e | https://github.com/apache/fluo/blob/8e06204d4167651e2d3b5219b8c1397644e6ba6e/modules/api/src/main/java/org/apache/fluo/api/data/Span.java#L214-L217 |
163,676 | apache/fluo | modules/api/src/main/java/org/apache/fluo/api/data/Span.java | Span.prefix | public static Span prefix(Bytes rowPrefix) {
Objects.requireNonNull(rowPrefix);
Bytes fp = followingPrefix(rowPrefix);
return new Span(rowPrefix, true, fp == null ? Bytes.EMPTY : fp, false);
} | java | public static Span prefix(Bytes rowPrefix) {
Objects.requireNonNull(rowPrefix);
Bytes fp = followingPrefix(rowPrefix);
return new Span(rowPrefix, true, fp == null ? Bytes.EMPTY : fp, false);
} | [
"public",
"static",
"Span",
"prefix",
"(",
"Bytes",
"rowPrefix",
")",
"{",
"Objects",
".",
"requireNonNull",
"(",
"rowPrefix",
")",
";",
"Bytes",
"fp",
"=",
"followingPrefix",
"(",
"rowPrefix",
")",
";",
"return",
"new",
"Span",
"(",
"rowPrefix",
",",
"true",
",",
"fp",
"==",
"null",
"?",
"Bytes",
".",
"EMPTY",
":",
"fp",
",",
"false",
")",
";",
"}"
] | Returns a Span that covers all rows beginning with a prefix. | [
"Returns",
"a",
"Span",
"that",
"covers",
"all",
"rows",
"beginning",
"with",
"a",
"prefix",
"."
] | 8e06204d4167651e2d3b5219b8c1397644e6ba6e | https://github.com/apache/fluo/blob/8e06204d4167651e2d3b5219b8c1397644e6ba6e/modules/api/src/main/java/org/apache/fluo/api/data/Span.java#L266-L270 |
163,677 | apache/fluo | modules/api/src/main/java/org/apache/fluo/api/data/Span.java | Span.prefix | public static Span prefix(CharSequence rowPrefix) {
Objects.requireNonNull(rowPrefix);
return prefix(Bytes.of(rowPrefix));
} | java | public static Span prefix(CharSequence rowPrefix) {
Objects.requireNonNull(rowPrefix);
return prefix(Bytes.of(rowPrefix));
} | [
"public",
"static",
"Span",
"prefix",
"(",
"CharSequence",
"rowPrefix",
")",
"{",
"Objects",
".",
"requireNonNull",
"(",
"rowPrefix",
")",
";",
"return",
"prefix",
"(",
"Bytes",
".",
"of",
"(",
"rowPrefix",
")",
")",
";",
"}"
] | Returns a Span that covers all rows beginning with a prefix String parameters will be encoded
as UTF-8 | [
"Returns",
"a",
"Span",
"that",
"covers",
"all",
"rows",
"beginning",
"with",
"a",
"prefix",
"String",
"parameters",
"will",
"be",
"encoded",
"as",
"UTF",
"-",
"8"
] | 8e06204d4167651e2d3b5219b8c1397644e6ba6e | https://github.com/apache/fluo/blob/8e06204d4167651e2d3b5219b8c1397644e6ba6e/modules/api/src/main/java/org/apache/fluo/api/data/Span.java#L276-L279 |
163,678 | apache/fluo | modules/api/src/main/java/org/apache/fluo/api/config/SimpleConfiguration.java | SimpleConfiguration.load | public void load(InputStream in) {
try {
PropertiesConfiguration config = new PropertiesConfiguration();
// disabled to prevent accumulo classpath value from being shortened
config.setDelimiterParsingDisabled(true);
config.load(in);
((CompositeConfiguration) internalConfig).addConfiguration(config);
} catch (ConfigurationException e) {
throw new IllegalArgumentException(e);
}
} | java | public void load(InputStream in) {
try {
PropertiesConfiguration config = new PropertiesConfiguration();
// disabled to prevent accumulo classpath value from being shortened
config.setDelimiterParsingDisabled(true);
config.load(in);
((CompositeConfiguration) internalConfig).addConfiguration(config);
} catch (ConfigurationException e) {
throw new IllegalArgumentException(e);
}
} | [
"public",
"void",
"load",
"(",
"InputStream",
"in",
")",
"{",
"try",
"{",
"PropertiesConfiguration",
"config",
"=",
"new",
"PropertiesConfiguration",
"(",
")",
";",
"// disabled to prevent accumulo classpath value from being shortened",
"config",
".",
"setDelimiterParsingDisabled",
"(",
"true",
")",
";",
"config",
".",
"load",
"(",
"in",
")",
";",
"(",
"(",
"CompositeConfiguration",
")",
"internalConfig",
")",
".",
"addConfiguration",
"(",
"config",
")",
";",
"}",
"catch",
"(",
"ConfigurationException",
"e",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"e",
")",
";",
"}",
"}"
] | Loads configuration from InputStream. Later loads have lower priority.
@param in InputStream to load from
@since 1.2.0 | [
"Loads",
"configuration",
"from",
"InputStream",
".",
"Later",
"loads",
"have",
"lower",
"priority",
"."
] | 8e06204d4167651e2d3b5219b8c1397644e6ba6e | https://github.com/apache/fluo/blob/8e06204d4167651e2d3b5219b8c1397644e6ba6e/modules/api/src/main/java/org/apache/fluo/api/config/SimpleConfiguration.java#L176-L186 |
163,679 | apache/fluo | modules/api/src/main/java/org/apache/fluo/api/config/SimpleConfiguration.java | SimpleConfiguration.load | public void load(File file) {
try {
PropertiesConfiguration config = new PropertiesConfiguration();
// disabled to prevent accumulo classpath value from being shortened
config.setDelimiterParsingDisabled(true);
config.load(file);
((CompositeConfiguration) internalConfig).addConfiguration(config);
} catch (ConfigurationException e) {
throw new IllegalArgumentException(e);
}
} | java | public void load(File file) {
try {
PropertiesConfiguration config = new PropertiesConfiguration();
// disabled to prevent accumulo classpath value from being shortened
config.setDelimiterParsingDisabled(true);
config.load(file);
((CompositeConfiguration) internalConfig).addConfiguration(config);
} catch (ConfigurationException e) {
throw new IllegalArgumentException(e);
}
} | [
"public",
"void",
"load",
"(",
"File",
"file",
")",
"{",
"try",
"{",
"PropertiesConfiguration",
"config",
"=",
"new",
"PropertiesConfiguration",
"(",
")",
";",
"// disabled to prevent accumulo classpath value from being shortened",
"config",
".",
"setDelimiterParsingDisabled",
"(",
"true",
")",
";",
"config",
".",
"load",
"(",
"file",
")",
";",
"(",
"(",
"CompositeConfiguration",
")",
"internalConfig",
")",
".",
"addConfiguration",
"(",
"config",
")",
";",
"}",
"catch",
"(",
"ConfigurationException",
"e",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"e",
")",
";",
"}",
"}"
] | Loads configuration from File. Later loads have lower priority.
@param file File to load from
@since 1.2.0 | [
"Loads",
"configuration",
"from",
"File",
".",
"Later",
"loads",
"have",
"lower",
"priority",
"."
] | 8e06204d4167651e2d3b5219b8c1397644e6ba6e | https://github.com/apache/fluo/blob/8e06204d4167651e2d3b5219b8c1397644e6ba6e/modules/api/src/main/java/org/apache/fluo/api/config/SimpleConfiguration.java#L194-L204 |
163,680 | apache/fluo | modules/core/src/main/java/org/apache/fluo/core/impl/FluoConfigurationImpl.java | FluoConfigurationImpl.getTxInfoCacheWeight | public static long getTxInfoCacheWeight(FluoConfiguration conf) {
long size = conf.getLong(TX_INFO_CACHE_WEIGHT, TX_INFO_CACHE_WEIGHT_DEFAULT);
if (size <= 0) {
throw new IllegalArgumentException("Cache size must be positive for " + TX_INFO_CACHE_WEIGHT);
}
return size;
} | java | public static long getTxInfoCacheWeight(FluoConfiguration conf) {
long size = conf.getLong(TX_INFO_CACHE_WEIGHT, TX_INFO_CACHE_WEIGHT_DEFAULT);
if (size <= 0) {
throw new IllegalArgumentException("Cache size must be positive for " + TX_INFO_CACHE_WEIGHT);
}
return size;
} | [
"public",
"static",
"long",
"getTxInfoCacheWeight",
"(",
"FluoConfiguration",
"conf",
")",
"{",
"long",
"size",
"=",
"conf",
".",
"getLong",
"(",
"TX_INFO_CACHE_WEIGHT",
",",
"TX_INFO_CACHE_WEIGHT_DEFAULT",
")",
";",
"if",
"(",
"size",
"<=",
"0",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Cache size must be positive for \"",
"+",
"TX_INFO_CACHE_WEIGHT",
")",
";",
"}",
"return",
"size",
";",
"}"
] | Gets the txinfo cache weight
@param conf The FluoConfiguration
@return The size of the cache value from the property value {@value #TX_INFO_CACHE_WEIGHT} if
it is set, else the value of the default value {@value #TX_INFO_CACHE_WEIGHT_DEFAULT} | [
"Gets",
"the",
"txinfo",
"cache",
"weight"
] | 8e06204d4167651e2d3b5219b8c1397644e6ba6e | https://github.com/apache/fluo/blob/8e06204d4167651e2d3b5219b8c1397644e6ba6e/modules/core/src/main/java/org/apache/fluo/core/impl/FluoConfigurationImpl.java#L118-L124 |
163,681 | apache/fluo | modules/core/src/main/java/org/apache/fluo/core/impl/FluoConfigurationImpl.java | FluoConfigurationImpl.getVisibilityCacheWeight | public static long getVisibilityCacheWeight(FluoConfiguration conf) {
long size = conf.getLong(VISIBILITY_CACHE_WEIGHT, VISIBILITY_CACHE_WEIGHT_DEFAULT);
if (size <= 0) {
throw new IllegalArgumentException(
"Cache size must be positive for " + VISIBILITY_CACHE_WEIGHT);
}
return size;
} | java | public static long getVisibilityCacheWeight(FluoConfiguration conf) {
long size = conf.getLong(VISIBILITY_CACHE_WEIGHT, VISIBILITY_CACHE_WEIGHT_DEFAULT);
if (size <= 0) {
throw new IllegalArgumentException(
"Cache size must be positive for " + VISIBILITY_CACHE_WEIGHT);
}
return size;
} | [
"public",
"static",
"long",
"getVisibilityCacheWeight",
"(",
"FluoConfiguration",
"conf",
")",
"{",
"long",
"size",
"=",
"conf",
".",
"getLong",
"(",
"VISIBILITY_CACHE_WEIGHT",
",",
"VISIBILITY_CACHE_WEIGHT_DEFAULT",
")",
";",
"if",
"(",
"size",
"<=",
"0",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Cache size must be positive for \"",
"+",
"VISIBILITY_CACHE_WEIGHT",
")",
";",
"}",
"return",
"size",
";",
"}"
] | Gets the visibility cache weight
@param conf The FluoConfiguration
@return The size of the cache value from the property value {@value #VISIBILITY_CACHE_WEIGHT}
if it is set, else the value of the default value
{@value #VISIBILITY_CACHE_WEIGHT_DEFAULT} | [
"Gets",
"the",
"visibility",
"cache",
"weight"
] | 8e06204d4167651e2d3b5219b8c1397644e6ba6e | https://github.com/apache/fluo/blob/8e06204d4167651e2d3b5219b8c1397644e6ba6e/modules/core/src/main/java/org/apache/fluo/core/impl/FluoConfigurationImpl.java#L159-L166 |
163,682 | apache/fluo | modules/accumulo/src/main/java/org/apache/fluo/accumulo/util/ZookeeperUtil.java | ZookeeperUtil.parseServers | public static String parseServers(String zookeepers) {
int slashIndex = zookeepers.indexOf("/");
if (slashIndex != -1) {
return zookeepers.substring(0, slashIndex);
}
return zookeepers;
} | java | public static String parseServers(String zookeepers) {
int slashIndex = zookeepers.indexOf("/");
if (slashIndex != -1) {
return zookeepers.substring(0, slashIndex);
}
return zookeepers;
} | [
"public",
"static",
"String",
"parseServers",
"(",
"String",
"zookeepers",
")",
"{",
"int",
"slashIndex",
"=",
"zookeepers",
".",
"indexOf",
"(",
"\"/\"",
")",
";",
"if",
"(",
"slashIndex",
"!=",
"-",
"1",
")",
"{",
"return",
"zookeepers",
".",
"substring",
"(",
"0",
",",
"slashIndex",
")",
";",
"}",
"return",
"zookeepers",
";",
"}"
] | Parses server section of Zookeeper connection string | [
"Parses",
"server",
"section",
"of",
"Zookeeper",
"connection",
"string"
] | 8e06204d4167651e2d3b5219b8c1397644e6ba6e | https://github.com/apache/fluo/blob/8e06204d4167651e2d3b5219b8c1397644e6ba6e/modules/accumulo/src/main/java/org/apache/fluo/accumulo/util/ZookeeperUtil.java#L41-L47 |
163,683 | apache/fluo | modules/accumulo/src/main/java/org/apache/fluo/accumulo/util/ZookeeperUtil.java | ZookeeperUtil.parseRoot | public static String parseRoot(String zookeepers) {
int slashIndex = zookeepers.indexOf("/");
if (slashIndex != -1) {
return zookeepers.substring(slashIndex).trim();
}
return "/";
} | java | public static String parseRoot(String zookeepers) {
int slashIndex = zookeepers.indexOf("/");
if (slashIndex != -1) {
return zookeepers.substring(slashIndex).trim();
}
return "/";
} | [
"public",
"static",
"String",
"parseRoot",
"(",
"String",
"zookeepers",
")",
"{",
"int",
"slashIndex",
"=",
"zookeepers",
".",
"indexOf",
"(",
"\"/\"",
")",
";",
"if",
"(",
"slashIndex",
"!=",
"-",
"1",
")",
"{",
"return",
"zookeepers",
".",
"substring",
"(",
"slashIndex",
")",
".",
"trim",
"(",
")",
";",
"}",
"return",
"\"/\"",
";",
"}"
] | Parses chroot section of Zookeeper connection string
@param zookeepers Zookeeper connection string
@return Returns root path or "/" if none found | [
"Parses",
"chroot",
"section",
"of",
"Zookeeper",
"connection",
"string"
] | 8e06204d4167651e2d3b5219b8c1397644e6ba6e | https://github.com/apache/fluo/blob/8e06204d4167651e2d3b5219b8c1397644e6ba6e/modules/accumulo/src/main/java/org/apache/fluo/accumulo/util/ZookeeperUtil.java#L55-L61 |
163,684 | apache/fluo | modules/accumulo/src/main/java/org/apache/fluo/accumulo/util/ZookeeperUtil.java | ZookeeperUtil.getGcTimestamp | public static long getGcTimestamp(String zookeepers) {
ZooKeeper zk = null;
try {
zk = new ZooKeeper(zookeepers, 30000, null);
// wait until zookeeper is connected
long start = System.currentTimeMillis();
while (!zk.getState().isConnected() && System.currentTimeMillis() - start < 30000) {
Uninterruptibles.sleepUninterruptibly(10, TimeUnit.MILLISECONDS);
}
byte[] d = zk.getData(ZookeeperPath.ORACLE_GC_TIMESTAMP, false, null);
return LongUtil.fromByteArray(d);
} catch (KeeperException | InterruptedException | IOException e) {
log.warn("Failed to get oldest timestamp of Oracle from Zookeeper", e);
return OLDEST_POSSIBLE;
} finally {
if (zk != null) {
try {
zk.close();
} catch (InterruptedException e) {
log.error("Failed to close zookeeper client", e);
}
}
}
} | java | public static long getGcTimestamp(String zookeepers) {
ZooKeeper zk = null;
try {
zk = new ZooKeeper(zookeepers, 30000, null);
// wait until zookeeper is connected
long start = System.currentTimeMillis();
while (!zk.getState().isConnected() && System.currentTimeMillis() - start < 30000) {
Uninterruptibles.sleepUninterruptibly(10, TimeUnit.MILLISECONDS);
}
byte[] d = zk.getData(ZookeeperPath.ORACLE_GC_TIMESTAMP, false, null);
return LongUtil.fromByteArray(d);
} catch (KeeperException | InterruptedException | IOException e) {
log.warn("Failed to get oldest timestamp of Oracle from Zookeeper", e);
return OLDEST_POSSIBLE;
} finally {
if (zk != null) {
try {
zk.close();
} catch (InterruptedException e) {
log.error("Failed to close zookeeper client", e);
}
}
}
} | [
"public",
"static",
"long",
"getGcTimestamp",
"(",
"String",
"zookeepers",
")",
"{",
"ZooKeeper",
"zk",
"=",
"null",
";",
"try",
"{",
"zk",
"=",
"new",
"ZooKeeper",
"(",
"zookeepers",
",",
"30000",
",",
"null",
")",
";",
"// wait until zookeeper is connected",
"long",
"start",
"=",
"System",
".",
"currentTimeMillis",
"(",
")",
";",
"while",
"(",
"!",
"zk",
".",
"getState",
"(",
")",
".",
"isConnected",
"(",
")",
"&&",
"System",
".",
"currentTimeMillis",
"(",
")",
"-",
"start",
"<",
"30000",
")",
"{",
"Uninterruptibles",
".",
"sleepUninterruptibly",
"(",
"10",
",",
"TimeUnit",
".",
"MILLISECONDS",
")",
";",
"}",
"byte",
"[",
"]",
"d",
"=",
"zk",
".",
"getData",
"(",
"ZookeeperPath",
".",
"ORACLE_GC_TIMESTAMP",
",",
"false",
",",
"null",
")",
";",
"return",
"LongUtil",
".",
"fromByteArray",
"(",
"d",
")",
";",
"}",
"catch",
"(",
"KeeperException",
"|",
"InterruptedException",
"|",
"IOException",
"e",
")",
"{",
"log",
".",
"warn",
"(",
"\"Failed to get oldest timestamp of Oracle from Zookeeper\"",
",",
"e",
")",
";",
"return",
"OLDEST_POSSIBLE",
";",
"}",
"finally",
"{",
"if",
"(",
"zk",
"!=",
"null",
")",
"{",
"try",
"{",
"zk",
".",
"close",
"(",
")",
";",
"}",
"catch",
"(",
"InterruptedException",
"e",
")",
"{",
"log",
".",
"error",
"(",
"\"Failed to close zookeeper client\"",
",",
"e",
")",
";",
"}",
"}",
"}",
"}"
] | Retrieves the GC timestamp, set by the Oracle, from zookeeper
@param zookeepers Zookeeper connection string
@return Oldest active timestamp or oldest possible ts (-1) if not found | [
"Retrieves",
"the",
"GC",
"timestamp",
"set",
"by",
"the",
"Oracle",
"from",
"zookeeper"
] | 8e06204d4167651e2d3b5219b8c1397644e6ba6e | https://github.com/apache/fluo/blob/8e06204d4167651e2d3b5219b8c1397644e6ba6e/modules/accumulo/src/main/java/org/apache/fluo/accumulo/util/ZookeeperUtil.java#L69-L94 |
163,685 | apache/fluo | modules/core/src/main/java/org/apache/fluo/core/util/ByteUtil.java | ByteUtil.toBytes | public static Bytes toBytes(Text t) {
return Bytes.of(t.getBytes(), 0, t.getLength());
} | java | public static Bytes toBytes(Text t) {
return Bytes.of(t.getBytes(), 0, t.getLength());
} | [
"public",
"static",
"Bytes",
"toBytes",
"(",
"Text",
"t",
")",
"{",
"return",
"Bytes",
".",
"of",
"(",
"t",
".",
"getBytes",
"(",
")",
",",
"0",
",",
"t",
".",
"getLength",
"(",
")",
")",
";",
"}"
] | Convert from Hadoop Text to Bytes | [
"Convert",
"from",
"Hadoop",
"Text",
"to",
"Bytes"
] | 8e06204d4167651e2d3b5219b8c1397644e6ba6e | https://github.com/apache/fluo/blob/8e06204d4167651e2d3b5219b8c1397644e6ba6e/modules/core/src/main/java/org/apache/fluo/core/util/ByteUtil.java#L48-L50 |
163,686 | apache/fluo | modules/mapreduce/src/main/java/org/apache/fluo/mapreduce/FluoEntryInputFormat.java | FluoEntryInputFormat.configure | public static void configure(Job conf, SimpleConfiguration config) {
try {
FluoConfiguration fconfig = new FluoConfiguration(config);
try (Environment env = new Environment(fconfig)) {
long ts =
env.getSharedResources().getTimestampTracker().allocateTimestamp().getTxTimestamp();
conf.getConfiguration().setLong(TIMESTAMP_CONF_KEY, ts);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
config.save(baos);
conf.getConfiguration().set(PROPS_CONF_KEY,
new String(baos.toByteArray(), StandardCharsets.UTF_8));
AccumuloInputFormat.setZooKeeperInstance(conf, fconfig.getAccumuloInstance(),
fconfig.getAccumuloZookeepers());
AccumuloInputFormat.setConnectorInfo(conf, fconfig.getAccumuloUser(),
new PasswordToken(fconfig.getAccumuloPassword()));
AccumuloInputFormat.setInputTableName(conf, env.getTable());
AccumuloInputFormat.setScanAuthorizations(conf, env.getAuthorizations());
}
} catch (Exception e) {
throw new RuntimeException(e);
}
} | java | public static void configure(Job conf, SimpleConfiguration config) {
try {
FluoConfiguration fconfig = new FluoConfiguration(config);
try (Environment env = new Environment(fconfig)) {
long ts =
env.getSharedResources().getTimestampTracker().allocateTimestamp().getTxTimestamp();
conf.getConfiguration().setLong(TIMESTAMP_CONF_KEY, ts);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
config.save(baos);
conf.getConfiguration().set(PROPS_CONF_KEY,
new String(baos.toByteArray(), StandardCharsets.UTF_8));
AccumuloInputFormat.setZooKeeperInstance(conf, fconfig.getAccumuloInstance(),
fconfig.getAccumuloZookeepers());
AccumuloInputFormat.setConnectorInfo(conf, fconfig.getAccumuloUser(),
new PasswordToken(fconfig.getAccumuloPassword()));
AccumuloInputFormat.setInputTableName(conf, env.getTable());
AccumuloInputFormat.setScanAuthorizations(conf, env.getAuthorizations());
}
} catch (Exception e) {
throw new RuntimeException(e);
}
} | [
"public",
"static",
"void",
"configure",
"(",
"Job",
"conf",
",",
"SimpleConfiguration",
"config",
")",
"{",
"try",
"{",
"FluoConfiguration",
"fconfig",
"=",
"new",
"FluoConfiguration",
"(",
"config",
")",
";",
"try",
"(",
"Environment",
"env",
"=",
"new",
"Environment",
"(",
"fconfig",
")",
")",
"{",
"long",
"ts",
"=",
"env",
".",
"getSharedResources",
"(",
")",
".",
"getTimestampTracker",
"(",
")",
".",
"allocateTimestamp",
"(",
")",
".",
"getTxTimestamp",
"(",
")",
";",
"conf",
".",
"getConfiguration",
"(",
")",
".",
"setLong",
"(",
"TIMESTAMP_CONF_KEY",
",",
"ts",
")",
";",
"ByteArrayOutputStream",
"baos",
"=",
"new",
"ByteArrayOutputStream",
"(",
")",
";",
"config",
".",
"save",
"(",
"baos",
")",
";",
"conf",
".",
"getConfiguration",
"(",
")",
".",
"set",
"(",
"PROPS_CONF_KEY",
",",
"new",
"String",
"(",
"baos",
".",
"toByteArray",
"(",
")",
",",
"StandardCharsets",
".",
"UTF_8",
")",
")",
";",
"AccumuloInputFormat",
".",
"setZooKeeperInstance",
"(",
"conf",
",",
"fconfig",
".",
"getAccumuloInstance",
"(",
")",
",",
"fconfig",
".",
"getAccumuloZookeepers",
"(",
")",
")",
";",
"AccumuloInputFormat",
".",
"setConnectorInfo",
"(",
"conf",
",",
"fconfig",
".",
"getAccumuloUser",
"(",
")",
",",
"new",
"PasswordToken",
"(",
"fconfig",
".",
"getAccumuloPassword",
"(",
")",
")",
")",
";",
"AccumuloInputFormat",
".",
"setInputTableName",
"(",
"conf",
",",
"env",
".",
"getTable",
"(",
")",
")",
";",
"AccumuloInputFormat",
".",
"setScanAuthorizations",
"(",
"conf",
",",
"env",
".",
"getAuthorizations",
"(",
")",
")",
";",
"}",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"e",
")",
";",
"}",
"}"
] | Configure properties needed to connect to a Fluo application
@param conf Job configuration
@param config use {@link FluoConfiguration} to configure programmatically | [
"Configure",
"properties",
"needed",
"to",
"connect",
"to",
"a",
"Fluo",
"application"
] | 8e06204d4167651e2d3b5219b8c1397644e6ba6e | https://github.com/apache/fluo/blob/8e06204d4167651e2d3b5219b8c1397644e6ba6e/modules/mapreduce/src/main/java/org/apache/fluo/mapreduce/FluoEntryInputFormat.java#L144-L167 |
163,687 | apache/fluo | modules/core/src/main/java/org/apache/fluo/core/impl/TransactionImpl.java | TransactionImpl.readUnread | private void readUnread(CommitData cd, Consumer<Entry<Key, Value>> locksSeen) {
// TODO make async
// TODO need to keep track of ranges read (not ranges passed in, but actual data read... user
// may not iterate over entire range
Map<Bytes, Set<Column>> columnsToRead = new HashMap<>();
for (Entry<Bytes, Set<Column>> entry : cd.getRejected().entrySet()) {
Set<Column> rowColsRead = columnsRead.get(entry.getKey());
if (rowColsRead == null) {
columnsToRead.put(entry.getKey(), entry.getValue());
} else {
HashSet<Column> colsToRead = new HashSet<>(entry.getValue());
colsToRead.removeAll(rowColsRead);
if (!colsToRead.isEmpty()) {
columnsToRead.put(entry.getKey(), colsToRead);
}
}
}
for (Entry<Bytes, Set<Column>> entry : columnsToRead.entrySet()) {
getImpl(entry.getKey(), entry.getValue(), locksSeen);
}
} | java | private void readUnread(CommitData cd, Consumer<Entry<Key, Value>> locksSeen) {
// TODO make async
// TODO need to keep track of ranges read (not ranges passed in, but actual data read... user
// may not iterate over entire range
Map<Bytes, Set<Column>> columnsToRead = new HashMap<>();
for (Entry<Bytes, Set<Column>> entry : cd.getRejected().entrySet()) {
Set<Column> rowColsRead = columnsRead.get(entry.getKey());
if (rowColsRead == null) {
columnsToRead.put(entry.getKey(), entry.getValue());
} else {
HashSet<Column> colsToRead = new HashSet<>(entry.getValue());
colsToRead.removeAll(rowColsRead);
if (!colsToRead.isEmpty()) {
columnsToRead.put(entry.getKey(), colsToRead);
}
}
}
for (Entry<Bytes, Set<Column>> entry : columnsToRead.entrySet()) {
getImpl(entry.getKey(), entry.getValue(), locksSeen);
}
} | [
"private",
"void",
"readUnread",
"(",
"CommitData",
"cd",
",",
"Consumer",
"<",
"Entry",
"<",
"Key",
",",
"Value",
">",
">",
"locksSeen",
")",
"{",
"// TODO make async",
"// TODO need to keep track of ranges read (not ranges passed in, but actual data read... user",
"// may not iterate over entire range",
"Map",
"<",
"Bytes",
",",
"Set",
"<",
"Column",
">",
">",
"columnsToRead",
"=",
"new",
"HashMap",
"<>",
"(",
")",
";",
"for",
"(",
"Entry",
"<",
"Bytes",
",",
"Set",
"<",
"Column",
">",
">",
"entry",
":",
"cd",
".",
"getRejected",
"(",
")",
".",
"entrySet",
"(",
")",
")",
"{",
"Set",
"<",
"Column",
">",
"rowColsRead",
"=",
"columnsRead",
".",
"get",
"(",
"entry",
".",
"getKey",
"(",
")",
")",
";",
"if",
"(",
"rowColsRead",
"==",
"null",
")",
"{",
"columnsToRead",
".",
"put",
"(",
"entry",
".",
"getKey",
"(",
")",
",",
"entry",
".",
"getValue",
"(",
")",
")",
";",
"}",
"else",
"{",
"HashSet",
"<",
"Column",
">",
"colsToRead",
"=",
"new",
"HashSet",
"<>",
"(",
"entry",
".",
"getValue",
"(",
")",
")",
";",
"colsToRead",
".",
"removeAll",
"(",
"rowColsRead",
")",
";",
"if",
"(",
"!",
"colsToRead",
".",
"isEmpty",
"(",
")",
")",
"{",
"columnsToRead",
".",
"put",
"(",
"entry",
".",
"getKey",
"(",
")",
",",
"colsToRead",
")",
";",
"}",
"}",
"}",
"for",
"(",
"Entry",
"<",
"Bytes",
",",
"Set",
"<",
"Column",
">",
">",
"entry",
":",
"columnsToRead",
".",
"entrySet",
"(",
")",
")",
"{",
"getImpl",
"(",
"entry",
".",
"getKey",
"(",
")",
",",
"entry",
".",
"getValue",
"(",
")",
",",
"locksSeen",
")",
";",
"}",
"}"
] | This function helps handle the following case
<OL>
<LI>TX1 locls r1 col1
<LI>TX1 fails before unlocking
<LI>TX2 attempts to write r1:col1 w/o reading it
</OL>
<p>
In this case TX2 would not roll back TX1, because it never read the column. This function
attempts to handle this case if TX2 fails. Only doing this in case of failures is cheaper than
trying to always read unread columns.
@param cd Commit data | [
"This",
"function",
"helps",
"handle",
"the",
"following",
"case"
] | 8e06204d4167651e2d3b5219b8c1397644e6ba6e | https://github.com/apache/fluo/blob/8e06204d4167651e2d3b5219b8c1397644e6ba6e/modules/core/src/main/java/org/apache/fluo/core/impl/TransactionImpl.java#L557-L579 |
163,688 | apache/fluo | modules/api/src/main/java/org/apache/fluo/api/data/Bytes.java | Bytes.byteAt | public byte byteAt(int i) {
if (i < 0) {
throw new IndexOutOfBoundsException("i < 0, " + i);
}
if (i >= length) {
throw new IndexOutOfBoundsException("i >= length, " + i + " >= " + length);
}
return data[offset + i];
} | java | public byte byteAt(int i) {
if (i < 0) {
throw new IndexOutOfBoundsException("i < 0, " + i);
}
if (i >= length) {
throw new IndexOutOfBoundsException("i >= length, " + i + " >= " + length);
}
return data[offset + i];
} | [
"public",
"byte",
"byteAt",
"(",
"int",
"i",
")",
"{",
"if",
"(",
"i",
"<",
"0",
")",
"{",
"throw",
"new",
"IndexOutOfBoundsException",
"(",
"\"i < 0, \"",
"+",
"i",
")",
";",
"}",
"if",
"(",
"i",
">=",
"length",
")",
"{",
"throw",
"new",
"IndexOutOfBoundsException",
"(",
"\"i >= length, \"",
"+",
"i",
"+",
"\" >= \"",
"+",
"length",
")",
";",
"}",
"return",
"data",
"[",
"offset",
"+",
"i",
"]",
";",
"}"
] | Gets a byte within this sequence of bytes
@param i index into sequence
@return byte
@throws IllegalArgumentException if i is out of range | [
"Gets",
"a",
"byte",
"within",
"this",
"sequence",
"of",
"bytes"
] | 8e06204d4167651e2d3b5219b8c1397644e6ba6e | https://github.com/apache/fluo/blob/8e06204d4167651e2d3b5219b8c1397644e6ba6e/modules/api/src/main/java/org/apache/fluo/api/data/Bytes.java#L103-L114 |
163,689 | apache/fluo | modules/api/src/main/java/org/apache/fluo/api/data/Bytes.java | Bytes.subSequence | public Bytes subSequence(int start, int end) {
if (start > end || start < 0 || end > length) {
throw new IndexOutOfBoundsException("Bad start and/end start = " + start + " end=" + end
+ " offset=" + offset + " length=" + length);
}
return new Bytes(data, offset + start, end - start);
} | java | public Bytes subSequence(int start, int end) {
if (start > end || start < 0 || end > length) {
throw new IndexOutOfBoundsException("Bad start and/end start = " + start + " end=" + end
+ " offset=" + offset + " length=" + length);
}
return new Bytes(data, offset + start, end - start);
} | [
"public",
"Bytes",
"subSequence",
"(",
"int",
"start",
",",
"int",
"end",
")",
"{",
"if",
"(",
"start",
">",
"end",
"||",
"start",
"<",
"0",
"||",
"end",
">",
"length",
")",
"{",
"throw",
"new",
"IndexOutOfBoundsException",
"(",
"\"Bad start and/end start = \"",
"+",
"start",
"+",
"\" end=\"",
"+",
"end",
"+",
"\" offset=\"",
"+",
"offset",
"+",
"\" length=\"",
"+",
"length",
")",
";",
"}",
"return",
"new",
"Bytes",
"(",
"data",
",",
"offset",
"+",
"start",
",",
"end",
"-",
"start",
")",
";",
"}"
] | Returns a portion of the Bytes object
@param start index of subsequence start (inclusive)
@param end index of subsequence end (exclusive) | [
"Returns",
"a",
"portion",
"of",
"the",
"Bytes",
"object"
] | 8e06204d4167651e2d3b5219b8c1397644e6ba6e | https://github.com/apache/fluo/blob/8e06204d4167651e2d3b5219b8c1397644e6ba6e/modules/api/src/main/java/org/apache/fluo/api/data/Bytes.java#L129-L135 |
163,690 | apache/fluo | modules/api/src/main/java/org/apache/fluo/api/data/Bytes.java | Bytes.toArray | public byte[] toArray() {
byte[] copy = new byte[length];
System.arraycopy(data, offset, copy, 0, length);
return copy;
} | java | public byte[] toArray() {
byte[] copy = new byte[length];
System.arraycopy(data, offset, copy, 0, length);
return copy;
} | [
"public",
"byte",
"[",
"]",
"toArray",
"(",
")",
"{",
"byte",
"[",
"]",
"copy",
"=",
"new",
"byte",
"[",
"length",
"]",
";",
"System",
".",
"arraycopy",
"(",
"data",
",",
"offset",
",",
"copy",
",",
"0",
",",
"length",
")",
";",
"return",
"copy",
";",
"}"
] | Returns a byte array containing a copy of the bytes | [
"Returns",
"a",
"byte",
"array",
"containing",
"a",
"copy",
"of",
"the",
"bytes"
] | 8e06204d4167651e2d3b5219b8c1397644e6ba6e | https://github.com/apache/fluo/blob/8e06204d4167651e2d3b5219b8c1397644e6ba6e/modules/api/src/main/java/org/apache/fluo/api/data/Bytes.java#L140-L144 |
163,691 | apache/fluo | modules/api/src/main/java/org/apache/fluo/api/data/Bytes.java | Bytes.contentEquals | public boolean contentEquals(byte[] bytes, int offset, int len) {
Preconditions.checkArgument(len >= 0 && offset >= 0 && offset + len <= bytes.length);
return contentEqualsUnchecked(bytes, offset, len);
} | java | public boolean contentEquals(byte[] bytes, int offset, int len) {
Preconditions.checkArgument(len >= 0 && offset >= 0 && offset + len <= bytes.length);
return contentEqualsUnchecked(bytes, offset, len);
} | [
"public",
"boolean",
"contentEquals",
"(",
"byte",
"[",
"]",
"bytes",
",",
"int",
"offset",
",",
"int",
"len",
")",
"{",
"Preconditions",
".",
"checkArgument",
"(",
"len",
">=",
"0",
"&&",
"offset",
">=",
"0",
"&&",
"offset",
"+",
"len",
"<=",
"bytes",
".",
"length",
")",
";",
"return",
"contentEqualsUnchecked",
"(",
"bytes",
",",
"offset",
",",
"len",
")",
";",
"}"
] | Returns true if this Bytes object equals another. This method checks it's arguments.
@since 1.2.0 | [
"Returns",
"true",
"if",
"this",
"Bytes",
"object",
"equals",
"another",
".",
"This",
"method",
"checks",
"it",
"s",
"arguments",
"."
] | 8e06204d4167651e2d3b5219b8c1397644e6ba6e | https://github.com/apache/fluo/blob/8e06204d4167651e2d3b5219b8c1397644e6ba6e/modules/api/src/main/java/org/apache/fluo/api/data/Bytes.java#L298-L301 |
163,692 | apache/fluo | modules/api/src/main/java/org/apache/fluo/api/data/Bytes.java | Bytes.contentEqualsUnchecked | private boolean contentEqualsUnchecked(byte[] bytes, int offset, int len) {
if (length != len) {
return false;
}
return compareToUnchecked(bytes, offset, len) == 0;
} | java | private boolean contentEqualsUnchecked(byte[] bytes, int offset, int len) {
if (length != len) {
return false;
}
return compareToUnchecked(bytes, offset, len) == 0;
} | [
"private",
"boolean",
"contentEqualsUnchecked",
"(",
"byte",
"[",
"]",
"bytes",
",",
"int",
"offset",
",",
"int",
"len",
")",
"{",
"if",
"(",
"length",
"!=",
"len",
")",
"{",
"return",
"false",
";",
"}",
"return",
"compareToUnchecked",
"(",
"bytes",
",",
"offset",
",",
"len",
")",
"==",
"0",
";",
"}"
] | Returns true if this Bytes object equals another. This method doesn't check it's arguments.
@since 1.2.0 | [
"Returns",
"true",
"if",
"this",
"Bytes",
"object",
"equals",
"another",
".",
"This",
"method",
"doesn",
"t",
"check",
"it",
"s",
"arguments",
"."
] | 8e06204d4167651e2d3b5219b8c1397644e6ba6e | https://github.com/apache/fluo/blob/8e06204d4167651e2d3b5219b8c1397644e6ba6e/modules/api/src/main/java/org/apache/fluo/api/data/Bytes.java#L308-L314 |
163,693 | apache/fluo | modules/api/src/main/java/org/apache/fluo/api/data/Bytes.java | Bytes.of | public static final Bytes of(byte[] array) {
Objects.requireNonNull(array);
if (array.length == 0) {
return EMPTY;
}
byte[] copy = new byte[array.length];
System.arraycopy(array, 0, copy, 0, array.length);
return new Bytes(copy);
} | java | public static final Bytes of(byte[] array) {
Objects.requireNonNull(array);
if (array.length == 0) {
return EMPTY;
}
byte[] copy = new byte[array.length];
System.arraycopy(array, 0, copy, 0, array.length);
return new Bytes(copy);
} | [
"public",
"static",
"final",
"Bytes",
"of",
"(",
"byte",
"[",
"]",
"array",
")",
"{",
"Objects",
".",
"requireNonNull",
"(",
"array",
")",
";",
"if",
"(",
"array",
".",
"length",
"==",
"0",
")",
"{",
"return",
"EMPTY",
";",
"}",
"byte",
"[",
"]",
"copy",
"=",
"new",
"byte",
"[",
"array",
".",
"length",
"]",
";",
"System",
".",
"arraycopy",
"(",
"array",
",",
"0",
",",
"copy",
",",
"0",
",",
"array",
".",
"length",
")",
";",
"return",
"new",
"Bytes",
"(",
"copy",
")",
";",
"}"
] | Creates a Bytes object by copying the data of the given byte array | [
"Creates",
"a",
"Bytes",
"object",
"by",
"copying",
"the",
"data",
"of",
"the",
"given",
"byte",
"array"
] | 8e06204d4167651e2d3b5219b8c1397644e6ba6e | https://github.com/apache/fluo/blob/8e06204d4167651e2d3b5219b8c1397644e6ba6e/modules/api/src/main/java/org/apache/fluo/api/data/Bytes.java#L332-L340 |
163,694 | apache/fluo | modules/api/src/main/java/org/apache/fluo/api/data/Bytes.java | Bytes.of | public static final Bytes of(byte[] data, int offset, int length) {
Objects.requireNonNull(data);
if (length == 0) {
return EMPTY;
}
byte[] copy = new byte[length];
System.arraycopy(data, offset, copy, 0, length);
return new Bytes(copy);
} | java | public static final Bytes of(byte[] data, int offset, int length) {
Objects.requireNonNull(data);
if (length == 0) {
return EMPTY;
}
byte[] copy = new byte[length];
System.arraycopy(data, offset, copy, 0, length);
return new Bytes(copy);
} | [
"public",
"static",
"final",
"Bytes",
"of",
"(",
"byte",
"[",
"]",
"data",
",",
"int",
"offset",
",",
"int",
"length",
")",
"{",
"Objects",
".",
"requireNonNull",
"(",
"data",
")",
";",
"if",
"(",
"length",
"==",
"0",
")",
"{",
"return",
"EMPTY",
";",
"}",
"byte",
"[",
"]",
"copy",
"=",
"new",
"byte",
"[",
"length",
"]",
";",
"System",
".",
"arraycopy",
"(",
"data",
",",
"offset",
",",
"copy",
",",
"0",
",",
"length",
")",
";",
"return",
"new",
"Bytes",
"(",
"copy",
")",
";",
"}"
] | Creates a Bytes object by copying the data of a subsequence of the given byte array
@param data Byte data
@param offset Starting offset in byte array (inclusive)
@param length Number of bytes to include | [
"Creates",
"a",
"Bytes",
"object",
"by",
"copying",
"the",
"data",
"of",
"a",
"subsequence",
"of",
"the",
"given",
"byte",
"array"
] | 8e06204d4167651e2d3b5219b8c1397644e6ba6e | https://github.com/apache/fluo/blob/8e06204d4167651e2d3b5219b8c1397644e6ba6e/modules/api/src/main/java/org/apache/fluo/api/data/Bytes.java#L349-L357 |
163,695 | apache/fluo | modules/api/src/main/java/org/apache/fluo/api/data/Bytes.java | Bytes.of | public static final Bytes of(ByteBuffer bb) {
Objects.requireNonNull(bb);
if (bb.remaining() == 0) {
return EMPTY;
}
byte[] data;
if (bb.hasArray()) {
data = Arrays.copyOfRange(bb.array(), bb.position() + bb.arrayOffset(),
bb.limit() + bb.arrayOffset());
} else {
data = new byte[bb.remaining()];
// duplicate so that it does not change position
bb.duplicate().get(data);
}
return new Bytes(data);
} | java | public static final Bytes of(ByteBuffer bb) {
Objects.requireNonNull(bb);
if (bb.remaining() == 0) {
return EMPTY;
}
byte[] data;
if (bb.hasArray()) {
data = Arrays.copyOfRange(bb.array(), bb.position() + bb.arrayOffset(),
bb.limit() + bb.arrayOffset());
} else {
data = new byte[bb.remaining()];
// duplicate so that it does not change position
bb.duplicate().get(data);
}
return new Bytes(data);
} | [
"public",
"static",
"final",
"Bytes",
"of",
"(",
"ByteBuffer",
"bb",
")",
"{",
"Objects",
".",
"requireNonNull",
"(",
"bb",
")",
";",
"if",
"(",
"bb",
".",
"remaining",
"(",
")",
"==",
"0",
")",
"{",
"return",
"EMPTY",
";",
"}",
"byte",
"[",
"]",
"data",
";",
"if",
"(",
"bb",
".",
"hasArray",
"(",
")",
")",
"{",
"data",
"=",
"Arrays",
".",
"copyOfRange",
"(",
"bb",
".",
"array",
"(",
")",
",",
"bb",
".",
"position",
"(",
")",
"+",
"bb",
".",
"arrayOffset",
"(",
")",
",",
"bb",
".",
"limit",
"(",
")",
"+",
"bb",
".",
"arrayOffset",
"(",
")",
")",
";",
"}",
"else",
"{",
"data",
"=",
"new",
"byte",
"[",
"bb",
".",
"remaining",
"(",
")",
"]",
";",
"// duplicate so that it does not change position",
"bb",
".",
"duplicate",
"(",
")",
".",
"get",
"(",
"data",
")",
";",
"}",
"return",
"new",
"Bytes",
"(",
"data",
")",
";",
"}"
] | Creates a Bytes object by copying the data of the given ByteBuffer.
@param bb Data will be read from this ByteBuffer in such a way that its position is not
changed. | [
"Creates",
"a",
"Bytes",
"object",
"by",
"copying",
"the",
"data",
"of",
"the",
"given",
"ByteBuffer",
"."
] | 8e06204d4167651e2d3b5219b8c1397644e6ba6e | https://github.com/apache/fluo/blob/8e06204d4167651e2d3b5219b8c1397644e6ba6e/modules/api/src/main/java/org/apache/fluo/api/data/Bytes.java#L365-L380 |
163,696 | apache/fluo | modules/api/src/main/java/org/apache/fluo/api/data/Bytes.java | Bytes.of | public static final Bytes of(CharSequence cs) {
if (cs instanceof String) {
return of((String) cs);
}
Objects.requireNonNull(cs);
if (cs.length() == 0) {
return EMPTY;
}
ByteBuffer bb = StandardCharsets.UTF_8.encode(CharBuffer.wrap(cs));
if (bb.hasArray()) {
// this byte buffer has never escaped so can use its byte array directly
return new Bytes(bb.array(), bb.position() + bb.arrayOffset(), bb.limit());
} else {
byte[] data = new byte[bb.remaining()];
bb.get(data);
return new Bytes(data);
}
} | java | public static final Bytes of(CharSequence cs) {
if (cs instanceof String) {
return of((String) cs);
}
Objects.requireNonNull(cs);
if (cs.length() == 0) {
return EMPTY;
}
ByteBuffer bb = StandardCharsets.UTF_8.encode(CharBuffer.wrap(cs));
if (bb.hasArray()) {
// this byte buffer has never escaped so can use its byte array directly
return new Bytes(bb.array(), bb.position() + bb.arrayOffset(), bb.limit());
} else {
byte[] data = new byte[bb.remaining()];
bb.get(data);
return new Bytes(data);
}
} | [
"public",
"static",
"final",
"Bytes",
"of",
"(",
"CharSequence",
"cs",
")",
"{",
"if",
"(",
"cs",
"instanceof",
"String",
")",
"{",
"return",
"of",
"(",
"(",
"String",
")",
"cs",
")",
";",
"}",
"Objects",
".",
"requireNonNull",
"(",
"cs",
")",
";",
"if",
"(",
"cs",
".",
"length",
"(",
")",
"==",
"0",
")",
"{",
"return",
"EMPTY",
";",
"}",
"ByteBuffer",
"bb",
"=",
"StandardCharsets",
".",
"UTF_8",
".",
"encode",
"(",
"CharBuffer",
".",
"wrap",
"(",
"cs",
")",
")",
";",
"if",
"(",
"bb",
".",
"hasArray",
"(",
")",
")",
"{",
"// this byte buffer has never escaped so can use its byte array directly",
"return",
"new",
"Bytes",
"(",
"bb",
".",
"array",
"(",
")",
",",
"bb",
".",
"position",
"(",
")",
"+",
"bb",
".",
"arrayOffset",
"(",
")",
",",
"bb",
".",
"limit",
"(",
")",
")",
";",
"}",
"else",
"{",
"byte",
"[",
"]",
"data",
"=",
"new",
"byte",
"[",
"bb",
".",
"remaining",
"(",
")",
"]",
";",
"bb",
".",
"get",
"(",
"data",
")",
";",
"return",
"new",
"Bytes",
"(",
"data",
")",
";",
"}",
"}"
] | Creates a Bytes object by copying the data of the CharSequence and encoding it using UTF-8. | [
"Creates",
"a",
"Bytes",
"object",
"by",
"copying",
"the",
"data",
"of",
"the",
"CharSequence",
"and",
"encoding",
"it",
"using",
"UTF",
"-",
"8",
"."
] | 8e06204d4167651e2d3b5219b8c1397644e6ba6e | https://github.com/apache/fluo/blob/8e06204d4167651e2d3b5219b8c1397644e6ba6e/modules/api/src/main/java/org/apache/fluo/api/data/Bytes.java#L385-L405 |
163,697 | apache/fluo | modules/api/src/main/java/org/apache/fluo/api/data/Bytes.java | Bytes.of | public static final Bytes of(String s) {
Objects.requireNonNull(s);
if (s.isEmpty()) {
return EMPTY;
}
byte[] data = s.getBytes(StandardCharsets.UTF_8);
return new Bytes(data, s);
} | java | public static final Bytes of(String s) {
Objects.requireNonNull(s);
if (s.isEmpty()) {
return EMPTY;
}
byte[] data = s.getBytes(StandardCharsets.UTF_8);
return new Bytes(data, s);
} | [
"public",
"static",
"final",
"Bytes",
"of",
"(",
"String",
"s",
")",
"{",
"Objects",
".",
"requireNonNull",
"(",
"s",
")",
";",
"if",
"(",
"s",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
"EMPTY",
";",
"}",
"byte",
"[",
"]",
"data",
"=",
"s",
".",
"getBytes",
"(",
"StandardCharsets",
".",
"UTF_8",
")",
";",
"return",
"new",
"Bytes",
"(",
"data",
",",
"s",
")",
";",
"}"
] | Creates a Bytes object by copying the value of the given String | [
"Creates",
"a",
"Bytes",
"object",
"by",
"copying",
"the",
"value",
"of",
"the",
"given",
"String"
] | 8e06204d4167651e2d3b5219b8c1397644e6ba6e | https://github.com/apache/fluo/blob/8e06204d4167651e2d3b5219b8c1397644e6ba6e/modules/api/src/main/java/org/apache/fluo/api/data/Bytes.java#L410-L417 |
163,698 | apache/fluo | modules/api/src/main/java/org/apache/fluo/api/data/Bytes.java | Bytes.of | public static final Bytes of(String s, Charset c) {
Objects.requireNonNull(s);
Objects.requireNonNull(c);
if (s.isEmpty()) {
return EMPTY;
}
byte[] data = s.getBytes(c);
return new Bytes(data);
} | java | public static final Bytes of(String s, Charset c) {
Objects.requireNonNull(s);
Objects.requireNonNull(c);
if (s.isEmpty()) {
return EMPTY;
}
byte[] data = s.getBytes(c);
return new Bytes(data);
} | [
"public",
"static",
"final",
"Bytes",
"of",
"(",
"String",
"s",
",",
"Charset",
"c",
")",
"{",
"Objects",
".",
"requireNonNull",
"(",
"s",
")",
";",
"Objects",
".",
"requireNonNull",
"(",
"c",
")",
";",
"if",
"(",
"s",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
"EMPTY",
";",
"}",
"byte",
"[",
"]",
"data",
"=",
"s",
".",
"getBytes",
"(",
"c",
")",
";",
"return",
"new",
"Bytes",
"(",
"data",
")",
";",
"}"
] | Creates a Bytes object by copying the value of the given String with a given charset | [
"Creates",
"a",
"Bytes",
"object",
"by",
"copying",
"the",
"value",
"of",
"the",
"given",
"String",
"with",
"a",
"given",
"charset"
] | 8e06204d4167651e2d3b5219b8c1397644e6ba6e | https://github.com/apache/fluo/blob/8e06204d4167651e2d3b5219b8c1397644e6ba6e/modules/api/src/main/java/org/apache/fluo/api/data/Bytes.java#L422-L430 |
163,699 | apache/fluo | modules/api/src/main/java/org/apache/fluo/api/data/Bytes.java | Bytes.startsWith | public boolean startsWith(Bytes prefix) {
Objects.requireNonNull(prefix, "startWith(Bytes prefix) cannot have null parameter");
if (prefix.length > this.length) {
return false;
} else {
int end = this.offset + prefix.length;
for (int i = this.offset, j = prefix.offset; i < end; i++, j++) {
if (this.data[i] != prefix.data[j]) {
return false;
}
}
}
return true;
} | java | public boolean startsWith(Bytes prefix) {
Objects.requireNonNull(prefix, "startWith(Bytes prefix) cannot have null parameter");
if (prefix.length > this.length) {
return false;
} else {
int end = this.offset + prefix.length;
for (int i = this.offset, j = prefix.offset; i < end; i++, j++) {
if (this.data[i] != prefix.data[j]) {
return false;
}
}
}
return true;
} | [
"public",
"boolean",
"startsWith",
"(",
"Bytes",
"prefix",
")",
"{",
"Objects",
".",
"requireNonNull",
"(",
"prefix",
",",
"\"startWith(Bytes prefix) cannot have null parameter\"",
")",
";",
"if",
"(",
"prefix",
".",
"length",
">",
"this",
".",
"length",
")",
"{",
"return",
"false",
";",
"}",
"else",
"{",
"int",
"end",
"=",
"this",
".",
"offset",
"+",
"prefix",
".",
"length",
";",
"for",
"(",
"int",
"i",
"=",
"this",
".",
"offset",
",",
"j",
"=",
"prefix",
".",
"offset",
";",
"i",
"<",
"end",
";",
"i",
"++",
",",
"j",
"++",
")",
"{",
"if",
"(",
"this",
".",
"data",
"[",
"i",
"]",
"!=",
"prefix",
".",
"data",
"[",
"j",
"]",
")",
"{",
"return",
"false",
";",
"}",
"}",
"}",
"return",
"true",
";",
"}"
] | Checks if this has the passed prefix
@param prefix is a Bytes object to compare to this
@return true or false
@since 1.1.0 | [
"Checks",
"if",
"this",
"has",
"the",
"passed",
"prefix"
] | 8e06204d4167651e2d3b5219b8c1397644e6ba6e | https://github.com/apache/fluo/blob/8e06204d4167651e2d3b5219b8c1397644e6ba6e/modules/api/src/main/java/org/apache/fluo/api/data/Bytes.java#L439-L453 |
Subsets and Splits