Set<DistributorVersionCapability> capabilities = distributorVersionCurator.
findCapabilitiesByDistVersion(existing.getFact("distributor_version"));
if (capabilities != null) {
Set<ConsumerCapability> ccaps = new HashSet<ConsumerCapability>();
for (DistributorVersionCapability dvc : capabilities) {
ConsumerCapability cc =
new ConsumerCapability(existing, dvc.getName());
ccaps.add(cc);
}
existing.setCapabilities(ccaps);
}
change = true;
}
}
else {
// update
if (update.getCapabilities() != null) {
change = update.getCapabilities().equals(existing.getCapabilities());
existing.setCapabilities(update.getCapabilities());
}
else if (update.getFact("distributor_version") != null) {
DistributorVersion dv = distributorVersionCurator.findByName(
update.getFact("distributor_version"));
if (dv != null) {
Set<ConsumerCapability> ccaps = new HashSet<ConsumerCapability>();
for (DistributorVersionCapability dvc : dv.getCapabilities()) {
ConsumerCapability cc =
new ConsumerCapability(existing, dvc.getName());
ccaps.add(cc);
}
existing.setCapabilities(ccaps);
}
change = true;