示例#1
0
 public EventBean lookup(int id) throws DAOException {
   try {
     return factory.lookup(id);
   } catch (RollbackException e) {
     throw new DAOException(e);
   }
 }
 public synchronized Course lookup(String courseName) throws MyDAOException {
   try {
     return factory.lookup(courseName);
   } catch (RollbackException e) {
     throw new MyDAOException(e);
   }
 }
示例#3
0
 public UserBean lookup(String userID) throws DAOException {
   try {
     return factory.lookup(userID);
   } catch (RollbackException e) {
     throw new DAOException(e);
   }
 }
示例#4
0
 public Community lookup(String name) throws DAOException {
   try {
     Community comm = factory.lookup(name);
     return comm;
   } catch (RollbackException e) {
     throw new DAOException(e);
   }
 }
示例#5
0
 public void updateUserCount(int x, String name) throws DAOException {
   try {
     Transaction.begin();
     Community comm = factory.lookup(name);
     comm.setUserCount(comm.getUserCount() + x);
     Transaction.commit();
   } catch (RollbackException e) {
     throw new DAOException(e);
   } finally {
     if (Transaction.isActive()) Transaction.rollback();
   }
 }
示例#6
0
  public void setEvent(int eventid, String userid) throws DAOException {
    try {
      Transaction.begin();
      UserBean dbUser = factory.lookup(userid);

      if (dbUser == null) {
        throw new DAOException("User " + userid + " no longer exists");
      }

      dbUser.seteventAttendingID(eventid);
      Transaction.commit();
    } catch (RollbackException e) {
      throw new DAOException(e);
    } finally {
      if (Transaction.isActive()) Transaction.rollback();
    }
  }
示例#7
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();
    }
  }