} catch (NoSessionException e1) {
logger.error("Could not roll back because no session.");
return;
}
UserProfileTask upTask = context.consumeUserProfileTask();
HybridEncryptedContent encrypted;
try {
encrypted = H2HEncryptionUtil.encryptHybrid(upTask, session.getKeyPair().getPublic());
} catch (DataLengthException | InvalidKeyException | IllegalStateException
| InvalidCipherTextException | IllegalBlockSizeException | BadPaddingException | IOException e) {
logger.error("Could not encrypt the user profile task while rollback.");
return;
}
String userId = networkManager.getUserId();
DataManager dataManager;
try {
dataManager = networkManager.getDataManager();
} catch (NoPeerConnectionException e) {
logger.warn(
"Rollback of remove user profile task failed. No connection. User ID = '{}', Content key = '{}'.",
userId, upTask.getContentKey());
return;
}
encrypted.setTimeToLive(upTask.getTimeToLive());
boolean success = dataManager.putUserProfileTask(userId, upTask.getContentKey(), encrypted,
upTask.getProtectionKey());
if (success) {
logger.debug(
"Rollback of removing user profile task succeeded. User ID = '{}', Content key = '{}'.",
userId, upTask.getContentKey());
} else {
logger.warn(
"Rollback of removing user profile task failed. Re-put failed. User ID = '{}', Content key = '{}'.",
userId, upTask.getContentKey());
}
}