use of org.opencastproject.scheduler.api.RecordingImpl in project opencast by opencast.
the class SchedulerServiceImpl method getRecordingState.
@Override
public Recording getRecordingState(String id) throws NotFoundException, SchedulerException {
notEmpty(id, "id");
try {
AQueryBuilder query = assetManager.createQuery();
Props p = new Props(query);
AResult result = query.select(p.recordingStatus().target(), p.recordingLastHeard().target()).where(withOrganization(query).and(query.mediaPackageId(id)).and(query.version().isLatest()).and(query.hasPropertiesOf(p.namespace())).and(p.recordingStatus().exists()).and(p.recordingLastHeard().exists())).run();
Opt<ARecord> record = result.getRecords().head();
if (record.isNone() || record.get().getProperties().isEmpty())
throw new NotFoundException();
String recordingState = record.get().getProperties().apply(Properties.getString(RECORDING_STATE_CONFIG));
Long lastHeard = record.get().getProperties().apply(Properties.getLong(RECORDING_LAST_HEARD_CONFIG));
return new RecordingImpl(id, recordingState, lastHeard);
} catch (NotFoundException e) {
throw e;
} catch (Exception e) {
logger.error("Failed to get recording status of event with mediapackage '{}': {}", id, getStackTrace(e));
throw new SchedulerException(e);
}
}
use of org.opencastproject.scheduler.api.RecordingImpl in project opencast by opencast.
the class SchedulerServiceImpl method getKnownRecordings.
@Override
public Map<String, Recording> getKnownRecordings() throws SchedulerException {
try {
AQueryBuilder query = assetManager.createQuery();
Props p = new Props(query);
AResult result = query.select(p.recordingStatus().target(), p.recordingLastHeard().target()).where(withOrganization(query).and(query.version().isLatest()).and(query.hasPropertiesOf(p.namespace())).and(p.recordingStatus().exists()).and(p.recordingLastHeard().exists())).run();
Map<String, Recording> recordings = new HashMap<>();
for (ARecord record : result.getRecords()) {
String recordingState = record.getProperties().apply(Properties.getString(RECORDING_STATE_CONFIG));
Long lastHeard = record.getProperties().apply(Properties.getLong(RECORDING_LAST_HEARD_CONFIG));
recordings.put(record.getMediaPackageId(), new RecordingImpl(record.getMediaPackageId(), recordingState, lastHeard));
}
return recordings;
} catch (Exception e) {
logger.error("Failed to get known recording states: {}", getStackTrace(e));
throw new SchedulerException(e);
}
}
use of org.opencastproject.scheduler.api.RecordingImpl in project opencast by opencast.
the class RecordingTest method setUp.
@Before
public void setUp() {
recording = new RecordingImpl("test", RecordingState.CAPTURING);
Assert.assertNotNull(recording);
time = recording.getLastCheckinTime();
}
use of org.opencastproject.scheduler.api.RecordingImpl in project opencast by opencast.
the class SchedulerServiceRemoteImpl method getRecordingState.
@Override
public Recording getRecordingState(String id) throws NotFoundException, SchedulerException {
HttpGet get = new HttpGet(UrlSupport.concat(id, "recordingStatus"));
HttpResponse response = getResponse(get, SC_OK, SC_NOT_FOUND);
try {
if (response != null) {
if (SC_OK == response.getStatusLine().getStatusCode()) {
String recordingStateJson = EntityUtils.toString(response.getEntity(), UTF_8);
JSONObject json = (JSONObject) parser.parse(recordingStateJson);
String recordingId = (String) json.get("id");
String status = (String) json.get("state");
Long lastHeard = (Long) json.get("lastHeardFrom");
logger.info("Successfully get calendar of agent with id {} from the remote scheduler service", id);
return new RecordingImpl(recordingId, status, lastHeard);
} else if (SC_NOT_FOUND == response.getStatusLine().getStatusCode()) {
logger.warn("Event with mediapackage id {} was not found by the scheduler service", id);
throw new NotFoundException("Event with mediapackage id '" + id + "' not found on remote scheduler service!");
}
}
} catch (NotFoundException e) {
throw e;
} catch (Exception e) {
throw new SchedulerException("Unable to get calendar from remote scheduler service: " + e);
} finally {
closeConnection(response);
}
throw new SchedulerException("Unable to get calendar from remote scheduler service");
}
Aggregations