/* * Copyright (c) 2015, 2017 Cisco Systems, Inc. and others. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ package org.opendaylight.controller.config.facade.xml.strategy; import java.util.Map; import javax.management.InstanceNotFoundException; import javax.management.ObjectName; import org.opendaylight.controller.config.facade.xml.exception.ConfigHandlingException; import org.opendaylight.controller.config.facade.xml.mapping.attributes.fromxml.AttributeConfigElement; import org.opendaylight.controller.config.facade.xml.mapping.config.ServiceRegistryWrapper; import org.opendaylight.controller.config.util.ConfigTransactionClient; import org.opendaylight.controller.config.util.xml.DocumentedException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class DeleteEditConfigStrategy extends AbstractEditConfigStrategy { private static final Logger LOG = LoggerFactory.getLogger(DeleteEditConfigStrategy.class); @Override void handleMissingInstance(final Map configuration, final ConfigTransactionClient ta, final String module, final String instance, final ServiceRegistryWrapper services) throws ConfigHandlingException { throw new ConfigHandlingException( String.format("Unable to delete %s : %s , ServiceInstance not found", module, instance), DocumentedException.ErrorType.APPLICATION, DocumentedException.ErrorTag.OPERATION_FAILED, DocumentedException.ErrorSeverity.ERROR); } @Override void executeStrategy(final Map 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); } } }