Skip to content

Commit 00a9ccf

Browse files
committed
Merge pull request #21 from rgauss/master
More In-Depth Handling of Job Progress and Detail
2 parents 851c9cc + dcdb53c commit 00a9ccf

File tree

2 files changed

+69
-6
lines changed

2 files changed

+69
-6
lines changed

src/main/java/de/bitzeche/video/transcoding/zencoder/IZencoderClient.java

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,60 @@ public Document createJob(ZencoderJob job)
3636
* Send a jobProgress request for a job.
3737
* @param jobId ID for the requested job.
3838
* @return State of job, or null if unable to parse response.
39+
* @deprecated use {@link #getJobState(int)}
3940
*/
4041
public ZencoderNotificationJobState jobProgress(int jobId);
4142

4243
/**
4344
* Send a jobProgress request for a job.
4445
* @param job
4546
* @return State of job, or null if unable to parse response.
47+
* @deprecated use {@link #getJobState(ZencoderJob)}
4648
*/
4749
public ZencoderNotificationJobState jobProgress(ZencoderJob job);
48-
50+
51+
/**
52+
* Send a job detail request for a job.
53+
* @param jobId ID for the requested job.
54+
* @return XML Response from zencoder
55+
*/
56+
public Document getJobDetails(int jobId);
57+
58+
/**
59+
* Send a job detail request for a job.
60+
* @param job
61+
* @return XML Response from zencoder
62+
*/
63+
public Document getJobDetails(ZencoderJob job);
64+
65+
/**
66+
* Send a jobProgress request for a job.
67+
* @param jobId ID for the requested job.
68+
* @return State of job, or null if unable to parse response.
69+
*/
70+
public Document getJobProgress(int jobId);
71+
72+
/**
73+
* Send a jobProgress request for a job.
74+
* @param job
75+
* @return State of job, or null if unable to parse response.
76+
*/
77+
public Document getJobProgress(ZencoderJob job);
78+
79+
/**
80+
* Send a jobProgress request to determine the state of a job.
81+
* @param jobId ID for the requested job.
82+
* @return State of job, or null if unable to parse response.
83+
*/
84+
public ZencoderNotificationJobState getJobState(int jobId);
85+
86+
/**
87+
* Send a jobProgress request to determine the state of a job.
88+
* @param job
89+
* @return State of job, or null if unable to parse response.
90+
*/
91+
public ZencoderNotificationJobState getJobState(ZencoderJob job);
92+
4993
/**
5094
* Send a resubmit request for a job.
5195
* @param jobId ID for the requested job.

src/main/java/de/bitzeche/video/transcoding/zencoder/ZencoderClient.java

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -175,13 +175,18 @@ public ZencoderNotificationJobState jobProgress(ZencoderJob job) {
175175
}
176176

177177
public ZencoderNotificationJobState jobProgress(int id) {
178-
if (zencoderAPIVersion != ZencoderAPIVersion.API_V2) {
179-
LOGGER.warn("jobProgress is only available for API v2. Returning null.");
178+
return getJobState(id);
179+
}
180+
181+
public ZencoderNotificationJobState getJobState(ZencoderJob job) {
182+
return getJobState(job.getJobId());
183+
}
184+
185+
public ZencoderNotificationJobState getJobState(int id) {
186+
Document response = getJobProgress(id);
187+
if (response == null) {
180188
return null;
181189
}
182-
String url = zencoderAPIBaseUrl + "jobs/" + id
183-
+ "/progress.xml?api_key=" + zencoderAPIKey;
184-
Document response = sendGetRequest(url);
185190
String stateString = null;
186191
try {
187192
stateString = (String) xPath.evaluate("/api-response/state",
@@ -195,6 +200,20 @@ public ZencoderNotificationJobState jobProgress(int id) {
195200
return null;
196201
}
197202

203+
public Document getJobProgress(ZencoderJob job) {
204+
return getJobProgress(job.getJobId());
205+
}
206+
207+
public Document getJobProgress(int id) {
208+
if (zencoderAPIVersion != ZencoderAPIVersion.API_V2) {
209+
LOGGER.warn("jobProgress is only available for API v2. Returning null.");
210+
return null;
211+
}
212+
String url = zencoderAPIBaseUrl + "jobs/" + id
213+
+ "/progress.xml?api_key=" + zencoderAPIKey;
214+
return sendGetRequest(url);
215+
}
216+
198217
public Document getJobDetails(ZencoderJob job) {
199218
return getJobDetails(job.getJobId());
200219
}

0 commit comments

Comments
 (0)