| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
|
| 17 |
|
|
| 18 |
|
|
| 19 |
|
package org.itracker.core; |
| 20 |
|
|
| 21 |
|
import org.apache.log4j.Logger; |
| 22 |
|
import org.itracker.core.resources.ITrackerResources; |
| 23 |
|
import org.itracker.model.User; |
| 24 |
|
import org.itracker.persistence.dao.NoSuchEntityException; |
| 25 |
|
import org.itracker.services.ConfigurationService; |
| 26 |
|
import org.itracker.services.ReportService; |
| 27 |
|
import org.itracker.services.UserService; |
| 28 |
|
import org.itracker.services.exceptions.PasswordException; |
| 29 |
|
import org.itracker.services.exceptions.UserException; |
| 30 |
|
import org.itracker.services.util.SystemConfigurationUtilities; |
| 31 |
|
import org.itracker.services.util.UserUtilities; |
| 32 |
|
|
| 33 |
|
import javax.jws.soap.InitParam; |
| 34 |
|
|
| 35 |
|
|
| 36 |
|
|
| 37 |
|
|
| 38 |
|
|
| 39 |
|
|
| 40 |
|
|
| 41 |
|
|
| 42 |
|
|
| 43 |
|
|
| 44 |
|
|
| 45 |
|
|
| 46 |
|
|
| 47 |
|
@author |
| 48 |
|
|
| 49 |
|
|
| 50 |
|
|
|
|
|
| 0% |
Uncovered Elements: 28 (28) |
Complexity: 7 |
Complexity Density: 0.3 |
|
| 51 |
|
public class ApplicationInitialization { |
| 52 |
|
|
| 53 |
|
private final Logger logger; |
| 54 |
|
private UserService userService; |
| 55 |
|
private ConfigurationService configurationService; |
| 56 |
|
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
| 57 |
0
|
public ApplicationInitialization(UserService userService, ConfigurationService configurationService, ReportService reportService) {... |
| 58 |
0
|
this.userService = userService; |
| 59 |
0
|
this.configurationService = configurationService; |
| 60 |
0
|
this.logger = Logger.getLogger(getClass()); |
| 61 |
|
} |
| 62 |
|
|
|
|
|
| 0% |
Uncovered Elements: 12 (12) |
Complexity: 3 |
Complexity Density: 0.25 |
|
| 63 |
0
|
public void init() {... |
| 64 |
0
|
try { |
| 65 |
0
|
ITrackerResources.setDefaultLocale(configurationService.getProperty("default_locale", ITrackerResources.DEFAULT_LOCALE)); |
| 66 |
0
|
logger.info("Set system default locale to '" + ITrackerResources.getDefaultLocale() + "'"); |
| 67 |
|
|
| 68 |
0
|
logger.info("Checking and initializing languages in the database."); |
| 69 |
0
|
SystemConfigurationUtilities.initializeAllLanguages(configurationService, false); |
| 70 |
|
|
| 71 |
0
|
logger.info("Checking and initializing default system configuration in the database."); |
| 72 |
0
|
configurationService.initializeConfiguration(); |
| 73 |
|
|
| 74 |
|
|
| 75 |
|
|
| 76 |
|
|
| 77 |
0
|
logger.info("Setting up cached configuration entries"); |
| 78 |
0
|
configurationService.resetConfigurationCache(); |
| 79 |
|
|
| 80 |
|
|
| 81 |
|
|
| 82 |
|
|
| 83 |
|
|
| 84 |
|
|
| 85 |
|
|
| 86 |
|
|
| 87 |
|
|
| 88 |
0
|
createAdminUser(configurationService); |
| 89 |
|
} catch (PasswordException pe) { |
| 90 |
0
|
logger.info("Unable to create admin user. Error: " + pe.getMessage()); |
| 91 |
|
} catch (UserException ue) { |
| 92 |
0
|
logger.warn("Exception while creating admin user.", ue); |
| 93 |
|
} |
| 94 |
|
} |
| 95 |
|
|
| 96 |
|
|
| 97 |
|
|
| 98 |
|
|
| 99 |
|
@param |
| 100 |
|
@throws |
| 101 |
|
@throws |
| 102 |
|
|
|
|
|
| 0% |
Uncovered Elements: 10 (10) |
Complexity: 3 |
Complexity Density: 0.38 |
|
| 103 |
0
|
private void createAdminUser(ConfigurationService configurationService) throws PasswordException, UserException {... |
| 104 |
0
|
boolean createAdmin = configurationService.getBooleanProperty("create_super_user", false); |
| 105 |
0
|
if (createAdmin) { |
| 106 |
0
|
logger.info("Create default admin user option set to true. Checking for existing admin user."); |
| 107 |
0
|
try { |
| 108 |
0
|
userService.getUserByLogin("admin"); |
| 109 |
|
} catch (NoSuchEntityException e) { |
| 110 |
0
|
logger.debug("Attempting to create admin user."); |
| 111 |
0
|
User adminUser = new User("admin", UserUtilities.encryptPassword("admin"), "Super", "User", |
| 112 |
|
"", true); |
| 113 |
0
|
userService.createUser(adminUser); |
| 114 |
|
} |
| 115 |
|
} |
| 116 |
|
} |
| 117 |
|
|
| 118 |
|
} |