@Override
public void setup(String siteAddress, String serverName, String serverDescription, String serverIcon, String adminName, String adminUsername, String adminPassword) throws ServerException, UserException {
SettingsInterface settingsInterface = getServiceMap().get(SettingsInterface.class);
if (!siteAddress.startsWith("http://") && !siteAddress.startsWith("https://")) {
throw new UserException("Site address should start with \"http://\" or \"https://\"");
}
if (siteAddress.startsWith("http://http://") || siteAddress.startsWith("https://https://")) {
throw new UserException("Site address should not have duplicate protocols");
}
settingsInterface.setSiteAddress(siteAddress);
settingsInterface.setServerName(serverName);
settingsInterface.setServerDescription(serverDescription);
settingsInterface.setServerIcon(serverIcon);
if (adminUsername.trim().isEmpty()) {
throw new UserException("Admin Username cannot be empty");
}
if (adminPassword.trim().isEmpty()) {
throw new UserException("Admin Password cannot be empty");
}
DatabaseSession session = getBimServer().getDatabase().createSession();
try {
AddUserDatabaseAction addUserDatabaseAction = new AddUserDatabaseAction(getBimServer(), session, AccessMethod.INTERNAL, adminUsername, adminPassword, adminName, UserType.ADMIN, getAuthorization(), false, "");
session.executeAndCommitAction(addUserDatabaseAction);
} catch (BimserverDatabaseException e) {
LOGGER.error("", e);
} finally {
session.close();
}
getBimServer().getServerInfoManager().update();
}