private void completeFileUpload(boolean success){ if (!AVUtils.isBlankString(token)) { try { JSONObject completeResult = new JSONObject(); completeResult.put("result",success); completeResult.put("token",this.token); PaasClient.storageInstance().postObject("fileCallback", completeResult.toJSONString(), false, new GenericObjectCallback() {}); } catch (Exception e) { // ignore } } }
private static void getServerDateInBackground(boolean sync, final AVServerDateCallback callback) { PaasClient.storageInstance().getObject("date", null, sync, null, new GenericObjectCallback() { @Override public void onSuccess(String content, AVException e) { try { Date date = AVUtils.dateFromMap(JSON.parseObject(content, Map.class)); if (callback != null) { callback.internalDone(date, null); } } catch (Exception ex) { if (callback != null) { callback.internalDone(null, AVErrorUtils.createException(ex, null)); } } } @Override public void onFailure(Throwable error, String content) { if (callback != null) { callback.internalDone(null, AVErrorUtils.createException(error, content)); } } }); }
private synchronized void sendArchivedRequests(boolean sync) { if (REPORTENABLEFLAG) { PaasClient.statistisInstance().handleAllArchivedRequest(sync); } }
@Override public void done(AVException e) { for (AVObject o : objects) { o.running = true; o.buildParameterForNonSavedObject(list); } PaasClient.storageInstance().postBatchSave(list, sync, false, null, genericObjectCallback, null, null); }
public static PaasClient.AVHttpClient getDirectlyClientForUse() { return PaasClient.storageInstance().clientInstance(); }
public void postBatchSave(final List list, final boolean sync, final boolean isEventually, final Map<String, String> header, final GenericObjectCallback callback, final String objectId, final String _internalId) { try { Map params = new HashMap(); params.put("requests", list); String paramString = AVUtils.jsonStringFromMapWithNull(params); if (isEventually) { File archivedFile = archiveRequest("post", batchSaveRelativeUrl(), paramString, objectId, _internalId); handleArchivedRequest(archivedFile, sync, callback); } else { String url = buildUrl(batchSaveRelativeUrl()); if (AVOSCloud.isDebugLogEnabled()) { dumpHttpPostRequest(header, url, paramString); } AsyncHttpResponseHandler handler = createPostHandler(callback); AVHttpClient client = AVHttpClient.clientInstance(); Request.Builder builder = new Request.Builder(); builder.url(url).post(RequestBody.create(AVHttpClient.JSON, paramString)); updateHeaders(builder, header, callback != null && callback.isRequestStatisticNeed()); client.execute(builder.build(), sync, handler); } } catch (Exception exception) { processException(exception, callback); } }
public void postObject(final String relativePath, String object, final Map<String, String> headers, boolean sync, boolean isEventually, GenericObjectCallback callback, String objectId, String _internalId) { try { if (isEventually) { File archivedFile = archiveRequest("post", relativePath, object, objectId, _internalId); handleArchivedRequest(archivedFile, sync, callback); } else { String url = buildUrl(relativePath); if (AVOSCloud.isDebugLogEnabled()) { dumpHttpPostRequest(null, url, object); } AsyncHttpResponseHandler handler = createPostHandler(callback); AVHttpClient client = AVHttpClient.clientInstance(); Request.Builder builder = new Request.Builder(); updateHeaders(builder, headers, callback != null && callback.isRequestStatisticNeed()); builder.url(url).post(RequestBody.create(AVHttpClient.JSON, object)); client.execute(builder.build(), sync, handler); } } catch (Exception exception) { processException(exception, callback); } }
public void putObject(final String relativePath, String object, boolean sync, boolean isEventually, Map<String, String> header, GenericObjectCallback callback, String objectId, String _internalId) { try { if (isEventually) { File archivedFile = archiveRequest("put", relativePath, object, objectId, _internalId); handleArchivedRequest(archivedFile, sync, callback); } else { String url = buildUrl(relativePath); AsyncHttpResponseHandler handler = createPostHandler(callback); if (AVOSCloud.isDebugLogEnabled()) { dumpHttpPutRequest(header, url, object); } AVHttpClient client = AVHttpClient.clientInstance(); Request.Builder builder = new Request.Builder(); builder.url(url).put(RequestBody.create(AVHttpClient.JSON, object)); updateHeaders(builder, header, callback != null && callback.isRequestStatisticNeed()); client.execute(builder.build(), sync, handler); } } catch (Exception exception) { processException(exception, callback); } }
public void deleteObject(final String relativePath, boolean sync, boolean isEventually, GenericObjectCallback callback, String objectId, String _internalId) { try { if (isEventually) { File archivedFile = archiveRequest("delete", relativePath, null, objectId, _internalId); handleArchivedRequest(archivedFile, sync, callback); } else { String url = buildUrl(relativePath); if (AVOSCloud.isDebugLogEnabled()) { dumpHttpDeleteRequest(null, url, null); } AsyncHttpResponseHandler handler = createPostHandler(callback); AVHttpClient client = AVHttpClient.clientInstance(); Request.Builder builder = new Request.Builder(); updateHeaders(builder, null, callback != null && callback.isRequestStatisticNeed()); builder.url(url).delete(); client.execute(builder.build(), sync, handler); } } catch (Exception exception) { processException(exception, callback); } }
public void postBatchObject(List<Object> parameters, boolean sync, Map<String, String> header, GenericObjectCallback callback) { try { String url = batchUrl(); Map<String, Object> requests = batchRequest(parameters); String json = JSON.toJSONString(requests); if (AVOSCloud.isDebugLogEnabled()) { dumpHttpPostRequest(header, url, json); } AsyncHttpResponseHandler handler = createPostHandler(callback); AVHttpClient client = AVHttpClient.clientInstance(); Request.Builder builder = new Request.Builder(); builder.url(url).post(RequestBody.create(AVHttpClient.JSON, json)); updateHeaders(builder, header, callback != null && callback.isRequestStatisticNeed()); client.execute(builder.build(), sync, handler); } catch (Exception exception) { processException(exception, callback); } }
protected static void resetPasswordBySmsCodeInBackground(String smsCode, String newPassword, boolean sync, UpdatePasswordCallback callback) { final UpdatePasswordCallback internalCallback = callback; if (AVUtils.isBlankString(smsCode) || !AVUtils.checkMobileVerifyCode(smsCode)) { callback .internalDone(new AVException(AVException.INVALID_PHONE_NUMBER, "Invalid Verify Code")); return; } String endpointer = String.format("resetPasswordBySmsCode/%s", smsCode); Map<String, Object> params = new HashMap<String, Object>(); params.put("password", newPassword); PaasClient.storageInstance().putObject(endpointer, AVUtils.restfulServerData(params), sync, null, new GenericObjectCallback() { @Override public void onFailure(Throwable error, String content) { if (internalCallback != null) { internalCallback.internalDone(new AVException(content, error)); } } @Override public void onSuccess(String content, AVException e) { internalCallback.internalDone(e); } }, null, null); }
@Override public void onFailure(Throwable error, String content) { getObject(relativePath, parameters, sync, header, callback, policy); } });
private void init() { objectId = ""; isDataReady = false; if (PaasClient.storageInstance().getDefaultACL() != null) { acl = new AVACL(PaasClient.storageInstance().getDefaultACL()); } running = false; }
PaasClient.storageInstance().putObject( String.format(FEEDBACK_PUT_PATH, currentComment.getObjectId()), mapFromObject(currentComment, false), true, null, new GenericObjectCallback() { PaasClient.storageInstance().postObject( i == 0 ? FEEDBACK_PATH : String.format(FEEDBACK_THREAD_PATH, commentList.get(0) .getObjectId()), mapFromObject(currentComment, i != 0), true,
postObject(relativePath, paramString, sync, newCallback); } else if ("put".equalsIgnoreCase(method)) { putObject(relativePath, paramString, sync, null, newCallback, objectId, _internalId); } else if ("delete".equalsIgnoreCase(method)) { deleteObject(relativePath, sync, newCallback, objectId, _internalId);
private static void sendAnalysisRequest(String jsonString, boolean sync, boolean eventually, GenericObjectCallback callback) { if (REPORTENABLEFLAG) { PaasClient.statistisInstance().postObject("stats/collect", jsonString, sync, eventually, callback, null, AVUtils.md5(jsonString)); } }
private static <T> void rpcFunctionInBackground(String name, Object params, final boolean sync, final FunctionCallback<T> callback) { String paramString = AVUtils.restfulCloudData(params); PaasClient.cloudInstance().postObject("call/" + name, paramString, sync, new GenericObjectCallback() { @Override public void onSuccess(String content, AVException e) { callback.internalDone((T) convertCloudResponse(content), e); } @Override public void onFailure(Throwable error, String content) { LogUtil.log.d(content + error); callback.internalDone(null, AVErrorUtils.createException(error, content)); } }); } }
postObject(relativePath, paramString, sync, newCallback); } else if ("put".equalsIgnoreCase(method)) { putObject(relativePath, paramString, sync, null, newCallback, objectId, _internalId); } else if ("delete".equalsIgnoreCase(method)) { deleteObject(relativePath, sync, newCallback, objectId, _internalId);
public void postObject(final String relativePath, String object, final Map<String, String> headers, boolean sync, GenericObjectCallback callback) { postObject(relativePath, object, headers, sync, false, callback, null, null); }
private Map<String, Object> wrapperRequestBody(Map<String, Object> requestBody, List children, boolean compoundRequest) { requestBody.put("__children", children); if (acl != null) { requestBody.putAll(AVUtils.getParsedMap(acl.getACLMap())); } requestBody.put("__internalId", internalId()); String method = "PUT"; boolean post = (AVUtils.isBlankString(getObjectId()) || alwaysUsePost()) && !compoundRequest; if (post) { method = "POST"; } String path = AVPowerfulUtils.getBatchEndpoint(PaasClient.storageInstance().getApiVersion(), this, post); return PaasClient.storageInstance().batchItemMap(method, path, requestBody, getBatchParams()); }