newService.activate();
}
}
public static void removeServiceEndpoints(TargetService service) throws Exception {
TargetService oldService = getService(service.getEpr());
if (oldService == null) {
throw new DiscoveryException("Error while updating discovery metadata. No service " +
"exists with the ID: " + service.getEpr().getAddress());
}
// When marking an existing service as inactive try to hold on to
// the old metadata of the service
if (service.getScopes() == null) {
service.setScopes(oldService.getScopes());
}
if (service.getTypes() == null) {
service.setTypes(oldService.getTypes());
}
if (service.getMetadataVersion() == -1) {
service.setMetadataVersion(oldService.getMetadataVersion());
}
if (service.getXAddresses() != null && oldService.getXAddresses() != null) {
// According to the spec this is the set of addresses on
// which the service is NO LONGER AVAILABLE.
// We should remove them from the registry.
List<URI> existingAddresses = new ArrayList<URI>();
for (URI xAddr : oldService.getXAddresses()) {
existingAddresses.add(xAddr);
}
for (URI xAddr : service.getXAddresses()) {
existingAddresses.remove(xAddr);