use of org.opencastproject.scheduler.api.SchedulerException in project opencast by opencast.
the class SchedulerServiceRemoteImpl method updateReviewStatus.
@Override
public void updateReviewStatus(String mediapackageId, ReviewStatus reviewStatus) throws NotFoundException, UnauthorizedException, SchedulerException {
HttpPut put = new HttpPut(UrlSupport.concat(mediapackageId, "reviewStatus"));
List<BasicNameValuePair> params = new ArrayList<BasicNameValuePair>();
params.add(new BasicNameValuePair("reviewStatus", reviewStatus.toString()));
put.setEntity(new UrlEncodedFormEntity(params, UTF_8));
HttpResponse response = getResponse(put, SC_OK, SC_NOT_FOUND, SC_UNAUTHORIZED);
try {
if (response != null) {
if (SC_NOT_FOUND == response.getStatusLine().getStatusCode()) {
logger.warn("Event with mediapackage id {} was not found by the scheduler service", mediapackageId);
throw new NotFoundException("Event with mediapackage id '" + mediapackageId + "' not found on remote scheduler service!");
} else if (SC_UNAUTHORIZED == response.getStatusLine().getStatusCode()) {
logger.info("Unauthorized to update review status of the event {}.", mediapackageId);
throw new UnauthorizedException("Unauthorized to update review status of the event " + mediapackageId);
} else if (SC_OK == response.getStatusLine().getStatusCode()) {
logger.info("Event with mediapackage id {} successfully updated with review status.", mediapackageId);
return;
} else {
throw new SchedulerException("Unexpected status code " + response.getStatusLine());
}
}
} catch (NotFoundException e) {
throw e;
} catch (UnauthorizedException e) {
throw e;
} catch (Exception e) {
throw new SchedulerException("Unable to update event with mediapackage id " + mediapackageId + " to the scheduler service: " + e);
} finally {
closeConnection(response);
}
throw new SchedulerException("Unable to update event with mediapackage id " + mediapackageId);
}
use of org.opencastproject.scheduler.api.SchedulerException in project opencast by opencast.
the class SchedulerServiceRemoteImpl method getMediaPackage.
@Override
public MediaPackage getMediaPackage(String eventId) throws NotFoundException, UnauthorizedException, SchedulerException {
HttpGet get = new HttpGet(eventId.concat("/mediapackage.xml"));
HttpResponse response = getResponse(get, SC_OK, SC_NOT_FOUND, SC_UNAUTHORIZED);
try {
if (response != null) {
if (SC_NOT_FOUND == response.getStatusLine().getStatusCode()) {
throw new NotFoundException("Event mediapackage '" + eventId + "' not found on remote scheduler service!");
} else if (SC_UNAUTHORIZED == response.getStatusLine().getStatusCode()) {
logger.info("Unauthorized to get mediapacakge of the event {}.", eventId);
throw new UnauthorizedException("Unauthorized to get mediapackage of the event " + eventId);
} else {
MediaPackage mp = MediaPackageParser.getFromXml(EntityUtils.toString(response.getEntity(), UTF_8));
logger.info("Successfully get event mediapackage {} from the remote scheduler service", eventId);
return mp;
}
}
} catch (NotFoundException e) {
throw e;
} catch (UnauthorizedException e) {
throw e;
} catch (Exception e) {
throw new SchedulerException("Unable to parse event media package from remote scheduler service: " + e);
} finally {
closeConnection(response);
}
throw new SchedulerException("Unable to get event media package from remote scheduler service");
}
use of org.opencastproject.scheduler.api.SchedulerException in project opencast by opencast.
the class SchedulerServiceRemoteImpl method getTransactionBySource.
@Override
public SchedulerTransaction getTransactionBySource(String source) throws NotFoundException, SchedulerException {
HttpGet get = new HttpGet("transaction/source/".concat(source));
HttpResponse response = getResponse(get, SC_OK, SC_NOT_FOUND);
try {
if (response != null) {
if (SC_NOT_FOUND == response.getStatusLine().getStatusCode()) {
throw new NotFoundException("Scheduler transaction with source '" + source + "' not found on remote scheduler service!");
} else {
String transactionJson = EntityUtils.toString(response.getEntity(), UTF_8);
JSONObject json = (JSONObject) parser.parse(transactionJson);
String transactionId = (String) json.get("id");
String schedulingSource = (String) json.get("source");
logger.info("Successfully get scheduler transaction with source {} from the remote scheduler service", source);
return new SchedulerTransactionRemoteImpl(transactionId, schedulingSource);
}
}
} catch (NotFoundException e) {
throw e;
} catch (Exception e) {
throw new SchedulerException("Unable to get scheduler transaction from remote scheduler service: " + e);
} finally {
closeConnection(response);
}
throw new SchedulerException("Unable to get scheduler transaction from remote scheduler service");
}
use of org.opencastproject.scheduler.api.SchedulerException in project opencast by opencast.
the class SchedulerServiceRemoteImpl method removeScheduledRecordingsBeforeBuffer.
@Override
public void removeScheduledRecordingsBeforeBuffer(long buffer) throws UnauthorizedException, SchedulerException {
HttpPost post = new HttpPost("/removeOldScheduledRecordings");
logger.debug("Start removing old schedules before buffer {} through remote Schedule Service", buffer);
List<BasicNameValuePair> params = new ArrayList<BasicNameValuePair>();
params.add(new BasicNameValuePair("buffer", Long.toString(buffer)));
post.setEntity(new UrlEncodedFormEntity(params, UTF_8));
HttpResponse response = getResponse(post, SC_OK, SC_UNAUTHORIZED);
try {
if (response != null && SC_OK == response.getStatusLine().getStatusCode()) {
logger.info("Successfully started removing old schedules before butter {} to the scheduler service", buffer);
return;
} else if (SC_UNAUTHORIZED == response.getStatusLine().getStatusCode()) {
logger.info("Unauthorized to remove old schedules before buffer {}.", buffer);
throw new UnauthorizedException("Unauthorized to remove old schedules");
}
} catch (UnauthorizedException e) {
throw e;
} catch (Exception e) {
throw new SchedulerException("Unable to remove old schedules from the scheduler service: " + e);
} finally {
closeConnection(response);
}
throw new SchedulerException("Unable to remove old schedules from the scheduler service");
}
use of org.opencastproject.scheduler.api.SchedulerException in project opencast by opencast.
the class SchedulerServiceRemoteImpl method hasActiveTransaction.
@Override
public boolean hasActiveTransaction(String mediaPackageId) throws NotFoundException, UnauthorizedException, SchedulerException {
HttpGet get = new HttpGet("transaction/event/".concat(mediaPackageId));
HttpResponse response = getResponse(get, SC_OK, SC_NOT_FOUND, SC_UNAUTHORIZED);
try {
if (response != null) {
if (SC_NOT_FOUND == response.getStatusLine().getStatusCode()) {
throw new NotFoundException("Event with mediapackage id '" + mediaPackageId + "' not found on remote scheduler service!");
} else if (SC_UNAUTHORIZED == response.getStatusLine().getStatusCode()) {
logger.info("Unauthorized to get active transaction status of event {}.", mediaPackageId);
throw new UnauthorizedException("Unauthorized to get active transaction status of the event " + mediaPackageId);
} else {
String hasActiveTransactionString = EntityUtils.toString(response.getEntity(), UTF_8);
Boolean booleanObject = BooleanUtils.toBooleanObject(hasActiveTransactionString);
if (booleanObject == null)
throw new SchedulerException("Could not parse active transaction status from the remote scheduler service: " + hasActiveTransactionString);
logger.info("Successfully get active transaction status of event with mediapackage id {} from the remote scheduler service", mediaPackageId);
return booleanObject.booleanValue();
}
}
} catch (NotFoundException e) {
throw e;
} catch (UnauthorizedException e) {
throw e;
} catch (Exception e) {
throw new SchedulerException("Unable to get active transaction status for event from remote scheduler service: " + e);
} finally {
closeConnection(response);
}
throw new SchedulerException("Unable to get active transaction status for event from from remote scheduler service");
}
Aggregations