Fix Operation not permitted warning. 90/6390/1
authorMartin Bobak <mbobak@cisco.com>
Fri, 25 Apr 2014 14:05:48 +0000 (16:05 +0200)
committerMartin Bobak <mbobak@cisco.com>
Fri, 25 Apr 2014 14:14:07 +0000 (16:14 +0200)
This fix removes warning
WARN  o.o.c.n.c.m.c.ModuleElementDefinition - Operation not permitted on
current strategy  while default strategy is merge. Element definition
strategy set to default

that occured on osgi startup.

Change-Id: Ic12ce37e9bfa08cfffd0cac0e591fc49ffe227c6
Signed-off-by: Martin Bobak <mbobak@cisco.com>
opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/mapping/config/InstanceConfigElementResolved.java
opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/mapping/config/ModuleElementDefinition.java

index 0d55902..c9605af 100644 (file)
@@ -9,15 +9,13 @@
 package org.opendaylight.controller.netconf.confignetconfconnector.mapping.config;
 
 import com.google.common.collect.Multimap;
+import java.util.Map;
 import org.opendaylight.controller.netconf.api.NetconfDocumentedException;
 import org.opendaylight.controller.netconf.confignetconfconnector.exception.OperationNotPermittedException;
 import org.opendaylight.controller.netconf.confignetconfconnector.mapping.attributes.fromxml.AttributeConfigElement;
 import org.opendaylight.controller.netconf.confignetconfconnector.operations.editconfig.EditConfigStrategy;
-import org.opendaylight.controller.netconf.confignetconfconnector.operations.editconfig.EditConfigXmlParser;
 import org.opendaylight.controller.netconf.confignetconfconnector.operations.editconfig.EditStrategyType;
 
-import java.util.Map;
-
 /**
  * Parsed xml element containing whole configuration for an instance of some
  * module. Contains preferred edit strategy type.
@@ -44,16 +42,6 @@ public class InstanceConfigElementResolved {
 
 
     static EditStrategyType parseStrategy(String currentStrategy, EditStrategyType defaultStrategy) throws OperationNotPermittedException {
-        if (null == currentStrategy || currentStrategy.equals("")){
-            throw new OperationNotPermittedException(String.format("With "
-                    + defaultStrategy
-                    + " as "
-                    + EditConfigXmlParser.DEFAULT_OPERATION_KEY
-                    + " operations on module elements are not permitted since the default option is restrictive"),
-                    NetconfDocumentedException.ErrorType.application,
-                    NetconfDocumentedException.ErrorTag.operation_failed,
-                    NetconfDocumentedException.ErrorSeverity.error);
-        }
         EditStrategyType parsedStrategy = EditStrategyType.valueOf(currentStrategy);
         EditStrategyType.compareParsedStrategyToDefaultEnforcing(parsedStrategy,defaultStrategy);
         return parsedStrategy;
index d1c3ebe..b772eee 100644 (file)
@@ -27,20 +27,22 @@ public class ModuleElementDefinition {
 
     public ModuleElementDefinition(String instanceName, String currentStrategy, EditStrategyType defaultStrategy) {
         this.instanceName = instanceName;
-        EditStrategyType _edStrategy = null;
-        try {
-            _edStrategy = InstanceConfigElementResolved.parseStrategy(currentStrategy, defaultStrategy);
-        } catch (OperationNotPermittedException e) {
-            _edStrategy = defaultStrategy;
-            logger.warn("Operation not permitted on current strategy {} while default strategy is {}. Element definition strategy set to default.",
-                    currentStrategy,
-                    defaultStrategy,
-                    e);
+        if (currentStrategy == null || currentStrategy.isEmpty()) {
+            this.editStrategy = defaultStrategy;
+        } else {
+            EditStrategyType _edStrategy = null;
+            try {
+                _edStrategy = InstanceConfigElementResolved.parseStrategy(currentStrategy, defaultStrategy);
+            } catch (OperationNotPermittedException e) {
+                _edStrategy = defaultStrategy;
+                logger.warn("Operation not permitted on current strategy {} while default strategy is {}. Element definition strategy set to default.",
+                        currentStrategy,
+                        defaultStrategy,
+                        e);
+            }
+            this.editStrategy = _edStrategy;
         }
-        if (currentStrategy == null || currentStrategy.isEmpty())
-            _edStrategy = defaultStrategy;
 
-        this.editStrategy = _edStrategy;
     }
 
     public String getInstanceName() {