Package org.opentides.bean.user

Examples of org.opentides.bean.user.BaseUser


    _log.debug("saving widget order...");
    //TODO: 1. validation in parsing the string order (valid, widget exists, proper format, etc)
    //    2. acegi security
   
    String order = req.getParameter("order");
    BaseUser user = userService.load(SecurityUtil.getSessionUser().getRealId());
    String[] col = order.split("\\|");
    int countCol = 1;
    for (int i=0;i<col.length;i++) {
      String[] widget = col[i].split(",");
      int countRow = 1;
View Full Code Here


    String status = req.getParameter("status");
    //must be a valid state before processing the code...
    if (status.equals(""+WidgetService.WIDGET_STATUS_MINIMIZE) || status.equals(""+WidgetService.WIDGET_STATUS_SHOW)
        || status.equals(""+WidgetService.WIDGET_STATUS_REMOVE)) {
      String widgetName = req.getParameter("widgetName");
      BaseUser user = userService.load(SecurityUtil.getSessionUser().getRealId());
      UserWidgets userWidgets = userWidgetsService.findSpecificUserWidgets(user, widgetName);
      if (userWidgets != null) {
        try {
          Integer statusNum = Integer.parseInt(status);
          userWidgetsService.updateUserWidgetsStatus(userWidgets, statusNum);
View Full Code Here

    Session session=null;
    try {
      session = HibernateUtil.getSessionFactory().openSession();
      Object object = session.load(log.getEntityClass(), log.getEntityId());
      log.setObject(object);
            BaseUser user = (BaseUser)session.load(BaseUser.class, log.getUserId());
            log.setUser(user.cloneUserProfile());
    } catch (Throwable e) {
      _log.error(e, e);
    } finally {
      if (session!=null) session.close();
    }
View Full Code Here

    }
 
  @Test
  public void testAddUser() {
    BaseUser user = new BaseUser();
    user.addGroup(group1);
    user.setFirstName("John");
    user.setLastName("Doe");
    user.setEmailAddress("johndoe@unittest.com");
    UserCredential userAccount = new UserCredential();
    userAccount.setPassword("unittest");
    userAccount.setUsername("jdoe");
    userAccount.setUser(user);
    user.setCredential(userAccount);
    coreUserDAO.saveEntityModel(user);
    // ensure user is saved and has id
    assertNotNull(user.getId());
    assertEquals( 1, jdbcTemplate.queryForInt("select count(*) from USER_PROFILE where EMAIL='johndoe@unittest.com'"));
    long userId = user.getId();
   
    Map result = jdbcTemplate.queryForMap("select * from USER_PROFILE where ID=?", new Object[]{userId});
    assertEquals("John",result.get("FIRSTNAME"));
    assertEquals("Doe",result.get("LASTNAME"));
    assertEquals("johndoe@unittest.com",result.get("EMAIL"));

    Map cred = jdbcTemplate.queryForMap("select * from USERS where USERID=?", new Object[]{userId});
    assertEquals("jdoe",cred.get("USERNAME"));
    assertEquals("unittest",cred.get("PASSWORD"))
   
    // add user group
    BaseUser testUser = coreUserDAO.loadEntityModel(user.getId());
    Set<UserGroup> groups = testUser.getGroups();
    assertNotNull(groups);
    assertTrue(groups.size() == 1);
    assertTrue(groups.iterator().next().getId().equals(group1.getId()));
   
    // remove user group
    testUser.removeGroup(group1);
    coreUserDAO.saveEntityModel(testUser);
    BaseUser testUser2 = coreUserDAO.loadEntityModel(testUser.getId());
    assertTrue(testUser2.getGroups().size() == 0);
   
    // remove user
    int id = jdbcTemplate.queryForInt("select id from USER_PROFILE where EMAIL='johndoe@unittest.com'");
    coreUserDAO.deleteEntityModel(user.getId());
    assertEquals(0, jdbcTemplate.queryForInt("select count(*) from USER_PROFILE where ID="+user.getId()));
View Full Code Here

        assertEquals(false, coreUserDAO.isRegisteredByEmail("test@missing.com"));
  }
 
  @Test
    public void testLoadByUsername() {
      BaseUser user = coreUserDAO.loadByUsername("admin");
        assertEquals("SuperAdmin", user.getFirstName());
        assertEquals("User", user.getLastName());       
        assertEquals(null, coreUserDAO.loadByUsername("missing"));
    assertNull(coreUserDAO.loadByUsername(""));
    assertNull(coreUserDAO.loadByUsername(null));
       
    }
View Full Code Here

       
    }
 
  @Test
    public void testLoadByEmailAddress() {
      BaseUser user = coreUserDAO.loadByEmailAddress("admin@ideyatech.com");
      assertEquals("SuperAdmin", user.getFirstName());
        assertEquals("User", user.getLastName());     
    }
View Full Code Here

 
    @Test
  public void testFindByUsergroupName() {
   
        // a user can be member of multiple user group
        user = new BaseUser();
        user.addGroup(group1);
        user.addGroup(group2);
        user.setEmailAddress("multiple@unittest.com");
        UserCredential userAccount = new UserCredential();
        userAccount.setPassword("test");
View Full Code Here

    }
 
  @Test
  public void testUniqueUsernameConstraints() {
    try {
      BaseUser user = new BaseUser();
      user.addGroup(group1);
      user.setFirstName("SuperUser");
      user.setLastName("Duplicate");
      user.setEmailAddress("duplicate@unittest.com");
      UserCredential userAccount = new UserCredential();
      userAccount.setPassword("unittest");
      userAccount.setUsername("admin");
      userAccount.setUser(user);
      user.setCredential(userAccount);
      coreUserDAO.saveEntityModel(user);
      fail("Failed to throw exception on duplicate username");
    } catch (Exception e) {
      // success
    }
View Full Code Here

  }
 
  @Test
  public void testUniqueEmailConstraints() {
    try {
      BaseUser user = new BaseUser();
      user.addGroup(group1);
      user.setFirstName("SuperUser");
      user.setLastName("Duplicate");
      user.setEmailAddress("admin@ideyatech.com");
      UserCredential userAccount = new UserCredential();
      userAccount.setPassword("unittest");
      userAccount.setUsername("admin");
      userAccount.setUser(user);
      user.setCredential(userAccount);
      coreUserDAO.saveEntityModel(user);
      fail("Failed to throw exception on duplicate email");
    } catch (Exception e) {
     
    }
View Full Code Here

    actual.setStatus(PasswordReset.STATUS_USED);
    passwordResetDAO.saveEntityModel(actual);

    // now reset the password
    UserDAO userDAO = (UserDAO) getDao();
    BaseUser user = userDAO.loadByEmailAddress(passwd.getEmailAddress());
    user.getCredential().setPassword(passwd.getPassword());
    userDAO.saveEntityModel(user);

    return true;
  }
View Full Code Here

TOP

Related Classes of org.opentides.bean.user.BaseUser

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.