Skip to content
Closed
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 @@ -63,18 +63,28 @@ public class ZencoderClient implements IZencoderClient {
private Client httpClient;
private final String zencoderAPIBaseUrl;
private final String zencoderAPIKey;
private final Strign zencoderReadOnlyAPIKey;
private final ZencoderAPIVersion zencoderAPIVersion;
private XPath xPath;

private final int MAX_CONNECTION_ATTEMPTS = 5;
private int currentConnectionAttempt = 0;

public ZencoderClient(String zencoderApiKey) {
this(zencoderApiKey, ZencoderAPIVersion.API_V1);
this(zencoderApiKey, null, ZencoderAPIVersion.API_V1);
}


public ZencoderClient(String zencdoerApiKey, String zencoderReadOnlyApiKey) {
this(zencoderApiKey, zencoderReadOnlyApiKey, ZencoderAPIVersion.API_V1);
}

public ZencoderClient(String zencoderApiKey, ZencoderAPIVersion apiVersion) {
this(zencoderApiKey, null, apiVersion);
}

public ZencoderClient(String zencoderApiKey, String zencoderReadOnlyApiKey, ZencoderAPIVersion apiVersion) {
this.zencoderAPIKey = zencoderApiKey;
this.zencoderReadOnlyAPIKey = zencoderReadOnlyApiKey;
if (ZencoderAPIVersion.API_DEV.equals(apiVersion)) {
LOGGER.warn("!!! Using development version of zencoder API !!!");
}
Expand Down Expand Up @@ -267,8 +277,10 @@ public Document getJobProgress(int id) {
LOGGER.warn("jobProgress is only available for API v2. Returning null.");
return null;
}
String apiKey = zencoderAPIKey;
if(zencoderReadOnlyAPIKey != null) apiKey = zencoderReadOnlyAPIKey;
String url = zencoderAPIBaseUrl + "jobs/" + id
+ "/progress.xml?api_key=" + zencoderAPIKey;
+ "/progress.xml?api_key=" + apiKey;
Document result = sendGetRequest(url);
if(result == null) {
currentConnectionAttempt++;
Expand All @@ -289,8 +301,10 @@ public Document getJobDetails(int id) {
LOGGER.error("Reached maximum number of attempts for getting job details. Aborting and returning null");
return null;
}
String apiKey = zencoderAPIKey;
if(zencoderReadOnlyAPIKey != null) apiKey = zencoderReadOnlyAPIKey;
String url = zencoderAPIBaseUrl + "jobs/" + id + ".xml?api_key="
+ zencoderAPIKey;
+ apiKey;
Document result = sendGetRequest(url);
if(result == null) {
currentConnectionAttempt++;
Expand Down