@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
try {
Long blueprintID = Long.valueOf(req.getParameter("blueprintID"));
logger.debug("Checking blueprint for consistency: {}", blueprintID);
Blueprint blueprint = blueprintDao.get(new Key<Blueprint>(Blueprint.class, blueprintID));
CharacterInfo attachedCharacterInfo = blueprint.getAttachedCharacterInfo();
if (attachedCharacterInfo == null) {
logger.debug("Blueprint does not have attached character, skipping");
return;
}
try {
Character character = characterDao.get(new Key<Character>(Character.class, attachedCharacterInfo.getId()));
logger.debug("Updating blueprint attached character information: {} ({})", character.getName(), character.getCharacterID());
attachedCharacterInfo.setCharacterID(character.getCharacterID());
attachedCharacterInfo.setName(character.getName());
attachedCharacterInfo.setCorporationID(character.getCorporationID());
attachedCharacterInfo.setCorporationName(character.getCorporationName());
attachedCharacterInfo.setCorporationTicker(character.getCorporationTicker());
attachedCharacterInfo.setAllianceID(character.getAllianceID());
attachedCharacterInfo.setAllianceName(character.getAllianceName());
} catch (NotFoundException e) {
logger.warn("Attached character does not exist: {}", attachedCharacterInfo.getId());
blueprint.setAttachedCharacterInfo(null);
}
blueprint.setUpdatedDate(new Date());
blueprintDao.putWithoutChecks(blueprint);
} catch (Throwable t) {
logger.error("Caught Throwable", t);
}
}