List of usage examples for org.apache.thrift TDeserializer fromString
public void fromString(TBase base, String data) throws TException
From source file:com.onesite.sdk.api.ApiMethod.java
License:Apache License
/** * Call the API via the OnesiteClient and populate the TBase obj. A OnesiteException * will be returned if an error occured during deserialization of the TBase obj * /*from ww w . ja v a 2s . c o m*/ * @param path * @param params * @param type * * @throws Exception */ protected void get(String path, Map<String, String> params, TBase obj) throws Exception { try { this.client.get(path, params); } catch (Exception e) { log.error("Error occurred during client call to " + path); throw e; } if (this.client.getHttpStatusCode() == HttpStatus.SC_OK) { try { TDeserializer deserializer = new TDeserializer(); deserializer.fromString(obj, this.client.getHttpResult()); Status status = (Status) obj.getFieldValue(obj.fieldForId(1)); if (status.getCode() != OnesiteResultCode.OK) { throw new OnesiteException(status.getCode(), status.getMessage()); } } catch (Exception e) { throw new Exception("Error deserializing result ", e); } } else { throw new OnesiteException(this.client.getHttpStatusCode(), this.client.getHttpStatusMessage()); } }