03-14-2016 01:48 AM
public void setRestTemplate(String username, String password) {
restTemplate = (this.restTemplate == null) ? new RestTemplate() : restTemplate;
ClientHttpRequestFactory requestFactory = null;
try {
requestFactory = getRequestFactory(username, password);
restTemplate.setRequestFactory(requestFactory);
} catch (Exception e) {
System.out.println("Not able to create rest template" + e);
}
}
public ClientHttpRequestFactory getRequestFactory(String activiti_username, String activiti_password) {
ClientHttpRequestFactory requestFactory = null;
try {
final RequestConfig config = RequestConfig.custom().setConnectTimeout(TIME_OUT * 1000)
.setConnectionRequestTimeout(TIME_OUT * 1000).setSocketTimeout(TIME_OUT * 1000).build();
final BasicCredentialsProvider credentialsProvider = new BasicCredentialsProvider();
credentialsProvider.setCredentials(new AuthScope(HOST, PORT, AuthScope.ANY_REALM),
new UsernamePasswordCredentials(activiti_username, activiti_password));
final CloseableHttpClient client = HttpClientBuilder.create().setDefaultRequestConfig(config)
.setDefaultCredentialsProvider(credentialsProvider).build();
requestFactory = new HttpComponentsClientHttpRequestFactory(client);
} catch (NumberFormatException e) {
System.out.println("Not able to create request factory: getRequestFactory" + e);
} catch (Exception e) {
System.out.println("Not able to create request factory: getRequestFactory" + e);
}
return requestFactory;
}
private void getProcessDefinitions() {
String url = BASE_URl + "repository/process-definitions";
String result = restTemplate.getForObject(url, String.class);
System.out.println(result);
}
03-14-2016 03:46 AM
03-14-2016 11:06 PM
Tags
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.