use of org.apache.commons.httpclient.DefaultHttpMethodRetryHandler in project tdi-studio-se by Talend.
the class SpagoBITalendEngineClient method getEngineComplianceVersion.
public static String getEngineComplianceVersion(String url) throws EngineUnavailableException, ServiceInvocationFailedException {
String version;
HttpClient client;
PostMethod method;
NameValuePair[] nameValuePairs;
version = null;
client = new HttpClient();
method = new PostMethod(url);
// Provide custom retry handler is necessary
method.getParams().setParameter(HttpMethodParams.RETRY_HANDLER, new DefaultHttpMethodRetryHandler(3, false));
//$NON-NLS-1$ //$NON-NLS-2$
nameValuePairs = new NameValuePair[] { new NameValuePair("infoType", "complianceVersion") };
method.setRequestBody(nameValuePairs);
try {
// Execute the method.
int statusCode = client.executeMethod(method);
if (statusCode != HttpStatus.SC_OK) {
throw new ServiceInvocationFailedException(Messages.getString("SpagoBITalendEngineClient.serviceFailed"), method.getStatusLine().toString(), //$NON-NLS-1$
method.getResponseBodyAsString());
} else {
version = method.getResponseBodyAsString();
}
} catch (HttpException e) {
//$NON-NLS-1$
throw new EngineUnavailableException(Messages.getString("SpagoBITalendEngineClient.5", e.getMessage()));
} catch (IOException e) {
//$NON-NLS-1$
throw new EngineUnavailableException(Messages.getString("SpagoBITalendEngineClient.6", e.getMessage()));
} finally {
// Release the connection.
method.releaseConnection();
}
return version;
}
use of org.apache.commons.httpclient.DefaultHttpMethodRetryHandler in project tdi-studio-se by Talend.
the class SpagoBITalendEngineClient_0_5_0 method getEngineInfo.
private String getEngineInfo(String infoType) throws EngineUnavailableException, ServiceInvocationFailedException {
String version;
HttpClient client;
PostMethod method;
NameValuePair[] nameValuePairs;
version = null;
client = new HttpClient();
method = new PostMethod(getServiceUrl(ENGINE_INFO_SERVICE));
// Provide custom retry handler is necessary
method.getParams().setParameter(HttpMethodParams.RETRY_HANDLER, new DefaultHttpMethodRetryHandler(3, false));
//$NON-NLS-1$
nameValuePairs = new NameValuePair[] { new NameValuePair("infoType", infoType) };
method.setRequestBody(nameValuePairs);
try {
// Execute the method.
int statusCode = client.executeMethod(method);
if (statusCode != HttpStatus.SC_OK) {
throw new ServiceInvocationFailedException(Messages.getString("SpagoBITalendEngineClient_0_5_0.serviceExcFailed") + ENGINE_INFO_SERVICE, //$NON-NLS-1$
method.getStatusLine().toString(), method.getResponseBodyAsString());
} else {
version = method.getResponseBodyAsString();
}
} catch (HttpException e) {
//$NON-NLS-1$
throw new EngineUnavailableException(Messages.getString("SpagoBITalendEngineClient_0_5_0.protocolViolation") + e.getMessage());
} catch (IOException e) {
//$NON-NLS-1$
throw new EngineUnavailableException(Messages.getString("SpagoBITalendEngineClient_0_5_0.transportError") + e.getMessage());
} finally {
// Release the connection.
method.releaseConnection();
}
return version;
}
Aggregations