repo
stringlengths
7
58
path
stringlengths
12
218
func_name
stringlengths
3
140
original_string
stringlengths
73
34.1k
language
stringclasses
1 value
code
stringlengths
73
34.1k
code_tokens
list
docstring
stringlengths
3
16k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
105
339
partition
stringclasses
1 value
radkovo/Pdf2Dom
src/main/java/org/fit/pdfdom/PDFBoxTree.java
PDFBoxTree.init
private void init() { style = new BoxStyle(UNIT); textLine = new StringBuilder(); textMetrics = null; graphicsPath = new Vector<PathSegment>(); startPage = 0; endPage = Integer.MAX_VALUE; fontTable = new FontTable(); }
java
private void init() { style = new BoxStyle(UNIT); textLine = new StringBuilder(); textMetrics = null; graphicsPath = new Vector<PathSegment>(); startPage = 0; endPage = Integer.MAX_VALUE; fontTable = new FontTable(); }
[ "private", "void", "init", "(", ")", "{", "style", "=", "new", "BoxStyle", "(", "UNIT", ")", ";", "textLine", "=", "new", "StringBuilder", "(", ")", ";", "textMetrics", "=", "null", ";", "graphicsPath", "=", "new", "Vector", "<", "PathSegment", ">", "(...
Internal initialization. @throws ParserConfigurationException
[ "Internal", "initialization", "." ]
12e52b80eca7f57fc41e6ed895bf1db72c38da53
https://github.com/radkovo/Pdf2Dom/blob/12e52b80eca7f57fc41e6ed895bf1db72c38da53/src/main/java/org/fit/pdfdom/PDFBoxTree.java#L189-L198
train
radkovo/Pdf2Dom
src/main/java/org/fit/pdfdom/PDFBoxTree.java
PDFBoxTree.updateFontTable
protected void updateFontTable() { PDResources resources = pdpage.getResources(); if (resources != null) { try { processFontResources(resources, fontTable); } catch (IOException e) { log.error("Error processing font resources: " + "Exception: {} {}", e.getMessage(), e.getClass()); } } }
java
protected void updateFontTable() { PDResources resources = pdpage.getResources(); if (resources != null) { try { processFontResources(resources, fontTable); } catch (IOException e) { log.error("Error processing font resources: " + "Exception: {} {}", e.getMessage(), e.getClass()); } } }
[ "protected", "void", "updateFontTable", "(", ")", "{", "PDResources", "resources", "=", "pdpage", ".", "getResources", "(", ")", ";", "if", "(", "resources", "!=", "null", ")", "{", "try", "{", "processFontResources", "(", "resources", ",", "fontTable", ")",...
Updates the font table by adding new fonts used at the current page.
[ "Updates", "the", "font", "table", "by", "adding", "new", "fonts", "used", "at", "the", "current", "page", "." ]
12e52b80eca7f57fc41e6ed895bf1db72c38da53
https://github.com/radkovo/Pdf2Dom/blob/12e52b80eca7f57fc41e6ed895bf1db72c38da53/src/main/java/org/fit/pdfdom/PDFBoxTree.java#L354-L367
train
radkovo/Pdf2Dom
src/main/java/org/fit/pdfdom/PDFBoxTree.java
PDFBoxTree.finishBox
protected void finishBox() { if (textLine.length() > 0) { String s; if (isReversed(Character.getDirectionality(textLine.charAt(0)))) s = textLine.reverse().toString(); else s = textLine.toString(); curstyle.setLeft(textMetrics.getX()); curstyle.setTop(textMetrics.getTop()); curstyle.setLineHeight(textMetrics.getHeight()); renderText(s, textMetrics); textLine = new StringBuilder(); textMetrics = null; } }
java
protected void finishBox() { if (textLine.length() > 0) { String s; if (isReversed(Character.getDirectionality(textLine.charAt(0)))) s = textLine.reverse().toString(); else s = textLine.toString(); curstyle.setLeft(textMetrics.getX()); curstyle.setTop(textMetrics.getTop()); curstyle.setLineHeight(textMetrics.getHeight()); renderText(s, textMetrics); textLine = new StringBuilder(); textMetrics = null; } }
[ "protected", "void", "finishBox", "(", ")", "{", "if", "(", "textLine", ".", "length", "(", ")", ">", "0", ")", "{", "String", "s", ";", "if", "(", "isReversed", "(", "Character", ".", "getDirectionality", "(", "textLine", ".", "charAt", "(", "0", ")...
Finishes the current box - empties the text line buffer and creates a DOM element from it.
[ "Finishes", "the", "current", "box", "-", "empties", "the", "text", "line", "buffer", "and", "creates", "a", "DOM", "element", "from", "it", "." ]
12e52b80eca7f57fc41e6ed895bf1db72c38da53
https://github.com/radkovo/Pdf2Dom/blob/12e52b80eca7f57fc41e6ed895bf1db72c38da53/src/main/java/org/fit/pdfdom/PDFBoxTree.java#L662-L680
train
radkovo/Pdf2Dom
src/main/java/org/fit/pdfdom/PDFBoxTree.java
PDFBoxTree.updateStyle
protected void updateStyle(BoxStyle bstyle, TextPosition text) { String font = text.getFont().getName(); String family = null; String weight = null; String fstyle = null; bstyle.setFontSize(text.getFontSizeInPt()); bstyle.setLineHeight(text.getHeight()); if (font != null) { //font style and weight for (int i = 0; i < pdFontType.length; i++) { if (font.toLowerCase().lastIndexOf(pdFontType[i]) >= 0) { weight = cssFontWeight[i]; fstyle = cssFontStyle[i]; break; } } if (weight != null) bstyle.setFontWeight(weight); else bstyle.setFontWeight(cssFontWeight[0]); if (fstyle != null) bstyle.setFontStyle(fstyle); else bstyle.setFontStyle(cssFontStyle[0]); //font family //If it's a known common font don't embed in html output to save space String knownFontFamily = findKnownFontFamily(font); if (!knownFontFamily.equals("")) family = knownFontFamily; else { family = fontTable.getUsedName(text.getFont()); if (family == null) family = font; } if (family != null) bstyle.setFontFamily(family); } updateStyleForRenderingMode(); }
java
protected void updateStyle(BoxStyle bstyle, TextPosition text) { String font = text.getFont().getName(); String family = null; String weight = null; String fstyle = null; bstyle.setFontSize(text.getFontSizeInPt()); bstyle.setLineHeight(text.getHeight()); if (font != null) { //font style and weight for (int i = 0; i < pdFontType.length; i++) { if (font.toLowerCase().lastIndexOf(pdFontType[i]) >= 0) { weight = cssFontWeight[i]; fstyle = cssFontStyle[i]; break; } } if (weight != null) bstyle.setFontWeight(weight); else bstyle.setFontWeight(cssFontWeight[0]); if (fstyle != null) bstyle.setFontStyle(fstyle); else bstyle.setFontStyle(cssFontStyle[0]); //font family //If it's a known common font don't embed in html output to save space String knownFontFamily = findKnownFontFamily(font); if (!knownFontFamily.equals("")) family = knownFontFamily; else { family = fontTable.getUsedName(text.getFont()); if (family == null) family = font; } if (family != null) bstyle.setFontFamily(family); } updateStyleForRenderingMode(); }
[ "protected", "void", "updateStyle", "(", "BoxStyle", "bstyle", ",", "TextPosition", "text", ")", "{", "String", "font", "=", "text", ".", "getFont", "(", ")", ".", "getName", "(", ")", ";", "String", "family", "=", "null", ";", "String", "weight", "=", ...
Updates the text style according to a new text position @param bstyle the style to be updated @param text the text position
[ "Updates", "the", "text", "style", "according", "to", "a", "new", "text", "position" ]
12e52b80eca7f57fc41e6ed895bf1db72c38da53
https://github.com/radkovo/Pdf2Dom/blob/12e52b80eca7f57fc41e6ed895bf1db72c38da53/src/main/java/org/fit/pdfdom/PDFBoxTree.java#L707-L755
train
radkovo/Pdf2Dom
src/main/java/org/fit/pdfdom/PDFBoxTree.java
PDFBoxTree.transformLength
protected float transformLength(float w) { Matrix ctm = getGraphicsState().getCurrentTransformationMatrix(); Matrix m = new Matrix(); m.setValue(2, 0, w); return m.multiply(ctm).getTranslateX(); }
java
protected float transformLength(float w) { Matrix ctm = getGraphicsState().getCurrentTransformationMatrix(); Matrix m = new Matrix(); m.setValue(2, 0, w); return m.multiply(ctm).getTranslateX(); }
[ "protected", "float", "transformLength", "(", "float", "w", ")", "{", "Matrix", "ctm", "=", "getGraphicsState", "(", ")", ".", "getCurrentTransformationMatrix", "(", ")", ";", "Matrix", "m", "=", "new", "Matrix", "(", ")", ";", "m", ".", "setValue", "(", ...
Transforms a length according to the current transformation matrix.
[ "Transforms", "a", "length", "according", "to", "the", "current", "transformation", "matrix", "." ]
12e52b80eca7f57fc41e6ed895bf1db72c38da53
https://github.com/radkovo/Pdf2Dom/blob/12e52b80eca7f57fc41e6ed895bf1db72c38da53/src/main/java/org/fit/pdfdom/PDFBoxTree.java#L809-L815
train
radkovo/Pdf2Dom
src/main/java/org/fit/pdfdom/PDFBoxTree.java
PDFBoxTree.transformPosition
protected float[] transformPosition(float x, float y) { Point2D.Float point = super.transformedPoint(x, y); AffineTransform pageTransform = createCurrentPageTransformation(); Point2D.Float transformedPoint = (Point2D.Float) pageTransform.transform(point, null); return new float[]{(float) transformedPoint.getX(), (float) transformedPoint.getY()}; }
java
protected float[] transformPosition(float x, float y) { Point2D.Float point = super.transformedPoint(x, y); AffineTransform pageTransform = createCurrentPageTransformation(); Point2D.Float transformedPoint = (Point2D.Float) pageTransform.transform(point, null); return new float[]{(float) transformedPoint.getX(), (float) transformedPoint.getY()}; }
[ "protected", "float", "[", "]", "transformPosition", "(", "float", "x", ",", "float", "y", ")", "{", "Point2D", ".", "Float", "point", "=", "super", ".", "transformedPoint", "(", "x", ",", "y", ")", ";", "AffineTransform", "pageTransform", "=", "createCurr...
Transforms a position according to the current transformation matrix and current page transformation. @param x @param y @return
[ "Transforms", "a", "position", "according", "to", "the", "current", "transformation", "matrix", "and", "current", "page", "transformation", "." ]
12e52b80eca7f57fc41e6ed895bf1db72c38da53
https://github.com/radkovo/Pdf2Dom/blob/12e52b80eca7f57fc41e6ed895bf1db72c38da53/src/main/java/org/fit/pdfdom/PDFBoxTree.java#L823-L830
train
radkovo/Pdf2Dom
src/main/java/org/fit/pdfdom/PDFBoxTree.java
PDFBoxTree.stringValue
protected String stringValue(COSBase value) { if (value instanceof COSString) return ((COSString) value).getString(); else if (value instanceof COSNumber) return String.valueOf(((COSNumber) value).floatValue()); else return ""; }
java
protected String stringValue(COSBase value) { if (value instanceof COSString) return ((COSString) value).getString(); else if (value instanceof COSNumber) return String.valueOf(((COSNumber) value).floatValue()); else return ""; }
[ "protected", "String", "stringValue", "(", "COSBase", "value", ")", "{", "if", "(", "value", "instanceof", "COSString", ")", "return", "(", "(", "COSString", ")", "value", ")", ".", "getString", "(", ")", ";", "else", "if", "(", "value", "instanceof", "C...
Obtains a string from a PDF value @param value the PDF value of the String, Integer or Float type @return the corresponging string value
[ "Obtains", "a", "string", "from", "a", "PDF", "value" ]
12e52b80eca7f57fc41e6ed895bf1db72c38da53
https://github.com/radkovo/Pdf2Dom/blob/12e52b80eca7f57fc41e6ed895bf1db72c38da53/src/main/java/org/fit/pdfdom/PDFBoxTree.java#L899-L907
train
radkovo/Pdf2Dom
src/main/java/org/fit/pdfdom/PDFBoxTree.java
PDFBoxTree.colorString
protected String colorString(PDColor pdcolor) { String color = null; try { float[] rgb = pdcolor.getColorSpace().toRGB(pdcolor.getComponents()); color = colorString(rgb[0], rgb[1], rgb[2]); } catch (IOException e) { log.error("colorString: IOException: {}", e.getMessage()); } catch (UnsupportedOperationException e) { log.error("colorString: UnsupportedOperationException: {}", e.getMessage()); } return color; }
java
protected String colorString(PDColor pdcolor) { String color = null; try { float[] rgb = pdcolor.getColorSpace().toRGB(pdcolor.getComponents()); color = colorString(rgb[0], rgb[1], rgb[2]); } catch (IOException e) { log.error("colorString: IOException: {}", e.getMessage()); } catch (UnsupportedOperationException e) { log.error("colorString: UnsupportedOperationException: {}", e.getMessage()); } return color; }
[ "protected", "String", "colorString", "(", "PDColor", "pdcolor", ")", "{", "String", "color", "=", "null", ";", "try", "{", "float", "[", "]", "rgb", "=", "pdcolor", ".", "getColorSpace", "(", ")", ".", "toRGB", "(", "pdcolor", ".", "getComponents", "(",...
Creates a CSS rgb specification from a PDF color @param pdcolor @return the rgb() string
[ "Creates", "a", "CSS", "rgb", "specification", "from", "a", "PDF", "color" ]
12e52b80eca7f57fc41e6ed895bf1db72c38da53
https://github.com/radkovo/Pdf2Dom/blob/12e52b80eca7f57fc41e6ed895bf1db72c38da53/src/main/java/org/fit/pdfdom/PDFBoxTree.java#L938-L951
train
mapbox/mapbox-events-android
libcore/src/main/java/com/mapbox/android/core/FileUtils.java
FileUtils.listAllFiles
@NonNull public static File[] listAllFiles(File directory) { if (directory == null) { return new File[0]; } File[] files = directory.listFiles(); return files != null ? files : new File[0]; }
java
@NonNull public static File[] listAllFiles(File directory) { if (directory == null) { return new File[0]; } File[] files = directory.listFiles(); return files != null ? files : new File[0]; }
[ "@", "NonNull", "public", "static", "File", "[", "]", "listAllFiles", "(", "File", "directory", ")", "{", "if", "(", "directory", "==", "null", ")", "{", "return", "new", "File", "[", "0", "]", ";", "}", "File", "[", "]", "files", "=", "directory", ...
Return list of all files in the directory. @param directory target directory on file system @return list of files in the directory or empty list if directory is empty.
[ "Return", "list", "of", "all", "files", "in", "the", "directory", "." ]
5b5ca7e04cb8fab31a8dc040b6e7521f930a58a4
https://github.com/mapbox/mapbox-events-android/blob/5b5ca7e04cb8fab31a8dc040b6e7521f930a58a4/libcore/src/main/java/com/mapbox/android/core/FileUtils.java#L111-L118
train
mapbox/mapbox-events-android
liblocation/src/main/java/com/mapbox/android/core/location/Utils.java
Utils.isOnClasspath
static boolean isOnClasspath(String className) { boolean isOnClassPath = true; try { Class.forName(className); } catch (ClassNotFoundException exception) { isOnClassPath = false; } return isOnClassPath; }
java
static boolean isOnClasspath(String className) { boolean isOnClassPath = true; try { Class.forName(className); } catch (ClassNotFoundException exception) { isOnClassPath = false; } return isOnClassPath; }
[ "static", "boolean", "isOnClasspath", "(", "String", "className", ")", "{", "boolean", "isOnClassPath", "=", "true", ";", "try", "{", "Class", ".", "forName", "(", "className", ")", ";", "}", "catch", "(", "ClassNotFoundException", "exception", ")", "{", "is...
Checks if class is on class path @param className of the class to check. @return true if class in on class path, false otherwise.
[ "Checks", "if", "class", "is", "on", "class", "path" ]
5b5ca7e04cb8fab31a8dc040b6e7521f930a58a4
https://github.com/mapbox/mapbox-events-android/blob/5b5ca7e04cb8fab31a8dc040b6e7521f930a58a4/liblocation/src/main/java/com/mapbox/android/core/location/Utils.java#L34-L42
train
mapbox/mapbox-events-android
liblocation/src/main/java/com/mapbox/android/core/location/LocationEngineResult.java
LocationEngineResult.extractResult
@Nullable public static LocationEngineResult extractResult(Intent intent) { LocationEngineResult result = null; if (isOnClasspath(GOOGLE_PLAY_LOCATION_RESULT)) { result = extractGooglePlayResult(intent); } return result == null ? extractAndroidResult(intent) : result; }
java
@Nullable public static LocationEngineResult extractResult(Intent intent) { LocationEngineResult result = null; if (isOnClasspath(GOOGLE_PLAY_LOCATION_RESULT)) { result = extractGooglePlayResult(intent); } return result == null ? extractAndroidResult(intent) : result; }
[ "@", "Nullable", "public", "static", "LocationEngineResult", "extractResult", "(", "Intent", "intent", ")", "{", "LocationEngineResult", "result", "=", "null", ";", "if", "(", "isOnClasspath", "(", "GOOGLE_PLAY_LOCATION_RESULT", ")", ")", "{", "result", "=", "extr...
Extracts location result from intent object @param intent valid intent object @return location result. @since 1.1.0
[ "Extracts", "location", "result", "from", "intent", "object" ]
5b5ca7e04cb8fab31a8dc040b6e7521f930a58a4
https://github.com/mapbox/mapbox-events-android/blob/5b5ca7e04cb8fab31a8dc040b6e7521f930a58a4/liblocation/src/main/java/com/mapbox/android/core/location/LocationEngineResult.java#L86-L93
train
mapbox/mapbox-events-android
liblocation/src/main/java/com/mapbox/android/core/permissions/PermissionsManager.java
PermissionsManager.onRequestPermissionsResult
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) { switch (requestCode) { case REQUEST_PERMISSIONS_CODE: if (listener != null) { boolean granted = grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED; listener.onPermissionResult(granted); } break; default: // Ignored } }
java
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) { switch (requestCode) { case REQUEST_PERMISSIONS_CODE: if (listener != null) { boolean granted = grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED; listener.onPermissionResult(granted); } break; default: // Ignored } }
[ "public", "void", "onRequestPermissionsResult", "(", "int", "requestCode", ",", "String", "[", "]", "permissions", ",", "int", "[", "]", "grantResults", ")", "{", "switch", "(", "requestCode", ")", "{", "case", "REQUEST_PERMISSIONS_CODE", ":", "if", "(", "list...
You should call this method from your activity onRequestPermissionsResult. @param requestCode The request code passed in requestPermissions(android.app.Activity, String[], int) @param permissions The requested permissions. Never null. @param grantResults The grant results for the corresponding permissions which is either PERMISSION_GRANTED or PERMISSION_DENIED. Never null.
[ "You", "should", "call", "this", "method", "from", "your", "activity", "onRequestPermissionsResult", "." ]
5b5ca7e04cb8fab31a8dc040b6e7521f930a58a4
https://github.com/mapbox/mapbox-events-android/blob/5b5ca7e04cb8fab31a8dc040b6e7521f930a58a4/liblocation/src/main/java/com/mapbox/android/core/permissions/PermissionsManager.java#L95-L106
train
mapbox/mapbox-events-android
libtelemetry/src/main/java/com/mapbox/android/telemetry/TelemetryUtils.java
TelemetryUtils.retrieveVendorId
public static String retrieveVendorId() { if (MapboxTelemetry.applicationContext == null) { return updateVendorId(); } SharedPreferences sharedPreferences = obtainSharedPreferences(MapboxTelemetry.applicationContext); String mapboxVendorId = sharedPreferences.getString(MAPBOX_SHARED_PREFERENCE_KEY_VENDOR_ID, ""); if (TelemetryUtils.isEmpty(mapboxVendorId)) { mapboxVendorId = TelemetryUtils.updateVendorId(); } return mapboxVendorId; }
java
public static String retrieveVendorId() { if (MapboxTelemetry.applicationContext == null) { return updateVendorId(); } SharedPreferences sharedPreferences = obtainSharedPreferences(MapboxTelemetry.applicationContext); String mapboxVendorId = sharedPreferences.getString(MAPBOX_SHARED_PREFERENCE_KEY_VENDOR_ID, ""); if (TelemetryUtils.isEmpty(mapboxVendorId)) { mapboxVendorId = TelemetryUtils.updateVendorId(); } return mapboxVendorId; }
[ "public", "static", "String", "retrieveVendorId", "(", ")", "{", "if", "(", "MapboxTelemetry", ".", "applicationContext", "==", "null", ")", "{", "return", "updateVendorId", "(", ")", ";", "}", "SharedPreferences", "sharedPreferences", "=", "obtainSharedPreferences"...
Do not call this method outside of activity!!!
[ "Do", "not", "call", "this", "method", "outside", "of", "activity!!!" ]
5b5ca7e04cb8fab31a8dc040b6e7521f930a58a4
https://github.com/mapbox/mapbox-events-android/blob/5b5ca7e04cb8fab31a8dc040b6e7521f930a58a4/libtelemetry/src/main/java/com/mapbox/android/telemetry/TelemetryUtils.java#L174-L185
train
mapbox/mapbox-events-android
libcore/src/main/java/com/mapbox/android/core/connectivity/ConnectivityReceiver.java
ConnectivityReceiver.getSystemConnectivity
private static boolean getSystemConnectivity(Context context) { try { ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); if (cm == null) { return false; } NetworkInfo activeNetwork = cm.getActiveNetworkInfo(); return activeNetwork.isConnectedOrConnecting(); } catch (Exception exception) { return false; } }
java
private static boolean getSystemConnectivity(Context context) { try { ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); if (cm == null) { return false; } NetworkInfo activeNetwork = cm.getActiveNetworkInfo(); return activeNetwork.isConnectedOrConnecting(); } catch (Exception exception) { return false; } }
[ "private", "static", "boolean", "getSystemConnectivity", "(", "Context", "context", ")", "{", "try", "{", "ConnectivityManager", "cm", "=", "(", "ConnectivityManager", ")", "context", ".", "getSystemService", "(", "Context", ".", "CONNECTIVITY_SERVICE", ")", ";", ...
Get the connectivity state as reported by the Android system @param context Android context @return the connectivity state as reported by the Android system
[ "Get", "the", "connectivity", "state", "as", "reported", "by", "the", "Android", "system" ]
5b5ca7e04cb8fab31a8dc040b6e7521f930a58a4
https://github.com/mapbox/mapbox-events-android/blob/5b5ca7e04cb8fab31a8dc040b6e7521f930a58a4/libcore/src/main/java/com/mapbox/android/core/connectivity/ConnectivityReceiver.java#L51-L63
train
mapbox/mapbox-events-android
libcore/src/main/java/com/mapbox/android/core/crashreporter/CrashReportBuilder.java
CrashReportBuilder.fromJson
public static CrashReport fromJson(String json) throws IllegalArgumentException { try { return new CrashReport(json); } catch (JSONException je) { throw new IllegalArgumentException(je.toString()); } }
java
public static CrashReport fromJson(String json) throws IllegalArgumentException { try { return new CrashReport(json); } catch (JSONException je) { throw new IllegalArgumentException(je.toString()); } }
[ "public", "static", "CrashReport", "fromJson", "(", "String", "json", ")", "throws", "IllegalArgumentException", "{", "try", "{", "return", "new", "CrashReport", "(", "json", ")", ";", "}", "catch", "(", "JSONException", "je", ")", "{", "throw", "new", "Ille...
Exports json encoded content to CrashReport object @param json valid json body. @return new instance of CrashReport
[ "Exports", "json", "encoded", "content", "to", "CrashReport", "object" ]
5b5ca7e04cb8fab31a8dc040b6e7521f930a58a4
https://github.com/mapbox/mapbox-events-android/blob/5b5ca7e04cb8fab31a8dc040b6e7521f930a58a4/libcore/src/main/java/com/mapbox/android/core/crashreporter/CrashReportBuilder.java#L41-L47
train
mapbox/mapbox-events-android
libtelemetry/src/full/java/com/mapbox/android/telemetry/location/LocationCollectionClient.java
LocationCollectionClient.uninstall
static boolean uninstall() { boolean uninstalled = false; synchronized (lock) { if (locationCollectionClient != null) { locationCollectionClient.locationEngineController.onDestroy(); locationCollectionClient.settingsChangeHandlerThread.quit(); locationCollectionClient.sharedPreferences.unregisterOnSharedPreferenceChangeListener(locationCollectionClient); locationCollectionClient = null; uninstalled = true; } } return uninstalled; }
java
static boolean uninstall() { boolean uninstalled = false; synchronized (lock) { if (locationCollectionClient != null) { locationCollectionClient.locationEngineController.onDestroy(); locationCollectionClient.settingsChangeHandlerThread.quit(); locationCollectionClient.sharedPreferences.unregisterOnSharedPreferenceChangeListener(locationCollectionClient); locationCollectionClient = null; uninstalled = true; } } return uninstalled; }
[ "static", "boolean", "uninstall", "(", ")", "{", "boolean", "uninstalled", "=", "false", ";", "synchronized", "(", "lock", ")", "{", "if", "(", "locationCollectionClient", "!=", "null", ")", "{", "locationCollectionClient", ".", "locationEngineController", ".", ...
Uninstall current location collection client. @return true if uninstall was successful
[ "Uninstall", "current", "location", "collection", "client", "." ]
5b5ca7e04cb8fab31a8dc040b6e7521f930a58a4
https://github.com/mapbox/mapbox-events-android/blob/5b5ca7e04cb8fab31a8dc040b6e7521f930a58a4/libtelemetry/src/full/java/com/mapbox/android/telemetry/location/LocationCollectionClient.java#L112-L124
train
google/openrtb-doubleclick
doubleclick-core/src/main/java/com/google/doubleclick/util/GeoTarget.java
GeoTarget.getCanonAncestor
@Nullable public GeoTarget getCanonAncestor(GeoTarget.Type type) { for (GeoTarget target = this; target != null; target = target.canonParent()) { if (target.key.type == type) { return target; } } return null; }
java
@Nullable public GeoTarget getCanonAncestor(GeoTarget.Type type) { for (GeoTarget target = this; target != null; target = target.canonParent()) { if (target.key.type == type) { return target; } } return null; }
[ "@", "Nullable", "public", "GeoTarget", "getCanonAncestor", "(", "GeoTarget", ".", "Type", "type", ")", "{", "for", "(", "GeoTarget", "target", "=", "this", ";", "target", "!=", "null", ";", "target", "=", "target", ".", "canonParent", "(", ")", ")", "{"...
Finds an ancestor of a specific type, if possible. <p>Example: (New York city target, {@link Type#COUNTRY}) returns (US country target)
[ "Finds", "an", "ancestor", "of", "a", "specific", "type", "if", "possible", "." ]
2dbbbb54fd7079f107a3dfdd748d2e44e18605c3
https://github.com/google/openrtb-doubleclick/blob/2dbbbb54fd7079f107a3dfdd748d2e44e18605c3/doubleclick-core/src/main/java/com/google/doubleclick/util/GeoTarget.java#L146-L154
train
google/openrtb-doubleclick
doubleclick-core/src/main/java/com/google/doubleclick/crypto/DoubleClickCrypto.java
DoubleClickCrypto.encrypt
public byte[] encrypt(byte[] plainData) { checkArgument(plainData.length >= OVERHEAD_SIZE, "Invalid plainData, %s bytes", plainData.length); // workBytes := initVector || payload || zeros:4 byte[] workBytes = plainData.clone(); ByteBuffer workBuffer = ByteBuffer.wrap(workBytes); boolean success = false; try { // workBytes := initVector || payload || I(signature) int signature = hmacSignature(workBytes); workBuffer.putInt(workBytes.length - SIGNATURE_SIZE, signature); // workBytes := initVector || E(payload) || I(signature) xorPayloadToHmacPad(workBytes); if (logger.isDebugEnabled()) { logger.debug(dump("Encrypted", plainData, workBytes)); } success = true; return workBytes; } finally { if (!success && logger.isDebugEnabled()) { logger.debug(dump("Encrypted (failed)", plainData, workBytes)); } } }
java
public byte[] encrypt(byte[] plainData) { checkArgument(plainData.length >= OVERHEAD_SIZE, "Invalid plainData, %s bytes", plainData.length); // workBytes := initVector || payload || zeros:4 byte[] workBytes = plainData.clone(); ByteBuffer workBuffer = ByteBuffer.wrap(workBytes); boolean success = false; try { // workBytes := initVector || payload || I(signature) int signature = hmacSignature(workBytes); workBuffer.putInt(workBytes.length - SIGNATURE_SIZE, signature); // workBytes := initVector || E(payload) || I(signature) xorPayloadToHmacPad(workBytes); if (logger.isDebugEnabled()) { logger.debug(dump("Encrypted", plainData, workBytes)); } success = true; return workBytes; } finally { if (!success && logger.isDebugEnabled()) { logger.debug(dump("Encrypted (failed)", plainData, workBytes)); } } }
[ "public", "byte", "[", "]", "encrypt", "(", "byte", "[", "]", "plainData", ")", "{", "checkArgument", "(", "plainData", ".", "length", ">=", "OVERHEAD_SIZE", ",", "\"Invalid plainData, %s bytes\"", ",", "plainData", ".", "length", ")", ";", "// workBytes := init...
Encrypts data. @param plainData {@code initVector || payload || zeros:4} @return {@code initVector || E(payload) || I(signature)}
[ "Encrypts", "data", "." ]
2dbbbb54fd7079f107a3dfdd748d2e44e18605c3
https://github.com/google/openrtb-doubleclick/blob/2dbbbb54fd7079f107a3dfdd748d2e44e18605c3/doubleclick-core/src/main/java/com/google/doubleclick/crypto/DoubleClickCrypto.java#L159-L186
train
box/box-java-sdk
src/main/java/com/box/sdk/BoxConfig.java
BoxConfig.readFrom
public static BoxConfig readFrom(Reader reader) throws IOException { JsonObject config = JsonObject.readFrom(reader); JsonObject settings = (JsonObject) config.get("boxAppSettings"); String clientId = settings.get("clientID").asString(); String clientSecret = settings.get("clientSecret").asString(); JsonObject appAuth = (JsonObject) settings.get("appAuth"); String publicKeyId = appAuth.get("publicKeyID").asString(); String privateKey = appAuth.get("privateKey").asString(); String passphrase = appAuth.get("passphrase").asString(); String enterpriseId = config.get("enterpriseID").asString(); return new BoxConfig(clientId, clientSecret, enterpriseId, publicKeyId, privateKey, passphrase); }
java
public static BoxConfig readFrom(Reader reader) throws IOException { JsonObject config = JsonObject.readFrom(reader); JsonObject settings = (JsonObject) config.get("boxAppSettings"); String clientId = settings.get("clientID").asString(); String clientSecret = settings.get("clientSecret").asString(); JsonObject appAuth = (JsonObject) settings.get("appAuth"); String publicKeyId = appAuth.get("publicKeyID").asString(); String privateKey = appAuth.get("privateKey").asString(); String passphrase = appAuth.get("passphrase").asString(); String enterpriseId = config.get("enterpriseID").asString(); return new BoxConfig(clientId, clientSecret, enterpriseId, publicKeyId, privateKey, passphrase); }
[ "public", "static", "BoxConfig", "readFrom", "(", "Reader", "reader", ")", "throws", "IOException", "{", "JsonObject", "config", "=", "JsonObject", ".", "readFrom", "(", "reader", ")", ";", "JsonObject", "settings", "=", "(", "JsonObject", ")", "config", ".", ...
Reads OAuth 2.0 with JWT app configurations from the reader. The file should be in JSON format. @param reader a reader object which points to a JSON formatted configuration file @return a new Instance of BoxConfig @throws IOException when unable to access the mapping file's content of the reader
[ "Reads", "OAuth", "2", ".", "0", "with", "JWT", "app", "configurations", "from", "the", "reader", ".", "The", "file", "should", "be", "in", "JSON", "format", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxConfig.java#L98-L109
train
box/box-java-sdk
src/main/java/com/box/sdk/BoxCollaborationWhitelist.java
BoxCollaborationWhitelist.create
public static BoxCollaborationWhitelist.Info create(final BoxAPIConnection api, String domain, WhitelistDirection direction) { URL url = COLLABORATION_WHITELIST_ENTRIES_URL_TEMPLATE.build(api.getBaseURL()); BoxJSONRequest request = new BoxJSONRequest(api, url, HttpMethod.POST); JsonObject requestJSON = new JsonObject() .add("domain", domain) .add("direction", direction.toString()); request.setBody(requestJSON.toString()); BoxJSONResponse response = (BoxJSONResponse) request.send(); JsonObject responseJSON = JsonObject.readFrom(response.getJSON()); BoxCollaborationWhitelist domainWhitelist = new BoxCollaborationWhitelist(api, responseJSON.get("id").asString()); return domainWhitelist.new Info(responseJSON); }
java
public static BoxCollaborationWhitelist.Info create(final BoxAPIConnection api, String domain, WhitelistDirection direction) { URL url = COLLABORATION_WHITELIST_ENTRIES_URL_TEMPLATE.build(api.getBaseURL()); BoxJSONRequest request = new BoxJSONRequest(api, url, HttpMethod.POST); JsonObject requestJSON = new JsonObject() .add("domain", domain) .add("direction", direction.toString()); request.setBody(requestJSON.toString()); BoxJSONResponse response = (BoxJSONResponse) request.send(); JsonObject responseJSON = JsonObject.readFrom(response.getJSON()); BoxCollaborationWhitelist domainWhitelist = new BoxCollaborationWhitelist(api, responseJSON.get("id").asString()); return domainWhitelist.new Info(responseJSON); }
[ "public", "static", "BoxCollaborationWhitelist", ".", "Info", "create", "(", "final", "BoxAPIConnection", "api", ",", "String", "domain", ",", "WhitelistDirection", "direction", ")", "{", "URL", "url", "=", "COLLABORATION_WHITELIST_ENTRIES_URL_TEMPLATE", ".", "build", ...
Creates a new Collaboration Whitelist for a domain. @param api the API connection to be used by the resource. @param domain the domain to be added to a collaboration whitelist for a Box Enterprise. @param direction an enum representing the direction of the collaboration whitelist. Can be set to inbound, outbound, or both. @return information about the collaboration whitelist created.
[ "Creates", "a", "new", "Collaboration", "Whitelist", "for", "a", "domain", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxCollaborationWhitelist.java#L58-L74
train
box/box-java-sdk
src/main/java/com/box/sdk/BoxCollaborationWhitelist.java
BoxCollaborationWhitelist.delete
public void delete() { BoxAPIConnection api = this.getAPI(); URL url = COLLABORATION_WHITELIST_ENTRY_URL_TEMPLATE.build(api.getBaseURL(), this.getID()); BoxAPIRequest request = new BoxAPIRequest(api, url, HttpMethod.DELETE); BoxAPIResponse response = request.send(); response.disconnect(); }
java
public void delete() { BoxAPIConnection api = this.getAPI(); URL url = COLLABORATION_WHITELIST_ENTRY_URL_TEMPLATE.build(api.getBaseURL(), this.getID()); BoxAPIRequest request = new BoxAPIRequest(api, url, HttpMethod.DELETE); BoxAPIResponse response = request.send(); response.disconnect(); }
[ "public", "void", "delete", "(", ")", "{", "BoxAPIConnection", "api", "=", "this", ".", "getAPI", "(", ")", ";", "URL", "url", "=", "COLLABORATION_WHITELIST_ENTRY_URL_TEMPLATE", ".", "build", "(", "api", ".", "getBaseURL", "(", ")", ",", "this", ".", "getI...
Deletes this collaboration whitelist.
[ "Deletes", "this", "collaboration", "whitelist", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxCollaborationWhitelist.java#L129-L136
train
box/box-java-sdk
src/main/java/com/box/sdk/internal/utils/CollectionUtils.java
CollectionUtils.map
public static <T_Result, T_Source> List<T_Result> map(Collection<T_Source> source, Mapper<T_Result, T_Source> mapper) { List<T_Result> result = new LinkedList<T_Result>(); for (T_Source element : source) { result.add(mapper.map(element)); } return result; }
java
public static <T_Result, T_Source> List<T_Result> map(Collection<T_Source> source, Mapper<T_Result, T_Source> mapper) { List<T_Result> result = new LinkedList<T_Result>(); for (T_Source element : source) { result.add(mapper.map(element)); } return result; }
[ "public", "static", "<", "T_Result", ",", "T_Source", ">", "List", "<", "T_Result", ">", "map", "(", "Collection", "<", "T_Source", ">", "source", ",", "Mapper", "<", "T_Result", ",", "T_Source", ">", "mapper", ")", "{", "List", "<", "T_Result", ">", "...
Re-maps a provided collection. @param <T_Result> type of result @param <T_Source> type of source @param source for mapping @param mapper element mapper @return mapped source
[ "Re", "-", "maps", "a", "provided", "collection", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/internal/utils/CollectionUtils.java#L31-L38
train
box/box-java-sdk
src/main/java/com/box/sdk/BoxFolder.java
BoxFolder.createFolder
public BoxFolder.Info createFolder(String name) { JsonObject parent = new JsonObject(); parent.add("id", this.getID()); JsonObject newFolder = new JsonObject(); newFolder.add("name", name); newFolder.add("parent", parent); BoxJSONRequest request = new BoxJSONRequest(this.getAPI(), CREATE_FOLDER_URL.build(this.getAPI().getBaseURL()), "POST"); request.setBody(newFolder.toString()); BoxJSONResponse response = (BoxJSONResponse) request.send(); JsonObject responseJSON = JsonObject.readFrom(response.getJSON()); BoxFolder createdFolder = new BoxFolder(this.getAPI(), responseJSON.get("id").asString()); return createdFolder.new Info(responseJSON); }
java
public BoxFolder.Info createFolder(String name) { JsonObject parent = new JsonObject(); parent.add("id", this.getID()); JsonObject newFolder = new JsonObject(); newFolder.add("name", name); newFolder.add("parent", parent); BoxJSONRequest request = new BoxJSONRequest(this.getAPI(), CREATE_FOLDER_URL.build(this.getAPI().getBaseURL()), "POST"); request.setBody(newFolder.toString()); BoxJSONResponse response = (BoxJSONResponse) request.send(); JsonObject responseJSON = JsonObject.readFrom(response.getJSON()); BoxFolder createdFolder = new BoxFolder(this.getAPI(), responseJSON.get("id").asString()); return createdFolder.new Info(responseJSON); }
[ "public", "BoxFolder", ".", "Info", "createFolder", "(", "String", "name", ")", "{", "JsonObject", "parent", "=", "new", "JsonObject", "(", ")", ";", "parent", ".", "add", "(", "\"id\"", ",", "this", ".", "getID", "(", ")", ")", ";", "JsonObject", "new...
Creates a new child folder inside this folder. @param name the new folder's name. @return the created folder's info.
[ "Creates", "a", "new", "child", "folder", "inside", "this", "folder", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxFolder.java#L348-L364
train
box/box-java-sdk
src/main/java/com/box/sdk/BoxFolder.java
BoxFolder.rename
public void rename(String newName) { URL url = FOLDER_INFO_URL_TEMPLATE.build(this.getAPI().getBaseURL(), this.getID()); BoxJSONRequest request = new BoxJSONRequest(this.getAPI(), url, "PUT"); JsonObject updateInfo = new JsonObject(); updateInfo.add("name", newName); request.setBody(updateInfo.toString()); BoxJSONResponse response = (BoxJSONResponse) request.send(); response.getJSON(); }
java
public void rename(String newName) { URL url = FOLDER_INFO_URL_TEMPLATE.build(this.getAPI().getBaseURL(), this.getID()); BoxJSONRequest request = new BoxJSONRequest(this.getAPI(), url, "PUT"); JsonObject updateInfo = new JsonObject(); updateInfo.add("name", newName); request.setBody(updateInfo.toString()); BoxJSONResponse response = (BoxJSONResponse) request.send(); response.getJSON(); }
[ "public", "void", "rename", "(", "String", "newName", ")", "{", "URL", "url", "=", "FOLDER_INFO_URL_TEMPLATE", ".", "build", "(", "this", ".", "getAPI", "(", ")", ".", "getBaseURL", "(", ")", ",", "this", ".", "getID", "(", ")", ")", ";", "BoxJSONReque...
Renames this folder. @param newName the new name of the folder.
[ "Renames", "this", "folder", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxFolder.java#L409-L419
train
box/box-java-sdk
src/main/java/com/box/sdk/BoxFolder.java
BoxFolder.uploadFile
public BoxFile.Info uploadFile(InputStream fileContent, String name, long fileSize, ProgressListener listener) { FileUploadParams uploadInfo = new FileUploadParams() .setContent(fileContent) .setName(name) .setSize(fileSize) .setProgressListener(listener); return this.uploadFile(uploadInfo); }
java
public BoxFile.Info uploadFile(InputStream fileContent, String name, long fileSize, ProgressListener listener) { FileUploadParams uploadInfo = new FileUploadParams() .setContent(fileContent) .setName(name) .setSize(fileSize) .setProgressListener(listener); return this.uploadFile(uploadInfo); }
[ "public", "BoxFile", ".", "Info", "uploadFile", "(", "InputStream", "fileContent", ",", "String", "name", ",", "long", "fileSize", ",", "ProgressListener", "listener", ")", "{", "FileUploadParams", "uploadInfo", "=", "new", "FileUploadParams", "(", ")", ".", "se...
Uploads a new file to this folder while reporting the progress to a ProgressListener. @param fileContent a stream containing the contents of the file to upload. @param name the name to give the uploaded file. @param fileSize the size of the file used for determining the progress of the upload. @param listener a listener for monitoring the upload's progress. @return the uploaded file's info.
[ "Uploads", "a", "new", "file", "to", "this", "folder", "while", "reporting", "the", "progress", "to", "a", "ProgressListener", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxFolder.java#L482-L489
train
box/box-java-sdk
src/main/java/com/box/sdk/BoxFolder.java
BoxFolder.uploadFile
public BoxFile.Info uploadFile(FileUploadParams uploadParams) { URL uploadURL = UPLOAD_FILE_URL.build(this.getAPI().getBaseUploadURL()); BoxMultipartRequest request = new BoxMultipartRequest(getAPI(), uploadURL); JsonObject fieldJSON = new JsonObject(); JsonObject parentIdJSON = new JsonObject(); parentIdJSON.add("id", getID()); fieldJSON.add("name", uploadParams.getName()); fieldJSON.add("parent", parentIdJSON); if (uploadParams.getCreated() != null) { fieldJSON.add("content_created_at", BoxDateFormat.format(uploadParams.getCreated())); } if (uploadParams.getModified() != null) { fieldJSON.add("content_modified_at", BoxDateFormat.format(uploadParams.getModified())); } if (uploadParams.getSHA1() != null && !uploadParams.getSHA1().isEmpty()) { request.setContentSHA1(uploadParams.getSHA1()); } if (uploadParams.getDescription() != null) { fieldJSON.add("description", uploadParams.getDescription()); } request.putField("attributes", fieldJSON.toString()); if (uploadParams.getSize() > 0) { request.setFile(uploadParams.getContent(), uploadParams.getName(), uploadParams.getSize()); } else if (uploadParams.getContent() != null) { request.setFile(uploadParams.getContent(), uploadParams.getName()); } else { request.setUploadFileCallback(uploadParams.getUploadFileCallback(), uploadParams.getName()); } BoxJSONResponse response; if (uploadParams.getProgressListener() == null) { response = (BoxJSONResponse) request.send(); } else { response = (BoxJSONResponse) request.send(uploadParams.getProgressListener()); } JsonObject collection = JsonObject.readFrom(response.getJSON()); JsonArray entries = collection.get("entries").asArray(); JsonObject fileInfoJSON = entries.get(0).asObject(); String uploadedFileID = fileInfoJSON.get("id").asString(); BoxFile uploadedFile = new BoxFile(getAPI(), uploadedFileID); return uploadedFile.new Info(fileInfoJSON); }
java
public BoxFile.Info uploadFile(FileUploadParams uploadParams) { URL uploadURL = UPLOAD_FILE_URL.build(this.getAPI().getBaseUploadURL()); BoxMultipartRequest request = new BoxMultipartRequest(getAPI(), uploadURL); JsonObject fieldJSON = new JsonObject(); JsonObject parentIdJSON = new JsonObject(); parentIdJSON.add("id", getID()); fieldJSON.add("name", uploadParams.getName()); fieldJSON.add("parent", parentIdJSON); if (uploadParams.getCreated() != null) { fieldJSON.add("content_created_at", BoxDateFormat.format(uploadParams.getCreated())); } if (uploadParams.getModified() != null) { fieldJSON.add("content_modified_at", BoxDateFormat.format(uploadParams.getModified())); } if (uploadParams.getSHA1() != null && !uploadParams.getSHA1().isEmpty()) { request.setContentSHA1(uploadParams.getSHA1()); } if (uploadParams.getDescription() != null) { fieldJSON.add("description", uploadParams.getDescription()); } request.putField("attributes", fieldJSON.toString()); if (uploadParams.getSize() > 0) { request.setFile(uploadParams.getContent(), uploadParams.getName(), uploadParams.getSize()); } else if (uploadParams.getContent() != null) { request.setFile(uploadParams.getContent(), uploadParams.getName()); } else { request.setUploadFileCallback(uploadParams.getUploadFileCallback(), uploadParams.getName()); } BoxJSONResponse response; if (uploadParams.getProgressListener() == null) { response = (BoxJSONResponse) request.send(); } else { response = (BoxJSONResponse) request.send(uploadParams.getProgressListener()); } JsonObject collection = JsonObject.readFrom(response.getJSON()); JsonArray entries = collection.get("entries").asArray(); JsonObject fileInfoJSON = entries.get(0).asObject(); String uploadedFileID = fileInfoJSON.get("id").asString(); BoxFile uploadedFile = new BoxFile(getAPI(), uploadedFileID); return uploadedFile.new Info(fileInfoJSON); }
[ "public", "BoxFile", ".", "Info", "uploadFile", "(", "FileUploadParams", "uploadParams", ")", "{", "URL", "uploadURL", "=", "UPLOAD_FILE_URL", ".", "build", "(", "this", ".", "getAPI", "(", ")", ".", "getBaseUploadURL", "(", ")", ")", ";", "BoxMultipartRequest...
Uploads a new file to this folder with custom upload parameters. @param uploadParams the custom upload parameters. @return the uploaded file's info.
[ "Uploads", "a", "new", "file", "to", "this", "folder", "with", "custom", "upload", "parameters", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxFolder.java#L513-L562
train
box/box-java-sdk
src/main/java/com/box/sdk/BoxFolder.java
BoxFolder.getChildren
public Iterable<BoxItem.Info> getChildren(final String... fields) { return new Iterable<BoxItem.Info>() { @Override public Iterator<BoxItem.Info> iterator() { String queryString = new QueryStringBuilder().appendParam("fields", fields).toString(); URL url = GET_ITEMS_URL.buildWithQuery(getAPI().getBaseURL(), queryString, getID()); return new BoxItemIterator(getAPI(), url); } }; }
java
public Iterable<BoxItem.Info> getChildren(final String... fields) { return new Iterable<BoxItem.Info>() { @Override public Iterator<BoxItem.Info> iterator() { String queryString = new QueryStringBuilder().appendParam("fields", fields).toString(); URL url = GET_ITEMS_URL.buildWithQuery(getAPI().getBaseURL(), queryString, getID()); return new BoxItemIterator(getAPI(), url); } }; }
[ "public", "Iterable", "<", "BoxItem", ".", "Info", ">", "getChildren", "(", "final", "String", "...", "fields", ")", "{", "return", "new", "Iterable", "<", "BoxItem", ".", "Info", ">", "(", ")", "{", "@", "Override", "public", "Iterator", "<", "BoxItem",...
Returns an iterable containing the items in this folder and specifies which child fields to retrieve from the API. @param fields the fields to retrieve. @return an iterable containing the items in this folder.
[ "Returns", "an", "iterable", "containing", "the", "items", "in", "this", "folder", "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/BoxFolder.java#L646-L655
train
box/box-java-sdk
src/main/java/com/box/sdk/BoxFolder.java
BoxFolder.getChildren
public Iterable<BoxItem.Info> getChildren(String sort, SortDirection direction, final String... fields) { QueryStringBuilder builder = new QueryStringBuilder() .appendParam("sort", sort) .appendParam("direction", direction.toString()); if (fields.length > 0) { builder.appendParam("fields", fields).toString(); } final String query = builder.toString(); return new Iterable<BoxItem.Info>() { @Override public Iterator<BoxItem.Info> iterator() { URL url = GET_ITEMS_URL.buildWithQuery(getAPI().getBaseURL(), query, getID()); return new BoxItemIterator(getAPI(), url); } }; }
java
public Iterable<BoxItem.Info> getChildren(String sort, SortDirection direction, final String... fields) { QueryStringBuilder builder = new QueryStringBuilder() .appendParam("sort", sort) .appendParam("direction", direction.toString()); if (fields.length > 0) { builder.appendParam("fields", fields).toString(); } final String query = builder.toString(); return new Iterable<BoxItem.Info>() { @Override public Iterator<BoxItem.Info> iterator() { URL url = GET_ITEMS_URL.buildWithQuery(getAPI().getBaseURL(), query, getID()); return new BoxItemIterator(getAPI(), url); } }; }
[ "public", "Iterable", "<", "BoxItem", ".", "Info", ">", "getChildren", "(", "String", "sort", ",", "SortDirection", "direction", ",", "final", "String", "...", "fields", ")", "{", "QueryStringBuilder", "builder", "=", "new", "QueryStringBuilder", "(", ")", "."...
Returns an iterable containing the items in this folder sorted by name and direction. @param sort the field to sort by, can be set as `name`, `id`, and `date`. @param direction the direction to display the item results. @param fields the fields to retrieve. @return an iterable containing the items in this folder.
[ "Returns", "an", "iterable", "containing", "the", "items", "in", "this", "folder", "sorted", "by", "name", "and", "direction", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxFolder.java#L664-L680
train
box/box-java-sdk
src/main/java/com/box/sdk/BoxFolder.java
BoxFolder.getChildrenRange
public PartialCollection<BoxItem.Info> getChildrenRange(long offset, long limit, String... fields) { QueryStringBuilder builder = new QueryStringBuilder() .appendParam("limit", limit) .appendParam("offset", offset); if (fields.length > 0) { builder.appendParam("fields", fields).toString(); } URL url = GET_ITEMS_URL.buildWithQuery(getAPI().getBaseURL(), builder.toString(), getID()); BoxAPIRequest request = new BoxAPIRequest(this.getAPI(), url, "GET"); BoxJSONResponse response = (BoxJSONResponse) request.send(); JsonObject responseJSON = JsonObject.readFrom(response.getJSON()); String totalCountString = responseJSON.get("total_count").toString(); long fullSize = Double.valueOf(totalCountString).longValue(); PartialCollection<BoxItem.Info> children = 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) { children.add(parsedItemInfo); } } return children; }
java
public PartialCollection<BoxItem.Info> getChildrenRange(long offset, long limit, String... fields) { QueryStringBuilder builder = new QueryStringBuilder() .appendParam("limit", limit) .appendParam("offset", offset); if (fields.length > 0) { builder.appendParam("fields", fields).toString(); } URL url = GET_ITEMS_URL.buildWithQuery(getAPI().getBaseURL(), builder.toString(), getID()); BoxAPIRequest request = new BoxAPIRequest(this.getAPI(), url, "GET"); BoxJSONResponse response = (BoxJSONResponse) request.send(); JsonObject responseJSON = JsonObject.readFrom(response.getJSON()); String totalCountString = responseJSON.get("total_count").toString(); long fullSize = Double.valueOf(totalCountString).longValue(); PartialCollection<BoxItem.Info> children = 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) { children.add(parsedItemInfo); } } return children; }
[ "public", "PartialCollection", "<", "BoxItem", ".", "Info", ">", "getChildrenRange", "(", "long", "offset", ",", "long", "limit", ",", "String", "...", "fields", ")", "{", "QueryStringBuilder", "builder", "=", "new", "QueryStringBuilder", "(", ")", ".", "appen...
Retrieves a specific range of child items in this folder. @param offset the index of the first child item to retrieve. @param limit the maximum number of children to retrieve after the offset. @param fields the fields to retrieve. @return a partial collection containing the specified range of child items.
[ "Retrieves", "a", "specific", "range", "of", "child", "items", "in", "this", "folder", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxFolder.java#L690-L716
train
box/box-java-sdk
src/main/java/com/box/sdk/BoxFolder.java
BoxFolder.iterator
@Override public Iterator<BoxItem.Info> iterator() { URL url = GET_ITEMS_URL.build(this.getAPI().getBaseURL(), BoxFolder.this.getID()); return new BoxItemIterator(BoxFolder.this.getAPI(), url); }
java
@Override public Iterator<BoxItem.Info> iterator() { URL url = GET_ITEMS_URL.build(this.getAPI().getBaseURL(), BoxFolder.this.getID()); return new BoxItemIterator(BoxFolder.this.getAPI(), url); }
[ "@", "Override", "public", "Iterator", "<", "BoxItem", ".", "Info", ">", "iterator", "(", ")", "{", "URL", "url", "=", "GET_ITEMS_URL", ".", "build", "(", "this", ".", "getAPI", "(", ")", ".", "getBaseURL", "(", ")", ",", "BoxFolder", ".", "this", "....
Returns an iterator over the items in this folder. @return an iterator over the items in this folder.
[ "Returns", "an", "iterator", "over", "the", "items", "in", "this", "folder", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxFolder.java#L723-L727
train
box/box-java-sdk
src/main/java/com/box/sdk/BoxFolder.java
BoxFolder.createMetadata
public Metadata createMetadata(String templateName, Metadata metadata) { String scope = Metadata.scopeBasedOnType(templateName); return this.createMetadata(templateName, scope, metadata); }
java
public Metadata createMetadata(String templateName, Metadata metadata) { String scope = Metadata.scopeBasedOnType(templateName); return this.createMetadata(templateName, scope, metadata); }
[ "public", "Metadata", "createMetadata", "(", "String", "templateName", ",", "Metadata", "metadata", ")", "{", "String", "scope", "=", "Metadata", ".", "scopeBasedOnType", "(", "templateName", ")", ";", "return", "this", ".", "createMetadata", "(", "templateName", ...
Creates metadata on this folder using a specified template. @param templateName the name of the metadata template. @param metadata the new metadata values. @return the metadata returned from the server.
[ "Creates", "metadata", "on", "this", "folder", "using", "a", "specified", "template", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxFolder.java#L837-L840
train
box/box-java-sdk
src/main/java/com/box/sdk/BoxFolder.java
BoxFolder.createMetadata
public Metadata createMetadata(String templateName, String scope, Metadata metadata) { URL url = METADATA_URL_TEMPLATE.build(this.getAPI().getBaseURL(), this.getID(), scope, templateName); BoxAPIRequest request = new BoxAPIRequest(this.getAPI(), url, "POST"); request.addHeader("Content-Type", "application/json"); request.setBody(metadata.toString()); BoxJSONResponse response = (BoxJSONResponse) request.send(); return new Metadata(JsonObject.readFrom(response.getJSON())); }
java
public Metadata createMetadata(String templateName, String scope, Metadata metadata) { URL url = METADATA_URL_TEMPLATE.build(this.getAPI().getBaseURL(), this.getID(), scope, templateName); BoxAPIRequest request = new BoxAPIRequest(this.getAPI(), url, "POST"); request.addHeader("Content-Type", "application/json"); request.setBody(metadata.toString()); BoxJSONResponse response = (BoxJSONResponse) request.send(); return new Metadata(JsonObject.readFrom(response.getJSON())); }
[ "public", "Metadata", "createMetadata", "(", "String", "templateName", ",", "String", "scope", ",", "Metadata", "metadata", ")", "{", "URL", "url", "=", "METADATA_URL_TEMPLATE", ".", "build", "(", "this", ".", "getAPI", "(", ")", ".", "getBaseURL", "(", ")",...
Creates metadata on this folder using a specified scope and template. @param templateName the name of the metadata template. @param scope the scope of the template (usually "global" or "enterprise"). @param metadata the new metadata values. @return the metadata returned from the server.
[ "Creates", "metadata", "on", "this", "folder", "using", "a", "specified", "scope", "and", "template", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxFolder.java#L850-L857
train
box/box-java-sdk
src/main/java/com/box/sdk/BoxFolder.java
BoxFolder.setMetadata
public Metadata setMetadata(String templateName, String scope, Metadata metadata) { Metadata metadataValue = null; try { metadataValue = this.createMetadata(templateName, scope, metadata); } catch (BoxAPIException e) { if (e.getResponseCode() == 409) { Metadata metadataToUpdate = new Metadata(scope, templateName); for (JsonValue value : metadata.getOperations()) { if (value.asObject().get("value").isNumber()) { metadataToUpdate.add(value.asObject().get("path").asString(), value.asObject().get("value").asFloat()); } else if (value.asObject().get("value").isString()) { metadataToUpdate.add(value.asObject().get("path").asString(), value.asObject().get("value").asString()); } else if (value.asObject().get("value").isArray()) { ArrayList<String> list = new ArrayList<String>(); for (JsonValue jsonValue : value.asObject().get("value").asArray()) { list.add(jsonValue.asString()); } metadataToUpdate.add(value.asObject().get("path").asString(), list); } } metadataValue = this.updateMetadata(metadataToUpdate); } } return metadataValue; }
java
public Metadata setMetadata(String templateName, String scope, Metadata metadata) { Metadata metadataValue = null; try { metadataValue = this.createMetadata(templateName, scope, metadata); } catch (BoxAPIException e) { if (e.getResponseCode() == 409) { Metadata metadataToUpdate = new Metadata(scope, templateName); for (JsonValue value : metadata.getOperations()) { if (value.asObject().get("value").isNumber()) { metadataToUpdate.add(value.asObject().get("path").asString(), value.asObject().get("value").asFloat()); } else if (value.asObject().get("value").isString()) { metadataToUpdate.add(value.asObject().get("path").asString(), value.asObject().get("value").asString()); } else if (value.asObject().get("value").isArray()) { ArrayList<String> list = new ArrayList<String>(); for (JsonValue jsonValue : value.asObject().get("value").asArray()) { list.add(jsonValue.asString()); } metadataToUpdate.add(value.asObject().get("path").asString(), list); } } metadataValue = this.updateMetadata(metadataToUpdate); } } return metadataValue; }
[ "public", "Metadata", "setMetadata", "(", "String", "templateName", ",", "String", "scope", ",", "Metadata", "metadata", ")", "{", "Metadata", "metadataValue", "=", "null", ";", "try", "{", "metadataValue", "=", "this", ".", "createMetadata", "(", "templateName"...
Sets the provided metadata on the folder, overwriting any existing metadata keys already present. @param templateName the name of the metadata template. @param scope the scope of the template (usually "global" or "enterprise"). @param metadata the new metadata values. @return the metadata returned from the server.
[ "Sets", "the", "provided", "metadata", "on", "the", "folder", "overwriting", "any", "existing", "metadata", "keys", "already", "present", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxFolder.java#L867-L895
train
box/box-java-sdk
src/main/java/com/box/sdk/BoxFolder.java
BoxFolder.getMetadata
public Metadata getMetadata(String templateName) { String scope = Metadata.scopeBasedOnType(templateName); return this.getMetadata(templateName, scope); }
java
public Metadata getMetadata(String templateName) { String scope = Metadata.scopeBasedOnType(templateName); return this.getMetadata(templateName, scope); }
[ "public", "Metadata", "getMetadata", "(", "String", "templateName", ")", "{", "String", "scope", "=", "Metadata", ".", "scopeBasedOnType", "(", "templateName", ")", ";", "return", "this", ".", "getMetadata", "(", "templateName", ",", "scope", ")", ";", "}" ]
Gets the metadata on this folder associated with a specified template. @param templateName the metadata template type name. @return the metadata returned from the server.
[ "Gets", "the", "metadata", "on", "this", "folder", "associated", "with", "a", "specified", "template", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxFolder.java#L912-L915
train
box/box-java-sdk
src/main/java/com/box/sdk/BoxFolder.java
BoxFolder.deleteMetadata
public void deleteMetadata(String templateName) { String scope = Metadata.scopeBasedOnType(templateName); this.deleteMetadata(templateName, scope); }
java
public void deleteMetadata(String templateName) { String scope = Metadata.scopeBasedOnType(templateName); this.deleteMetadata(templateName, scope); }
[ "public", "void", "deleteMetadata", "(", "String", "templateName", ")", "{", "String", "scope", "=", "Metadata", ".", "scopeBasedOnType", "(", "templateName", ")", ";", "this", ".", "deleteMetadata", "(", "templateName", ",", "scope", ")", ";", "}" ]
Deletes the metadata on this folder associated with a specified template. @param templateName the metadata template type name.
[ "Deletes", "the", "metadata", "on", "this", "folder", "associated", "with", "a", "specified", "template", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxFolder.java#L959-L962
train
box/box-java-sdk
src/main/java/com/box/sdk/BoxFolder.java
BoxFolder.deleteMetadata
public void deleteMetadata(String templateName, String scope) { URL url = METADATA_URL_TEMPLATE.build(this.getAPI().getBaseURL(), this.getID(), scope, templateName); BoxAPIRequest request = new BoxAPIRequest(this.getAPI(), url, "DELETE"); BoxAPIResponse response = request.send(); response.disconnect(); }
java
public void deleteMetadata(String templateName, String scope) { URL url = METADATA_URL_TEMPLATE.build(this.getAPI().getBaseURL(), this.getID(), scope, templateName); BoxAPIRequest request = new BoxAPIRequest(this.getAPI(), url, "DELETE"); BoxAPIResponse response = request.send(); response.disconnect(); }
[ "public", "void", "deleteMetadata", "(", "String", "templateName", ",", "String", "scope", ")", "{", "URL", "url", "=", "METADATA_URL_TEMPLATE", ".", "build", "(", "this", ".", "getAPI", "(", ")", ".", "getBaseURL", "(", ")", ",", "this", ".", "getID", "...
Deletes the metadata on this folder associated with a specified scope and template. @param templateName the metadata template type name. @param scope the scope of the template (usually "global" or "enterprise").
[ "Deletes", "the", "metadata", "on", "this", "folder", "associated", "with", "a", "specified", "scope", "and", "template", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxFolder.java#L970-L975
train
box/box-java-sdk
src/main/java/com/box/sdk/BoxFolder.java
BoxFolder.addClassification
public String addClassification(String classificationType) { Metadata metadata = new Metadata().add(Metadata.CLASSIFICATION_KEY, classificationType); Metadata classification = this.createMetadata(Metadata.CLASSIFICATION_TEMPLATE_KEY, "enterprise", metadata); return classification.getString(Metadata.CLASSIFICATION_KEY); }
java
public String addClassification(String classificationType) { Metadata metadata = new Metadata().add(Metadata.CLASSIFICATION_KEY, classificationType); Metadata classification = this.createMetadata(Metadata.CLASSIFICATION_TEMPLATE_KEY, "enterprise", metadata); return classification.getString(Metadata.CLASSIFICATION_KEY); }
[ "public", "String", "addClassification", "(", "String", "classificationType", ")", "{", "Metadata", "metadata", "=", "new", "Metadata", "(", ")", ".", "add", "(", "Metadata", ".", "CLASSIFICATION_KEY", ",", "classificationType", ")", ";", "Metadata", "classificati...
Adds a metadata classification to the specified file. @param classificationType the metadata classification type. @return the metadata classification type added to the file.
[ "Adds", "a", "metadata", "classification", "to", "the", "specified", "file", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxFolder.java#L983-L989
train
box/box-java-sdk
src/main/java/com/box/sdk/BoxFolder.java
BoxFolder.uploadLargeFile
public BoxFile.Info uploadLargeFile(InputStream inputStream, String fileName, long fileSize) throws InterruptedException, IOException { URL url = UPLOAD_SESSION_URL_TEMPLATE.build(this.getAPI().getBaseUploadURL()); return new LargeFileUpload(). upload(this.getAPI(), this.getID(), inputStream, url, fileName, fileSize); }
java
public BoxFile.Info uploadLargeFile(InputStream inputStream, String fileName, long fileSize) throws InterruptedException, IOException { URL url = UPLOAD_SESSION_URL_TEMPLATE.build(this.getAPI().getBaseUploadURL()); return new LargeFileUpload(). upload(this.getAPI(), this.getID(), inputStream, url, fileName, fileSize); }
[ "public", "BoxFile", ".", "Info", "uploadLargeFile", "(", "InputStream", "inputStream", ",", "String", "fileName", ",", "long", "fileSize", ")", "throws", "InterruptedException", ",", "IOException", "{", "URL", "url", "=", "UPLOAD_SESSION_URL_TEMPLATE", ".", "build"...
Creates a new file. @param inputStream the stream instance that contains the data. @param fileName the name of the file to be created. @param fileSize the size of the file that will be uploaded. @return the created file instance. @throws InterruptedException when a thread execution is interrupted. @throws IOException when reading a stream throws exception.
[ "Creates", "a", "new", "file", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxFolder.java#L1085-L1090
train
box/box-java-sdk
src/main/java/com/box/sdk/BoxFolder.java
BoxFolder.getMetadataCascadePolicies
public Iterable<BoxMetadataCascadePolicy.Info> getMetadataCascadePolicies(String... fields) { Iterable<BoxMetadataCascadePolicy.Info> cascadePoliciesInfo = BoxMetadataCascadePolicy.getAll(this.getAPI(), this.getID(), fields); return cascadePoliciesInfo; }
java
public Iterable<BoxMetadataCascadePolicy.Info> getMetadataCascadePolicies(String... fields) { Iterable<BoxMetadataCascadePolicy.Info> cascadePoliciesInfo = BoxMetadataCascadePolicy.getAll(this.getAPI(), this.getID(), fields); return cascadePoliciesInfo; }
[ "public", "Iterable", "<", "BoxMetadataCascadePolicy", ".", "Info", ">", "getMetadataCascadePolicies", "(", "String", "...", "fields", ")", "{", "Iterable", "<", "BoxMetadataCascadePolicy", ".", "Info", ">", "cascadePoliciesInfo", "=", "BoxMetadataCascadePolicy", ".", ...
Retrieves all Metadata Cascade Policies on a folder. @param fields optional fields to retrieve for cascade policies. @return the Iterable of Box Metadata Cascade Policies in your enterprise.
[ "Retrieves", "all", "Metadata", "Cascade", "Policies", "on", "a", "folder", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxFolder.java#L1131-L1136
train
box/box-java-sdk
src/main/java/com/box/sdk/BoxRetentionPolicy.java
BoxRetentionPolicy.createIndefinitePolicy
public static BoxRetentionPolicy.Info createIndefinitePolicy(BoxAPIConnection api, String name) { return createRetentionPolicy(api, name, TYPE_INDEFINITE, 0, ACTION_REMOVE_RETENTION); }
java
public static BoxRetentionPolicy.Info createIndefinitePolicy(BoxAPIConnection api, String name) { return createRetentionPolicy(api, name, TYPE_INDEFINITE, 0, ACTION_REMOVE_RETENTION); }
[ "public", "static", "BoxRetentionPolicy", ".", "Info", "createIndefinitePolicy", "(", "BoxAPIConnection", "api", ",", "String", "name", ")", "{", "return", "createRetentionPolicy", "(", "api", ",", "name", ",", "TYPE_INDEFINITE", ",", "0", ",", "ACTION_REMOVE_RETENT...
Used to create a new indefinite retention policy. @param api the API connection to be used by the created user. @param name the name of the retention policy. @return the created retention policy's info.
[ "Used", "to", "create", "a", "new", "indefinite", "retention", "policy", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxRetentionPolicy.java#L93-L95
train
box/box-java-sdk
src/main/java/com/box/sdk/BoxRetentionPolicy.java
BoxRetentionPolicy.createFinitePolicy
public static BoxRetentionPolicy.Info createFinitePolicy(BoxAPIConnection api, String name, int length, String action, RetentionPolicyParams optionalParams) { return createRetentionPolicy(api, name, TYPE_FINITE, length, action, optionalParams); }
java
public static BoxRetentionPolicy.Info createFinitePolicy(BoxAPIConnection api, String name, int length, String action, RetentionPolicyParams optionalParams) { return createRetentionPolicy(api, name, TYPE_FINITE, length, action, optionalParams); }
[ "public", "static", "BoxRetentionPolicy", ".", "Info", "createFinitePolicy", "(", "BoxAPIConnection", "api", ",", "String", "name", ",", "int", "length", ",", "String", "action", ",", "RetentionPolicyParams", "optionalParams", ")", "{", "return", "createRetentionPolic...
Used to create a new finite retention policy with optional parameters. @param api the API connection to be used by the created user. @param name the name of the retention policy. @param length the duration in days that the retention policy will be active for after being assigned to content. @param action the disposition action can be "permanently_delete" or "remove_retention". @param optionalParams the optional parameters. @return the created retention policy's info.
[ "Used", "to", "create", "a", "new", "finite", "retention", "policy", "with", "optional", "parameters", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxRetentionPolicy.java#L131-L134
train
box/box-java-sdk
src/main/java/com/box/sdk/BoxRetentionPolicy.java
BoxRetentionPolicy.createRetentionPolicy
private static BoxRetentionPolicy.Info createRetentionPolicy(BoxAPIConnection api, String name, String type, int length, String action) { return createRetentionPolicy(api, name, type, length, action, null); }
java
private static BoxRetentionPolicy.Info createRetentionPolicy(BoxAPIConnection api, String name, String type, int length, String action) { return createRetentionPolicy(api, name, type, length, action, null); }
[ "private", "static", "BoxRetentionPolicy", ".", "Info", "createRetentionPolicy", "(", "BoxAPIConnection", "api", ",", "String", "name", ",", "String", "type", ",", "int", "length", ",", "String", "action", ")", "{", "return", "createRetentionPolicy", "(", "api", ...
Used to create a new retention policy. @param api the API connection to be used by the created user. @param name the name of the retention policy. @param type the type of the retention policy. Can be "finite" or "indefinite". @param length the duration in days that the retention policy will be active for after being assigned to content. @param action the disposition action can be "permanently_delete" or "remove_retention". @return the created retention policy's info.
[ "Used", "to", "create", "a", "new", "retention", "policy", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxRetentionPolicy.java#L145-L148
train
box/box-java-sdk
src/main/java/com/box/sdk/BoxRetentionPolicy.java
BoxRetentionPolicy.createRetentionPolicy
private static BoxRetentionPolicy.Info createRetentionPolicy(BoxAPIConnection api, String name, String type, int length, String action, RetentionPolicyParams optionalParams) { URL url = RETENTION_POLICIES_URL_TEMPLATE.build(api.getBaseURL()); BoxJSONRequest request = new BoxJSONRequest(api, url, "POST"); JsonObject requestJSON = new JsonObject() .add("policy_name", name) .add("policy_type", type) .add("disposition_action", action); if (!type.equals(TYPE_INDEFINITE)) { requestJSON.add("retention_length", length); } if (optionalParams != null) { requestJSON.add("can_owner_extend_retention", optionalParams.getCanOwnerExtendRetention()); requestJSON.add("are_owners_notified", optionalParams.getAreOwnersNotified()); List<BoxUser.Info> customNotificationRecipients = optionalParams.getCustomNotificationRecipients(); if (customNotificationRecipients.size() > 0) { JsonArray users = new JsonArray(); for (BoxUser.Info user : customNotificationRecipients) { JsonObject userJSON = new JsonObject() .add("type", "user") .add("id", user.getID()); users.add(userJSON); } requestJSON.add("custom_notification_recipients", users); } } request.setBody(requestJSON.toString()); BoxJSONResponse response = (BoxJSONResponse) request.send(); JsonObject responseJSON = JsonObject.readFrom(response.getJSON()); BoxRetentionPolicy createdPolicy = new BoxRetentionPolicy(api, responseJSON.get("id").asString()); return createdPolicy.new Info(responseJSON); }
java
private static BoxRetentionPolicy.Info createRetentionPolicy(BoxAPIConnection api, String name, String type, int length, String action, RetentionPolicyParams optionalParams) { URL url = RETENTION_POLICIES_URL_TEMPLATE.build(api.getBaseURL()); BoxJSONRequest request = new BoxJSONRequest(api, url, "POST"); JsonObject requestJSON = new JsonObject() .add("policy_name", name) .add("policy_type", type) .add("disposition_action", action); if (!type.equals(TYPE_INDEFINITE)) { requestJSON.add("retention_length", length); } if (optionalParams != null) { requestJSON.add("can_owner_extend_retention", optionalParams.getCanOwnerExtendRetention()); requestJSON.add("are_owners_notified", optionalParams.getAreOwnersNotified()); List<BoxUser.Info> customNotificationRecipients = optionalParams.getCustomNotificationRecipients(); if (customNotificationRecipients.size() > 0) { JsonArray users = new JsonArray(); for (BoxUser.Info user : customNotificationRecipients) { JsonObject userJSON = new JsonObject() .add("type", "user") .add("id", user.getID()); users.add(userJSON); } requestJSON.add("custom_notification_recipients", users); } } request.setBody(requestJSON.toString()); BoxJSONResponse response = (BoxJSONResponse) request.send(); JsonObject responseJSON = JsonObject.readFrom(response.getJSON()); BoxRetentionPolicy createdPolicy = new BoxRetentionPolicy(api, responseJSON.get("id").asString()); return createdPolicy.new Info(responseJSON); }
[ "private", "static", "BoxRetentionPolicy", ".", "Info", "createRetentionPolicy", "(", "BoxAPIConnection", "api", ",", "String", "name", ",", "String", "type", ",", "int", "length", ",", "String", "action", ",", "RetentionPolicyParams", "optionalParams", ")", "{", ...
Used to create a new retention policy with optional parameters. @param api the API connection to be used by the created user. @param name the name of the retention policy. @param type the type of the retention policy. Can be "finite" or "indefinite". @param length the duration in days that the retention policy will be active for after being assigned to content. @param action the disposition action can be "permanently_delete" or "remove_retention". @param optionalParams the optional parameters. @return the created retention policy's info.
[ "Used", "to", "create", "a", "new", "retention", "policy", "with", "optional", "parameters", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxRetentionPolicy.java#L160-L193
train
box/box-java-sdk
src/main/java/com/box/sdk/BoxRetentionPolicy.java
BoxRetentionPolicy.getFolderAssignments
public Iterable<BoxRetentionPolicyAssignment.Info> getFolderAssignments(int limit, String ... fields) { return this.getAssignments(BoxRetentionPolicyAssignment.TYPE_FOLDER, limit, fields); }
java
public Iterable<BoxRetentionPolicyAssignment.Info> getFolderAssignments(int limit, String ... fields) { return this.getAssignments(BoxRetentionPolicyAssignment.TYPE_FOLDER, limit, fields); }
[ "public", "Iterable", "<", "BoxRetentionPolicyAssignment", ".", "Info", ">", "getFolderAssignments", "(", "int", "limit", ",", "String", "...", "fields", ")", "{", "return", "this", ".", "getAssignments", "(", "BoxRetentionPolicyAssignment", ".", "TYPE_FOLDER", ",",...
Returns iterable with all folder assignments of this retention policy. @param limit the limit of entries per response. The default value is 100. @param fields the fields to retrieve. @return an iterable containing all folder assignments.
[ "Returns", "iterable", "with", "all", "folder", "assignments", "of", "this", "retention", "policy", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxRetentionPolicy.java#L210-L212
train
box/box-java-sdk
src/main/java/com/box/sdk/BoxRetentionPolicy.java
BoxRetentionPolicy.getEnterpriseAssignments
public Iterable<BoxRetentionPolicyAssignment.Info> getEnterpriseAssignments(int limit, String ... fields) { return this.getAssignments(BoxRetentionPolicyAssignment.TYPE_ENTERPRISE, limit, fields); }
java
public Iterable<BoxRetentionPolicyAssignment.Info> getEnterpriseAssignments(int limit, String ... fields) { return this.getAssignments(BoxRetentionPolicyAssignment.TYPE_ENTERPRISE, limit, fields); }
[ "public", "Iterable", "<", "BoxRetentionPolicyAssignment", ".", "Info", ">", "getEnterpriseAssignments", "(", "int", "limit", ",", "String", "...", "fields", ")", "{", "return", "this", ".", "getAssignments", "(", "BoxRetentionPolicyAssignment", ".", "TYPE_ENTERPRISE"...
Returns iterable with all enterprise assignments of this retention policy. @param limit the limit of entries per response. The default value is 100. @param fields the fields to retrieve. @return an iterable containing all enterprise assignments.
[ "Returns", "iterable", "with", "all", "enterprise", "assignments", "of", "this", "retention", "policy", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxRetentionPolicy.java#L229-L231
train
box/box-java-sdk
src/main/java/com/box/sdk/BoxRetentionPolicy.java
BoxRetentionPolicy.getAllAssignments
public Iterable<BoxRetentionPolicyAssignment.Info> getAllAssignments(int limit, String ... fields) { return this.getAssignments(null, limit, fields); }
java
public Iterable<BoxRetentionPolicyAssignment.Info> getAllAssignments(int limit, String ... fields) { return this.getAssignments(null, limit, fields); }
[ "public", "Iterable", "<", "BoxRetentionPolicyAssignment", ".", "Info", ">", "getAllAssignments", "(", "int", "limit", ",", "String", "...", "fields", ")", "{", "return", "this", ".", "getAssignments", "(", "null", ",", "limit", ",", "fields", ")", ";", "}" ...
Returns iterable with all assignments of this retention policy. @param limit the limit of entries per response. The default value is 100. @param fields the fields to retrieve. @return an iterable containing all assignments.
[ "Returns", "iterable", "with", "all", "assignments", "of", "this", "retention", "policy", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxRetentionPolicy.java#L248-L250
train
box/box-java-sdk
src/main/java/com/box/sdk/BoxRetentionPolicy.java
BoxRetentionPolicy.getAssignments
private Iterable<BoxRetentionPolicyAssignment.Info> getAssignments(String type, int limit, String ... fields) { QueryStringBuilder queryString = new QueryStringBuilder(); if (type != null) { queryString.appendParam("type", type); } if (fields.length > 0) { queryString.appendParam("fields", fields); } URL url = ASSIGNMENTS_URL_TEMPLATE.buildWithQuery(getAPI().getBaseURL(), queryString.toString(), getID()); return new BoxResourceIterable<BoxRetentionPolicyAssignment.Info>(getAPI(), url, limit) { @Override protected BoxRetentionPolicyAssignment.Info factory(JsonObject jsonObject) { BoxRetentionPolicyAssignment assignment = new BoxRetentionPolicyAssignment(getAPI(), jsonObject.get("id").asString()); return assignment.new Info(jsonObject); } }; }
java
private Iterable<BoxRetentionPolicyAssignment.Info> getAssignments(String type, int limit, String ... fields) { QueryStringBuilder queryString = new QueryStringBuilder(); if (type != null) { queryString.appendParam("type", type); } if (fields.length > 0) { queryString.appendParam("fields", fields); } URL url = ASSIGNMENTS_URL_TEMPLATE.buildWithQuery(getAPI().getBaseURL(), queryString.toString(), getID()); return new BoxResourceIterable<BoxRetentionPolicyAssignment.Info>(getAPI(), url, limit) { @Override protected BoxRetentionPolicyAssignment.Info factory(JsonObject jsonObject) { BoxRetentionPolicyAssignment assignment = new BoxRetentionPolicyAssignment(getAPI(), jsonObject.get("id").asString()); return assignment.new Info(jsonObject); } }; }
[ "private", "Iterable", "<", "BoxRetentionPolicyAssignment", ".", "Info", ">", "getAssignments", "(", "String", "type", ",", "int", "limit", ",", "String", "...", "fields", ")", "{", "QueryStringBuilder", "queryString", "=", "new", "QueryStringBuilder", "(", ")", ...
Returns iterable with all assignments of given type of this retention policy. @param type the type of the retention policy assignment to retrieve. Can either be "folder" or "enterprise". @param limit the limit of entries per response. The default value is 100. @param fields the fields to retrieve. @return an iterable containing all assignments of given type.
[ "Returns", "iterable", "with", "all", "assignments", "of", "given", "type", "of", "this", "retention", "policy", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxRetentionPolicy.java#L259-L278
train
box/box-java-sdk
src/main/java/com/box/sdk/BoxRetentionPolicy.java
BoxRetentionPolicy.assignTo
public BoxRetentionPolicyAssignment.Info assignTo(BoxFolder folder) { return BoxRetentionPolicyAssignment.createAssignmentToFolder(this.getAPI(), this.getID(), folder.getID()); }
java
public BoxRetentionPolicyAssignment.Info assignTo(BoxFolder folder) { return BoxRetentionPolicyAssignment.createAssignmentToFolder(this.getAPI(), this.getID(), folder.getID()); }
[ "public", "BoxRetentionPolicyAssignment", ".", "Info", "assignTo", "(", "BoxFolder", "folder", ")", "{", "return", "BoxRetentionPolicyAssignment", ".", "createAssignmentToFolder", "(", "this", ".", "getAPI", "(", ")", ",", "this", ".", "getID", "(", ")", ",", "f...
Assigns this retention policy to folder. @param folder the folder to assign policy to. @return info about created assignment.
[ "Assigns", "this", "retention", "policy", "to", "folder", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxRetentionPolicy.java#L285-L287
train
box/box-java-sdk
src/main/java/com/box/sdk/BoxRetentionPolicy.java
BoxRetentionPolicy.assignToMetadataTemplate
public BoxRetentionPolicyAssignment.Info assignToMetadataTemplate(String templateID, MetadataFieldFilter... fieldFilters) { return BoxRetentionPolicyAssignment.createAssignmentToMetadata(this.getAPI(), this.getID(), templateID, fieldFilters); }
java
public BoxRetentionPolicyAssignment.Info assignToMetadataTemplate(String templateID, MetadataFieldFilter... fieldFilters) { return BoxRetentionPolicyAssignment.createAssignmentToMetadata(this.getAPI(), this.getID(), templateID, fieldFilters); }
[ "public", "BoxRetentionPolicyAssignment", ".", "Info", "assignToMetadataTemplate", "(", "String", "templateID", ",", "MetadataFieldFilter", "...", "fieldFilters", ")", "{", "return", "BoxRetentionPolicyAssignment", ".", "createAssignmentToMetadata", "(", "this", ".", "getAP...
Assigns this retention policy to a metadata template, optionally with certain field values. @param templateID the ID of the metadata template to apply to. @param fieldFilters optional field value filters. @return info about the created assignment.
[ "Assigns", "this", "retention", "policy", "to", "a", "metadata", "template", "optionally", "with", "certain", "field", "values", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxRetentionPolicy.java#L303-L307
train
box/box-java-sdk
src/main/java/com/box/sdk/BoxRetentionPolicy.java
BoxRetentionPolicy.getAll
public static Iterable<BoxRetentionPolicy.Info> getAll(final BoxAPIConnection api, String ... fields) { return getAll(null, null, null, DEFAULT_LIMIT, api, fields); }
java
public static Iterable<BoxRetentionPolicy.Info> getAll(final BoxAPIConnection api, String ... fields) { return getAll(null, null, null, DEFAULT_LIMIT, api, fields); }
[ "public", "static", "Iterable", "<", "BoxRetentionPolicy", ".", "Info", ">", "getAll", "(", "final", "BoxAPIConnection", "api", ",", "String", "...", "fields", ")", "{", "return", "getAll", "(", "null", ",", "null", ",", "null", ",", "DEFAULT_LIMIT", ",", ...
Returns all the retention policies. @param api the API connection to be used by the resource. @param fields the fields to retrieve. @return an iterable with all the retention policies.
[ "Returns", "all", "the", "retention", "policies", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxRetentionPolicy.java#L346-L348
train
box/box-java-sdk
src/main/java/com/box/sdk/BoxRetentionPolicy.java
BoxRetentionPolicy.getAll
public static Iterable<BoxRetentionPolicy.Info> getAll( String name, String type, String userID, int limit, final BoxAPIConnection api, String ... fields) { QueryStringBuilder queryString = new QueryStringBuilder(); if (name != null) { queryString.appendParam("policy_name", name); } if (type != null) { queryString.appendParam("policy_type", type); } if (userID != null) { queryString.appendParam("created_by_user_id", userID); } if (fields.length > 0) { queryString.appendParam("fields", fields); } URL url = RETENTION_POLICIES_URL_TEMPLATE.buildWithQuery(api.getBaseURL(), queryString.toString()); return new BoxResourceIterable<BoxRetentionPolicy.Info>(api, url, limit) { @Override protected BoxRetentionPolicy.Info factory(JsonObject jsonObject) { BoxRetentionPolicy policy = new BoxRetentionPolicy(api, jsonObject.get("id").asString()); return policy.new Info(jsonObject); } }; }
java
public static Iterable<BoxRetentionPolicy.Info> getAll( String name, String type, String userID, int limit, final BoxAPIConnection api, String ... fields) { QueryStringBuilder queryString = new QueryStringBuilder(); if (name != null) { queryString.appendParam("policy_name", name); } if (type != null) { queryString.appendParam("policy_type", type); } if (userID != null) { queryString.appendParam("created_by_user_id", userID); } if (fields.length > 0) { queryString.appendParam("fields", fields); } URL url = RETENTION_POLICIES_URL_TEMPLATE.buildWithQuery(api.getBaseURL(), queryString.toString()); return new BoxResourceIterable<BoxRetentionPolicy.Info>(api, url, limit) { @Override protected BoxRetentionPolicy.Info factory(JsonObject jsonObject) { BoxRetentionPolicy policy = new BoxRetentionPolicy(api, jsonObject.get("id").asString()); return policy.new Info(jsonObject); } }; }
[ "public", "static", "Iterable", "<", "BoxRetentionPolicy", ".", "Info", ">", "getAll", "(", "String", "name", ",", "String", "type", ",", "String", "userID", ",", "int", "limit", ",", "final", "BoxAPIConnection", "api", ",", "String", "...", "fields", ")", ...
Returns all the retention policies with specified filters. @param name a name to filter the retention policies by. A trailing partial match search is performed. Set to null if no name filtering is required. @param type a policy type to filter the retention policies by. Set to null if no type filtering is required. @param userID a user id to filter the retention policies by. Set to null if no type filtering is required. @param limit the limit of items per single response. The default value is 100. @param api the API connection to be used by the resource. @param fields the fields to retrieve. @return an iterable with all the retention policies met search conditions.
[ "Returns", "all", "the", "retention", "policies", "with", "specified", "filters", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxRetentionPolicy.java#L361-L386
train
box/box-java-sdk
src/main/java/com/box/sdk/EventStream.java
EventStream.start
public void start() { if (this.started) { throw new IllegalStateException("Cannot start the EventStream because it isn't stopped."); } final long initialPosition; if (this.startingPosition == STREAM_POSITION_NOW) { BoxAPIRequest request = new BoxAPIRequest(this.api, EVENT_URL.build(this.api.getBaseURL(), "now"), "GET"); BoxJSONResponse response = (BoxJSONResponse) request.send(); JsonObject jsonObject = JsonObject.readFrom(response.getJSON()); initialPosition = jsonObject.get("next_stream_position").asLong(); } else { assert this.startingPosition >= 0 : "Starting position must be non-negative"; initialPosition = this.startingPosition; } this.poller = new Poller(initialPosition); this.pollerThread = new Thread(this.poller); this.pollerThread.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { public void uncaughtException(Thread t, Throwable e) { EventStream.this.notifyException(e); } }); this.pollerThread.start(); this.started = true; }
java
public void start() { if (this.started) { throw new IllegalStateException("Cannot start the EventStream because it isn't stopped."); } final long initialPosition; if (this.startingPosition == STREAM_POSITION_NOW) { BoxAPIRequest request = new BoxAPIRequest(this.api, EVENT_URL.build(this.api.getBaseURL(), "now"), "GET"); BoxJSONResponse response = (BoxJSONResponse) request.send(); JsonObject jsonObject = JsonObject.readFrom(response.getJSON()); initialPosition = jsonObject.get("next_stream_position").asLong(); } else { assert this.startingPosition >= 0 : "Starting position must be non-negative"; initialPosition = this.startingPosition; } this.poller = new Poller(initialPosition); this.pollerThread = new Thread(this.poller); this.pollerThread.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { public void uncaughtException(Thread t, Throwable e) { EventStream.this.notifyException(e); } }); this.pollerThread.start(); this.started = true; }
[ "public", "void", "start", "(", ")", "{", "if", "(", "this", ".", "started", ")", "{", "throw", "new", "IllegalStateException", "(", "\"Cannot start the EventStream because it isn't stopped.\"", ")", ";", "}", "final", "long", "initialPosition", ";", "if", "(", ...
Starts this EventStream and begins long polling the API. @throws IllegalStateException if the EventStream is already started.
[ "Starts", "this", "EventStream", "and", "begins", "long", "polling", "the", "API", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/EventStream.java#L109-L137
train
box/box-java-sdk
src/main/java/com/box/sdk/EventStream.java
EventStream.isDuplicate
protected boolean isDuplicate(String eventID) { if (this.receivedEvents == null) { this.receivedEvents = new LRUCache<String>(); } return !this.receivedEvents.add(eventID); }
java
protected boolean isDuplicate(String eventID) { if (this.receivedEvents == null) { this.receivedEvents = new LRUCache<String>(); } return !this.receivedEvents.add(eventID); }
[ "protected", "boolean", "isDuplicate", "(", "String", "eventID", ")", "{", "if", "(", "this", ".", "receivedEvents", "==", "null", ")", "{", "this", ".", "receivedEvents", "=", "new", "LRUCache", "<", "String", ">", "(", ")", ";", "}", "return", "!", "...
Indicates whether or not an event ID is a duplicate. <p>This method can be overridden by a subclass in order to provide custom de-duping logic.</p> @param eventID the event ID. @return true if the event is a duplicate; otherwise false.
[ "Indicates", "whether", "or", "not", "an", "event", "ID", "is", "a", "duplicate", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/EventStream.java#L147-L153
train
box/box-java-sdk
src/main/java/com/box/sdk/BoxRetentionPolicyAssignment.java
BoxRetentionPolicyAssignment.createAssignmentToEnterprise
public static BoxRetentionPolicyAssignment.Info createAssignmentToEnterprise(BoxAPIConnection api, String policyID) { return createAssignment(api, policyID, new JsonObject().add("type", TYPE_ENTERPRISE), null); }
java
public static BoxRetentionPolicyAssignment.Info createAssignmentToEnterprise(BoxAPIConnection api, String policyID) { return createAssignment(api, policyID, new JsonObject().add("type", TYPE_ENTERPRISE), null); }
[ "public", "static", "BoxRetentionPolicyAssignment", ".", "Info", "createAssignmentToEnterprise", "(", "BoxAPIConnection", "api", ",", "String", "policyID", ")", "{", "return", "createAssignment", "(", "api", ",", "policyID", ",", "new", "JsonObject", "(", ")", ".", ...
Assigns retention policy with givenID to the enterprise. @param api the API connection to be used by the created assignment. @param policyID id of the assigned retention policy. @return info about created assignment.
[ "Assigns", "retention", "policy", "with", "givenID", "to", "the", "enterprise", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxRetentionPolicyAssignment.java#L65-L68
train
box/box-java-sdk
src/main/java/com/box/sdk/BoxRetentionPolicyAssignment.java
BoxRetentionPolicyAssignment.createAssignmentToFolder
public static BoxRetentionPolicyAssignment.Info createAssignmentToFolder(BoxAPIConnection api, String policyID, String folderID) { return createAssignment(api, policyID, new JsonObject().add("type", TYPE_FOLDER).add("id", folderID), null); }
java
public static BoxRetentionPolicyAssignment.Info createAssignmentToFolder(BoxAPIConnection api, String policyID, String folderID) { return createAssignment(api, policyID, new JsonObject().add("type", TYPE_FOLDER).add("id", folderID), null); }
[ "public", "static", "BoxRetentionPolicyAssignment", ".", "Info", "createAssignmentToFolder", "(", "BoxAPIConnection", "api", ",", "String", "policyID", ",", "String", "folderID", ")", "{", "return", "createAssignment", "(", "api", ",", "policyID", ",", "new", "JsonO...
Assigns retention policy with givenID to the folder. @param api the API connection to be used by the created assignment. @param policyID id of the assigned retention policy. @param folderID id of the folder to assign policy to. @return info about created assignment.
[ "Assigns", "retention", "policy", "with", "givenID", "to", "the", "folder", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxRetentionPolicyAssignment.java#L77-L80
train
box/box-java-sdk
src/main/java/com/box/sdk/BoxRetentionPolicyAssignment.java
BoxRetentionPolicyAssignment.createAssignmentToMetadata
public static BoxRetentionPolicyAssignment.Info createAssignmentToMetadata(BoxAPIConnection api, String policyID, String templateID, MetadataFieldFilter... filter) { JsonObject assignTo = new JsonObject().add("type", TYPE_METADATA).add("id", templateID); JsonArray filters = null; if (filter.length > 0) { filters = new JsonArray(); for (MetadataFieldFilter f : filter) { filters.add(f.getJsonObject()); } } return createAssignment(api, policyID, assignTo, filters); }
java
public static BoxRetentionPolicyAssignment.Info createAssignmentToMetadata(BoxAPIConnection api, String policyID, String templateID, MetadataFieldFilter... filter) { JsonObject assignTo = new JsonObject().add("type", TYPE_METADATA).add("id", templateID); JsonArray filters = null; if (filter.length > 0) { filters = new JsonArray(); for (MetadataFieldFilter f : filter) { filters.add(f.getJsonObject()); } } return createAssignment(api, policyID, assignTo, filters); }
[ "public", "static", "BoxRetentionPolicyAssignment", ".", "Info", "createAssignmentToMetadata", "(", "BoxAPIConnection", "api", ",", "String", "policyID", ",", "String", "templateID", ",", "MetadataFieldFilter", "...", "filter", ")", "{", "JsonObject", "assignTo", "=", ...
Assigns a retention policy to all items with a given metadata template, optionally matching on fields. @param api the API connection to be used by the created assignment. @param policyID id of the assigned retention policy. @param templateID the ID of the metadata template to assign the policy to. @param filter optional fields to match against in the metadata template. @return info about the created assignment.
[ "Assigns", "a", "retention", "policy", "to", "all", "items", "with", "a", "given", "metadata", "template", "optionally", "matching", "on", "fields", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxRetentionPolicyAssignment.java#L90-L103
train
box/box-java-sdk
src/main/java/com/box/sdk/BoxRetentionPolicyAssignment.java
BoxRetentionPolicyAssignment.createAssignment
private static BoxRetentionPolicyAssignment.Info createAssignment(BoxAPIConnection api, String policyID, JsonObject assignTo, JsonArray filter) { URL url = ASSIGNMENTS_URL_TEMPLATE.build(api.getBaseURL()); BoxJSONRequest request = new BoxJSONRequest(api, url, "POST"); JsonObject requestJSON = new JsonObject() .add("policy_id", policyID) .add("assign_to", assignTo); if (filter != null) { requestJSON.add("filter_fields", filter); } request.setBody(requestJSON.toString()); BoxJSONResponse response = (BoxJSONResponse) request.send(); JsonObject responseJSON = JsonObject.readFrom(response.getJSON()); BoxRetentionPolicyAssignment createdAssignment = new BoxRetentionPolicyAssignment(api, responseJSON.get("id").asString()); return createdAssignment.new Info(responseJSON); }
java
private static BoxRetentionPolicyAssignment.Info createAssignment(BoxAPIConnection api, String policyID, JsonObject assignTo, JsonArray filter) { URL url = ASSIGNMENTS_URL_TEMPLATE.build(api.getBaseURL()); BoxJSONRequest request = new BoxJSONRequest(api, url, "POST"); JsonObject requestJSON = new JsonObject() .add("policy_id", policyID) .add("assign_to", assignTo); if (filter != null) { requestJSON.add("filter_fields", filter); } request.setBody(requestJSON.toString()); BoxJSONResponse response = (BoxJSONResponse) request.send(); JsonObject responseJSON = JsonObject.readFrom(response.getJSON()); BoxRetentionPolicyAssignment createdAssignment = new BoxRetentionPolicyAssignment(api, responseJSON.get("id").asString()); return createdAssignment.new Info(responseJSON); }
[ "private", "static", "BoxRetentionPolicyAssignment", ".", "Info", "createAssignment", "(", "BoxAPIConnection", "api", ",", "String", "policyID", ",", "JsonObject", "assignTo", ",", "JsonArray", "filter", ")", "{", "URL", "url", "=", "ASSIGNMENTS_URL_TEMPLATE", ".", ...
Assigns retention policy with givenID to folder or enterprise. @param api the API connection to be used by the created assignment. @param policyID id of the assigned retention policy. @param assignTo object representing folder or enterprise to assign policy to. @return info about created assignment.
[ "Assigns", "retention", "policy", "with", "givenID", "to", "folder", "or", "enterprise", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxRetentionPolicyAssignment.java#L112-L131
train
box/box-java-sdk
src/main/java/com/box/sdk/Metadata.java
Metadata.getAllMetadata
public static Iterable<Metadata> getAllMetadata(BoxItem item, String ... fields) { QueryStringBuilder builder = new QueryStringBuilder(); if (fields.length > 0) { builder.appendParam("fields", fields); } return new BoxResourceIterable<Metadata>( item.getAPI(), GET_ALL_METADATA_URL_TEMPLATE.buildWithQuery(item.getItemURL().toString(), builder.toString()), DEFAULT_LIMIT) { @Override protected Metadata factory(JsonObject jsonObject) { return new Metadata(jsonObject); } }; }
java
public static Iterable<Metadata> getAllMetadata(BoxItem item, String ... fields) { QueryStringBuilder builder = new QueryStringBuilder(); if (fields.length > 0) { builder.appendParam("fields", fields); } return new BoxResourceIterable<Metadata>( item.getAPI(), GET_ALL_METADATA_URL_TEMPLATE.buildWithQuery(item.getItemURL().toString(), builder.toString()), DEFAULT_LIMIT) { @Override protected Metadata factory(JsonObject jsonObject) { return new Metadata(jsonObject); } }; }
[ "public", "static", "Iterable", "<", "Metadata", ">", "getAllMetadata", "(", "BoxItem", "item", ",", "String", "...", "fields", ")", "{", "QueryStringBuilder", "builder", "=", "new", "QueryStringBuilder", "(", ")", ";", "if", "(", "fields", ".", "length", ">...
Used to retrieve all metadata associated with the item. @param item item to get metadata for. @param fields the optional fields to retrieve. @return An iterable of metadata instances associated with the item.
[ "Used", "to", "retrieve", "all", "metadata", "associated", "with", "the", "item", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/Metadata.java#L106-L122
train
box/box-java-sdk
src/main/java/com/box/sdk/Metadata.java
Metadata.add
public Metadata add(String path, String value) { this.values.add(this.pathToProperty(path), value); this.addOp("add", path, value); return this; }
java
public Metadata add(String path, String value) { this.values.add(this.pathToProperty(path), value); this.addOp("add", path, value); return this; }
[ "public", "Metadata", "add", "(", "String", "path", ",", "String", "value", ")", "{", "this", ".", "values", ".", "add", "(", "this", ".", "pathToProperty", "(", "path", ")", ",", "value", ")", ";", "this", ".", "addOp", "(", "\"add\"", ",", "path", ...
Adds a new metadata value. @param path the path that designates the key. Must be prefixed with a "/". @param value the value. @return this metadata object.
[ "Adds", "a", "new", "metadata", "value", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/Metadata.java#L170-L174
train
box/box-java-sdk
src/main/java/com/box/sdk/Metadata.java
Metadata.add
public Metadata add(String path, List<String> values) { JsonArray arr = new JsonArray(); for (String value : values) { arr.add(value); } this.values.add(this.pathToProperty(path), arr); this.addOp("add", path, arr); return this; }
java
public Metadata add(String path, List<String> values) { JsonArray arr = new JsonArray(); for (String value : values) { arr.add(value); } this.values.add(this.pathToProperty(path), arr); this.addOp("add", path, arr); return this; }
[ "public", "Metadata", "add", "(", "String", "path", ",", "List", "<", "String", ">", "values", ")", "{", "JsonArray", "arr", "=", "new", "JsonArray", "(", ")", ";", "for", "(", "String", "value", ":", "values", ")", "{", "arr", ".", "add", "(", "va...
Adds a new metadata value of array type. @param path the path to the field. @param values the collection of values. @return the metadata object for chaining.
[ "Adds", "a", "new", "metadata", "value", "of", "array", "type", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/Metadata.java#L194-L202
train
box/box-java-sdk
src/main/java/com/box/sdk/Metadata.java
Metadata.replace
public Metadata replace(String path, String value) { this.values.set(this.pathToProperty(path), value); this.addOp("replace", path, value); return this; }
java
public Metadata replace(String path, String value) { this.values.set(this.pathToProperty(path), value); this.addOp("replace", path, value); return this; }
[ "public", "Metadata", "replace", "(", "String", "path", ",", "String", "value", ")", "{", "this", ".", "values", ".", "set", "(", "this", ".", "pathToProperty", "(", "path", ")", ",", "value", ")", ";", "this", ".", "addOp", "(", "\"replace\"", ",", ...
Replaces an existing metadata value. @param path the path that designates the key. Must be prefixed with a "/". @param value the value. @return this metadata object.
[ "Replaces", "an", "existing", "metadata", "value", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/Metadata.java#L210-L214
train
box/box-java-sdk
src/main/java/com/box/sdk/Metadata.java
Metadata.remove
public Metadata remove(String path) { this.values.remove(this.pathToProperty(path)); this.addOp("remove", path, (String) null); return this; }
java
public Metadata remove(String path) { this.values.remove(this.pathToProperty(path)); this.addOp("remove", path, (String) null); return this; }
[ "public", "Metadata", "remove", "(", "String", "path", ")", "{", "this", ".", "values", ".", "remove", "(", "this", ".", "pathToProperty", "(", "path", ")", ")", ";", "this", ".", "addOp", "(", "\"remove\"", ",", "path", ",", "(", "String", ")", "nul...
Removes an existing metadata value. @param path the path that designates the key. Must be prefixed with a "/". @return this metadata object.
[ "Removes", "an", "existing", "metadata", "value", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/Metadata.java#L233-L237
train
box/box-java-sdk
src/main/java/com/box/sdk/Metadata.java
Metadata.get
@Deprecated public String get(String path) { final JsonValue value = this.values.get(this.pathToProperty(path)); if (value == null) { return null; } if (!value.isString()) { return value.toString(); } return value.asString(); }
java
@Deprecated public String get(String path) { final JsonValue value = this.values.get(this.pathToProperty(path)); if (value == null) { return null; } if (!value.isString()) { return value.toString(); } return value.asString(); }
[ "@", "Deprecated", "public", "String", "get", "(", "String", "path", ")", "{", "final", "JsonValue", "value", "=", "this", ".", "values", ".", "get", "(", "this", ".", "pathToProperty", "(", "path", ")", ")", ";", "if", "(", "value", "==", "null", ")...
Returns a value. @param path the path that designates the key. Must be prefixed with a "/". @return the metadata property value. @deprecated Metadata#get() does not handle all possible metadata types; use Metadata#getValue() instead
[ "Returns", "a", "value", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/Metadata.java#L272-L282
train
box/box-java-sdk
src/main/java/com/box/sdk/Metadata.java
Metadata.getDate
public Date getDate(String path) throws ParseException { return BoxDateFormat.parse(this.getValue(path).asString()); }
java
public Date getDate(String path) throws ParseException { return BoxDateFormat.parse(this.getValue(path).asString()); }
[ "public", "Date", "getDate", "(", "String", "path", ")", "throws", "ParseException", "{", "return", "BoxDateFormat", ".", "parse", "(", "this", ".", "getValue", "(", "path", ")", ".", "asString", "(", ")", ")", ";", "}" ]
Get a value from a date metadata field. @param path the key path in the metadata object. Must be prefixed with a "/". @return the metadata value as a Date. @throws ParseException when the value cannot be parsed as a valid date
[ "Get", "a", "value", "from", "a", "date", "metadata", "field", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/Metadata.java#L318-L320
train
box/box-java-sdk
src/main/java/com/box/sdk/Metadata.java
Metadata.getMultiSelect
public List<String> getMultiSelect(String path) { List<String> values = new ArrayList<String>(); for (JsonValue val : this.getValue(path).asArray()) { values.add(val.asString()); } return values; }
java
public List<String> getMultiSelect(String path) { List<String> values = new ArrayList<String>(); for (JsonValue val : this.getValue(path).asArray()) { values.add(val.asString()); } return values; }
[ "public", "List", "<", "String", ">", "getMultiSelect", "(", "String", "path", ")", "{", "List", "<", "String", ">", "values", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "for", "(", "JsonValue", "val", ":", "this", ".", "getValue", "...
Get a value from a multiselect metadata field. @param path the key path in the metadata object. Must be prefixed with a "/". @return the list of values set in the field.
[ "Get", "a", "value", "from", "a", "multiselect", "metadata", "field", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/Metadata.java#L327-L334
train
box/box-java-sdk
src/main/java/com/box/sdk/Metadata.java
Metadata.getPropertyPaths
public List<String> getPropertyPaths() { List<String> result = new ArrayList<String>(); for (String property : this.values.names()) { if (!property.startsWith("$")) { result.add(this.propertyToPath(property)); } } return result; }
java
public List<String> getPropertyPaths() { List<String> result = new ArrayList<String>(); for (String property : this.values.names()) { if (!property.startsWith("$")) { result.add(this.propertyToPath(property)); } } return result; }
[ "public", "List", "<", "String", ">", "getPropertyPaths", "(", ")", "{", "List", "<", "String", ">", "result", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "for", "(", "String", "property", ":", "this", ".", "values", ".", "names", "("...
Returns a list of metadata property paths. @return the list of metdata property paths.
[ "Returns", "a", "list", "of", "metadata", "property", "paths", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/Metadata.java#L340-L350
train
box/box-java-sdk
src/main/java/com/box/sdk/Metadata.java
Metadata.pathToProperty
private String pathToProperty(String path) { if (path == null || !path.startsWith("/")) { throw new IllegalArgumentException("Path must be prefixed with a \"/\"."); } return path.substring(1); }
java
private String pathToProperty(String path) { if (path == null || !path.startsWith("/")) { throw new IllegalArgumentException("Path must be prefixed with a \"/\"."); } return path.substring(1); }
[ "private", "String", "pathToProperty", "(", "String", "path", ")", "{", "if", "(", "path", "==", "null", "||", "!", "path", ".", "startsWith", "(", "\"/\"", ")", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Path must be prefixed with a \\\"/\\\"...
Converts a JSON patch path to a JSON property name. Currently the metadata API only supports flat maps. @param path the path that designates the key. Must be prefixed with a "/". @return the JSON property name.
[ "Converts", "a", "JSON", "patch", "path", "to", "a", "JSON", "property", "name", ".", "Currently", "the", "metadata", "API", "only", "supports", "flat", "maps", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/Metadata.java#L386-L391
train
box/box-java-sdk
src/main/java/com/box/sdk/Metadata.java
Metadata.addOp
private void addOp(String op, String path, String value) { if (this.operations == null) { this.operations = new JsonArray(); } this.operations.add(new JsonObject() .add("op", op) .add("path", path) .add("value", value)); }
java
private void addOp(String op, String path, String value) { if (this.operations == null) { this.operations = new JsonArray(); } this.operations.add(new JsonObject() .add("op", op) .add("path", path) .add("value", value)); }
[ "private", "void", "addOp", "(", "String", "op", ",", "String", "path", ",", "String", "value", ")", "{", "if", "(", "this", ".", "operations", "==", "null", ")", "{", "this", ".", "operations", "=", "new", "JsonArray", "(", ")", ";", "}", "this", ...
Adds a patch operation. @param op the operation type. Must be add, replace, remove, or test. @param path the path that designates the key. Must be prefixed with a "/". @param value the value to be set.
[ "Adds", "a", "patch", "operation", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/Metadata.java#L411-L420
train
box/box-java-sdk
src/main/java/com/box/sdk/BoxCollaboration.java
BoxCollaboration.create
protected static BoxCollaboration.Info create(BoxAPIConnection api, JsonObject accessibleBy, JsonObject item, BoxCollaboration.Role role, Boolean notify, Boolean canViewPath) { String queryString = ""; if (notify != null) { queryString = new QueryStringBuilder().appendParam("notify", notify.toString()).toString(); } URL url; if (queryString.length() > 0) { url = COLLABORATIONS_URL_TEMPLATE.buildWithQuery(api.getBaseURL(), queryString); } else { url = COLLABORATIONS_URL_TEMPLATE.build(api.getBaseURL()); } JsonObject requestJSON = new JsonObject(); requestJSON.add("item", item); requestJSON.add("accessible_by", accessibleBy); requestJSON.add("role", role.toJSONString()); if (canViewPath != null) { requestJSON.add("can_view_path", canViewPath.booleanValue()); } BoxJSONRequest request = new BoxJSONRequest(api, url, "POST"); request.setBody(requestJSON.toString()); BoxJSONResponse response = (BoxJSONResponse) request.send(); JsonObject responseJSON = JsonObject.readFrom(response.getJSON()); BoxCollaboration newCollaboration = new BoxCollaboration(api, responseJSON.get("id").asString()); return newCollaboration.new Info(responseJSON); }
java
protected static BoxCollaboration.Info create(BoxAPIConnection api, JsonObject accessibleBy, JsonObject item, BoxCollaboration.Role role, Boolean notify, Boolean canViewPath) { String queryString = ""; if (notify != null) { queryString = new QueryStringBuilder().appendParam("notify", notify.toString()).toString(); } URL url; if (queryString.length() > 0) { url = COLLABORATIONS_URL_TEMPLATE.buildWithQuery(api.getBaseURL(), queryString); } else { url = COLLABORATIONS_URL_TEMPLATE.build(api.getBaseURL()); } JsonObject requestJSON = new JsonObject(); requestJSON.add("item", item); requestJSON.add("accessible_by", accessibleBy); requestJSON.add("role", role.toJSONString()); if (canViewPath != null) { requestJSON.add("can_view_path", canViewPath.booleanValue()); } BoxJSONRequest request = new BoxJSONRequest(api, url, "POST"); request.setBody(requestJSON.toString()); BoxJSONResponse response = (BoxJSONResponse) request.send(); JsonObject responseJSON = JsonObject.readFrom(response.getJSON()); BoxCollaboration newCollaboration = new BoxCollaboration(api, responseJSON.get("id").asString()); return newCollaboration.new Info(responseJSON); }
[ "protected", "static", "BoxCollaboration", ".", "Info", "create", "(", "BoxAPIConnection", "api", ",", "JsonObject", "accessibleBy", ",", "JsonObject", "item", ",", "BoxCollaboration", ".", "Role", "role", ",", "Boolean", "notify", ",", "Boolean", "canViewPath", "...
Create a new collaboration object. @param api the API connection used to make the request. @param accessibleBy the JSON object describing who should be collaborated. @param item the JSON object describing which item to collaborate. @param role the role to give the collaborators. @param notify the user/group should receive email notification of the collaboration or not. @param canViewPath the view path collaboration feature is enabled or not. @return info about the new collaboration.
[ "Create", "a", "new", "collaboration", "object", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxCollaboration.java#L68-L99
train
box/box-java-sdk
src/main/java/com/box/sdk/BoxCollaboration.java
BoxCollaboration.getPendingCollaborations
public static Collection<Info> getPendingCollaborations(BoxAPIConnection api) { URL url = PENDING_COLLABORATIONS_URL.build(api.getBaseURL()); BoxAPIRequest request = new BoxAPIRequest(api, url, "GET"); BoxJSONResponse response = (BoxJSONResponse) request.send(); JsonObject responseJSON = JsonObject.readFrom(response.getJSON()); int entriesCount = responseJSON.get("total_count").asInt(); Collection<BoxCollaboration.Info> collaborations = new ArrayList<BoxCollaboration.Info>(entriesCount); JsonArray entries = responseJSON.get("entries").asArray(); for (JsonValue entry : entries) { JsonObject entryObject = entry.asObject(); BoxCollaboration collaboration = new BoxCollaboration(api, entryObject.get("id").asString()); BoxCollaboration.Info info = collaboration.new Info(entryObject); collaborations.add(info); } return collaborations; }
java
public static Collection<Info> getPendingCollaborations(BoxAPIConnection api) { URL url = PENDING_COLLABORATIONS_URL.build(api.getBaseURL()); BoxAPIRequest request = new BoxAPIRequest(api, url, "GET"); BoxJSONResponse response = (BoxJSONResponse) request.send(); JsonObject responseJSON = JsonObject.readFrom(response.getJSON()); int entriesCount = responseJSON.get("total_count").asInt(); Collection<BoxCollaboration.Info> collaborations = new ArrayList<BoxCollaboration.Info>(entriesCount); JsonArray entries = responseJSON.get("entries").asArray(); for (JsonValue entry : entries) { JsonObject entryObject = entry.asObject(); BoxCollaboration collaboration = new BoxCollaboration(api, entryObject.get("id").asString()); BoxCollaboration.Info info = collaboration.new Info(entryObject); collaborations.add(info); } return collaborations; }
[ "public", "static", "Collection", "<", "Info", ">", "getPendingCollaborations", "(", "BoxAPIConnection", "api", ")", "{", "URL", "url", "=", "PENDING_COLLABORATIONS_URL", ".", "build", "(", "api", ".", "getBaseURL", "(", ")", ")", ";", "BoxAPIRequest", "request"...
Gets all pending collaboration invites for the current user. @param api the API connection to use. @return a collection of pending collaboration infos.
[ "Gets", "all", "pending", "collaboration", "invites", "for", "the", "current", "user", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxCollaboration.java#L107-L125
train
box/box-java-sdk
src/main/java/com/box/sdk/BoxCollaboration.java
BoxCollaboration.getInfo
public Info getInfo() { BoxAPIConnection api = this.getAPI(); URL url = COLLABORATION_URL_TEMPLATE.build(api.getBaseURL(), this.getID()); BoxAPIRequest request = new BoxAPIRequest(api, url, "GET"); BoxJSONResponse response = (BoxJSONResponse) request.send(); JsonObject jsonObject = JsonObject.readFrom(response.getJSON()); return new Info(jsonObject); }
java
public Info getInfo() { BoxAPIConnection api = this.getAPI(); URL url = COLLABORATION_URL_TEMPLATE.build(api.getBaseURL(), this.getID()); BoxAPIRequest request = new BoxAPIRequest(api, url, "GET"); BoxJSONResponse response = (BoxJSONResponse) request.send(); JsonObject jsonObject = JsonObject.readFrom(response.getJSON()); return new Info(jsonObject); }
[ "public", "Info", "getInfo", "(", ")", "{", "BoxAPIConnection", "api", "=", "this", ".", "getAPI", "(", ")", ";", "URL", "url", "=", "COLLABORATION_URL_TEMPLATE", ".", "build", "(", "api", ".", "getBaseURL", "(", ")", ",", "this", ".", "getID", "(", ")...
Gets information about this collaboration. @return info about this collaboration.
[ "Gets", "information", "about", "this", "collaboration", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxCollaboration.java#L132-L140
train
box/box-java-sdk
src/main/java/com/box/sdk/BoxCollaboration.java
BoxCollaboration.updateInfo
public void updateInfo(Info info) { BoxAPIConnection api = this.getAPI(); URL url = COLLABORATION_URL_TEMPLATE.build(api.getBaseURL(), this.getID()); BoxJSONRequest request = new BoxJSONRequest(api, url, "PUT"); request.setBody(info.getPendingChanges()); BoxAPIResponse boxAPIResponse = request.send(); if (boxAPIResponse instanceof BoxJSONResponse) { BoxJSONResponse response = (BoxJSONResponse) boxAPIResponse; JsonObject jsonObject = JsonObject.readFrom(response.getJSON()); info.update(jsonObject); } }
java
public void updateInfo(Info info) { BoxAPIConnection api = this.getAPI(); URL url = COLLABORATION_URL_TEMPLATE.build(api.getBaseURL(), this.getID()); BoxJSONRequest request = new BoxJSONRequest(api, url, "PUT"); request.setBody(info.getPendingChanges()); BoxAPIResponse boxAPIResponse = request.send(); if (boxAPIResponse instanceof BoxJSONResponse) { BoxJSONResponse response = (BoxJSONResponse) boxAPIResponse; JsonObject jsonObject = JsonObject.readFrom(response.getJSON()); info.update(jsonObject); } }
[ "public", "void", "updateInfo", "(", "Info", "info", ")", "{", "BoxAPIConnection", "api", "=", "this", ".", "getAPI", "(", ")", ";", "URL", "url", "=", "COLLABORATION_URL_TEMPLATE", ".", "build", "(", "api", ".", "getBaseURL", "(", ")", ",", "this", ".",...
Updates the information about this collaboration with any info fields that have been modified locally. @param info the updated info.
[ "Updates", "the", "information", "about", "this", "collaboration", "with", "any", "info", "fields", "that", "have", "been", "modified", "locally", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxCollaboration.java#L162-L175
train
box/box-java-sdk
src/main/java/com/box/sdk/BoxCollaboration.java
BoxCollaboration.delete
public void delete() { BoxAPIConnection api = this.getAPI(); URL url = COLLABORATION_URL_TEMPLATE.build(api.getBaseURL(), this.getID()); BoxAPIRequest request = new BoxAPIRequest(api, url, "DELETE"); BoxAPIResponse response = request.send(); response.disconnect(); }
java
public void delete() { BoxAPIConnection api = this.getAPI(); URL url = COLLABORATION_URL_TEMPLATE.build(api.getBaseURL(), this.getID()); BoxAPIRequest request = new BoxAPIRequest(api, url, "DELETE"); BoxAPIResponse response = request.send(); response.disconnect(); }
[ "public", "void", "delete", "(", ")", "{", "BoxAPIConnection", "api", "=", "this", ".", "getAPI", "(", ")", ";", "URL", "url", "=", "COLLABORATION_URL_TEMPLATE", ".", "build", "(", "api", ".", "getBaseURL", "(", ")", ",", "this", ".", "getID", "(", ")"...
Deletes this collaboration.
[ "Deletes", "this", "collaboration", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxCollaboration.java#L180-L187
train
box/box-java-sdk
src/main/java/com/box/sdk/BoxLegalHoldAssignment.java
BoxLegalHoldAssignment.create
public static BoxLegalHoldAssignment.Info create(BoxAPIConnection api, String policyID, String resourceType, String resourceID) { URL url = ASSIGNMENTS_URL_TEMPLATE.build(api.getBaseURL()); BoxJSONRequest request = new BoxJSONRequest(api, url, "POST"); JsonObject requestJSON = new JsonObject() .add("policy_id", policyID) .add("assign_to", new JsonObject() .add("type", resourceType) .add("id", resourceID)); request.setBody(requestJSON.toString()); BoxJSONResponse response = (BoxJSONResponse) request.send(); JsonObject responseJSON = JsonObject.readFrom(response.getJSON()); BoxLegalHoldAssignment createdAssignment = new BoxLegalHoldAssignment(api, responseJSON.get("id").asString()); return createdAssignment.new Info(responseJSON); }
java
public static BoxLegalHoldAssignment.Info create(BoxAPIConnection api, String policyID, String resourceType, String resourceID) { URL url = ASSIGNMENTS_URL_TEMPLATE.build(api.getBaseURL()); BoxJSONRequest request = new BoxJSONRequest(api, url, "POST"); JsonObject requestJSON = new JsonObject() .add("policy_id", policyID) .add("assign_to", new JsonObject() .add("type", resourceType) .add("id", resourceID)); request.setBody(requestJSON.toString()); BoxJSONResponse response = (BoxJSONResponse) request.send(); JsonObject responseJSON = JsonObject.readFrom(response.getJSON()); BoxLegalHoldAssignment createdAssignment = new BoxLegalHoldAssignment(api, responseJSON.get("id").asString()); return createdAssignment.new Info(responseJSON); }
[ "public", "static", "BoxLegalHoldAssignment", ".", "Info", "create", "(", "BoxAPIConnection", "api", ",", "String", "policyID", ",", "String", "resourceType", ",", "String", "resourceID", ")", "{", "URL", "url", "=", "ASSIGNMENTS_URL_TEMPLATE", ".", "build", "(", ...
Creates new legal hold policy assignment. @param api the API connection to be used by the resource. @param policyID ID of policy to create assignment for. @param resourceType type of target resource. Can be 'file_version', 'file', 'folder', or 'user'. @param resourceID ID of the target resource. @return info about created legal hold policy assignment.
[ "Creates", "new", "legal", "hold", "policy", "assignment", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxLegalHoldAssignment.java#L72-L87
train
box/box-java-sdk
src/main/java/com/box/sdk/RetentionPolicyParams.java
RetentionPolicyParams.addCustomNotificationRecipient
public void addCustomNotificationRecipient(String userID) { BoxUser user = new BoxUser(null, userID); this.customNotificationRecipients.add(user.new Info()); }
java
public void addCustomNotificationRecipient(String userID) { BoxUser user = new BoxUser(null, userID); this.customNotificationRecipients.add(user.new Info()); }
[ "public", "void", "addCustomNotificationRecipient", "(", "String", "userID", ")", "{", "BoxUser", "user", "=", "new", "BoxUser", "(", "null", ",", "userID", ")", ";", "this", ".", "customNotificationRecipients", ".", "add", "(", "user", ".", "new", "Info", "...
Add a user by ID to the list of people to notify when the retention period is ending. @param userID The ID of the user to add to the list.
[ "Add", "a", "user", "by", "ID", "to", "the", "list", "of", "people", "to", "notify", "when", "the", "retention", "period", "is", "ending", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/RetentionPolicyParams.java#L85-L89
train
box/box-java-sdk
src/main/java/com/box/sdk/BoxCollection.java
BoxCollection.getAllCollections
public static Iterable<BoxCollection.Info> getAllCollections(final BoxAPIConnection api) { return new Iterable<BoxCollection.Info>() { public Iterator<BoxCollection.Info> iterator() { URL url = GET_COLLECTIONS_URL_TEMPLATE.build(api.getBaseURL()); return new BoxCollectionIterator(api, url); } }; }
java
public static Iterable<BoxCollection.Info> getAllCollections(final BoxAPIConnection api) { return new Iterable<BoxCollection.Info>() { public Iterator<BoxCollection.Info> iterator() { URL url = GET_COLLECTIONS_URL_TEMPLATE.build(api.getBaseURL()); return new BoxCollectionIterator(api, url); } }; }
[ "public", "static", "Iterable", "<", "BoxCollection", ".", "Info", ">", "getAllCollections", "(", "final", "BoxAPIConnection", "api", ")", "{", "return", "new", "Iterable", "<", "BoxCollection", ".", "Info", ">", "(", ")", "{", "public", "Iterator", "<", "Bo...
Gets an iterable of all the collections for the given user. @param api the API connection to be used when retrieving the collections. @return an iterable containing info about all the collections.
[ "Gets", "an", "iterable", "of", "all", "the", "collections", "for", "the", "given", "user", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxCollection.java#L44-L51
train
box/box-java-sdk
src/main/java/com/box/sdk/BoxCollection.java
BoxCollection.getItemsRange
public PartialCollection<BoxItem.Info> getItemsRange(long offset, long limit, String... fields) { QueryStringBuilder builder = new QueryStringBuilder() .appendParam("offset", offset) .appendParam("limit", limit); if (fields.length > 0) { builder.appendParam("fields", fields).toString(); } URL url = GET_COLLECTION_ITEMS_URL.buildWithQuery(getAPI().getBaseURL(), builder.toString(), getID()); BoxAPIRequest request = new BoxAPIRequest(this.getAPI(), url, "GET"); BoxJSONResponse response = (BoxJSONResponse) request.send(); JsonObject responseJSON = JsonObject.readFrom(response.getJSON()); String totalCountString = responseJSON.get("total_count").toString(); long fullSize = Double.valueOf(totalCountString).longValue(); PartialCollection<BoxItem.Info> items = new PartialCollection<BoxItem.Info>(offset, limit, fullSize); JsonArray entries = responseJSON.get("entries").asArray(); for (JsonValue entry : entries) { BoxItem.Info entryInfo = (BoxItem.Info) BoxResource.parseInfo(this.getAPI(), entry.asObject()); if (entryInfo != null) { items.add(entryInfo); } } return items; }
java
public PartialCollection<BoxItem.Info> getItemsRange(long offset, long limit, String... fields) { QueryStringBuilder builder = new QueryStringBuilder() .appendParam("offset", offset) .appendParam("limit", limit); if (fields.length > 0) { builder.appendParam("fields", fields).toString(); } URL url = GET_COLLECTION_ITEMS_URL.buildWithQuery(getAPI().getBaseURL(), builder.toString(), getID()); BoxAPIRequest request = new BoxAPIRequest(this.getAPI(), url, "GET"); BoxJSONResponse response = (BoxJSONResponse) request.send(); JsonObject responseJSON = JsonObject.readFrom(response.getJSON()); String totalCountString = responseJSON.get("total_count").toString(); long fullSize = Double.valueOf(totalCountString).longValue(); PartialCollection<BoxItem.Info> items = new PartialCollection<BoxItem.Info>(offset, limit, fullSize); JsonArray entries = responseJSON.get("entries").asArray(); for (JsonValue entry : entries) { BoxItem.Info entryInfo = (BoxItem.Info) BoxResource.parseInfo(this.getAPI(), entry.asObject()); if (entryInfo != null) { items.add(entryInfo); } } return items; }
[ "public", "PartialCollection", "<", "BoxItem", ".", "Info", ">", "getItemsRange", "(", "long", "offset", ",", "long", "limit", ",", "String", "...", "fields", ")", "{", "QueryStringBuilder", "builder", "=", "new", "QueryStringBuilder", "(", ")", ".", "appendPa...
Retrieves a specific range of items in this collection. @param offset the index of the first item to retrieve. @param limit the maximum number of items to retrieve after the offset. @param fields the fields to retrieve. @return a partial collection containing the specified range of items.
[ "Retrieves", "a", "specific", "range", "of", "items", "in", "this", "collection", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxCollection.java#L86-L111
train
box/box-java-sdk
src/main/java/com/box/sdk/BoxCollection.java
BoxCollection.iterator
@Override public Iterator<BoxItem.Info> iterator() { URL url = GET_COLLECTION_ITEMS_URL.build(this.getAPI().getBaseURL(), BoxCollection.this.getID()); return new BoxItemIterator(BoxCollection.this.getAPI(), url); }
java
@Override public Iterator<BoxItem.Info> iterator() { URL url = GET_COLLECTION_ITEMS_URL.build(this.getAPI().getBaseURL(), BoxCollection.this.getID()); return new BoxItemIterator(BoxCollection.this.getAPI(), url); }
[ "@", "Override", "public", "Iterator", "<", "BoxItem", ".", "Info", ">", "iterator", "(", ")", "{", "URL", "url", "=", "GET_COLLECTION_ITEMS_URL", ".", "build", "(", "this", ".", "getAPI", "(", ")", ".", "getBaseURL", "(", ")", ",", "BoxCollection", ".",...
Returns an iterator over the items in this collection. @return an iterator over the items in this collection.
[ "Returns", "an", "iterator", "over", "the", "items", "in", "this", "collection", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxCollection.java#L117-L121
train
box/box-java-sdk
src/main/java/com/box/sdk/BoxCollaborationWhitelistExemptTarget.java
BoxCollaborationWhitelistExemptTarget.create
public static BoxCollaborationWhitelistExemptTarget.Info create(final BoxAPIConnection api, String userID) { URL url = COLLABORATION_WHITELIST_EXEMPT_TARGET_ENTRIES_URL_TEMPLATE.build(api.getBaseURL()); BoxJSONRequest request = new BoxJSONRequest(api, url, HttpMethod.POST); JsonObject requestJSON = new JsonObject() .add("user", new JsonObject() .add("type", "user") .add("id", userID)); request.setBody(requestJSON.toString()); BoxJSONResponse response = (BoxJSONResponse) request.send(); JsonObject responseJSON = JsonObject.readFrom(response.getJSON()); BoxCollaborationWhitelistExemptTarget userWhitelist = new BoxCollaborationWhitelistExemptTarget(api, responseJSON.get("id").asString()); return userWhitelist.new Info(responseJSON); }
java
public static BoxCollaborationWhitelistExemptTarget.Info create(final BoxAPIConnection api, String userID) { URL url = COLLABORATION_WHITELIST_EXEMPT_TARGET_ENTRIES_URL_TEMPLATE.build(api.getBaseURL()); BoxJSONRequest request = new BoxJSONRequest(api, url, HttpMethod.POST); JsonObject requestJSON = new JsonObject() .add("user", new JsonObject() .add("type", "user") .add("id", userID)); request.setBody(requestJSON.toString()); BoxJSONResponse response = (BoxJSONResponse) request.send(); JsonObject responseJSON = JsonObject.readFrom(response.getJSON()); BoxCollaborationWhitelistExemptTarget userWhitelist = new BoxCollaborationWhitelistExemptTarget(api, responseJSON.get("id").asString()); return userWhitelist.new Info(responseJSON); }
[ "public", "static", "BoxCollaborationWhitelistExemptTarget", ".", "Info", "create", "(", "final", "BoxAPIConnection", "api", ",", "String", "userID", ")", "{", "URL", "url", "=", "COLLABORATION_WHITELIST_EXEMPT_TARGET_ENTRIES_URL_TEMPLATE", ".", "build", "(", "api", "."...
Creates a collaboration whitelist for a Box User with a given ID. @param api the API connection to be used by the collaboration whitelist. @param userID the ID of the Box User to add to the collaboration whitelist. @return information about the collaboration whitelist created for user.
[ "Creates", "a", "collaboration", "whitelist", "for", "a", "Box", "User", "with", "a", "given", "ID", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxCollaborationWhitelistExemptTarget.java#L56-L71
train
box/box-java-sdk
src/main/java/com/box/sdk/BoxCollaborationWhitelistExemptTarget.java
BoxCollaborationWhitelistExemptTarget.getInfo
public BoxCollaborationWhitelistExemptTarget.Info getInfo() { URL url = COLLABORATION_WHITELIST_EXEMPT_TARGET_ENTRY_URL_TEMPLATE.build(this.getAPI().getBaseURL(), this.getID()); BoxAPIRequest request = new BoxAPIRequest(this.getAPI(), url, HttpMethod.GET); BoxJSONResponse response = (BoxJSONResponse) request.send(); return new Info(JsonObject.readFrom(response.getJSON())); }
java
public BoxCollaborationWhitelistExemptTarget.Info getInfo() { URL url = COLLABORATION_WHITELIST_EXEMPT_TARGET_ENTRY_URL_TEMPLATE.build(this.getAPI().getBaseURL(), this.getID()); BoxAPIRequest request = new BoxAPIRequest(this.getAPI(), url, HttpMethod.GET); BoxJSONResponse response = (BoxJSONResponse) request.send(); return new Info(JsonObject.readFrom(response.getJSON())); }
[ "public", "BoxCollaborationWhitelistExemptTarget", ".", "Info", "getInfo", "(", ")", "{", "URL", "url", "=", "COLLABORATION_WHITELIST_EXEMPT_TARGET_ENTRY_URL_TEMPLATE", ".", "build", "(", "this", ".", "getAPI", "(", ")", ".", "getBaseURL", "(", ")", ",", "this", "...
Retrieves information for a collaboration whitelist for a given whitelist ID. @return information about this {@link BoxCollaborationWhitelistExemptTarget}.
[ "Retrieves", "information", "for", "a", "collaboration", "whitelist", "for", "a", "given", "whitelist", "ID", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxCollaborationWhitelistExemptTarget.java#L78-L85
train
box/box-java-sdk
src/main/java/com/box/sdk/BoxDeveloperEditionAPIConnection.java
BoxDeveloperEditionAPIConnection.getAppEnterpriseConnection
public static BoxDeveloperEditionAPIConnection getAppEnterpriseConnection(String enterpriseId, String clientId, String clientSecret, JWTEncryptionPreferences encryptionPref, IAccessTokenCache accessTokenCache) { BoxDeveloperEditionAPIConnection connection = new BoxDeveloperEditionAPIConnection(enterpriseId, DeveloperEditionEntityType.ENTERPRISE, clientId, clientSecret, encryptionPref, accessTokenCache); connection.tryRestoreUsingAccessTokenCache(); return connection; }
java
public static BoxDeveloperEditionAPIConnection getAppEnterpriseConnection(String enterpriseId, String clientId, String clientSecret, JWTEncryptionPreferences encryptionPref, IAccessTokenCache accessTokenCache) { BoxDeveloperEditionAPIConnection connection = new BoxDeveloperEditionAPIConnection(enterpriseId, DeveloperEditionEntityType.ENTERPRISE, clientId, clientSecret, encryptionPref, accessTokenCache); connection.tryRestoreUsingAccessTokenCache(); return connection; }
[ "public", "static", "BoxDeveloperEditionAPIConnection", "getAppEnterpriseConnection", "(", "String", "enterpriseId", ",", "String", "clientId", ",", "String", "clientSecret", ",", "JWTEncryptionPreferences", "encryptionPref", ",", "IAccessTokenCache", "accessTokenCache", ")", ...
Creates a new Box Developer Edition connection with enterprise token leveraging an access token cache. @param enterpriseId the enterprise ID to use for requesting access token. @param clientId the client ID to use when exchanging the JWT assertion for an access token. @param clientSecret the client secret to use when exchanging the JWT assertion for an access token. @param encryptionPref the encryption preferences for signing the JWT. @param accessTokenCache the cache for storing access token information (to minimize fetching new tokens) @return a new instance of BoxAPIConnection.
[ "Creates", "a", "new", "Box", "Developer", "Edition", "connection", "with", "enterprise", "token", "leveraging", "an", "access", "token", "cache", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxDeveloperEditionAPIConnection.java#L193-L202
train
box/box-java-sdk
src/main/java/com/box/sdk/BoxDeveloperEditionAPIConnection.java
BoxDeveloperEditionAPIConnection.getAppEnterpriseConnection
public static BoxDeveloperEditionAPIConnection getAppEnterpriseConnection(BoxConfig boxConfig) { BoxDeveloperEditionAPIConnection connection = getAppEnterpriseConnection(boxConfig.getEnterpriseId(), boxConfig.getClientId(), boxConfig.getClientSecret(), boxConfig.getJWTEncryptionPreferences()); return connection; }
java
public static BoxDeveloperEditionAPIConnection getAppEnterpriseConnection(BoxConfig boxConfig) { BoxDeveloperEditionAPIConnection connection = getAppEnterpriseConnection(boxConfig.getEnterpriseId(), boxConfig.getClientId(), boxConfig.getClientSecret(), boxConfig.getJWTEncryptionPreferences()); return connection; }
[ "public", "static", "BoxDeveloperEditionAPIConnection", "getAppEnterpriseConnection", "(", "BoxConfig", "boxConfig", ")", "{", "BoxDeveloperEditionAPIConnection", "connection", "=", "getAppEnterpriseConnection", "(", "boxConfig", ".", "getEnterpriseId", "(", ")", ",", "boxCon...
Creates a new Box Developer Edition connection with enterprise token leveraging BoxConfig. @param boxConfig box configuration settings object @return a new instance of BoxAPIConnection.
[ "Creates", "a", "new", "Box", "Developer", "Edition", "connection", "with", "enterprise", "token", "leveraging", "BoxConfig", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxDeveloperEditionAPIConnection.java#L209-L215
train
box/box-java-sdk
src/main/java/com/box/sdk/BoxDeveloperEditionAPIConnection.java
BoxDeveloperEditionAPIConnection.getAppUserConnection
public static BoxDeveloperEditionAPIConnection getAppUserConnection(String userId, String clientId, String clientSecret, JWTEncryptionPreferences encryptionPref, IAccessTokenCache accessTokenCache) { BoxDeveloperEditionAPIConnection connection = new BoxDeveloperEditionAPIConnection(userId, DeveloperEditionEntityType.USER, clientId, clientSecret, encryptionPref, accessTokenCache); connection.tryRestoreUsingAccessTokenCache(); return connection; }
java
public static BoxDeveloperEditionAPIConnection getAppUserConnection(String userId, String clientId, String clientSecret, JWTEncryptionPreferences encryptionPref, IAccessTokenCache accessTokenCache) { BoxDeveloperEditionAPIConnection connection = new BoxDeveloperEditionAPIConnection(userId, DeveloperEditionEntityType.USER, clientId, clientSecret, encryptionPref, accessTokenCache); connection.tryRestoreUsingAccessTokenCache(); return connection; }
[ "public", "static", "BoxDeveloperEditionAPIConnection", "getAppUserConnection", "(", "String", "userId", ",", "String", "clientId", ",", "String", "clientSecret", ",", "JWTEncryptionPreferences", "encryptionPref", ",", "IAccessTokenCache", "accessTokenCache", ")", "{", "Box...
Creates a new Box Developer Edition connection with App User token. @param userId the user ID to use for an App User. @param clientId the client ID to use when exchanging the JWT assertion for an access token. @param clientSecret the client secret to use when exchanging the JWT assertion for an access token. @param encryptionPref the encryption preferences for signing the JWT. @param accessTokenCache the cache for storing access token information (to minimize fetching new tokens) @return a new instance of BoxAPIConnection.
[ "Creates", "a", "new", "Box", "Developer", "Edition", "connection", "with", "App", "User", "token", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxDeveloperEditionAPIConnection.java#L265-L274
train
box/box-java-sdk
src/main/java/com/box/sdk/BoxDeveloperEditionAPIConnection.java
BoxDeveloperEditionAPIConnection.getAppUserConnection
public static BoxDeveloperEditionAPIConnection getAppUserConnection(String userId, BoxConfig boxConfig) { return getAppUserConnection(userId, boxConfig.getClientId(), boxConfig.getClientSecret(), boxConfig.getJWTEncryptionPreferences()); }
java
public static BoxDeveloperEditionAPIConnection getAppUserConnection(String userId, BoxConfig boxConfig) { return getAppUserConnection(userId, boxConfig.getClientId(), boxConfig.getClientSecret(), boxConfig.getJWTEncryptionPreferences()); }
[ "public", "static", "BoxDeveloperEditionAPIConnection", "getAppUserConnection", "(", "String", "userId", ",", "BoxConfig", "boxConfig", ")", "{", "return", "getAppUserConnection", "(", "userId", ",", "boxConfig", ".", "getClientId", "(", ")", ",", "boxConfig", ".", ...
Creates a new Box Developer Edition connection with App User token levaraging BoxConfig. @param userId the user ID to use for an App User. @param boxConfig box configuration settings object @return a new instance of BoxAPIConnection.
[ "Creates", "a", "new", "Box", "Developer", "Edition", "connection", "with", "App", "User", "token", "levaraging", "BoxConfig", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxDeveloperEditionAPIConnection.java#L282-L285
train
box/box-java-sdk
src/main/java/com/box/sdk/BoxDeveloperEditionAPIConnection.java
BoxDeveloperEditionAPIConnection.authenticate
public void authenticate() { URL url; try { url = new URL(this.getTokenURL()); } catch (MalformedURLException e) { assert false : "An invalid token URL indicates a bug in the SDK."; throw new RuntimeException("An invalid token URL indicates a bug in the SDK.", e); } String jwtAssertion = this.constructJWTAssertion(); String urlParameters = String.format(JWT_GRANT_TYPE, this.getClientID(), this.getClientSecret(), jwtAssertion); BoxAPIRequest request = new BoxAPIRequest(this, url, "POST"); request.shouldAuthenticate(false); request.setBody(urlParameters); String json; try { BoxJSONResponse response = (BoxJSONResponse) request.send(); json = response.getJSON(); } catch (BoxAPIException ex) { // Use the Date advertised by the Box server as the current time to synchronize clocks List<String> responseDates = ex.getHeaders().get("Date"); NumericDate currentTime; if (responseDates != null) { String responseDate = responseDates.get(0); SimpleDateFormat dateFormat = new SimpleDateFormat("EEE, d MMM yyyy HH:mm:ss zzz"); try { Date date = dateFormat.parse(responseDate); currentTime = NumericDate.fromMilliseconds(date.getTime()); } catch (ParseException e) { currentTime = NumericDate.now(); } } else { currentTime = NumericDate.now(); } // Reconstruct the JWT assertion, which regenerates the jti claim, with the new "current" time jwtAssertion = this.constructJWTAssertion(currentTime); urlParameters = String.format(JWT_GRANT_TYPE, this.getClientID(), this.getClientSecret(), jwtAssertion); // Re-send the updated request request = new BoxAPIRequest(this, url, "POST"); request.shouldAuthenticate(false); request.setBody(urlParameters); BoxJSONResponse response = (BoxJSONResponse) request.send(); json = response.getJSON(); } JsonObject jsonObject = JsonObject.readFrom(json); this.setAccessToken(jsonObject.get("access_token").asString()); this.setLastRefresh(System.currentTimeMillis()); this.setExpires(jsonObject.get("expires_in").asLong() * 1000); //if token cache is specified, save to cache if (this.accessTokenCache != null) { String key = this.getAccessTokenCacheKey(); JsonObject accessTokenCacheInfo = new JsonObject() .add("accessToken", this.getAccessToken()) .add("lastRefresh", this.getLastRefresh()) .add("expires", this.getExpires()); this.accessTokenCache.put(key, accessTokenCacheInfo.toString()); } }
java
public void authenticate() { URL url; try { url = new URL(this.getTokenURL()); } catch (MalformedURLException e) { assert false : "An invalid token URL indicates a bug in the SDK."; throw new RuntimeException("An invalid token URL indicates a bug in the SDK.", e); } String jwtAssertion = this.constructJWTAssertion(); String urlParameters = String.format(JWT_GRANT_TYPE, this.getClientID(), this.getClientSecret(), jwtAssertion); BoxAPIRequest request = new BoxAPIRequest(this, url, "POST"); request.shouldAuthenticate(false); request.setBody(urlParameters); String json; try { BoxJSONResponse response = (BoxJSONResponse) request.send(); json = response.getJSON(); } catch (BoxAPIException ex) { // Use the Date advertised by the Box server as the current time to synchronize clocks List<String> responseDates = ex.getHeaders().get("Date"); NumericDate currentTime; if (responseDates != null) { String responseDate = responseDates.get(0); SimpleDateFormat dateFormat = new SimpleDateFormat("EEE, d MMM yyyy HH:mm:ss zzz"); try { Date date = dateFormat.parse(responseDate); currentTime = NumericDate.fromMilliseconds(date.getTime()); } catch (ParseException e) { currentTime = NumericDate.now(); } } else { currentTime = NumericDate.now(); } // Reconstruct the JWT assertion, which regenerates the jti claim, with the new "current" time jwtAssertion = this.constructJWTAssertion(currentTime); urlParameters = String.format(JWT_GRANT_TYPE, this.getClientID(), this.getClientSecret(), jwtAssertion); // Re-send the updated request request = new BoxAPIRequest(this, url, "POST"); request.shouldAuthenticate(false); request.setBody(urlParameters); BoxJSONResponse response = (BoxJSONResponse) request.send(); json = response.getJSON(); } JsonObject jsonObject = JsonObject.readFrom(json); this.setAccessToken(jsonObject.get("access_token").asString()); this.setLastRefresh(System.currentTimeMillis()); this.setExpires(jsonObject.get("expires_in").asLong() * 1000); //if token cache is specified, save to cache if (this.accessTokenCache != null) { String key = this.getAccessTokenCacheKey(); JsonObject accessTokenCacheInfo = new JsonObject() .add("accessToken", this.getAccessToken()) .add("lastRefresh", this.getLastRefresh()) .add("expires", this.getExpires()); this.accessTokenCache.put(key, accessTokenCacheInfo.toString()); } }
[ "public", "void", "authenticate", "(", ")", "{", "URL", "url", ";", "try", "{", "url", "=", "new", "URL", "(", "this", ".", "getTokenURL", "(", ")", ")", ";", "}", "catch", "(", "MalformedURLException", "e", ")", "{", "assert", "false", ":", "\"An in...
Authenticates the API connection for Box Developer Edition.
[ "Authenticates", "the", "API", "connection", "for", "Box", "Developer", "Edition", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxDeveloperEditionAPIConnection.java#L311-L377
train
box/box-java-sdk
src/main/java/com/box/sdk/BoxDeveloperEditionAPIConnection.java
BoxDeveloperEditionAPIConnection.refresh
public void refresh() { this.getRefreshLock().writeLock().lock(); try { this.authenticate(); } catch (BoxAPIException e) { this.notifyError(e); this.getRefreshLock().writeLock().unlock(); throw e; } this.notifyRefresh(); this.getRefreshLock().writeLock().unlock(); }
java
public void refresh() { this.getRefreshLock().writeLock().lock(); try { this.authenticate(); } catch (BoxAPIException e) { this.notifyError(e); this.getRefreshLock().writeLock().unlock(); throw e; } this.notifyRefresh(); this.getRefreshLock().writeLock().unlock(); }
[ "public", "void", "refresh", "(", ")", "{", "this", ".", "getRefreshLock", "(", ")", ".", "writeLock", "(", ")", ".", "lock", "(", ")", ";", "try", "{", "this", ".", "authenticate", "(", ")", ";", "}", "catch", "(", "BoxAPIException", "e", ")", "{"...
Refresh's this connection's access token using Box Developer Edition. @throws IllegalStateException if this connection's access token cannot be refreshed.
[ "Refresh", "s", "this", "connection", "s", "access", "token", "using", "Box", "Developer", "Edition", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxDeveloperEditionAPIConnection.java#L391-L404
train
box/box-java-sdk
src/main/java/com/box/sdk/BoxFile.java
BoxFile.addTask
public BoxTask.Info addTask(BoxTask.Action action, String message, Date dueAt) { JsonObject itemJSON = new JsonObject(); itemJSON.add("type", "file"); itemJSON.add("id", this.getID()); JsonObject requestJSON = new JsonObject(); requestJSON.add("item", itemJSON); requestJSON.add("action", action.toJSONString()); if (message != null && !message.isEmpty()) { requestJSON.add("message", message); } if (dueAt != null) { requestJSON.add("due_at", BoxDateFormat.format(dueAt)); } URL url = ADD_TASK_URL_TEMPLATE.build(this.getAPI().getBaseURL()); BoxJSONRequest request = new BoxJSONRequest(this.getAPI(), url, "POST"); request.setBody(requestJSON.toString()); BoxJSONResponse response = (BoxJSONResponse) request.send(); JsonObject responseJSON = JsonObject.readFrom(response.getJSON()); BoxTask addedTask = new BoxTask(this.getAPI(), responseJSON.get("id").asString()); return addedTask.new Info(responseJSON); }
java
public BoxTask.Info addTask(BoxTask.Action action, String message, Date dueAt) { JsonObject itemJSON = new JsonObject(); itemJSON.add("type", "file"); itemJSON.add("id", this.getID()); JsonObject requestJSON = new JsonObject(); requestJSON.add("item", itemJSON); requestJSON.add("action", action.toJSONString()); if (message != null && !message.isEmpty()) { requestJSON.add("message", message); } if (dueAt != null) { requestJSON.add("due_at", BoxDateFormat.format(dueAt)); } URL url = ADD_TASK_URL_TEMPLATE.build(this.getAPI().getBaseURL()); BoxJSONRequest request = new BoxJSONRequest(this.getAPI(), url, "POST"); request.setBody(requestJSON.toString()); BoxJSONResponse response = (BoxJSONResponse) request.send(); JsonObject responseJSON = JsonObject.readFrom(response.getJSON()); BoxTask addedTask = new BoxTask(this.getAPI(), responseJSON.get("id").asString()); return addedTask.new Info(responseJSON); }
[ "public", "BoxTask", ".", "Info", "addTask", "(", "BoxTask", ".", "Action", "action", ",", "String", "message", ",", "Date", "dueAt", ")", "{", "JsonObject", "itemJSON", "=", "new", "JsonObject", "(", ")", ";", "itemJSON", ".", "add", "(", "\"type\"", ",...
Adds a new task to this file. The task can have an optional message to include, and a due date. @param action the action the task assignee will be prompted to do. @param message an optional message to include with the task. @param dueAt the day at which this task is due. @return information about the newly added task.
[ "Adds", "a", "new", "task", "to", "this", "file", ".", "The", "task", "can", "have", "an", "optional", "message", "to", "include", "and", "a", "due", "date", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxFile.java#L233-L258
train
box/box-java-sdk
src/main/java/com/box/sdk/BoxFile.java
BoxFile.getDownloadURL
public URL getDownloadURL() { URL url = CONTENT_URL_TEMPLATE.build(this.getAPI().getBaseURL(), this.getID()); BoxAPIRequest request = new BoxAPIRequest(this.getAPI(), url, "GET"); request.setFollowRedirects(false); BoxRedirectResponse response = (BoxRedirectResponse) request.send(); return response.getRedirectURL(); }
java
public URL getDownloadURL() { URL url = CONTENT_URL_TEMPLATE.build(this.getAPI().getBaseURL(), this.getID()); BoxAPIRequest request = new BoxAPIRequest(this.getAPI(), url, "GET"); request.setFollowRedirects(false); BoxRedirectResponse response = (BoxRedirectResponse) request.send(); return response.getRedirectURL(); }
[ "public", "URL", "getDownloadURL", "(", ")", "{", "URL", "url", "=", "CONTENT_URL_TEMPLATE", ".", "build", "(", "this", ".", "getAPI", "(", ")", ".", "getBaseURL", "(", ")", ",", "this", ".", "getID", "(", ")", ")", ";", "BoxAPIRequest", "request", "="...
Gets an expiring URL for downloading a file directly from Box. This can be user, for example, for sending as a redirect to a browser to cause the browser to download the file directly from Box. @return the temporary download URL
[ "Gets", "an", "expiring", "URL", "for", "downloading", "a", "file", "directly", "from", "Box", ".", "This", "can", "be", "user", "for", "example", "for", "sending", "as", "a", "redirect", "to", "a", "browser", "to", "cause", "the", "browser", "to", "down...
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxFile.java#L267-L275
train
box/box-java-sdk
src/main/java/com/box/sdk/BoxFile.java
BoxFile.downloadRange
public void downloadRange(OutputStream output, long rangeStart, long rangeEnd) { this.downloadRange(output, rangeStart, rangeEnd, null); }
java
public void downloadRange(OutputStream output, long rangeStart, long rangeEnd) { this.downloadRange(output, rangeStart, rangeEnd, null); }
[ "public", "void", "downloadRange", "(", "OutputStream", "output", ",", "long", "rangeStart", ",", "long", "rangeEnd", ")", "{", "this", ".", "downloadRange", "(", "output", ",", "rangeStart", ",", "rangeEnd", ",", "null", ")", ";", "}" ]
Downloads a part of this file's contents, starting at rangeStart and stopping at rangeEnd. @param output the stream to where the file will be written. @param rangeStart the byte offset at which to start the download. @param rangeEnd the byte offset at which to stop the download.
[ "Downloads", "a", "part", "of", "this", "file", "s", "contents", "starting", "at", "rangeStart", "and", "stopping", "at", "rangeEnd", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxFile.java#L329-L331
train
box/box-java-sdk
src/main/java/com/box/sdk/BoxFile.java
BoxFile.downloadRange
public void downloadRange(OutputStream output, long rangeStart, long rangeEnd, ProgressListener listener) { URL url = CONTENT_URL_TEMPLATE.build(this.getAPI().getBaseURL(), this.getID()); BoxAPIRequest request = new BoxAPIRequest(this.getAPI(), url, "GET"); if (rangeEnd > 0) { request.addHeader("Range", String.format("bytes=%s-%s", Long.toString(rangeStart), Long.toString(rangeEnd))); } else { request.addHeader("Range", String.format("bytes=%s-", Long.toString(rangeStart))); } BoxAPIResponse response = request.send(); InputStream input = response.getBody(listener); byte[] buffer = new byte[BUFFER_SIZE]; try { int n = input.read(buffer); while (n != -1) { output.write(buffer, 0, n); n = input.read(buffer); } } catch (IOException e) { throw new BoxAPIException("Couldn't connect to the Box API due to a network error.", e); } finally { response.disconnect(); } }
java
public void downloadRange(OutputStream output, long rangeStart, long rangeEnd, ProgressListener listener) { URL url = CONTENT_URL_TEMPLATE.build(this.getAPI().getBaseURL(), this.getID()); BoxAPIRequest request = new BoxAPIRequest(this.getAPI(), url, "GET"); if (rangeEnd > 0) { request.addHeader("Range", String.format("bytes=%s-%s", Long.toString(rangeStart), Long.toString(rangeEnd))); } else { request.addHeader("Range", String.format("bytes=%s-", Long.toString(rangeStart))); } BoxAPIResponse response = request.send(); InputStream input = response.getBody(listener); byte[] buffer = new byte[BUFFER_SIZE]; try { int n = input.read(buffer); while (n != -1) { output.write(buffer, 0, n); n = input.read(buffer); } } catch (IOException e) { throw new BoxAPIException("Couldn't connect to the Box API due to a network error.", e); } finally { response.disconnect(); } }
[ "public", "void", "downloadRange", "(", "OutputStream", "output", ",", "long", "rangeStart", ",", "long", "rangeEnd", ",", "ProgressListener", "listener", ")", "{", "URL", "url", "=", "CONTENT_URL_TEMPLATE", ".", "build", "(", "this", ".", "getAPI", "(", ")", ...
Downloads a part of this file's contents, starting at rangeStart and stopping at rangeEnd, while reporting the progress to a ProgressListener. @param output the stream to where the file will be written. @param rangeStart the byte offset at which to start the download. @param rangeEnd the byte offset at which to stop the download. @param listener a listener for monitoring the download's progress.
[ "Downloads", "a", "part", "of", "this", "file", "s", "contents", "starting", "at", "rangeStart", "and", "stopping", "at", "rangeEnd", "while", "reporting", "the", "progress", "to", "a", "ProgressListener", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxFile.java#L342-L367
train
box/box-java-sdk
src/main/java/com/box/sdk/BoxFile.java
BoxFile.rename
public void rename(String newName) { URL url = FILE_URL_TEMPLATE.build(this.getAPI().getBaseURL(), this.getID()); BoxJSONRequest request = new BoxJSONRequest(this.getAPI(), url, "PUT"); JsonObject updateInfo = new JsonObject(); updateInfo.add("name", newName); request.setBody(updateInfo.toString()); BoxAPIResponse response = request.send(); response.disconnect(); }
java
public void rename(String newName) { URL url = FILE_URL_TEMPLATE.build(this.getAPI().getBaseURL(), this.getID()); BoxJSONRequest request = new BoxJSONRequest(this.getAPI(), url, "PUT"); JsonObject updateInfo = new JsonObject(); updateInfo.add("name", newName); request.setBody(updateInfo.toString()); BoxAPIResponse response = request.send(); response.disconnect(); }
[ "public", "void", "rename", "(", "String", "newName", ")", "{", "URL", "url", "=", "FILE_URL_TEMPLATE", ".", "build", "(", "this", ".", "getAPI", "(", ")", ".", "getBaseURL", "(", ")", ",", "this", ".", "getID", "(", ")", ")", ";", "BoxJSONRequest", ...
Renames this file. @param newName the new name of the file.
[ "Renames", "this", "file", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxFile.java#L436-L446
train
box/box-java-sdk
src/main/java/com/box/sdk/BoxFile.java
BoxFile.getRepresentationContent
public void getRepresentationContent(String representationHint, String assetPath, OutputStream output) { List<Representation> reps = this.getInfoWithRepresentations(representationHint).getRepresentations(); if (reps.size() < 1) { throw new BoxAPIException("No matching representations found"); } Representation representation = reps.get(0); String repState = representation.getStatus().getState(); if (repState.equals("viewable") || repState.equals("success")) { this.makeRepresentationContentRequest(representation.getContent().getUrlTemplate(), assetPath, output); return; } else if (repState.equals("pending") || repState.equals("none")) { String repContentURLString = null; while (repContentURLString == null) { repContentURLString = this.pollRepInfo(representation.getInfo().getUrl()); } this.makeRepresentationContentRequest(repContentURLString, assetPath, output); return; } else if (repState.equals("error")) { throw new BoxAPIException("Representation had error status"); } else { throw new BoxAPIException("Representation had unknown status"); } }
java
public void getRepresentationContent(String representationHint, String assetPath, OutputStream output) { List<Representation> reps = this.getInfoWithRepresentations(representationHint).getRepresentations(); if (reps.size() < 1) { throw new BoxAPIException("No matching representations found"); } Representation representation = reps.get(0); String repState = representation.getStatus().getState(); if (repState.equals("viewable") || repState.equals("success")) { this.makeRepresentationContentRequest(representation.getContent().getUrlTemplate(), assetPath, output); return; } else if (repState.equals("pending") || repState.equals("none")) { String repContentURLString = null; while (repContentURLString == null) { repContentURLString = this.pollRepInfo(representation.getInfo().getUrl()); } this.makeRepresentationContentRequest(repContentURLString, assetPath, output); return; } else if (repState.equals("error")) { throw new BoxAPIException("Representation had error status"); } else { throw new BoxAPIException("Representation had unknown status"); } }
[ "public", "void", "getRepresentationContent", "(", "String", "representationHint", ",", "String", "assetPath", ",", "OutputStream", "output", ")", "{", "List", "<", "Representation", ">", "reps", "=", "this", ".", "getInfoWithRepresentations", "(", "representationHint...
Fetches the contents of a file representation with asset path and writes them to the provided output stream. @see <a href=https://developer.box.com/reference#section-x-rep-hints-header>X-Rep-Hints Header</a> @param representationHint the X-Rep-Hints query for the representation to fetch. @param assetPath the path of the asset for representations containing multiple files. @param output the output stream to write the contents to.
[ "Fetches", "the", "contents", "of", "a", "file", "representation", "with", "asset", "path", "and", "writes", "them", "to", "the", "provided", "output", "stream", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxFile.java#L511-L543
train
box/box-java-sdk
src/main/java/com/box/sdk/BoxFile.java
BoxFile.getVersions
public Collection<BoxFileVersion> getVersions() { URL url = VERSIONS_URL_TEMPLATE.build(this.getAPI().getBaseURL(), this.getID()); BoxAPIRequest request = new BoxAPIRequest(this.getAPI(), url, "GET"); BoxJSONResponse response = (BoxJSONResponse) request.send(); JsonObject jsonObject = JsonObject.readFrom(response.getJSON()); JsonArray entries = jsonObject.get("entries").asArray(); Collection<BoxFileVersion> versions = new ArrayList<BoxFileVersion>(); for (JsonValue entry : entries) { versions.add(new BoxFileVersion(this.getAPI(), entry.asObject(), this.getID())); } return versions; }
java
public Collection<BoxFileVersion> getVersions() { URL url = VERSIONS_URL_TEMPLATE.build(this.getAPI().getBaseURL(), this.getID()); BoxAPIRequest request = new BoxAPIRequest(this.getAPI(), url, "GET"); BoxJSONResponse response = (BoxJSONResponse) request.send(); JsonObject jsonObject = JsonObject.readFrom(response.getJSON()); JsonArray entries = jsonObject.get("entries").asArray(); Collection<BoxFileVersion> versions = new ArrayList<BoxFileVersion>(); for (JsonValue entry : entries) { versions.add(new BoxFileVersion(this.getAPI(), entry.asObject(), this.getID())); } return versions; }
[ "public", "Collection", "<", "BoxFileVersion", ">", "getVersions", "(", ")", "{", "URL", "url", "=", "VERSIONS_URL_TEMPLATE", ".", "build", "(", "this", ".", "getAPI", "(", ")", ".", "getBaseURL", "(", ")", ",", "this", ".", "getID", "(", ")", ")", ";"...
Gets any previous versions of this file. Note that only users with premium accounts will be able to retrieve previous versions of their files. @return a list of previous file versions.
[ "Gets", "any", "previous", "versions", "of", "this", "file", ".", "Note", "that", "only", "users", "with", "premium", "accounts", "will", "be", "able", "to", "retrieve", "previous", "versions", "of", "their", "files", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxFile.java#L629-L642
train
box/box-java-sdk
src/main/java/com/box/sdk/BoxFile.java
BoxFile.canUploadVersion
public boolean canUploadVersion(String name, long fileSize) { URL url = CONTENT_URL_TEMPLATE.build(this.getAPI().getBaseURL(), this.getID()); BoxJSONRequest request = new BoxJSONRequest(this.getAPI(), url, "OPTIONS"); JsonObject preflightInfo = new JsonObject(); if (name != null) { preflightInfo.add("name", name); } preflightInfo.add("size", fileSize); request.setBody(preflightInfo.toString()); try { BoxAPIResponse response = request.send(); return response.getResponseCode() == 200; } catch (BoxAPIException ex) { if (ex.getResponseCode() >= 400 && ex.getResponseCode() < 500) { // This looks like an error response, menaing the upload would fail return false; } else { // This looks like a network error or server error, rethrow exception throw ex; } } }
java
public boolean canUploadVersion(String name, long fileSize) { URL url = CONTENT_URL_TEMPLATE.build(this.getAPI().getBaseURL(), this.getID()); BoxJSONRequest request = new BoxJSONRequest(this.getAPI(), url, "OPTIONS"); JsonObject preflightInfo = new JsonObject(); if (name != null) { preflightInfo.add("name", name); } preflightInfo.add("size", fileSize); request.setBody(preflightInfo.toString()); try { BoxAPIResponse response = request.send(); return response.getResponseCode() == 200; } catch (BoxAPIException ex) { if (ex.getResponseCode() >= 400 && ex.getResponseCode() < 500) { // This looks like an error response, menaing the upload would fail return false; } else { // This looks like a network error or server error, rethrow exception throw ex; } } }
[ "public", "boolean", "canUploadVersion", "(", "String", "name", ",", "long", "fileSize", ")", "{", "URL", "url", "=", "CONTENT_URL_TEMPLATE", ".", "build", "(", "this", ".", "getAPI", "(", ")", ".", "getBaseURL", "(", ")", ",", "this", ".", "getID", "(",...
Checks if a new version of the file can be uploaded with the specified name and size. @param name the new name for the file. @param fileSize the size of the new version content in bytes. @return whether or not the file version can be uploaded.
[ "Checks", "if", "a", "new", "version", "of", "the", "file", "can", "be", "uploaded", "with", "the", "specified", "name", "and", "size", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxFile.java#L688-L715
train
box/box-java-sdk
src/main/java/com/box/sdk/BoxFile.java
BoxFile.getThumbnail
public byte[] getThumbnail(ThumbnailFileType fileType, int minWidth, int minHeight, int maxWidth, int maxHeight) { QueryStringBuilder builder = new QueryStringBuilder(); builder.appendParam("min_width", minWidth); builder.appendParam("min_height", minHeight); builder.appendParam("max_width", maxWidth); builder.appendParam("max_height", maxHeight); URLTemplate template; if (fileType == ThumbnailFileType.PNG) { template = GET_THUMBNAIL_PNG_TEMPLATE; } else if (fileType == ThumbnailFileType.JPG) { template = GET_THUMBNAIL_JPG_TEMPLATE; } else { throw new BoxAPIException("Unsupported thumbnail file type"); } URL url = template.buildWithQuery(this.getAPI().getBaseURL(), builder.toString(), this.getID()); BoxAPIRequest request = new BoxAPIRequest(this.getAPI(), url, "GET"); BoxAPIResponse response = request.send(); ByteArrayOutputStream thumbOut = new ByteArrayOutputStream(); InputStream body = response.getBody(); byte[] buffer = new byte[BUFFER_SIZE]; try { int n = body.read(buffer); while (n != -1) { thumbOut.write(buffer, 0, n); n = body.read(buffer); } } catch (IOException e) { throw new BoxAPIException("Error reading thumbnail bytes from response body", e); } finally { response.disconnect(); } return thumbOut.toByteArray(); }
java
public byte[] getThumbnail(ThumbnailFileType fileType, int minWidth, int minHeight, int maxWidth, int maxHeight) { QueryStringBuilder builder = new QueryStringBuilder(); builder.appendParam("min_width", minWidth); builder.appendParam("min_height", minHeight); builder.appendParam("max_width", maxWidth); builder.appendParam("max_height", maxHeight); URLTemplate template; if (fileType == ThumbnailFileType.PNG) { template = GET_THUMBNAIL_PNG_TEMPLATE; } else if (fileType == ThumbnailFileType.JPG) { template = GET_THUMBNAIL_JPG_TEMPLATE; } else { throw new BoxAPIException("Unsupported thumbnail file type"); } URL url = template.buildWithQuery(this.getAPI().getBaseURL(), builder.toString(), this.getID()); BoxAPIRequest request = new BoxAPIRequest(this.getAPI(), url, "GET"); BoxAPIResponse response = request.send(); ByteArrayOutputStream thumbOut = new ByteArrayOutputStream(); InputStream body = response.getBody(); byte[] buffer = new byte[BUFFER_SIZE]; try { int n = body.read(buffer); while (n != -1) { thumbOut.write(buffer, 0, n); n = body.read(buffer); } } catch (IOException e) { throw new BoxAPIException("Error reading thumbnail bytes from response body", e); } finally { response.disconnect(); } return thumbOut.toByteArray(); }
[ "public", "byte", "[", "]", "getThumbnail", "(", "ThumbnailFileType", "fileType", ",", "int", "minWidth", ",", "int", "minHeight", ",", "int", "maxWidth", ",", "int", "maxHeight", ")", "{", "QueryStringBuilder", "builder", "=", "new", "QueryStringBuilder", "(", ...
Retrieves a thumbnail, or smaller image representation, of this file. Sizes of 32x32, 64x64, 128x128, and 256x256 can be returned in the .png format and sizes of 32x32, 94x94, 160x160, and 320x320 can be returned in the .jpg format. @param fileType either PNG of JPG @param minWidth minimum width @param minHeight minimum height @param maxWidth maximum width @param maxHeight maximum height @return the byte array of the thumbnail image
[ "Retrieves", "a", "thumbnail", "or", "smaller", "image", "representation", "of", "this", "file", ".", "Sizes", "of", "32x32", "64x64", "128x128", "and", "256x256", "can", "be", "returned", "in", "the", ".", "png", "format", "and", "sizes", "of", "32x32", "...
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxFile.java#L911-L947
train
box/box-java-sdk
src/main/java/com/box/sdk/BoxFile.java
BoxFile.getComments
public List<BoxComment.Info> getComments() { URL url = GET_COMMENTS_URL_TEMPLATE.build(this.getAPI().getBaseURL(), this.getID()); BoxAPIRequest request = new BoxAPIRequest(this.getAPI(), url, "GET"); BoxJSONResponse response = (BoxJSONResponse) request.send(); JsonObject responseJSON = JsonObject.readFrom(response.getJSON()); int totalCount = responseJSON.get("total_count").asInt(); List<BoxComment.Info> comments = new ArrayList<BoxComment.Info>(totalCount); JsonArray entries = responseJSON.get("entries").asArray(); for (JsonValue value : entries) { JsonObject commentJSON = value.asObject(); BoxComment comment = new BoxComment(this.getAPI(), commentJSON.get("id").asString()); BoxComment.Info info = comment.new Info(commentJSON); comments.add(info); } return comments; }
java
public List<BoxComment.Info> getComments() { URL url = GET_COMMENTS_URL_TEMPLATE.build(this.getAPI().getBaseURL(), this.getID()); BoxAPIRequest request = new BoxAPIRequest(this.getAPI(), url, "GET"); BoxJSONResponse response = (BoxJSONResponse) request.send(); JsonObject responseJSON = JsonObject.readFrom(response.getJSON()); int totalCount = responseJSON.get("total_count").asInt(); List<BoxComment.Info> comments = new ArrayList<BoxComment.Info>(totalCount); JsonArray entries = responseJSON.get("entries").asArray(); for (JsonValue value : entries) { JsonObject commentJSON = value.asObject(); BoxComment comment = new BoxComment(this.getAPI(), commentJSON.get("id").asString()); BoxComment.Info info = comment.new Info(commentJSON); comments.add(info); } return comments; }
[ "public", "List", "<", "BoxComment", ".", "Info", ">", "getComments", "(", ")", "{", "URL", "url", "=", "GET_COMMENTS_URL_TEMPLATE", ".", "build", "(", "this", ".", "getAPI", "(", ")", ".", "getBaseURL", "(", ")", ",", "this", ".", "getID", "(", ")", ...
Gets a list of any comments on this file. @return a list of comments on this file.
[ "Gets", "a", "list", "of", "any", "comments", "on", "this", "file", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxFile.java#L954-L971
train
box/box-java-sdk
src/main/java/com/box/sdk/BoxFile.java
BoxFile.getTasks
public List<BoxTask.Info> getTasks(String... fields) { QueryStringBuilder builder = new QueryStringBuilder(); if (fields.length > 0) { builder.appendParam("fields", fields).toString(); } URL url = GET_TASKS_URL_TEMPLATE.buildWithQuery(this.getAPI().getBaseURL(), builder.toString(), this.getID()); BoxAPIRequest request = new BoxAPIRequest(this.getAPI(), url, "GET"); BoxJSONResponse response = (BoxJSONResponse) request.send(); JsonObject responseJSON = JsonObject.readFrom(response.getJSON()); int totalCount = responseJSON.get("total_count").asInt(); List<BoxTask.Info> tasks = new ArrayList<BoxTask.Info>(totalCount); JsonArray entries = responseJSON.get("entries").asArray(); for (JsonValue value : entries) { JsonObject taskJSON = value.asObject(); BoxTask task = new BoxTask(this.getAPI(), taskJSON.get("id").asString()); BoxTask.Info info = task.new Info(taskJSON); tasks.add(info); } return tasks; }
java
public List<BoxTask.Info> getTasks(String... fields) { QueryStringBuilder builder = new QueryStringBuilder(); if (fields.length > 0) { builder.appendParam("fields", fields).toString(); } URL url = GET_TASKS_URL_TEMPLATE.buildWithQuery(this.getAPI().getBaseURL(), builder.toString(), this.getID()); BoxAPIRequest request = new BoxAPIRequest(this.getAPI(), url, "GET"); BoxJSONResponse response = (BoxJSONResponse) request.send(); JsonObject responseJSON = JsonObject.readFrom(response.getJSON()); int totalCount = responseJSON.get("total_count").asInt(); List<BoxTask.Info> tasks = new ArrayList<BoxTask.Info>(totalCount); JsonArray entries = responseJSON.get("entries").asArray(); for (JsonValue value : entries) { JsonObject taskJSON = value.asObject(); BoxTask task = new BoxTask(this.getAPI(), taskJSON.get("id").asString()); BoxTask.Info info = task.new Info(taskJSON); tasks.add(info); } return tasks; }
[ "public", "List", "<", "BoxTask", ".", "Info", ">", "getTasks", "(", "String", "...", "fields", ")", "{", "QueryStringBuilder", "builder", "=", "new", "QueryStringBuilder", "(", ")", ";", "if", "(", "fields", ".", "length", ">", "0", ")", "{", "builder",...
Gets a list of any tasks on this file with requested fields. @param fields optional fields to retrieve for this task. @return a list of tasks on this file.
[ "Gets", "a", "list", "of", "any", "tasks", "on", "this", "file", "with", "requested", "fields", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxFile.java#L979-L1000
train
box/box-java-sdk
src/main/java/com/box/sdk/BoxFile.java
BoxFile.createMetadata
public Metadata createMetadata(String typeName, Metadata metadata) { String scope = Metadata.scopeBasedOnType(typeName); return this.createMetadata(typeName, scope, metadata); }
java
public Metadata createMetadata(String typeName, Metadata metadata) { String scope = Metadata.scopeBasedOnType(typeName); return this.createMetadata(typeName, scope, metadata); }
[ "public", "Metadata", "createMetadata", "(", "String", "typeName", ",", "Metadata", "metadata", ")", "{", "String", "scope", "=", "Metadata", ".", "scopeBasedOnType", "(", "typeName", ")", ";", "return", "this", ".", "createMetadata", "(", "typeName", ",", "sc...
Creates metadata on this file in the specified template type. @param typeName the metadata template type name. @param metadata the new metadata values. @return the metadata returned from the server.
[ "Creates", "metadata", "on", "this", "file", "in", "the", "specified", "template", "type", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxFile.java#L1019-L1022
train
box/box-java-sdk
src/main/java/com/box/sdk/BoxFile.java
BoxFile.updateClassification
public String updateClassification(String classificationType) { Metadata metadata = new Metadata("enterprise", Metadata.CLASSIFICATION_TEMPLATE_KEY); metadata.add("/Box__Security__Classification__Key", classificationType); Metadata classification = this.updateMetadata(metadata); return classification.getString(Metadata.CLASSIFICATION_KEY); }
java
public String updateClassification(String classificationType) { Metadata metadata = new Metadata("enterprise", Metadata.CLASSIFICATION_TEMPLATE_KEY); metadata.add("/Box__Security__Classification__Key", classificationType); Metadata classification = this.updateMetadata(metadata); return classification.getString(Metadata.CLASSIFICATION_KEY); }
[ "public", "String", "updateClassification", "(", "String", "classificationType", ")", "{", "Metadata", "metadata", "=", "new", "Metadata", "(", "\"enterprise\"", ",", "Metadata", ".", "CLASSIFICATION_TEMPLATE_KEY", ")", ";", "metadata", ".", "add", "(", "\"/Box__Sec...
Updates a metadata classification on the specified file. @param classificationType the metadata classification type. @return the new metadata classification type updated on the file.
[ "Updates", "a", "metadata", "classification", "on", "the", "specified", "file", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxFile.java#L1099-L1105
train
box/box-java-sdk
src/main/java/com/box/sdk/BoxFile.java
BoxFile.setClassification
public String setClassification(String classificationType) { Metadata metadata = new Metadata().add(Metadata.CLASSIFICATION_KEY, classificationType); Metadata classification = null; try { classification = this.createMetadata(Metadata.CLASSIFICATION_TEMPLATE_KEY, "enterprise", metadata); } catch (BoxAPIException e) { if (e.getResponseCode() == 409) { metadata = new Metadata("enterprise", Metadata.CLASSIFICATION_TEMPLATE_KEY); metadata.replace(Metadata.CLASSIFICATION_KEY, classificationType); classification = this.updateMetadata(metadata); } else { throw e; } } return classification.getString(Metadata.CLASSIFICATION_KEY); }
java
public String setClassification(String classificationType) { Metadata metadata = new Metadata().add(Metadata.CLASSIFICATION_KEY, classificationType); Metadata classification = null; try { classification = this.createMetadata(Metadata.CLASSIFICATION_TEMPLATE_KEY, "enterprise", metadata); } catch (BoxAPIException e) { if (e.getResponseCode() == 409) { metadata = new Metadata("enterprise", Metadata.CLASSIFICATION_TEMPLATE_KEY); metadata.replace(Metadata.CLASSIFICATION_KEY, classificationType); classification = this.updateMetadata(metadata); } else { throw e; } } return classification.getString(Metadata.CLASSIFICATION_KEY); }
[ "public", "String", "setClassification", "(", "String", "classificationType", ")", "{", "Metadata", "metadata", "=", "new", "Metadata", "(", ")", ".", "add", "(", "Metadata", ".", "CLASSIFICATION_KEY", ",", "classificationType", ")", ";", "Metadata", "classificati...
Attempts to add classification to a file. If classification already exists then do update. @param classificationType the metadata classification type. @return the metadata classification type on the file.
[ "Attempts", "to", "add", "classification", "to", "a", "file", ".", "If", "classification", "already", "exists", "then", "do", "update", "." ]
35b4ba69417f9d6a002c19dfaab57527750ef349
https://github.com/box/box-java-sdk/blob/35b4ba69417f9d6a002c19dfaab57527750ef349/src/main/java/com/box/sdk/BoxFile.java#L1113-L1130
train