use of org.eclipse.jetty.client.api.Request in project camel by apache.
the class DefaultRestClient method updateSObject.
@Override
public void updateSObject(String sObjectName, String id, InputStream sObject, ResponseCallback callback) {
final Request patch = getRequest("PATCH", sobjectsUrl(sObjectName + "/" + id));
// requires authorization token
setAccessToken(patch);
// input stream as entity content
patch.content(new InputStreamContentProvider(sObject));
patch.header(HttpHeader.CONTENT_TYPE, PayloadFormat.JSON.equals(format) ? APPLICATION_JSON_UTF8 : APPLICATION_XML_UTF8);
doHttpRequest(patch, new DelegatingClientCallback(callback));
}
use of org.eclipse.jetty.client.api.Request in project camel by apache.
the class DefaultRestClient method apexCall.
@Override
public void apexCall(String httpMethod, String apexUrl, Map<String, Object> queryParams, InputStream requestDto, ResponseCallback callback) {
// create APEX call request
final Request request;
try {
request = getRequest(httpMethod, apexCallUrl(apexUrl, queryParams));
// set request SObject and content type
if (requestDto != null) {
request.content(new InputStreamContentProvider(requestDto));
request.header(HttpHeader.CONTENT_TYPE, PayloadFormat.JSON.equals(format) ? APPLICATION_JSON_UTF8 : APPLICATION_XML_UTF8);
}
// requires authorization token
setAccessToken(request);
doHttpRequest(request, new DelegatingClientCallback(callback));
} catch (UnsupportedEncodingException e) {
String msg = "Unexpected error: " + e.getMessage();
callback.onResponse(null, new SalesforceException(msg, e));
} catch (URISyntaxException e) {
String msg = "Unexpected error: " + e.getMessage();
callback.onResponse(null, new SalesforceException(msg, e));
}
}
use of org.eclipse.jetty.client.api.Request in project camel by apache.
the class DefaultRestClient method getBasicInfo.
@Override
public void getBasicInfo(String sObjectName, ResponseCallback callback) {
Request get = getRequest(HttpMethod.GET, sobjectsUrl(sObjectName + "/"));
// requires authorization token
setAccessToken(get);
doHttpRequest(get, new DelegatingClientCallback(callback));
}
use of org.eclipse.jetty.client.api.Request in project camel by apache.
the class DefaultRestClient method createSObject.
@Override
public void createSObject(String sObjectName, InputStream sObject, ResponseCallback callback) {
// post the sObject
final Request post = getRequest(HttpMethod.POST, sobjectsUrl(sObjectName));
// authorization
setAccessToken(post);
// input stream as entity content
post.content(new InputStreamContentProvider(sObject));
post.header(HttpHeader.CONTENT_TYPE, PayloadFormat.JSON.equals(format) ? APPLICATION_JSON_UTF8 : APPLICATION_XML_UTF8);
doHttpRequest(post, new DelegatingClientCallback(callback));
}
use of org.eclipse.jetty.client.api.Request in project camel by apache.
the class DefaultRestClient method getBlobField.
@Override
public void getBlobField(String sObjectName, String id, String blobFieldName, ResponseCallback callback) {
final Request get = getRequest(HttpMethod.GET, sobjectsUrl(sObjectName + "/" + id + "/" + blobFieldName));
// TODO this doesn't seem to be required, the response is always the content binary stream
//get.header(HttpHeader.ACCEPT_ENCODING, "base64");
// requires authorization token
setAccessToken(get);
doHttpRequest(get, new DelegatingClientCallback(callback));
}
Aggregations