logger.debug("User does not have any characters, setting main character to null, main character corporation titles to null and character infos to null");
user.setCharacterInfos(null);
user.setMainCharacterInfo(null);
user.setMainCharacterCorporationTitles(null);
} else if (user.getMainCharacterInfo() == null) {
CharacterInfo characterInfo = characterInfos.get(0);
logger.debug("User does not have main character, will set to first random: {} ({})", characterInfo.getName(), characterInfo.getCharacterID());
user.setMainCharacterInfo(characterInfo);
} else {
CharacterInfo mainCharacterInfo = user.getMainCharacterInfo();
Long mainCharacterID = mainCharacterInfo.getCharacterID();
logger.debug("Checking whether current main character still exists: {} ({})", mainCharacterInfo.getName(), mainCharacterID);
for (CharacterInfo characterInfo : characterInfos) {
if (characterInfo.getCharacterID().equals(mainCharacterID)) {
logger.debug("Current main character exists, updating only list of character infos");
user.setCharacterInfos(characterInfos);
userDao.put(user);
return;
}
}
CharacterInfo characterInfo = characterInfos.get(0);
logger.debug("Current main character does not exist, will set to first random: {} ({})", characterInfo.getName(), characterInfo.getCharacterID());
user.setMainCharacterInfo(characterInfo);
}
CharacterInfo mainCharacterInfo = user.getMainCharacterInfo();
if (mainCharacterInfo != null) {
Character character = characterDao.get(new Key<Character>(Character.class, mainCharacterInfo.getId()));
List<String> corporationTitles = character.getCorporationTitles();
logger.debug("Setting main character corporation titles: {}", corporationTitles);
user.setMainCharacterCorporationTitles(corporationTitles);
}
userDao.put(user);