Revision 120:a9f1f5b7505b

View differences:

src/main/java/my/com/upass/MinimalUPassControllerV2.java
96 96
				while (itr.hasNext()) {
97 97
					configPojo = (ConfigurationBean) itr.next();
98 98
					configType = configPojo.getApplicationId();
99

  
99
					
100 100
					configBean = (ConfigBean) configurationMap.get(new Integer(configType));
101 101
					if (configBean == null) {
102 102
						configBean = new ConfigBean();
......
110 110
					configFirstLoad = false; // this value dictate for every instance restart to refresh the map. After
111 111
												// first load, turn it off
112 112
				}
113
				
114
				configurationMap.put(ClientApp.APP_ID_IM2U, configurationMap.get(ClientApp.APP_ID_M2U));
115
				configurationMap.put(ClientApp.APP_ID_ONLINE_STOCK, configurationMap.get(ClientApp.APP_ID_M2U));
116
				
113 117
				logger.info("Refresh Configuration Done ....");
114 118
			}
115 119
		} catch (Exception e) {
src/main/java/my/com/upass/dao/UserDAO.java
104 104
			Map/* <Integer, ConfigBean> */configsMap, final Session txSession)
105 105
			throws Exception;
106 106

  
107
	List/* <UserProfile> */listDormantProfiles(
108
			List/* <UserProfile> */exampleProfiles, 
109
			Map/* <Integer, ConfigBean> */configsMap, final Session txSession)
110
			throws Exception;
111
	
107 112
	AuthenticationBean retrieveAuthBeanFor(
108 113
			String invokerUsername, String invokerHashedPassword,
109 114
			String targetUsername, String targetHashedPassword, final Session txSession)
src/main/java/my/com/upass/dao/hibernate/UserDAOHibernate.java
565 565
		}
566 566
		return profiles;
567 567
	}
568
	
569
	public List listDormantProfiles(List exampleProfiles, Map configsMap, Session txSession) throws Exception {
570

  
571
		List profiles = new ArrayList(5);
572
		Session session = null;
573
		try {
574
			session = txSession != null ? txSession : getSession();
575

  
576
			for (Iterator iter = exampleProfiles.iterator(); iter.hasNext();) {
577
				UserProfile example = (UserProfile) iter.next();
578

  
579
				Criteria c = session.createCriteria(example.getClass())
580
						.add(Example.create(example).ignoreCase().enableLike());
581

  
582
				final String MU = "mu";
583
				if (example instanceof StockUser || example instanceof Im2uUser) {
584
					c.createAlias("m2uUser", "m2u");
585
					c.createAlias("m2u.minUser", MU);
586
				} else {
587
					c.createAlias("minUser", MU);
588
				}
589
				
590
				final Integer appId = AppAccessMgtService.getAppIdForProfile(example);
591
				final ConfigBean config = (ConfigBean) configsMap.get(appId);
592
				final int dormantPeriod = config.getUserDormantPeriod();
593
				final Calendar finalDate = Calendar.getInstance();
594
				finalDate.add(Calendar.DATE, - dormantPeriod);
595
				
596
				c.add(Restrictions.lt(MU + ".pdateLastUsed", finalDate.getTime()));
597
				
598
				profiles.addAll(c.list());
599
				if (txSession == null)
600
					ensureUserInitialized(profiles);
601
				
602
			}
603
		} finally {
604
			if (txSession == null)
605
				closeSessionIfAny(session);
606
		}
607
		return profiles;
608
	}
568 609

  
569 610
	public List/* <UserProfile> */listProfilesByExamples(
570 611
			List/* <UserProfile> */exampleProfiles, Session txSession)
src/main/java/my/com/upass/services/ModifyUserService.java
236 236
		return null;
237 237
	}
238 238

  
239
	public List/* <UserProfile> */listDormantProfiles(
240
			List/* <UserProfile> */exampleProfiles,
241
			Map/* <Integer, ConfigBean> */configsMap,
242
			Session txSession) 
243
			throws UPassException{
244
		
245
		if (exampleProfiles == null) {
246
			throw new UPassException(MinimalConstants.ERR_INVALID_INPUT);
247
		}
248
		
249
		try {
250
			UserDAO userDao = MinimalDAOFactory.minimalInstance().getUserDAO();
251
			return userDao.listDormantProfiles(exampleProfiles, configsMap, txSession);
252

  
253
		} catch (Exception e) {
254
			if (e instanceof UPassException) {
255
				UPassException upassEx = (UPassException) e;
256
				throw upassEx;
257

  
258
			} else
259
				e.printStackTrace();
260
		}
261
		
262
		return null;
263
	}
239 264
}

Also available in: Unified diff