Example #1
0
  public void create(EventBean newEvent) throws DAOException {
    try {
      Transaction.begin();
      EventBean dbEvent = factory.create();
      factory.copyInto(newEvent, dbEvent);
      Transaction.commit();

    } catch (RollbackException e) {
      throw new DAOException(e);
    } finally {
      if (Transaction.isActive()) Transaction.rollback();
    }
  }
Example #2
0
  public void create(Community community) throws DAOException {
    try {
      Transaction.begin();
      Community dbcommunity = factory.create(community.getName());
      factory.copyInto(community, dbcommunity);

      Transaction.commit();

    } catch (DuplicateKeyException e) {
      throw new DAOException("Community named " + community.getName() + " already exists.");
    } catch (RollbackException e) {
      throw new DAOException(e);
    } finally {
      if (Transaction.isActive()) Transaction.rollback();
    }
  }
Example #3
0
 public void create(UserBean user) throws DAOException {
   String origID = user.getUserID();
   try {
     Transaction.begin();
     user.setUserID(user.getUserID().toLowerCase());
     UserBean dBUser = factory.create(user.getUserID());
     factory.copyInto(user, dBUser);
     Transaction.commit();
   } catch (DuplicateKeyException e) {
     throw new DAOException("UserID: " + user.getUserID() + "already exists.");
   } catch (RollbackException e) {
     throw new DAOException(e);
   } finally {
     if (Transaction.isActive()) Transaction.rollback();
   }
 }