Search in sources :

Example 6 with RecordingImpl

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);
    }
}
Also used : ARecord(org.opencastproject.assetmanager.api.query.ARecord) SchedulerException(org.opencastproject.scheduler.api.SchedulerException) AQueryBuilder(org.opencastproject.assetmanager.api.query.AQueryBuilder) AResult(org.opencastproject.assetmanager.api.query.AResult) NotFoundException(org.opencastproject.util.NotFoundException) RecordingImpl(org.opencastproject.scheduler.api.RecordingImpl) Log.getHumanReadableTimeString(org.opencastproject.util.Log.getHumanReadableTimeString) SchedulerException(org.opencastproject.scheduler.api.SchedulerException) SchedulerConflictException(org.opencastproject.scheduler.api.SchedulerConflictException) IOException(java.io.IOException) ServiceException(org.osgi.framework.ServiceException) SchedulerTransactionLockException(org.opencastproject.scheduler.api.SchedulerTransactionLockException) ConfigurationException(org.osgi.service.cm.ConfigurationException) SeriesException(org.opencastproject.series.api.SeriesException) MediaPackageException(org.opencastproject.mediapackage.MediaPackageException) ValidationException(net.fortuna.ical4j.model.ValidationException) UnauthorizedException(org.opencastproject.security.api.UnauthorizedException) NotFoundException(org.opencastproject.util.NotFoundException)

Example 7 with RecordingImpl

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);
    }
}
Also used : ARecord(org.opencastproject.assetmanager.api.query.ARecord) SchedulerException(org.opencastproject.scheduler.api.SchedulerException) LinkedHashMap(java.util.LinkedHashMap) HashMap(java.util.HashMap) AQueryBuilder(org.opencastproject.assetmanager.api.query.AQueryBuilder) AResult(org.opencastproject.assetmanager.api.query.AResult) RecordingImpl(org.opencastproject.scheduler.api.RecordingImpl) Log.getHumanReadableTimeString(org.opencastproject.util.Log.getHumanReadableTimeString) Recording(org.opencastproject.scheduler.api.Recording) SchedulerException(org.opencastproject.scheduler.api.SchedulerException) SchedulerConflictException(org.opencastproject.scheduler.api.SchedulerConflictException) IOException(java.io.IOException) ServiceException(org.osgi.framework.ServiceException) SchedulerTransactionLockException(org.opencastproject.scheduler.api.SchedulerTransactionLockException) ConfigurationException(org.osgi.service.cm.ConfigurationException) SeriesException(org.opencastproject.series.api.SeriesException) MediaPackageException(org.opencastproject.mediapackage.MediaPackageException) ValidationException(net.fortuna.ical4j.model.ValidationException) UnauthorizedException(org.opencastproject.security.api.UnauthorizedException) NotFoundException(org.opencastproject.util.NotFoundException)

Example 8 with RecordingImpl

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();
}
Also used : RecordingImpl(org.opencastproject.scheduler.api.RecordingImpl) Before(org.junit.Before)

Example 9 with RecordingImpl

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");
}
Also used : SchedulerException(org.opencastproject.scheduler.api.SchedulerException) JSONObject(org.json.simple.JSONObject) HttpGet(org.apache.http.client.methods.HttpGet) HttpResponse(org.apache.http.HttpResponse) RecordingImpl(org.opencastproject.scheduler.api.RecordingImpl) NotFoundException(org.opencastproject.util.NotFoundException) SchedulerException(org.opencastproject.scheduler.api.SchedulerException) SchedulerTransactionLockException(org.opencastproject.scheduler.api.SchedulerTransactionLockException) SchedulerConflictException(org.opencastproject.scheduler.api.SchedulerConflictException) UnauthorizedException(org.opencastproject.security.api.UnauthorizedException) NotFoundException(org.opencastproject.util.NotFoundException)

Aggregations

RecordingImpl (org.opencastproject.scheduler.api.RecordingImpl)9 SchedulerConflictException (org.opencastproject.scheduler.api.SchedulerConflictException)7 SchedulerException (org.opencastproject.scheduler.api.SchedulerException)7 SchedulerTransactionLockException (org.opencastproject.scheduler.api.SchedulerTransactionLockException)7 UnauthorizedException (org.opencastproject.security.api.UnauthorizedException)7 NotFoundException (org.opencastproject.util.NotFoundException)7 Recording (org.opencastproject.scheduler.api.Recording)5 Log.getHumanReadableTimeString (org.opencastproject.util.Log.getHumanReadableTimeString)5 IOException (java.io.IOException)4 HashMap (java.util.HashMap)4 ValidationException (net.fortuna.ical4j.model.ValidationException)4 AQueryBuilder (org.opencastproject.assetmanager.api.query.AQueryBuilder)4 ARecord (org.opencastproject.assetmanager.api.query.ARecord)4 AResult (org.opencastproject.assetmanager.api.query.AResult)4 MediaPackageException (org.opencastproject.mediapackage.MediaPackageException)4 SeriesException (org.opencastproject.series.api.SeriesException)4 ServiceException (org.osgi.framework.ServiceException)4 ConfigurationException (org.osgi.service.cm.ConfigurationException)4 Date (java.util.Date)3 HttpResponse (org.apache.http.HttpResponse)3