Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ public class XecdApiConfigBean
private String apiKey;
private String serverPrefix;
private Integer connectTimeout;
private Boolean useSystemProperties;

public String getAccountId()
{
Expand Down Expand Up @@ -55,4 +56,12 @@ public void setConnectTimeout(Integer connectTimeout)
{
this.connectTimeout = connectTimeout;
}

public Boolean useSystemProperties() {
return useSystemProperties;
}

public void setUseSystemProperties(final Boolean useSystemProperties) {
this.useSystemProperties = useSystemProperties;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,30 +61,30 @@ public class XecdApiServiceImpl implements XecdApiService
this.apiKey = config.getApiKey();
this.serverPrefix = config.getServerPrefix() != null ? config.getServerPrefix() : this.serverPrefix;
this.jsonUtils = new JsonUtils();
this.wsClient = new XecdHttpClientImpl(config.getConnectTimeout());
this.wsClient = new XecdHttpClientImpl(config.getConnectTimeout(), config.useSystemProperties());
}

/**
* Looks at the environment variables to satisfy required properties
* - XECD_ACCOUNT_ID
* - XECD_API_KEY
* @throws XecdApiException
* @throws XecdApiException
*/
XecdApiServiceImpl() throws XecdApiException
{
String apiKeyVar = System.getenv("XECD_API_KEY");
String accountIdVar = System.getenv("XECD_ACCOUNT_ID");
this.wsClient = new XecdHttpClientImpl(null);

this.wsClient = new XecdHttpClientImpl(null, null);

if(apiKeyVar != null && accountIdVar != null && !apiKeyVar.isEmpty() && !accountIdVar.isEmpty())
{
logger.debug("INITIALIZING WITH ENVIRONMENT VARIABLES");

this.apiKey = System.getenv("XECD_API_KEY");
this.accountId = System.getenv("XECD_ACCOUNT_ID");
this.jsonUtils = new JsonUtils();

}
else
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,17 @@ public class XecdHttpClientImpl implements XecdHttpClient

private HttpClient client = null;

public XecdHttpClientImpl(Integer connectTimeout)
public XecdHttpClientImpl(Integer connectTimeout, Boolean useSystemProperties)
{
HttpClientBuilder builder = HttpClientBuilder.create();
if (connectTimeout != null)
{
RequestConfig requestConfig = RequestConfig.custom().setConnectTimeout(connectTimeout).build();
builder.setDefaultRequestConfig(requestConfig);
}
if(useSystemProperties != null && useSystemProperties) {
builder.useSystemProperties();
}
try
{
SSLContext sslContext = SSLContext.getInstance("TLSv1.2");
Expand Down