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); } }
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 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 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 (InternalConfigurationController.globalInstance().getInternalLogger().isDebugEnabled()) { dumpHttpPostRequest(header, url, json); } AsyncHttpResponseHandler handler = createPostHandler(callback); AVHttpClient client = 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); } }
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 (InternalConfigurationController.globalInstance().getInternalLogger().isDebugEnabled()) { dumpHttpPostRequest(header, url, paramString); } AsyncHttpResponseHandler handler = createPostHandler(callback); AVHttpClient client = clientInstance(); Request.Builder builder = new Request.Builder(); updateHeaders(builder, header, callback != null && callback.isRequestStatisticNeed()); builder.url(url).post(RequestBody.create(AVHttpClient.JSON, paramString)); client.execute(builder.build(), sync, handler); } } catch (Exception exception) { processException(exception, callback); } }
public void getObject(final String relativePath, final AVRequestParams parameters, final boolean sync, final Map<String, String> inputHeader, GenericObjectCallback callback, final AVQuery.CachePolicy policy, final boolean fetchRetry) { Map<String, String> myHeader = inputHeader; if (inputHeader == null) { myHeader = new HashMap<String, String>(); } updateHeaderForPath(relativePath, parameters, myHeader); String url = buildUrl(relativePath, parameters); AsyncHttpResponseHandler handler = createGetHandler(callback, policy, url); if (InternalConfigurationController.globalInstance().getInternalLogger().isDebugEnabled()) { dumpHttpGetRequest(buildUrl(relativePath), parameters == null ? null : parameters.getDumpQueryString()); } AVHttpClient client = clientInstance(); Request.Builder builder = new Request.Builder(); builder.url(url).get(); try { updateHeaders(builder, myHeader, callback != null && callback.isRequestStatisticNeed()); } catch (AVException e) { processException(e, callback); } client.execute(builder.build(), sync, handler); }
public void postObject(final String relativePath, String object, 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 (InternalConfigurationController.globalInstance().getInternalLogger().isDebugEnabled()) { dumpHttpPostRequest(null, url, object); } AsyncHttpResponseHandler handler = createPostHandler(callback); AVHttpClient client = clientInstance(); Request.Builder builder = new Request.Builder(); updateHeaders(builder, null, 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 (InternalConfigurationController.globalInstance().getInternalLogger().isDebugEnabled()) { dumpHttpPutRequest(header, url, object); } AVHttpClient client = 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, Map<String, Object> object, 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); String body = AVUtils.jsonStringFromMapWithNull(object); if (InternalConfigurationController.globalInstance().getInternalLogger().isDebugEnabled()) { dumpHttpDeleteRequest(null, url, body); } AsyncHttpResponseHandler handler = createPostHandler(callback); AVHttpClient client = clientInstance(); Request.Builder builder = new Request.Builder(); updateHeaders(builder, null, callback != null && callback.isRequestStatisticNeed()); builder.url(url) .delete(RequestBody.create(AVHttpClient.JSON, body)); client.execute(builder.build(), sync, handler); } } catch (Exception exception) { processException(exception, callback); } }