Пример #1
0
  public void delete(int id, String owner) throws DAOException {
    try {
      Transaction.begin();
      EventBean p = factory.lookup(id);

      if (p == null) {
        throw new DAOException("Event does not exist: id=" + id);
      }

      if (!owner.equals(p.getUserId())) {
        throw new DAOException("Event not owned by " + owner);
      }
      factory.delete(id);
      Transaction.commit();
    } catch (RollbackException e) {
      throw new DAOException(e);
    } finally {
      if (Transaction.isActive()) Transaction.rollback();
    }
  }