/** * Retrieves and loads the value of the Item specified by the ItemId given from the Cloud * Synchronously <strong>Use only if you plan to do your own threading</strong> * * @param itemId the Id of the Item to retrieve from the ClearBlade Cloud * @throws ClearBladeException will be thrown if no Item is found or if the API call failed */ public void load(String itemId, final DataCallback callback) throws ClearBladeException { // create the query string to look for the object loadSetup(itemId); // PlatformResponse<String> result = request.execute(); // if(result.getError()) { // throw new ClearBladeException("Call to Load failed:"+result.getData()); // } else { // this.json = convertJsonArrayToJsonObject(result.getData()); // } DataTask asyncFetch = new DataTask( new PlatformCallback(this, callback) { @Override public void done(String response) { _item.json = convertJsonToJsonObject(response); Item[] ret = {_item}; callback.done(ret); } @Override public void error(ClearBladeException exception) { callback.error(exception); } }); asyncFetch.execute(request); }
/** * If Item has not been saved to the Cloud, it will save it, otherwise it will modify the Item in * the cloud. It loads the value of the Item from the Cloud with the most up-to-date Item. After * creation of an Item it will have a ItemId. This function operates Synchronously. <strong>Use * only if you plan to do your own threading</strong> * * @throws ClearBladeException will be thrown if no Item is found or if the API call failed */ public void save(final DataCallback callback) { saveSetup(); DataTask asyncFetch = new DataTask( new PlatformCallback(this, callback) { @Override public void done(String response) { _item.json = convertJsonToJsonObject(response); Item[] ret = {_item}; callback.done(ret); } @Override public void error(ClearBladeException exception) { callback.error(exception); } }); asyncFetch.execute(request); clearChanges(); }