code
stringlengths
73
34.1k
label
stringclasses
1 value
public void setExplodedAppDirectory(File explodedAppDirectory) { this.explodedAppDirectory = explodedAppDirectory; into(explodedAppDirectory); preserve( patternFilterable -> patternFilterable.include("WEB-INF/appengine-generated/datastore-indexes-auto.xml")); }
java
@Optional @InputFiles public FileCollection getExtraFilesDirectoriesAsInputFiles() { if (extraFilesDirectories == null) { return null; } FileCollection files = project.files(); for (File directory : extraFilesDirectories) { files = files.plus(project.fileTree(directory)); } return files; }
java
public void configureCoreProperties( Project project, AppEngineCoreExtensionProperties appEngineCoreExtensionProperties, String taskGroup, boolean requiresAppEngineJava) { project .getLogger() .warn( "WARNING: You are a using release candidate " + getClass().getPackage().getImplementationVersion() + ". Behavior of this plugin has changed since 1.3.5. Please see release notes at: " + "https://github.com/GoogleCloudPlatform/app-gradle-plugin."); project .getLogger() .warn( "Missing a feature? Can't get it to work?, please file a bug at: " + "https://github.com/GoogleCloudPlatform/app-gradle-plugin/issues."); checkGradleVersion(); this.project = project; this.taskGroup = taskGroup; this.toolsExtension = appEngineCoreExtensionProperties.getTools(); this.deployExtension = appEngineCoreExtensionProperties.getDeploy(); this.requiresAppEngineJava = requiresAppEngineJava; configureFactories(); createDownloadCloudSdkTask(); createCheckCloudSdkTask(); createLoginTask(); createDeployTask(); createDeployCronTask(); createDeployDispatchTask(); createDeployDosTask(); createDeployIndexTask(); createDeployQueueTask(); createDeployAllTask(); createShowConfigurationTask(); }
java
public boolean isVm() { try { XPath xpath = XPathFactory.newInstance().newXPath(); String expression = "/appengine-web-app/vm/text()='true'"; return (Boolean) xpath.evaluate(expression, document, XPathConstants.BOOLEAN); } catch (XPathExpressionException e) { throw new GradleException("XPath evaluation failed on appengine-web.xml", e); } }
java
public ManagedCloudSdk newManagedSdk() throws UnsupportedOsException, BadCloudSdkVersionException { if (Strings.isNullOrEmpty(version)) { return ManagedCloudSdk.newManagedSdk(); } else { return ManagedCloudSdk.newManagedSdk(new Version(version)); } }
java
@SuppressWarnings("unchecked") public <T> T get(String... path) { ExtensionAware root = searchRoot; for (String name : path) { ExtensionContainer children = root.getExtensions(); root = (ExtensionAware) children.getByName(name); } return (T) root; // this is potentially unchecked. }
java
private void configureArchiveTask(AbstractArchiveTask archiveTask) { if (archiveTask == null) { return; } archiveTask.dependsOn("_createSourceContext"); archiveTask.from(extension.getOutputDirectory(), copySpec -> copySpec.into("WEB-INF/classes")); }
java
private void writeMetrics() throws IOException { if (metrics.size() > 0) { try { byte[] payload = pickleMetrics(metrics); byte[] header = ByteBuffer.allocate(4).putInt(payload.length).array(); OutputStream outputStream = socket.getOutputStream(); outputStream.write(header); outputStream.write(payload); outputStream.flush(); if (LOGGER.isDebugEnabled()) { LOGGER.debug("Wrote {} metrics", metrics.size()); } } catch (IOException e) { this.failures++; throw e; } finally { // if there was an error, we might miss some data. for now, drop those on the floor and // try to keep going. metrics.clear(); } } }
java
@Override public SystemState restore(long fromVersion, TxRepository repository) { workflowContext.repository(repository); final long snapshotTransactionId = repository.getO(SystemInfo.class, 0L).orElse(new SystemInfo(0L)).lastTransactionId; final long[] transactionId = {snapshotTransactionId}; try (InputProcessor processor = new DefaultInputProcessor(journalStorage)) { processor.process(fromVersion, b -> { EventsCommitInfo e = eventsContext.serializer().deserialize(eventsContext.eventsCommitBuilder(), b); eventBus.processNextEvent(e); }, JournalType.EVENTS); processor.process(fromVersion, b -> { TransactionCommitInfo tx = workflowContext.serializer().deserialize(workflowContext.transactionCommitBuilder(), b); if (tx.transactionId() > transactionId[0] || tx.transactionId() == snapshotTransactionId) { transactionId[0] = tx.transactionId(); workflowEngine.getPipe().executeRestore(eventBus, tx); } else if (LOG.isDebugEnabled()) { LOG.debug("Transaction ID {} less than last Transaction ID {}", tx.transactionId(), transactionId[0]); } }, JournalType.TRANSACTIONS); } catch (Throwable t) { LOG.error("restore", t); throw new RuntimeException(t); } workflowEngine.getPipe().sync(); workflowContext.eventPublisher().getPipe().sync(); return new SystemState(transactionId[0]); }
java
public static void printStackTrace(SQLException e, PrintWriter pw) { SQLException next = e; while (next != null) { next.printStackTrace(pw); next = next.getNextException(); if (next != null) { pw.println("Next SQLException:"); } } }
java
public static void printWarnings(Connection conn, PrintWriter pw) { if (conn != null) { try { printStackTrace(conn.getWarnings(), pw); } catch (SQLException e) { printStackTrace(e, pw); } } }
java
public XComponentContext connect(String host, int port) throws BootstrapException { String unoConnectString = "uno:socket,host=" + host + ",port=" + port + ";urp;StarOffice.ComponentContext"; return connect(unoConnectString); }
java
public void addDependency(Area main, Area dependent) { List<Area> set = areasDependency.get(main); if (set == null) { set = new ArrayList<Area>(); areasDependency.put(main, set); } set.add(dependent); }
java
public synchronized void kill() { if (oooProcess != null) { log.info("OOServer is killing office instance with port {}", port); List<Long> pids = processManager.findPid(host, port); processManager.kill(oooProcess, pids); oooProcess = null; } }
java
public XComponentContext connect(String oooConnectionString) throws BootstrapException { this.oooConnectionString = oooConnectionString; XComponentContext xContext = null; try { // get local context XComponentContext xLocalContext = getLocalContext(); oooServer.start(); // initial service manager XMultiComponentFactory xLocalServiceManager = xLocalContext.getServiceManager(); if ( xLocalServiceManager == null ) throw new BootstrapException("no initial service manager!"); // create a URL resolver XUnoUrlResolver xUrlResolver = UnoUrlResolver.create(xLocalContext); // wait until office is started for (int i = 0;; ++i) { try { xContext = getRemoteContext(xUrlResolver); break; } catch ( NoConnectException ex ) { // Wait 500 ms, then try to connect again, but do not wait // longer than 5 sec total: if (i == 10) { throw new BootstrapException(ex); } Thread.sleep(500); } } } catch (RuntimeException e) { throw e; } catch (Exception e) { throw new BootstrapException(e); } return xContext; }
java
public void disconnect() { if (oooConnectionString == null) return; // call office to terminate itself try { // get local context XComponentContext xLocalContext = getLocalContext(); // create a URL resolver XUnoUrlResolver xUrlResolver = UnoUrlResolver.create(xLocalContext); // get remote context XComponentContext xRemoteContext = getRemoteContext(xUrlResolver); // get desktop to terminate office Object desktop = xRemoteContext.getServiceManager().createInstanceWithContext("com.sun.star.frame.Desktop",xRemoteContext); XDesktop xDesktop = (XDesktop) UnoRuntime.queryInterface(XDesktop.class, desktop); xDesktop.terminate(); } catch (Exception e) { // Bad luck, unable to terminate office } oooServer.kill(); oooConnectionString = null; }
java
protected XComponentContext getLocalContext() throws BootstrapException, Exception { XComponentContext xLocalContext = Bootstrap.createInitialComponentContext(null); if (xLocalContext == null) { throw new BootstrapException("no local component context!"); } return xLocalContext; }
java
protected XComponentContext getRemoteContext(XUnoUrlResolver xUrlResolver) throws BootstrapException, ConnectionSetupException, IllegalArgumentException, NoConnectException { Object context = xUrlResolver.resolve(oooConnectionString); XComponentContext xContext = (XComponentContext) UnoRuntime.queryInterface(XComponentContext.class, context); if (xContext == null) { throw new BootstrapException("no component context!"); } return xContext; }
java
@Override public boolean next() throws JRException { List<BandData> children = currentBand.getChildrenList(); if (children != null && !children.isEmpty() && !visitedBands.containsKey(currentBand)) { currentIterator = children.iterator(); visitedBands.put(currentBand, currentIterator); } else if (currentIterator == null) { currentIterator = Collections.singletonList(currentBand).iterator(); } if (currentIterator.hasNext()) { currentBand = currentIterator.next(); if (readBands.contains(currentBand) || currentBand.getData().isEmpty()) return next(); return true; } else { BandData parentBand = currentBand.getParentBand(); currentBand = parentBand; currentIterator = visitedBands.get(parentBand); if (parentBand == null || parentBand.equals(root)) return false; return next(); } }
java
public JRBandDataDataSource subDataSource(String bandName) { if (containsVisitedBand(bandName)) return null; BandData newParentBand = createNewBand(bandName); currentBand = root; currentIterator = root.getChildrenList().iterator(); visitedBands.put(root, currentIterator); return new JRBandDataDataSource(newParentBand); }
java
public <T> T query(Connection conn, String sql, Object param, ResultSetHandler<T> rsh) throws SQLException { return this.query(conn, sql, new Object[] { param }, rsh); }
java
public <T> T query(Connection conn, String sql, Object[] params, ResultSetHandler<T> rsh) throws SQLException { PreparedStatement stmt = null; ResultSet rs = null; T result = null; try { stmt = this.prepareStatement(conn, sql); this.fillStatement(stmt, params); rs = this.wrap(stmt.executeQuery()); result = rsh.handle(rs); } catch (SQLException e) { this.rethrow(e, sql, params); } finally { try { close(rs); } finally { close(stmt); } } return result; }
java
public int update(Connection conn, String sql) throws SQLException { return this.update(conn, sql, (Object[]) null); }
java
public int update(Connection conn, String sql, Object param) throws SQLException { return this.update(conn, sql, new Object[] { param }); }
java
public int update(Connection conn, String sql, Object[] params, int[] paramTypes) throws SQLException { if ((paramTypes != null) && params.length != paramTypes.length) { throw new IllegalArgumentException("Sizes of params and paramTypes must be equal!"); } PreparedStatement stmt = null; int rows = 0; try { stmt = this.prepareStatement(conn, sql); this.fillStatement(stmt, params, paramTypes); rows = stmt.executeUpdate(); } catch (SQLException e) { this.rethrow(e, sql, params); } finally { close(stmt); } return rows; }
java
protected void copyMergeRegions(HSSFSheet resultSheet, String rangeName, int firstTargetRangeRow, int firstTargetRangeColumn) { int rangeNameIdx = templateWorkbook.getNameIndex(rangeName); if (rangeNameIdx == -1) return; HSSFName aNamedRange = templateWorkbook.getNameAt(rangeNameIdx); AreaReference aref = new AreaReference(aNamedRange.getRefersToFormula(), SpreadsheetVersion.EXCEL97); int column = aref.getFirstCell().getCol(); int row = aref.getFirstCell().getRow(); List<SheetRange> regionsList = mergeRegionsForRangeNames.get(rangeName); if (regionsList != null) for (SheetRange sheetRange : regionsList) { if (resultSheet.getSheetName().equals(sheetRange.getSheetName())) { CellRangeAddress cra = sheetRange.getCellRangeAddress(); if (cra != null) { int regionHeight = cra.getLastRow() - cra.getFirstRow() + 1; int regionWidth = cra.getLastColumn() - cra.getFirstColumn() + 1; int regionVOffset = cra.getFirstRow() - row; int regionHOffset = cra.getFirstColumn() - column; CellRangeAddress newRegion = cra.copy(); newRegion.setFirstColumn(regionHOffset + firstTargetRangeColumn); newRegion.setLastColumn(regionHOffset + regionWidth - 1 + firstTargetRangeColumn); newRegion.setFirstRow(regionVOffset + firstTargetRangeRow); newRegion.setLastRow(regionVOffset + regionHeight - 1 + firstTargetRangeRow); boolean skipRegion = false; for (int mergedIndex = 0; mergedIndex < resultSheet.getNumMergedRegions(); mergedIndex++) { CellRangeAddress mergedRegion = resultSheet.getMergedRegion(mergedIndex); if (!intersects(newRegion, mergedRegion)) { continue; } skipRegion = true; } if (!skipRegion) { resultSheet.addMergedRegion(newRegion); } } } } }
java
private HSSFCell copyCellFromTemplate(HSSFCell templateCell, HSSFRow resultRow, int resultColumn, BandData band) { checkThreadInterrupted(); if (templateCell == null) return null; HSSFCell resultCell = resultRow.createCell(resultColumn); HSSFCellStyle templateStyle = templateCell.getCellStyle(); HSSFCellStyle resultStyle = copyCellStyle(templateStyle); resultCell.setCellStyle(resultStyle); String templateCellValue = ""; int cellType = templateCell.getCellType(); if (cellType != HSSFCell.CELL_TYPE_FORMULA && cellType != HSSFCell.CELL_TYPE_NUMERIC) { HSSFRichTextString richStringCellValue = templateCell.getRichStringCellValue(); templateCellValue = richStringCellValue != null ? richStringCellValue.getString() : ""; templateCellValue = extractStyles(templateCell, resultCell, templateCellValue, band); } if (cellType == HSSFCell.CELL_TYPE_STRING && containsJustOneAlias(templateCellValue)) { updateValueCell(rootBand, band, templateCellValue, resultCell, drawingPatriarchsMap.get(resultCell.getSheet())); } else { String cellValue = inlineBandDataToCellString(templateCell, templateCellValue, band); setValueToCell(resultCell, cellValue, cellType); } return resultCell; }
java
protected void updateValueCell(BandData rootBand, BandData bandData, String templateCellValue, HSSFCell resultCell, HSSFPatriarch patriarch) { String parameterName = templateCellValue; parameterName = unwrapParameterName(parameterName); String fullParameterName = bandData.getName() + "." + parameterName; if (StringUtils.isEmpty(parameterName)) return; if (!bandData.getData().containsKey(parameterName)) { resultCell.setCellValue((String) null); return; } Object value = bandData.getData().get(parameterName); if (value == null) { resultCell.setCellType(HSSFCell.CELL_TYPE_BLANK); return; } String formatString = getFormatString(parameterName, fullParameterName); InlinerAndMatcher inlinerAndMatcher = getContentInlinerForFormat(formatString); if (inlinerAndMatcher != null) { inlinerAndMatcher.contentInliner.inlineToXls(patriarch, resultCell, value, inlinerAndMatcher.matcher); return; } if (formatString != null) { resultCell.setCellValue(new HSSFRichTextString(formatValue(value, parameterName, fullParameterName))); } else if (value instanceof Number) { resultCell.setCellValue(((Number) value).doubleValue()); } else if (value instanceof Boolean) { resultCell.setCellValue((Boolean) value); } else if (value instanceof Date) { resultCell.setCellValue((Date) value); } else { resultCell.setCellValue(new HSSFRichTextString(formatValue(value, parameterName, fullParameterName))); } }
java
protected void addRangeBounds(BandData band, CellReference[] crefs) { if (templateBounds.containsKey(band.getName())) return; Bounds bounds = new Bounds(crefs[0].getRow(), crefs[0].getCol(), crefs[crefs.length - 1].getRow(), crefs[crefs.length - 1].getCol()); templateBounds.put(band.getName(), bounds); }
java
protected EscherAggregate getEscherAggregate(HSSFSheet sheet) { EscherAggregate agg = sheetToEscherAggregate.get(sheet.getSheetName()); if (agg == null) { agg = sheet.getDrawingEscherAggregate(); sheetToEscherAggregate.put(sheet.getSheetName(), agg); } return agg; }
java
protected void copyPicturesFromTemplateToResult(HSSFSheet templateSheet, HSSFSheet resultSheet) { List<HSSFClientAnchor> list = getAllAnchors(getEscherAggregate(templateSheet)); int i = 0; if (CollectionUtils.isNotEmpty(orderedPicturesId)) {//just a shitty workaround for anchors without pictures for (HSSFClientAnchor anchor : list) { Cell topLeft = getCellFromTemplate(new Cell(anchor.getCol1(), anchor.getRow1())); anchor.setCol1(topLeft.getCol()); anchor.setRow1(topLeft.getRow()); anchor.setCol2(topLeft.getCol() + anchor.getCol2() - anchor.getCol1()); anchor.setRow2(topLeft.getRow() + anchor.getRow2() - anchor.getRow1()); HSSFPatriarch sheetPatriarch = drawingPatriarchsMap.get(resultSheet); if (sheetPatriarch != null) { sheetPatriarch.createPicture(anchor, orderedPicturesId.get(i++)); } } } }
java
protected void updateFormulas() { CTCalcChain calculationChain = getCalculationChain(); int formulaCount = processInnerFormulas(calculationChain); processOuterFormulas(formulaCount, calculationChain); }
java
protected void createFakeTemplateCellsForEmptyOnes(Range oneRowRange, Map<CellReference, Cell> cellsForOneRowRange, List<Cell> templateCells) { if (oneRowRange.toCellReferences().size() != templateCells.size()) { final HashBiMap<CellReference, Cell> referencesToCells = HashBiMap.create(cellsForOneRowRange); for (CellReference cellReference : oneRowRange.toCellReferences()) { if (!cellsForOneRowRange.containsKey(cellReference)) { Cell newCell = Context.getsmlObjectFactory().createCell(); newCell.setV(null); newCell.setT(STCellType.STR); newCell.setR(cellReference.toReference()); templateCells.add(newCell); referencesToCells.put(cellReference, newCell); } } templateCells.sort((o1, o2) -> { CellReference cellReference1 = referencesToCells.inverse().get(o1); CellReference cellReference2 = referencesToCells.inverse().get(o2); return cellReference1.compareTo(cellReference2); }); } }
java
public RunParams templateCode(String templateCode) { if (templateCode == null) { throw new NullPointerException("\"templateCode\" parameter can not be null"); } this.reportTemplate = report.getReportTemplates().get(templateCode); if (reportTemplate == null) { throw new NullPointerException(String.format("Report template not found for code [%s]", templateCode)); } return this; }
java
public RunParams params(Map<String, Object> params) { if (params == null) { throw new NullPointerException("\"params\" parameter can not be null"); } this.params.putAll(params); return this; }
java
public RunParams param(String key, Object value) { params.put(key, value); return this; }
java
public BoxRequestsCollections.GetCollections getCollectionsRequest() { BoxRequestsCollections.GetCollections request = new BoxRequestsCollections.GetCollections(getCollectionsUrl(), mSession); return request; }
java
public BoxRequestsCollections.GetCollectionItems getItemsRequest(String id) { BoxRequestsCollections.GetCollectionItems request = new BoxRequestsCollections.GetCollectionItems(id, getCollectionItemsUrl(id), mSession); return request; }
java
public static BoxUser createFromId(String userId) { JsonObject object = new JsonObject(); object.add(BoxCollaborator.FIELD_ID, userId); object.add(BoxCollaborator.FIELD_TYPE, BoxUser.TYPE); BoxUser user = new BoxUser(); user.createFromJson(object); return user; }
java
public BoxRequestsEvent.GetUserEvents getUserEventsRequest() { BoxRequestsEvent.GetUserEvents request = new BoxRequestsEvent.GetUserEvents( getEventsUrl(), mSession); return request; }
java
public BoxRequestsEvent.GetEnterpriseEvents getEnterpriseEventsRequest() { BoxRequestsEvent.GetEnterpriseEvents request = new BoxRequestsEvent.GetEnterpriseEvents(getEventsUrl(), mSession); return request; }
java
public RealTimeServerConnection getLongPollServerConnection(RealTimeServerConnection.OnChangeListener changeListener) { BoxRequestsEvent.EventRealTimeServerRequest request = new BoxRequestsEvent.EventRealTimeServerRequest(getEventsUrl(), mSession); return new RealTimeServerConnection(request,changeListener, mSession ); }
java
public JsonValue getPropertyValue(String name) { // Return a copy of json value to ensure user can't change the underlying object directly JsonValue jsonValue = mCacheMap.getAsJsonValue(name); return jsonValue == null ? null : JsonValue.readFrom(jsonValue.toString()); }
java
public R setMessage(String message) { mBodyMap.put(BoxComment.FIELD_MESSAGE, message); return (R) this; }
java
public String getItemId() { return mBodyMap.containsKey(BoxComment.FIELD_ITEM) ? (String) mBodyMap.get(BoxItem.FIELD_ID) : null; }
java
protected R setItemId(String id) { JsonObject object = new JsonObject(); if (mBodyMap.containsKey(BoxComment.FIELD_ITEM)) { BoxEntity item = (BoxEntity) mBodyMap.get(BoxComment.FIELD_ITEM); object = item.toJsonObject(); } object.add(BoxEntity.FIELD_ID, id); BoxEntity item = new BoxEntity(object); mBodyMap.put(BoxComment.FIELD_ITEM, item); return (R) this; }
java
public String getItemType() { return mBodyMap.containsKey(BoxComment.FIELD_ITEM) ? (String) mBodyMap.get(BoxItem.FIELD_TYPE) : null; }
java
protected R setItemType(String type) { JsonObject object = new JsonObject(); if (mBodyMap.containsKey(BoxComment.FIELD_ITEM)) { BoxEntity item = (BoxEntity) mBodyMap.get(BoxComment.FIELD_ITEM); object = item.toJsonObject(); } object.add(BoxEntity.FIELD_TYPE, type); BoxEntity item = new BoxEntity(object); mBodyMap.put(BoxComment.FIELD_ITEM, item); return (R) this; }
java
public void open() throws IOException { mConnection.connect(); mContentType = mConnection.getContentType(); mResponseCode = mConnection.getResponseCode(); mContentEncoding = mConnection.getContentEncoding(); }
java
public R setLimit(int limit) { mQueryMap.put(LIMIT, String.valueOf(limit)); return (R) this; }
java
public R setOffset(int offset) { mQueryMap.put(OFFSET, String.valueOf(offset)); return (R) this; }
java
protected String getBaseUri() { if (mSession != null && mSession.getAuthInfo() != null && mSession.getAuthInfo().getBaseDomain() != null){ return String.format(BoxConstants.BASE_URI_TEMPLATE,mSession.getAuthInfo().getBaseDomain()); } return mBaseUri; }
java
protected String getBaseUploadUri() { if (mSession != null && mSession.getAuthInfo() != null && mSession.getAuthInfo().getBaseDomain() != null){ return String.format(BoxConstants.BASE_UPLOAD_URI_TEMPLATE, mSession.getAuthInfo().getBaseDomain()); } return mBaseUploadUri; }
java
public ArrayList<BoxCollaboration.Role> getAllowedInviteeRoles() { if (mCachedAllowedInviteeRoles != null){ return mCachedAllowedInviteeRoles; } ArrayList<String> roles = getPropertyAsStringArray(FIELD_ALLOWED_INVITEE_ROLES); if (roles == null){ return null; } mCachedAllowedInviteeRoles = new ArrayList<BoxCollaboration.Role>(roles.size()); for (String role : roles){ mCachedAllowedInviteeRoles.add(BoxCollaboration.Role.fromString(role)); } return mCachedAllowedInviteeRoles; }
java
public Map<String, String> getEndpointsMap () { List<String> keys = getPropertiesKeySet(); HashMap<String, String> endpoints = new HashMap<>(keys.size()); for (String key : keys) { endpoints.put(key, getPropertyAsString(key)); } return endpoints; }
java
public static BoxGroup createFromId(String groupId) { JsonObject object = new JsonObject(); object.add(BoxCollaborator.FIELD_ID, groupId); object.add(BoxCollaborator.FIELD_TYPE, BoxUser.TYPE); return new BoxGroup(object); }
java
public BoxRequestsMetadata.AddItemMetadata getAddFolderMetadataRequest(String id, LinkedHashMap<String, Object> values, String scope, String template) { BoxRequestsMetadata.AddItemMetadata request = new BoxRequestsMetadata.AddItemMetadata(values, getFolderMetadataUrl(id, scope, template), mSession); return request; }
java
public BoxRequestsMetadata.GetItemMetadata getFolderMetadataRequest(String id, String template) { BoxRequestsMetadata.GetItemMetadata request = new BoxRequestsMetadata.GetItemMetadata(getFolderMetadataUrl(id, template), mSession); return request; }
java
public BoxRequestsMetadata.UpdateFileMetadata getUpdateFileMetadataRequest(String id, String scope, String template) { BoxRequestsMetadata.UpdateFileMetadata request = new BoxRequestsMetadata.UpdateFileMetadata(getFileMetadataUrl(id, scope, template), mSession); return request; }
java
public BoxRequestsMetadata.UpdateItemMetadata getUpdateFolderMetadataRequest(String id, String scope, String template) { BoxRequestsMetadata.UpdateItemMetadata request = new BoxRequestsMetadata.UpdateItemMetadata(getFolderMetadataUrl(id, scope, template), mSession); return request; }
java
public BoxRequestsMetadata.DeleteFileMetadata getDeleteFileMetadataTemplateRequest(String id, String template) { BoxRequestsMetadata.DeleteFileMetadata request = new BoxRequestsMetadata.DeleteFileMetadata(getFileMetadataUrl(id, template), mSession); return request; }
java
public BoxRequestsMetadata.DeleteItemMetadata getDeleteFolderMetadataTemplateRequest(String id, String template) { BoxRequestsMetadata.DeleteItemMetadata request = new BoxRequestsMetadata.DeleteItemMetadata(getFolderMetadataUrl(id, template), mSession); return request; }
java
public BoxRequestsMetadata.GetMetadataTemplates getMetadataTemplatesRequest() { BoxRequestsMetadata.GetMetadataTemplates request = new BoxRequestsMetadata.GetMetadataTemplates(getMetadataTemplatesUrl(), mSession); return request; }
java
public BoxFutureTask<BoxSession> logout() { final BoxFutureTask<BoxSession> task = (new BoxSessionLogoutRequest(this)).toTask(); new Thread(){ @Override public void run() { task.run(); } }.start(); return task; }
java
public BoxFutureTask<BoxSession> refresh() { if (mRefreshTask != null && mRefreshTask.get() != null){ BoxFutureTask<BoxSession> lastRefreshTask = mRefreshTask.get(); if (!(lastRefreshTask.isCancelled() || lastRefreshTask.isDone())){ return lastRefreshTask; } } final BoxFutureTask<BoxSession> task = (new BoxSessionRefreshRequest(this)).toTask(); new Thread(){ @Override public void run() { task.run(); } }.start(); mRefreshTask = new WeakReference<BoxFutureTask<BoxSession>>(task); return task; }
java
@Override public void onRefreshed(BoxAuthentication.BoxAuthenticationInfo info) { if (sameUser(info)) { BoxAuthentication.BoxAuthenticationInfo.cloneInfo(mAuthInfo, info); if (sessionAuthListener != null) { sessionAuthListener.onRefreshed(info); } } }
java
@Override public void onAuthCreated(BoxAuthentication.BoxAuthenticationInfo info) { if (sameUser(info) || getUserId() == null) { BoxAuthentication.BoxAuthenticationInfo.cloneInfo(mAuthInfo, info); if (info.getUser() != null) { setUserId(info.getUser().getId()); } if (sessionAuthListener != null) { sessionAuthListener.onAuthCreated(info); } } }
java
@Override public void onAuthFailure(BoxAuthentication.BoxAuthenticationInfo info, Exception ex) { if (sameUser(info) || (info == null && getUserId() == null)) { if (sessionAuthListener != null) { sessionAuthListener.onAuthFailure(info, ex); } if (ex instanceof BoxException) { BoxException.ErrorType errorType = ((BoxException) ex).getErrorType(); switch (errorType) { case NETWORK_ERROR: toastString(mApplicationContext, R.string.boxsdk_error_network_connection); break; case IP_BLOCKED: } } } }
java
public String getName() { return mBodyMap.containsKey(BoxItem.FIELD_NAME) ? (String) mBodyMap.get(BoxItem.FIELD_NAME) : null; }
java
public R setName(String name) { mBodyMap.put(BoxItem.FIELD_NAME, name); return (R) this; }
java
public String getParentId() { return mBodyMap.containsKey(BoxItem.FIELD_PARENT) ? ((BoxFolder) mBodyMap.get(BoxItem.FIELD_PARENT)).getId() : null; }
java
public R setParentId(String parentId) { BoxFolder parentFolder = BoxFolder.createFromId(parentId); mBodyMap.put(BoxItem.FIELD_PARENT, parentFolder); return (R) this; }
java
public void setPartsSha1(List<String> sha1s) { JsonArray jsonArray = new JsonArray(); for (String s : sha1s) { jsonArray.add(s); } set(FIELD_PARTS_SHA1, jsonArray); }
java
public static int getChunkSize(BoxUploadSession uploadSession, int partNumber, long fileSize) { if (partNumber == uploadSession.getTotalParts() - 1) { return (int) (fileSize - partNumber * uploadSession.getPartSize()); } return uploadSession.getPartSize(); }
java
public BoxIterator<BoxFolder> getPathCollection() { return (BoxIterator<BoxFolder>)getPropertyAsJsonObject(BoxJsonObject.getBoxJsonObjectCreator(BoxIteratorBoxEntity.class),FIELD_PATH_COLLECTION); }
java
@Deprecated public static BoxItem createBoxItemFromJson(final String json) { BoxEntity createdByEntity = new BoxEntity(); createdByEntity.createFromJson(json); if (createdByEntity.getType().equals(BoxFile.TYPE)) { BoxFile file = new BoxFile(); file.createFromJson(json); return file; } else if (createdByEntity.getType().equals(BoxBookmark.TYPE)) { BoxBookmark bookmark = new BoxBookmark(); bookmark.createFromJson(json); return bookmark; } else if (createdByEntity.getType().equals(BoxFolder.TYPE)) { BoxFolder folder = new BoxFolder(); folder.createFromJson(json); return folder; } return null; }
java
protected String getUploadSessionForNewFileVersionUrl(final String id) { return String.format(Locale.ENGLISH, "%s/files/%s/upload_sessions", getBaseUploadUri(), id); }
java
public BoxRequestsFile.GetFileInfo getInfoRequest(final String id) { BoxRequestsFile.GetFileInfo request = new BoxRequestsFile.GetFileInfo(id, getFileInfoUrl(id), mSession); return request; }
java
public BoxRequestsFile.GetEmbedLinkFileInfo getEmbedLinkRequest(final String id) { BoxRequestsFile.GetEmbedLinkFileInfo request = new BoxRequestsFile.GetEmbedLinkFileInfo(id, getFileInfoUrl(id), mSession); return request; }
java
public BoxRequestsFile.UpdateFile getUpdateRequest(String id) { BoxRequestsFile.UpdateFile request = new BoxRequestsFile.UpdateFile(id, getFileInfoUrl(id), mSession); return request; }
java
public BoxRequestsFile.CopyFile getCopyRequest(String id, String parentId) { BoxRequestsFile.CopyFile request = new BoxRequestsFile.CopyFile(id, parentId, getFileCopyUrl(id), mSession); return request; }
java
public BoxRequestsFile.UpdateFile getRenameRequest(String id, String newName) { BoxRequestsFile.UpdateFile request = new BoxRequestsFile.UpdateFile(id, getFileInfoUrl(id), mSession); request.setName(newName); return request; }
java
public BoxRequestsFile.UpdateFile getMoveRequest(String id, String parentId) { BoxRequestsFile.UpdateFile request = new BoxRequestsFile.UpdateFile(id, getFileInfoUrl(id), mSession); request.setParentId(parentId); return request; }
java
public BoxRequestsFile.UpdatedSharedFile getCreateSharedLinkRequest(String id) { BoxRequestsFile.UpdatedSharedFile request = new BoxRequestsFile.UpdatedSharedFile(id, getFileInfoUrl(id), mSession) .setAccess(null); return request; }
java
public BoxRequestsFile.AddCommentToFile getAddCommentRequest(String fileId, String message) { BoxRequestsFile.AddCommentToFile request = new BoxRequestsFile.AddCommentToFile(fileId, message, getCommentUrl(), mSession); return request; }
java
public BoxRequestsFile.AddTaggedCommentToFile getAddTaggedCommentRequest(String fileId, String taggedMessage) { BoxRequestsFile.AddTaggedCommentToFile request = new BoxRequestsFile.AddTaggedCommentToFile( fileId, taggedMessage, getCommentUrl(), mSession); return request; }
java
public BoxRequestsFile.UploadFile getUploadRequest(InputStream fileInputStream, String fileName, String destinationFolderId){ BoxRequestsFile.UploadFile request = new BoxRequestsFile.UploadFile(fileInputStream, fileName, destinationFolderId, getFileUploadUrl(), mSession); return request; }
java
public BoxRequestsFile.UploadFile getUploadRequest(File file, String destinationFolderId) { BoxRequestsFile.UploadFile request = new BoxRequestsFile.UploadFile(file, destinationFolderId, getFileUploadUrl(), mSession); return request; }
java
public BoxRequestsFile.UploadNewVersion getUploadNewVersionRequest(InputStream fileInputStream, String destinationFileId){ BoxRequestsFile.UploadNewVersion request = new BoxRequestsFile.UploadNewVersion(fileInputStream, getFileUploadNewVersionUrl(destinationFileId), mSession); return request; }
java
public BoxRequestsFile.UploadNewVersion getUploadNewVersionRequest(File file, String destinationFileId) { try { BoxRequestsFile.UploadNewVersion request = getUploadNewVersionRequest(new FileInputStream(file), destinationFileId); request.setUploadSize(file.length()); request.setModifiedDate(new Date(file.lastModified())); return request; } catch (FileNotFoundException e) { throw new IllegalArgumentException(e); } }
java
public BoxRequestsFile.DownloadFile getDownloadRequest(File target, String fileId) throws IOException{ if (!target.exists()){ throw new FileNotFoundException(); } BoxRequestsFile.DownloadFile request = new BoxRequestsFile.DownloadFile(fileId, target, getFileDownloadUrl(fileId),mSession); return request; }
java
public BoxRequestsFile.DownloadFile getDownloadUrlRequest(File target, String url) throws IOException{ if (!target.exists()){ throw new FileNotFoundException(); } BoxRequestsFile.DownloadFile request = new BoxRequestsFile.DownloadFile(target, url,mSession); return request; }
java
public BoxRequestsFile.DownloadFile getDownloadRequest(OutputStream outputStream, String fileId) { BoxRequestsFile.DownloadFile request = new BoxRequestsFile.DownloadFile(fileId, outputStream, getFileDownloadUrl(fileId),mSession); return request; }
java
public BoxRequestsFile.DownloadThumbnail getDownloadThumbnailRequest(File target, String fileId) throws IOException{ if (!target.exists()){ throw new FileNotFoundException(); } if (target.isDirectory()){ throw new RuntimeException("This endpoint only supports files and does not support directories"); } BoxRequestsFile.DownloadThumbnail request = new BoxRequestsFile.DownloadThumbnail(fileId, target, getThumbnailFileDownloadUrl(fileId), mSession); return request; }
java
public BoxRequestsFile.DownloadThumbnail getDownloadThumbnailRequest(OutputStream outputStream, String fileId) { BoxRequestsFile.DownloadThumbnail request = new BoxRequestsFile.DownloadThumbnail(fileId, outputStream, getThumbnailFileDownloadUrl(fileId), mSession); return request; }
java
public BoxRequestsFile.DownloadRepresentation getDownloadRepresentationRequest(String id, File targetFile, BoxRepresentation representation) { return new BoxRequestsFile.DownloadRepresentation(id, targetFile, representation, mSession); }
java
public BoxRequestsFile.GetTrashedFile getTrashedFileRequest(String id) { BoxRequestsFile.GetTrashedFile request = new BoxRequestsFile.GetTrashedFile(id, getTrashedFileUrl(id), mSession); return request; }
java
public BoxRequestsFile.DeleteTrashedFile getDeleteTrashedFileRequest(String id) { BoxRequestsFile.DeleteTrashedFile request = new BoxRequestsFile.DeleteTrashedFile(id, getTrashedFileUrl(id), mSession); return request; }
java
public BoxRequestsFile.RestoreTrashedFile getRestoreTrashedFileRequest(String id) { BoxRequestsFile.RestoreTrashedFile request = new BoxRequestsFile.RestoreTrashedFile(id, getFileInfoUrl(id), mSession); return request; }
java
public BoxRequestsFile.GetFileComments getCommentsRequest(String id) { BoxRequestsFile.GetFileComments request = new BoxRequestsFile.GetFileComments(id, getFileCommentsUrl(id), mSession); return request; }
java