use of org.opendaylight.controller.config.facade.xml.mapping.config.Services in project controller by opendaylight.
the class ConfigSubsystemFacade method setServicesOnTransaction.
private static void setServicesOnTransaction(final ConfigTransactionClient ta, final ConfigExecution execution) throws DocumentedException {
Services services = execution.getServices();
Map<String, Map<String, Map<String, Services.ServiceInstance>>> namespaceToServiceNameToRefNameToInstance = services.getNamespaceToServiceNameToRefNameToInstance();
for (Map.Entry<String, Map<String, Map<String, Services.ServiceInstance>>> namespaceToServiceToRefEntry : namespaceToServiceNameToRefNameToInstance.entrySet()) {
for (Map.Entry<String, Map<String, Services.ServiceInstance>> serviceToRefEntry : namespaceToServiceToRefEntry.getValue().entrySet()) {
String qnameOfService = getQname(ta, namespaceToServiceToRefEntry.getKey(), serviceToRefEntry.getKey());
Map<String, Services.ServiceInstance> refNameToInstance = serviceToRefEntry.getValue();
for (Map.Entry<String, Services.ServiceInstance> refNameToServiceEntry : refNameToInstance.entrySet()) {
ObjectName on = refNameToServiceEntry.getValue().getObjectName(ta.getTransactionName());
try {
if (Services.ServiceInstance.EMPTY_SERVICE_INSTANCE == refNameToServiceEntry.getValue()) {
ta.removeServiceReference(qnameOfService, refNameToServiceEntry.getKey());
LOG.debug("Removing service {} with name {}", qnameOfService, refNameToServiceEntry.getKey());
} else {
ObjectName saved = ta.saveServiceReference(qnameOfService, refNameToServiceEntry.getKey(), on);
LOG.debug("Saving service {} with on {} under name {} with service on {}", qnameOfService, on, refNameToServiceEntry.getKey(), saved);
}
} catch (final InstanceNotFoundException e) {
throw new DocumentedException(String.format("Unable to edit ref name " + refNameToServiceEntry.getKey() + " for instance " + on, e), ErrorType.APPLICATION, ErrorTag.OPERATION_FAILED, ErrorSeverity.ERROR);
}
}
}
}
}
Aggregations