this.networkManager = networkManager;
}
@Override
protected void doExecute() throws InvalidProcessStateException {
Locations locations = context.consumeLocations();
if (unreachablePeers.isEmpty()) {
logger.debug("No locations to remove. Skip the cleanup.");
return;
}
KeyPair protectionKeys;
try {
protectionKeys = networkManager.getSession().getProfileManager().getDefaultProtectionKey();
} catch (GetFailedException | NoSessionException e) {
logger.error("Could not get the protection keys.", e);
return;
}
for (PeerAddress toRemove : unreachablePeers) {
locations.removePeerAddress(toRemove);
}
locations.setBasedOnKey(locations.getVersionKey());
try {
locations.generateVersionKey();
} catch (IOException e) {
logger.error("Version key could not be generated.");
return;
}
try {
put(locations.getUserId(), H2HConstants.USER_LOCATIONS, locations, protectionKeys);
} catch (PutFailedException e) {
logger.error("Could not put the updated locations.");
}
}