Revision 88:1444d50d51db

View differences:

src/main/java/my/com/upass/MinimalConstants.java
45 45
	public static final int ERR_TOKEN_NOT_ASSIGNED = 7;
46 46
	public static final int UID_STATE_ACTIVE = 0;
47 47
	public static final int UID_STATE_TMP_LOCKED = 1;
48
	public static final int UID_STATE_LOCKED = 2;
49
	public static final int UID_STATE_INACTIVE = 3;
50
	public static final int UID_STATE_DELETED = 4;
48 51
	public static final int ERR_APP_SERV_NOT_PERMITTED = 10;
49 52
	public static final int ERR_SYSTEM_NOT_READY = 98;
50 53
	public static final int ERR_ALREADY_EXIST = 11;
src/main/java/my/com/upass/MinimalUPassControllerV2.java
880 880
				if (checkResult.invokerAppId == null)
881 881
					throw new UPassException(MinimalConstants.ERR_APP_SERV_NOT_PERMITTED);
882 882
			}
883
			List profiles = modifyUserService.listProfilesByExamples(exampleProfiles, fromDate, toDate, txSession);
883
			List profiles = modifyUserService.listProfilesByExamples(
884
					exampleProfiles, fromDate, toDate,
885
					configurationMap, txSession);
884 886

  
885 887
			return profiles;
886 888

  
src/main/java/my/com/upass/dao/UserDAO.java
100 100
			throws Exception;
101 101

  
102 102
	List/* <UserProfile> */listProfilesByExamples(
103
			List/* <UserProfile> */exampleProfiles, Date fromDate, Date toDate, final Session txSession)
103
			List/* <UserProfile> */exampleProfiles, Date fromDate, Date toDate,
104
			Map/* <Integer, ConfigBean> */configsMap, final Session txSession)
104 105
			throws Exception;
105 106

  
106 107
	AuthenticationBean retrieveAuthBeanFor(
src/main/java/my/com/upass/dao/hibernate/UserDAOHibernate.java
21 21
import java.util.List;
22 22
import java.util.Map;
23 23

  
24
import my.com.upass.ConfigBean;
24 25
import my.com.upass.MinimalConstants;
25 26
import my.com.upass.dao.UserDAO;
26 27
import my.com.upass.generic.hibernate.GenericDAOHibernate;
......
32 33
import my.com.upass.pojo.MinimalUserBean;
33 34
import my.com.upass.pojo.MinimalUserBeanBackup;
34 35
import my.com.upass.pojo.UserAppAccess;
36
import my.com.upass.services.AppAccessMgtService;
35 37

  
36 38
import org.apache.commons.collections.CollectionUtils;
37 39
import org.apache.commons.collections.PredicateUtils;
......
586 588
					}
587 589
					c.add(Restrictions.ilike(MU + ".userAlias", username));
588 590
				}
589

  
590 591
				profiles.addAll(c.list());
591 592
				if (txSession == null)
592 593
					ensureUserInitialized(profiles);
......
599 600
	}
600 601

  
601 602
	public List/* <UserProfile> */listProfilesByExamples(
602
			List/* <UserProfile> */exampleProfiles, Date fromDate, Date toDate, Session txSession)
603
			List/* <UserProfile> */exampleProfiles, Date fromDate, Date toDate,
604
			Map/* <Integer, ConfigBean> */configsMap, Session txSession)
603 605
			throws Exception {
604 606

  
605 607
		List profiles = new ArrayList();
......
621 623
				} else {
622 624
					c.createAlias("minUser", MU);
623 625
				}
624

  
625 626
				final String username = example.getMinUser().getUsername();
626 627
				if (username != null) {
627 628
					c.add(Restrictions.ilike(MU + ".userAlias", username));
628 629
				}
630
				int userStatus = example.getMinUser().getUstate();
631
				switch (userStatus) {
632
				case -1: // An indicator for ignoring the status
633
					break;
634
				case MinimalConstants.UID_STATE_INACTIVE:
635
					final Integer appId = AppAccessMgtService.getAppIdForProfile(example);
636
					ConfigBean config = (ConfigBean) configsMap.get(appId);
637
					Calendar calender = new GregorianCalendar();
638
					calender.add(Calendar.DATE, -config.getUserDormantPeriod());
639
					c.add(Restrictions.gt(MU + ".pdateLastUsed", calender.getTime()));
629 640

  
630
				Integer userStatus = null;
631
				boolean userStatusSelected = true;
632
				try {
633
					userStatus = new Integer(example.getMinUser().getUstate());
634

  
635
				} catch (NumberFormatException e) {
636
					userStatusSelected = false;
641
				default:
642
					Integer userStatusInt = new Integer(userStatus);
643
					c.add(Restrictions.eq(MU + ".ustate", userStatusInt));
644
					break;
637 645
				}
638
				if (userStatusSelected) {
639
					c.add(Restrictions.eq(MU + ".ustate", userStatus));
640
				}
641

  
642 646
				Calendar calender = new GregorianCalendar();
643 647
				if (fromDate != null) {
644 648
					calender.setTime(fromDate);
645 649
					calender.add(Calendar.DATE, -1);
646 650
					c.add(Restrictions.gt(MU + ".udateCreated", calender.getTime()));
647
				}
648
				else if (toDate != null) {
651

  
652
				} else if (toDate != null) {
649 653
					calender.setTime(toDate);
650 654
					calender.add(Calendar.DATE, 1);
651 655
					c.add(Restrictions.lt(MU + ".udateCreated", calender.getTime()));
652 656
				}
653

  
654 657
				profiles.addAll(c.list());
655 658
				if (txSession == null)
656 659
					ensureUserInitialized(profiles);
src/main/java/my/com/upass/services/ModifyUserService.java
213 213
	}
214 214

  
215 215
	public List/* <UserProfile> */listProfilesByExamples(
216
			List/* <UserProfile> */exampleProfiles, Date fromDate, Date toDate, Session txSession)
216
			List/* <UserProfile> */exampleProfiles, Date fromDate, Date toDate,
217
			Map/* <Integer, ConfigBean> */configsMap, Session txSession)
217 218
			throws UPassException {
218 219

  
219 220
		// int rc = MinimalConstants.ERR_SYSTEM_NOT_READY;
......
222 223
		}
223 224
		try {
224 225
			UserDAO userDao = MinimalDAOFactory.minimalInstance().getUserDAO();
225
			return userDao.listProfilesByExamples(exampleProfiles, fromDate, toDate, txSession);
226
			return userDao.listProfilesByExamples(exampleProfiles, fromDate, toDate, configsMap, txSession);
226 227

  
227 228
		} catch (Exception e) {
228 229
			if (e instanceof UPassException) {

Also available in: Unified diff