2 * Copyright (c) 2016 Brocade Communications Systems, Inc. and others. All rights reserved.
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
8 package org.opendaylight.controller.config.facade.xml.strategy;
11 import javax.management.InstanceNotFoundException;
12 import javax.management.ObjectName;
13 import org.opendaylight.controller.config.facade.xml.exception.ConfigHandlingException;
14 import org.opendaylight.controller.config.facade.xml.mapping.attributes.fromxml.AttributeConfigElement;
15 import org.opendaylight.controller.config.facade.xml.mapping.config.ServiceRegistryWrapper;
16 import org.opendaylight.controller.config.util.ConfigTransactionClient;
17 import org.opendaylight.controller.config.util.xml.DocumentedException;
20 * Edit strategy that forces re-creation of a module instance even if the config didn't change.
22 * @author Thomas Pantelis
24 public class ReCreateEditConfigStrategy extends AbstractEditConfigStrategy {
27 void handleMissingInstance(Map<String, AttributeConfigElement> configuration, ConfigTransactionClient ta,
28 String module, String instance, ServiceRegistryWrapper services) throws ConfigHandlingException {
29 throw new ConfigHandlingException(
30 String.format("Unable to recreate %s : %s, Existing module instance not found", module, instance),
31 DocumentedException.ErrorType.APPLICATION,
32 DocumentedException.ErrorTag.OPERATION_FAILED,
33 DocumentedException.ErrorSeverity.ERROR);
37 void executeStrategy(Map<String, AttributeConfigElement> configuration, ConfigTransactionClient ta,
38 ObjectName objectName, ServiceRegistryWrapper services) throws ConfigHandlingException {
40 ta.reCreateModule(objectName);
41 } catch(InstanceNotFoundException e) {
42 throw new ConfigHandlingException(String.format("Unable to recreate instance for %s", objectName),
43 DocumentedException.ErrorType.APPLICATION,
44 DocumentedException.ErrorTag.OPERATION_FAILED,
45 DocumentedException.ErrorSeverity.ERROR);