use of org.opendaylight.controller.config.facade.xml.exception.ConfigHandlingException in project controller by opendaylight.
the class DeleteEditConfigStrategy method executeStrategy.
@Override
void executeStrategy(final Map<String, AttributeConfigElement> configuration, final ConfigTransactionClient ta, final ObjectName on, final ServiceRegistryWrapper services) throws ConfigHandlingException {
try {
ta.destroyModule(on);
LOG.debug("ServiceInstance {} deleted successfully", on);
} catch (InstanceNotFoundException e) {
throw new ConfigHandlingException(String.format("Unable to delete %s because of exception %s" + on, e.getMessage()), e, DocumentedException.ErrorType.APPLICATION, DocumentedException.ErrorTag.OPERATION_FAILED, DocumentedException.ErrorSeverity.ERROR);
}
}
use of org.opendaylight.controller.config.facade.xml.exception.ConfigHandlingException in project controller by opendaylight.
the class MissingInstanceHandlingStrategy method handleMissingInstance.
@Override
void handleMissingInstance(Map<String, AttributeConfigElement> configuration, ConfigTransactionClient ta, String module, String instance, ServiceRegistryWrapper services) throws ConfigHandlingException {
try {
ObjectName on = ta.createModule(module, instance);
LOG.trace("New instance for {} {} created under name {}", module, instance, on);
} catch (InstanceAlreadyExistsException e1) {
throw new ConfigHandlingException(String.format("Unable to create instance for %s : %s.", module, instance), e1, DocumentedException.ErrorType.APPLICATION, DocumentedException.ErrorTag.OPERATION_FAILED, DocumentedException.ErrorSeverity.ERROR);
}
}
use of org.opendaylight.controller.config.facade.xml.exception.ConfigHandlingException in project controller by opendaylight.
the class MergeEditConfigStrategy method executeStrategy.
@Override
@SuppressWarnings("IllegalCatch")
void executeStrategy(Map<String, AttributeConfigElement> configuration, ConfigTransactionClient ta, ObjectName on, ServiceRegistryWrapper services) throws ConfigHandlingException {
for (Entry<String, AttributeConfigElement> configAttributeEntry : configuration.entrySet()) {
try {
AttributeConfigElement ace = configAttributeEntry.getValue();
if (!ace.getResolvedValue().isPresent()) {
LOG.debug("Skipping attribute {} for {}", configAttributeEntry.getKey(), on);
continue;
}
Object toBeMergedIn = ace.getResolvedValue().get();
// Get the existing values so we can merge the new values with them.
Attribute currentAttribute = ta.getAttribute(on, ace.getJmxName());
Object oldValue = currentAttribute != null ? currentAttribute.getValue() : null;
// Merge value with currentValue
toBeMergedIn = merge(oldValue, toBeMergedIn);
ta.setAttribute(on, ace.getJmxName(), new Attribute(ace.getJmxName(), toBeMergedIn));
LOG.debug("Attribute {} set to {} for {}", configAttributeEntry.getKey(), toBeMergedIn, on);
} catch (RuntimeException e) {
LOG.error("Error while merging object names of {}", on, e);
throw new ConfigHandlingException(String.format("Unable to set attributes for %s, " + "Error with attribute %s : %s ", on, configAttributeEntry.getKey(), configAttributeEntry.getValue()), e, DocumentedException.ErrorType.APPLICATION, DocumentedException.ErrorTag.OPERATION_FAILED, DocumentedException.ErrorSeverity.ERROR);
}
}
}
Aggregations