use of org.opencastproject.scheduler.impl.SchedulerServiceDatabaseException in project opencast by opencast.
the class SchedulerServiceDatabaseImpl method getLastModified.
@Override
public Date getLastModified(String agentId) throws NotFoundException, SchedulerServiceDatabaseException {
EntityManager em = null;
try {
em = emf.createEntityManager();
LastModifiedDto entity = em.find(LastModifiedDto.class, agentId);
if (entity == null)
throw new NotFoundException("Agent with ID " + agentId + " does not exist");
return entity.getLastModifiedDate();
} catch (NotFoundException e) {
throw e;
} catch (Exception e) {
logger.error("Could not retrieve last modified date for agent with id '{}': {}", agentId, 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 deleteTransaction.
@Override
public void deleteTransaction(String id) throws NotFoundException, SchedulerServiceDatabaseException {
EntityManager em = null;
EntityTransaction tx = null;
try {
em = emf.createEntityManager();
tx = em.getTransaction();
tx.begin();
Opt<TransactionDto> entity = getTransactionDto(id, em);
if (entity.isNone())
throw new NotFoundException("Transaction with ID " + id + " does not exist");
em.remove(entity.get());
tx.commit();
} catch (NotFoundException e) {
throw e;
} catch (Exception e) {
logger.error("Could not delete transaction with id '{}': {}", id, getStackTrace(e));
if (tx.isActive())
tx.rollback();
throw new SchedulerServiceDatabaseException(e);
} finally {
if (em != null)
em.close();
}
}
Aggregations