Initial code drop of netconf protocol implementation
[controller.git] / opendaylight / netconf / config-netconf-connector / src / main / java / org / opendaylight / controller / netconf / confignetconfconnector / operations / editconfig / DeleteEditConfigStrategy.java
1 /*
2  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8
9 package org.opendaylight.controller.netconf.confignetconfconnector.operations.editconfig;
10
11 import java.util.Map;
12
13 import javax.management.InstanceNotFoundException;
14 import javax.management.ObjectName;
15
16 import org.opendaylight.controller.config.util.ConfigTransactionClient;
17 import org.opendaylight.controller.netconf.confignetconfconnector.mapping.attributes.fromxml.AttributeConfigElement;
18 import org.slf4j.Logger;
19 import org.slf4j.LoggerFactory;
20
21 public class DeleteEditConfigStrategy extends AbstractEditConfigStrategy {
22
23     private static final Logger logger = LoggerFactory.getLogger(DeleteEditConfigStrategy.class);
24
25     @Override
26     void handleMissingInstance(Map<String, AttributeConfigElement> configuration, ConfigTransactionClient ta,
27             String module, String instance) {
28         throw new IllegalStateException("Unable to delete " + module + ":" + instance + " , ServiceInstance not found");
29     }
30
31     @Override
32     void executeStrategy(Map<String, AttributeConfigElement> configuration, ConfigTransactionClient ta, ObjectName on) {
33         try {
34             ta.destroyModule(on);
35             logger.debug("ServiceInstance {} deleted successfully", on);
36         } catch (InstanceNotFoundException e) {
37             throw new IllegalStateException("Unable to delete " + on, e);
38         }
39     }
40 }