}
}
if (createRootUser) {
if (dao.findUser(rootUserName) == null) {
try {
UserImpl rootUser = new UserImpl();
rootUser.setName("Admin");
rootUser.setEmail(rootUserEmail);
rootUser.setTheme(rootUserTheme);
rootUser.setUsername(rootUserName);
rootUser.setSalt(rootPasswordSalt);
rootUser.setPassword(rootPassword);
rootUser.setRoles(new HashSet(dao.findAuthorities()));
if ((supportedLocales != null) && (!supportedLocales.isEmpty())) rootUser.setLocale(supportedLocales.get(0));
if (logger.isDebugEnabled()) logger.debug("Creating root user [" + rootUserName + "] with roles: " + rootUser.getRoles());
dao.createUser(rootUser);
} catch (Exception creationException) {
if (logger.isWarnEnabled()) logger.warn("Could not create Root user [" + rootUserName + "]: " + creationException, creationException);
}
} else if (logger.isDebugEnabled()) logger.debug("Root user [" + rootUserName + "] already exists. Skipping creation");