use of org.opencastproject.scheduler.impl.SchedulerServiceDatabaseException in project opencast by opencast.
the class SchedulerServiceDatabaseImpl method getTransactionId.
@Override
public String getTransactionId(String source) throws NotFoundException, SchedulerServiceDatabaseException {
EntityManager em = null;
try {
em = emf.createEntityManager();
String orgId = securityService.getOrganization().getId();
Query q = em.createNamedQuery("Transaction.findBySource").setParameter("source", source).setParameter("org", orgId);
TransactionDto dto = (TransactionDto) q.getSingleResult();
return dto.getId();
} catch (NoResultException e) {
throw new NotFoundException("Transaction with source " + source + " does not exist");
} catch (Exception e) {
logger.error("Could not retrieve id for transaction with source '{}': {}", source, getStackTrace(e));
throw new SchedulerServiceDatabaseException(e);
} finally {
if (em != null)
em.close();
}
}
use of org.opencastproject.scheduler.impl.SchedulerServiceDatabaseException in project opencast by opencast.
the class SchedulerServiceDatabaseImpl method countConfirmedResponses.
public long countConfirmedResponses() throws SchedulerServiceDatabaseException {
EntityManager em = null;
try {
em = emf.createEntityManager();
Query q = em.createNamedQuery("ExtendedEvent.countConfirmed");
Number countResult = (Number) q.getSingleResult();
return countResult.longValue();
} catch (Exception e) {
throw new SchedulerServiceDatabaseException(e);
} finally {
if (em != null)
em.close();
}
}
use of org.opencastproject.scheduler.impl.SchedulerServiceDatabaseException in project opencast by opencast.
the class SchedulerServiceDatabaseImpl method deleteEvent.
@Override
public void deleteEvent(String mediapackageId) throws NotFoundException, SchedulerServiceDatabaseException {
EntityManager em = null;
EntityTransaction tx = null;
try {
em = emf.createEntityManager();
tx = em.getTransaction();
tx.begin();
Opt<ExtendedEventDto> entity = getExtendedEventDto(mediapackageId, em);
if (entity.isNone()) {
throw new NotFoundException("Event with ID " + mediapackageId + " does not exist");
}
em.remove(entity.get());
tx.commit();
} catch (NotFoundException e) {
throw e;
} catch (Exception e) {
if (tx.isActive())
tx.rollback();
logger.error("Could not delete extended event: {}", getStackTrace(e));
throw new SchedulerServiceDatabaseException(e);
} finally {
if (em != null)
em.close();
}
}
use of org.opencastproject.scheduler.impl.SchedulerServiceDatabaseException in project opencast by opencast.
the class SchedulerServiceDatabaseImpl method getTransactionSource.
@Override
public String getTransactionSource(String id) throws NotFoundException, SchedulerServiceDatabaseException {
EntityManager em = null;
try {
em = emf.createEntityManager();
Opt<TransactionDto> entity = getTransactionDto(id, em);
if (entity.isNone())
throw new NotFoundException("Transaction with ID " + id + " does not exist");
return entity.get().getSource();
} catch (NotFoundException e) {
throw e;
} catch (Exception e) {
logger.error("Could not retrieve source for transaction with id '{}': {}", id, getStackTrace(e));
throw new SchedulerServiceDatabaseException(e);
} finally {
if (em != null)
em.close();
}
}
use of org.opencastproject.scheduler.impl.SchedulerServiceDatabaseException in project opencast by opencast.
the class SchedulerServiceDatabaseImpl method getLastModifiedDates.
@Override
@SuppressWarnings("unchecked")
public Map<String, Date> getLastModifiedDates() throws SchedulerServiceDatabaseException {
EntityManager em = null;
try {
em = emf.createEntityManager();
Query q = em.createNamedQuery("LastModified.findAll");
List<LastModifiedDto> resultList = q.getResultList();
Map<String, Date> dates = new HashMap<String, Date>();
for (LastModifiedDto dto : resultList) {
dates.put(dto.getCaptureAgentId(), dto.getLastModifiedDate());
}
return dates;
} catch (Exception e) {
logger.error("Could not retrieve last modified dates: {}", getStackTrace(e));
throw new SchedulerServiceDatabaseException(e);
} finally {
if (em != null)
em.close();
}
}
Aggregations