downloadUpdateVersionsFromServer();
}
void downloadUpdateVersionsFromServer() throws Exception {
for (final UpdateMessage um : sessions) {
final ArtifactDescriptor ad = um.artifactDescriptor();
final UpdateDescriptor ud = uds.get(ad);
if (null == ud)
uds.put(ad, updateDescriptor(ad,
updateClient().version(ad)));
}
}
@Override public Void call() throws Exception {
tellUpdateResolver();
notifySubscribers();
return null;
}
void tellUpdateResolver() throws Exception {
synchronized (updateResolver) {
updateResolver.restart();
for (UpdateMessage um : sessions)
for (UpdateDescriptor ud : availableUpdate(um))
updateResolver.allocate(ud);
}
}
void notifySubscribers() throws Exception {
for (UpdateMessage um : sessions)
for (UpdateDescriptor ud : availableUpdate(um))
if (!blacklisted.contains(ud))
sendAndLog(updateNotice(um, ud.updateVersion()));
}
@SuppressWarnings("unchecked")
List<UpdateDescriptor> availableUpdate(UpdateMessage um) {
final ArtifactDescriptor ad = um.artifactDescriptor();
final UpdateDescriptor ud = uds.get(ad);
return ud.updateVersion().equals(ad.version())
? Collections.EMPTY_LIST
: Collections.singletonList(ud);
}
UpdateMessage updateNotice(UpdateMessage um, String uv) {