예제 #1
0
 public EventBean lookup(int id) throws DAOException {
   try {
     return factory.lookup(id);
   } catch (RollbackException e) {
     throw new DAOException(e);
   }
 }
예제 #2
0
 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();
    }
  }