Revision 123:28041a5d68d2

View differences:

src/main/java/my/com/upass/MinimalUPassControllerV2.java
294 294
		logger.info("addUser - user alias: [" + userAlias + "] Return: " + rc);
295 295
		return rc;
296 296
	}
297
	
298
	/**
299
	 * This method will add user together with the profile provided.
300
	 * Because of the ability to choose the target app,
301
	 * this method is meant for USS only.
302
	 * 
303
	 */
304
	public int addUserWithProfile(String adminUsername, String adminHashedPassword, UserProfile profile,
305
			Character accessType, Integer targetAppId, boolean checkPassword){
306
		
307
		int rc = MinimalConstants.ERR_UNKNOWN;
308
		Session session = null;
309
		try {
310
			session = HibernateUtils.currentSession();
311
			session.beginTransaction();
312

  
313
			if(profile instanceof M2uUserContainer){
314
				rc = MinimalConstants.ERR_SUCCESS;
315
			}else{
316
				rc = addUser(adminUsername, adminHashedPassword, profile.getMinUser(), accessType, targetAppId, session, checkPassword);
317
			}
318

  
319
			if (rc == MinimalConstants.ERR_SUCCESS) {
320
				rc = updateProfileShallowly_noAccessCheck(profile, session);
321

  
322
				if (rc == MinimalConstants.ERR_SUCCESS) {
323
					session.getTransaction().commit();
324

  
325
				} else {
326
					GenericDAOHibernate.rollbackTransactionIfAny(session);
327
				}
328
			} else {
329
				GenericDAOHibernate.rollbackTransactionIfAny(session);
330
			}
331
		} catch (UPassException e) {
332
			rc = e.getErrorCode();
333
			logger.error(e, e);
334
			GenericDAOHibernate.rollbackTransactionIfAny(session);
335

  
336
		} catch (Exception e) {
337
			logger.error(e, e);
338
			GenericDAOHibernate.rollbackTransactionIfAny(session);
339

  
340
		} finally {
341
			GenericDAOHibernate.closeSessionIfAny(session);
342
		}
343
		
344
		return rc;
345
	}
297 346

  
298 347
	/**
299 348
	 * This method verify static password generated using SP_ChangeStaticPassword().

Also available in: Unified diff