Fix sonar warnings in config-util. 78/46578/3
authorDana Kutenicsova <dana.kutenics@gmail.com>
Wed, 5 Oct 2016 19:41:14 +0000 (21:41 +0200)
committerTom Pantelis <tpanteli@brocade.com>
Mon, 10 Oct 2016 19:24:45 +0000 (19:24 +0000)
Mostly renaming enum constants.

Change-Id: I24a3afe1281a070550ef3c8424b35ed58d3691f6
Signed-off-by: Dana Kutenicsova <dana.kutenics@gmail.com>
14 files changed:
opendaylight/config/config-manager-facade-xml/src/main/java/org/opendaylight/controller/config/facade/xml/ConfigSubsystemFacade.java
opendaylight/config/config-manager-facade-xml/src/main/java/org/opendaylight/controller/config/facade/xml/mapping/attributes/resolving/SimpleAttributeResolvingStrategy.java
opendaylight/config/config-manager-facade-xml/src/main/java/org/opendaylight/controller/config/facade/xml/mapping/config/InstanceConfig.java
opendaylight/config/config-manager-facade-xml/src/main/java/org/opendaylight/controller/config/facade/xml/strategy/DeleteEditConfigStrategy.java
opendaylight/config/config-manager-facade-xml/src/main/java/org/opendaylight/controller/config/facade/xml/strategy/EditStrategyType.java
opendaylight/config/config-manager-facade-xml/src/main/java/org/opendaylight/controller/config/facade/xml/strategy/MergeEditConfigStrategy.java
opendaylight/config/config-manager-facade-xml/src/main/java/org/opendaylight/controller/config/facade/xml/strategy/MissingInstanceHandlingStrategy.java
opendaylight/config/config-manager-facade-xml/src/main/java/org/opendaylight/controller/config/facade/xml/strategy/ReCreateEditConfigStrategy.java
opendaylight/config/config-manager-facade-xml/src/main/java/org/opendaylight/controller/config/facade/xml/strategy/ReplaceEditConfigStrategy.java
opendaylight/config/config-util/src/main/java/org/opendaylight/controller/config/util/CloseableUtil.java
opendaylight/config/config-util/src/main/java/org/opendaylight/controller/config/util/ConfigRegistryJMXClient.java
opendaylight/config/config-util/src/main/java/org/opendaylight/controller/config/util/xml/DocumentedException.java
opendaylight/config/config-util/src/main/java/org/opendaylight/controller/config/util/xml/XmlElement.java
opendaylight/config/config-util/src/main/java/org/opendaylight/controller/config/util/xml/XmlMappingConstants.java

index 41629ce..d70376f 100644 (file)
@@ -210,9 +210,9 @@ public class ConfigSubsystemFacade implements Closeable {
                         }
                     } catch (InstanceNotFoundException e) {
                         throw new DocumentedException(String.format("Unable to edit ref name " + refNameToServiceEntry.getKey() + " for instance " + on, e),
-                                ErrorType.application,
-                                ErrorTag.operation_failed,
-                                ErrorSeverity.error);
+                                ErrorType.APPLICATION,
+                                ErrorTag.OPERATION_FAILED,
+                                ErrorSeverity.ERROR);
                     }
                 }
             }
index 6c53b80..5412882 100644 (file)
@@ -83,9 +83,9 @@ final class SimpleAttributeResolvingStrategy extends AbstractAttributeResolvingS
                 return parseObject(type, value);
             } catch (Exception e) {
                 throw new DocumentedException("Unable to resolve attribute " + attrName + " from " + value,
-                        DocumentedException.ErrorType.application,
-                        DocumentedException.ErrorTag.operation_failed,
-                        DocumentedException.ErrorSeverity.error);
+                        DocumentedException.ErrorType.APPLICATION,
+                        DocumentedException.ErrorTag.OPERATION_FAILED,
+                        DocumentedException.ErrorSeverity.ERROR);
             }
         }
 
@@ -97,9 +97,9 @@ final class SimpleAttributeResolvingStrategy extends AbstractAttributeResolvingS
             } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
                 LOG.trace("Error parsing object ",e);
                 throw new DocumentedException("Error parsing object.",
-                        DocumentedException.ErrorType.application,
-                        DocumentedException.ErrorTag.operation_failed,
-                        DocumentedException.ErrorSeverity.error);
+                        DocumentedException.ErrorType.APPLICATION,
+                        DocumentedException.ErrorTag.OPERATION_FAILED,
+                        DocumentedException.ErrorSeverity.ERROR);
             }
         }
     }
@@ -144,9 +144,9 @@ final class SimpleAttributeResolvingStrategy extends AbstractAttributeResolvingS
             } catch (ParseException e) {
                 LOG.trace("Unable parse value {} due to ",value, e);
                 throw new DocumentedException("Unable to parse value "+value+" as date.",
-                        DocumentedException.ErrorType.application,
-                        DocumentedException.ErrorTag.operation_failed,
-                        DocumentedException.ErrorSeverity.error);
+                        DocumentedException.ErrorType.APPLICATION,
+                        DocumentedException.ErrorTag.OPERATION_FAILED,
+                        DocumentedException.ErrorSeverity.ERROR);
             }
         }
     }
index 84fb064..a66fd75 100644 (file)
@@ -215,9 +215,9 @@ public final class InstanceConfig {
             if (!foundWithoutNamespaceNodes.isEmpty()){
                 throw new DocumentedException(String.format("Element %s present multiple times with different namespaces: %s, %s", name, foundConfigNodes,
                         foundWithoutNamespaceNodes),
-                        DocumentedException.ErrorType.application,
-                        DocumentedException.ErrorTag.invalid_value,
-                        DocumentedException.ErrorSeverity.error);
+                        DocumentedException.ErrorType.APPLICATION,
+                        DocumentedException.ErrorTag.INVALID_VALUE,
+                        DocumentedException.ErrorSeverity.ERROR);
             }
         }
 
index 423fac9..555af1e 100644 (file)
@@ -29,9 +29,9 @@ public class DeleteEditConfigStrategy extends AbstractEditConfigStrategy {
                                String module, String instance, 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);
+                DocumentedException.ErrorType.APPLICATION,
+                DocumentedException.ErrorTag.OPERATION_FAILED,
+                DocumentedException.ErrorSeverity.ERROR);
     }
 
     @Override
@@ -43,9 +43,9 @@ public class DeleteEditConfigStrategy extends AbstractEditConfigStrategy {
         } catch (InstanceNotFoundException e) {
             throw new ConfigHandlingException(
                     String.format("Unable to delete %s because of exception %s" + on, e.getMessage()),
-                    DocumentedException.ErrorType.application,
-                    DocumentedException.ErrorTag.operation_failed,
-                    DocumentedException.ErrorSeverity.error);
+                    DocumentedException.ErrorType.APPLICATION,
+                    DocumentedException.ErrorTag.OPERATION_FAILED,
+                    DocumentedException.ErrorSeverity.ERROR);
         }
     }
 }
index 47f5078..9954592 100644 (file)
@@ -48,9 +48,9 @@ public enum EditStrategyType {
                 throw new OperationNotPermittedException(String.format("With "
                         + defaultStrategy
                         + " as default-operation operations on module elements are not permitted since the default option is restrictive"),
-                        DocumentedException.ErrorType.application,
-                        DocumentedException.ErrorTag.operation_failed,
-                        DocumentedException.ErrorSeverity.error);
+                        DocumentedException.ErrorType.APPLICATION,
+                        DocumentedException.ErrorTag.OPERATION_FAILED,
+                        DocumentedException.ErrorSeverity.ERROR);
             }
         }
 
index 1a57141..5f0b23b 100644 (file)
@@ -40,9 +40,9 @@ public class MergeEditConfigStrategy extends AbstractEditConfigStrategy {
                 String.format("Unable to handle missing instance, no missing instances should appear at this point, missing: %s : %s ",
                         module,
                         instance),
-                DocumentedException.ErrorType.application,
-                DocumentedException.ErrorTag.operation_failed,
-                DocumentedException.ErrorSeverity.error);
+                DocumentedException.ErrorType.APPLICATION,
+                DocumentedException.ErrorTag.OPERATION_FAILED,
+                DocumentedException.ErrorSeverity.ERROR);
     }
 
     @Override
@@ -72,9 +72,9 @@ public class MergeEditConfigStrategy extends AbstractEditConfigStrategy {
                         on,
                         configAttributeEntry.getKey(),
                         configAttributeEntry.getValue()),
-                        DocumentedException.ErrorType.application,
-                        DocumentedException.ErrorTag.operation_failed,
-                        DocumentedException.ErrorSeverity.error);
+                        DocumentedException.ErrorType.APPLICATION,
+                        DocumentedException.ErrorTag.OPERATION_FAILED,
+                        DocumentedException.ErrorSeverity.ERROR);
             }
         }
     }
index 00e8504..591595e 100644 (file)
@@ -31,9 +31,9 @@ public class MissingInstanceHandlingStrategy extends AbstractEditConfigStrategy
             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),
-                    DocumentedException.ErrorType.application,
-                    DocumentedException.ErrorTag.operation_failed,
-                    DocumentedException.ErrorSeverity.error);
+                    DocumentedException.ErrorType.APPLICATION,
+                    DocumentedException.ErrorTag.OPERATION_FAILED,
+                    DocumentedException.ErrorSeverity.ERROR);
         }
     }
 
index 5d695ac..8df51a2 100644 (file)
@@ -28,9 +28,9 @@ public class ReCreateEditConfigStrategy extends AbstractEditConfigStrategy {
             String module, String instance, ServiceRegistryWrapper services) throws ConfigHandlingException {
         throw new ConfigHandlingException(
                 String.format("Unable to recreate %s : %s, Existing module instance not found", module, instance),
-                DocumentedException.ErrorType.application,
-                DocumentedException.ErrorTag.operation_failed,
-                DocumentedException.ErrorSeverity.error);
+                DocumentedException.ErrorType.APPLICATION,
+                DocumentedException.ErrorTag.OPERATION_FAILED,
+                DocumentedException.ErrorSeverity.ERROR);
     }
 
     @Override
@@ -40,9 +40,9 @@ public class ReCreateEditConfigStrategy extends AbstractEditConfigStrategy {
             ta.reCreateModule(objectName);
         } catch(InstanceNotFoundException e) {
             throw new ConfigHandlingException(String.format("Unable to recreate instance for %s", objectName),
-                    DocumentedException.ErrorType.application,
-                    DocumentedException.ErrorTag.operation_failed,
-                    DocumentedException.ErrorSeverity.error);
+                    DocumentedException.ErrorType.APPLICATION,
+                    DocumentedException.ErrorTag.OPERATION_FAILED,
+                    DocumentedException.ErrorSeverity.ERROR);
         }
     }
 }
index 0d18d56..9821a8b 100644 (file)
@@ -32,9 +32,9 @@ public class ReplaceEditConfigStrategy extends AbstractEditConfigStrategy {
                 String.format("Unable to handle missing instance, no missing instances should appear at this point, missing: %s : %s ",
                         module,
                         instance),
-                DocumentedException.ErrorType.application,
-                DocumentedException.ErrorTag.operation_failed,
-                DocumentedException.ErrorSeverity.error);
+                DocumentedException.ErrorType.APPLICATION,
+                DocumentedException.ErrorTag.OPERATION_FAILED,
+                DocumentedException.ErrorSeverity.ERROR);
     }
 
     @Override
index 9777861..b5f5752 100644 (file)
@@ -10,6 +10,9 @@ package org.opendaylight.controller.config.util;
 
 public class CloseableUtil {
 
+    private CloseableUtil() {
+    }
+
     public static void closeAll(Iterable<? extends AutoCloseable> autoCloseables) throws Exception {
         Exception lastException = null;
         for (AutoCloseable autoCloseable : autoCloseables) {
@@ -26,6 +29,5 @@ public class CloseableUtil {
         if (lastException != null) {
             throw lastException;
         }
-
     }
 }
index 74dd2ef..71adea8 100644 (file)
@@ -41,7 +41,7 @@ public class ConfigRegistryJMXClient implements ConfigRegistryClient {
         this.configMBeanServer = configMBeanServer;
         this.configRegistryON = configRegistryON;
         Set<ObjectInstance> searchResult = configMBeanServer.queryMBeans(configRegistryON, null);
-        if (!(searchResult.size() == 1)) {
+        if (searchResult.size() != 1) {
             throw new IllegalStateException("Config registry not found");
         }
         configRegistryMXBeanProxy = JMX.newMXBeanProxy(configMBeanServer, configRegistryON, ConfigRegistryMXBean.class,
@@ -87,7 +87,7 @@ public class ConfigRegistryJMXClient implements ConfigRegistryClient {
 
     static  ObjectName translateServiceRefIfPossible(ObjectName on, Class<?> clazz, MBeanServer configMBeanServer) {
         ObjectName onObj = on;
-        if (ObjectNameUtil.isServiceReference(onObj) && clazz.equals(ServiceReferenceMXBean.class) == false) {
+        if (ObjectNameUtil.isServiceReference(onObj) && !clazz.equals(ServiceReferenceMXBean.class)) {
             ServiceReferenceMXBean proxy = JMX.newMXBeanProxy(configMBeanServer, onObj, ServiceReferenceMXBean.class);
             onObj = proxy.getCurrentImplementation();
         }
index 854255d..09b82f1 100644 (file)
@@ -10,7 +10,6 @@ package org.opendaylight.controller.config.util.xml;
 
 import static org.opendaylight.controller.config.util.xml.XmlMappingConstants.RPC_REPLY_KEY;
 import static org.opendaylight.controller.config.util.xml.XmlMappingConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0;
-
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.Map;
@@ -42,7 +41,7 @@ public class DocumentedException extends Exception {
 
     private static final long serialVersionUID = 1L;
 
-    private final static Logger LOG = LoggerFactory.getLogger( DocumentedException.class );
+    private static final Logger LOG = LoggerFactory.getLogger(DocumentedException.class);
 
     private static final DocumentBuilderFactory BUILDER_FACTORY;
 
@@ -64,7 +63,7 @@ public class DocumentedException extends Exception {
     }
 
     public enum ErrorType {
-        transport, rpc, protocol, application;
+        TRANSPORT, RPC, PROTOCOL, APPLICATION;
 
         public String getTagValue() {
             return name();
@@ -75,31 +74,31 @@ public class DocumentedException extends Exception {
                 return valueOf( text );
             }
             catch( Exception e ) {
-                return application;
+                return APPLICATION;
             }
         }
     }
 
     public enum ErrorTag {
-        access_denied("access-denied"),
-        bad_attribute("bad-attribute"),
-        bad_element("bad-element"),
-        data_exists("data-exists"),
-        data_missing("data-missing"),
-        in_use("in-use"),
-        invalid_value("invalid-value"),
-        lock_denied("lock-denied"),
-        malformed_message("malformed-message"),
-        missing_attribute("missing-attribute"),
-        missing_element("missing-element"),
-        operation_failed("operation-failed"),
-        operation_not_supported("operation-not-supported"),
-        resource_denied("resource-denied"),
-        rollback_failed("rollback-failed"),
-        too_big("too-big"),
-        unknown_attribute("unknown-attribute"),
-        unknown_element("unknown-element"),
-        unknown_namespace("unknown-namespace");
+        ACCESS_DENIED("access-denied"),
+        BAD_ATTRIBUTE("bad-attribute"),
+        BAD_ELEMENT("bad-element"),
+        DATA_EXISTS("data-exists"),
+        DATA_MISSING("data-missing"),
+        IN_USE("in-use"),
+        INVALID_VALUE("invalid-value"),
+        LOCK_DENIED("lock-denied"),
+        MALFORMED_MESSAGE("malformed-message"),
+        MISSING_ATTRIBUTE("missing-attribute"),
+        MISSING_ELEMENT("missing-element"),
+        OPERATION_FAILED("operation-failed"),
+        OPERATION_NOT_SUPPORTED("operation-not-supported"),
+        RESOURCE_DENIED("resource-denied"),
+        ROLLBCK_FAILED("rollback-failed"),
+        TOO_BIG("too-big"),
+        UNKNOWN_ATTRIBUTE("unknown-attribute"),
+        UNKNOWN_ELEMENT("unknown-element"),
+        UNKNOWN_NAMESPACE("unknown-namespace");
 
         private final String tagValue;
 
@@ -119,12 +118,12 @@ public class DocumentedException extends Exception {
                 }
             }
 
-            return operation_failed;
+            return OPERATION_FAILED;
         }
     }
 
     public enum ErrorSeverity {
-        error, warning;
+        ERROR, WARNING;
 
         public String getTagValue() {
             return name();
@@ -135,7 +134,7 @@ public class DocumentedException extends Exception {
                 return valueOf( text );
             }
             catch( Exception e ) {
-                return error;
+                return ERROR;
             }
         }
     }
@@ -147,9 +146,9 @@ public class DocumentedException extends Exception {
 
     public DocumentedException(String message) {
         this(message,
-                DocumentedException.ErrorType.application,
-                DocumentedException.ErrorTag.invalid_value,
-                DocumentedException.ErrorSeverity.error
+                DocumentedException.ErrorType.APPLICATION,
+                DocumentedException.ErrorTag.INVALID_VALUE,
+                DocumentedException.ErrorSeverity.ERROR
         );
     }
 
@@ -183,29 +182,29 @@ public class DocumentedException extends Exception {
 
     public static <E extends Exception> DocumentedException wrap(E exception) throws DocumentedException {
         final Map<String, String> errorInfo = new HashMap<>();
-        errorInfo.put(ErrorTag.operation_failed.name(), "Exception thrown");
-        throw new DocumentedException(exception.getMessage(), exception, ErrorType.application, ErrorTag.operation_failed,
-                ErrorSeverity.error, errorInfo);
+        errorInfo.put(ErrorTag.OPERATION_FAILED.name(), "Exception thrown");
+        throw new DocumentedException(exception.getMessage(), exception, ErrorType.APPLICATION, ErrorTag.OPERATION_FAILED,
+                ErrorSeverity.ERROR, errorInfo);
     }
     public static DocumentedException wrap(ValidationException e) throws DocumentedException {
         final Map<String, String> errorInfo = new HashMap<>();
-        errorInfo.put(ErrorTag.operation_failed.name(), "Validation failed");
-        throw new DocumentedException(e.getMessage(), e, ErrorType.application, ErrorTag.operation_failed,
-                ErrorSeverity.error, errorInfo);
+        errorInfo.put(ErrorTag.OPERATION_FAILED.name(), "Validation failed");
+        throw new DocumentedException(e.getMessage(), e, ErrorType.APPLICATION, ErrorTag.OPERATION_FAILED,
+                ErrorSeverity.ERROR, errorInfo);
     }
 
     public static DocumentedException wrap(ConflictingVersionException e) throws DocumentedException {
         final Map<String, String> errorInfo = new HashMap<>();
-        errorInfo.put(ErrorTag.operation_failed.name(), "Optimistic lock failed");
-        throw new DocumentedException(e.getMessage(), e, ErrorType.application, ErrorTag.operation_failed,
-                ErrorSeverity.error, errorInfo);
+        errorInfo.put(ErrorTag.OPERATION_FAILED.name(), "Optimistic lock failed");
+        throw new DocumentedException(e.getMessage(), e, ErrorType.APPLICATION, ErrorTag.OPERATION_FAILED,
+                ErrorSeverity.ERROR, errorInfo);
     }
 
     public static DocumentedException fromXMLDocument( Document fromDoc ) {
 
-        ErrorType errorType = ErrorType.application;
-        ErrorTag errorTag = ErrorTag.operation_failed;
-        ErrorSeverity errorSeverity = ErrorSeverity.error;
+        ErrorType errorType = ErrorType.APPLICATION;
+        ErrorTag errorTag = ErrorTag.OPERATION_FAILED;
+        ErrorSeverity errorSeverity = ErrorSeverity.ERROR;
         Map<String, String> errorInfo = null;
         String errorMessage = "";
 
@@ -310,7 +309,8 @@ public class DocumentedException extends Exception {
             }
         }
         catch( ParserConfigurationException e ) {
-            LOG.error( "Error outputting to XML document", e ); // this shouldn't happen
+            // this shouldn't happen
+            LOG.error("Error outputting to XML document", e);
         }
 
         return doc;
index 795c6b6..d58acf1 100644 (file)
@@ -83,9 +83,9 @@ public final class XmlElement {
                 } else {
                     if (!attribKey.startsWith(XmlUtil.XMLNS_ATTRIBUTE_KEY + ":")){
                         throw new DocumentedException("Attribute doesn't start with :",
-                                DocumentedException.ErrorType.application,
-                                DocumentedException.ErrorTag.invalid_value,
-                                DocumentedException.ErrorSeverity.error);
+                                DocumentedException.ErrorType.APPLICATION,
+                                DocumentedException.ErrorTag.INVALID_VALUE,
+                                DocumentedException.ErrorSeverity.ERROR);
                     }
                     prefix = attribKey.substring(XmlUtil.XMLNS_ATTRIBUTE_KEY.length() + 1);
                 }
@@ -108,9 +108,9 @@ public final class XmlElement {
         if (!getName().equals(expectedName)){
             throw new UnexpectedElementException(String.format("Expected %s xml element but was %s", expectedName,
                     getName()),
-                    DocumentedException.ErrorType.application,
-                    DocumentedException.ErrorTag.operation_failed,
-                    DocumentedException.ErrorSeverity.error);
+                    DocumentedException.ErrorType.APPLICATION,
+                    DocumentedException.ErrorTag.OPERATION_FAILED,
+                    DocumentedException.ErrorSeverity.ERROR);
         }
     }
 
@@ -120,9 +120,9 @@ public final class XmlElement {
             throw new UnexpectedNamespaceException(String.format("Unexpected namespace %s should be %s",
                     getNamespaceAttribute(),
                     expectedNamespace),
-                    DocumentedException.ErrorType.application,
-                    DocumentedException.ErrorTag.operation_failed,
-                    DocumentedException.ErrorSeverity.error);
+                    DocumentedException.ErrorType.APPLICATION,
+                    DocumentedException.ErrorTag.OPERATION_FAILED,
+                    DocumentedException.ErrorSeverity.ERROR);
         }
     }
 
@@ -132,9 +132,9 @@ public final class XmlElement {
             throw new UnexpectedNamespaceException(String.format("Unexpected namespace %s should be %s",
                     getNamespace(),
                     expectedNamespace),
-                    DocumentedException.ErrorType.application,
-                    DocumentedException.ErrorTag.operation_failed,
-                    DocumentedException.ErrorSeverity.error);
+                    DocumentedException.ErrorType.APPLICATION,
+                    DocumentedException.ErrorTag.OPERATION_FAILED,
+                    DocumentedException.ErrorSeverity.ERROR);
         }
     }
 
@@ -250,9 +250,9 @@ public final class XmlElement {
         List<XmlElement> nameElements = getChildElements(childName);
         if (nameElements.size() != 1){
             throw new DocumentedException("One element " + childName + " expected in " + toString(),
-                    DocumentedException.ErrorType.application,
-                    DocumentedException.ErrorTag.invalid_value,
-                    DocumentedException.ErrorSeverity.error);
+                    DocumentedException.ErrorType.APPLICATION,
+                    DocumentedException.ErrorTag.INVALID_VALUE,
+                    DocumentedException.ErrorSeverity.ERROR);
         }
         return nameElements.get(0);
     }
@@ -329,9 +329,9 @@ public final class XmlElement {
         if (children.size() != 1){
             throw new DocumentedException(String.format("One element %s:%s expected in %s but was %s", namespace,
                     childName, toString(), children.size()),
-                    DocumentedException.ErrorType.application,
-                    DocumentedException.ErrorTag.invalid_value,
-                    DocumentedException.ErrorSeverity.error);
+                    DocumentedException.ErrorType.APPLICATION,
+                    DocumentedException.ErrorTag.INVALID_VALUE,
+                    DocumentedException.ErrorSeverity.ERROR);
         }
 
         return children.get(0);
@@ -342,9 +342,9 @@ public final class XmlElement {
         if (children.size() != 1){
             throw new DocumentedException(String.format( "One element expected in %s but was %s", toString(),
                     children.size()),
-                    DocumentedException.ErrorType.application,
-                    DocumentedException.ErrorTag.invalid_value,
-                    DocumentedException.ErrorSeverity.error);
+                    DocumentedException.ErrorType.APPLICATION,
+                    DocumentedException.ErrorTag.INVALID_VALUE,
+                    DocumentedException.ErrorSeverity.ERROR);
         }
         return children.get(0);
     }
@@ -370,9 +370,9 @@ public final class XmlElement {
             }
         }
         throw new DocumentedException(getName() + " should contain text.",
-                DocumentedException.ErrorType.application,
-                DocumentedException.ErrorTag.invalid_value,
-                DocumentedException.ErrorSeverity.error
+                DocumentedException.ErrorType.APPLICATION,
+                DocumentedException.ErrorTag.INVALID_VALUE,
+                DocumentedException.ErrorSeverity.ERROR
         );
     }
 
@@ -392,9 +392,9 @@ public final class XmlElement {
         if (attribute == null || attribute.equals(DEFAULT_NAMESPACE_PREFIX)){
             throw new MissingNameSpaceException(String.format("Element %s must specify namespace",
                     toString()),
-                    DocumentedException.ErrorType.application,
-                    DocumentedException.ErrorTag.operation_failed,
-                    DocumentedException.ErrorSeverity.error);
+                    DocumentedException.ErrorType.APPLICATION,
+                    DocumentedException.ErrorTag.OPERATION_FAILED,
+                    DocumentedException.ErrorSeverity.ERROR);
         }
         return attribute;
     }
@@ -420,9 +420,9 @@ public final class XmlElement {
         Optional<String> namespaceURI = getNamespaceOptionally();
         if (!namespaceURI.isPresent()){
             throw new MissingNameSpaceException(String.format("No namespace defined for %s", this),
-                    DocumentedException.ErrorType.application,
-                    DocumentedException.ErrorTag.operation_failed,
-                    DocumentedException.ErrorSeverity.error);
+                    DocumentedException.ErrorType.APPLICATION,
+                    DocumentedException.ErrorTag.OPERATION_FAILED,
+                    DocumentedException.ErrorSeverity.ERROR);
         }
         return namespaceURI.get();
     }
@@ -491,9 +491,9 @@ public final class XmlElement {
         }
         if (!childElements.isEmpty()){
             throw new DocumentedException(String.format("Unrecognised elements %s in %s", childElements, this),
-                    DocumentedException.ErrorType.application,
-                    DocumentedException.ErrorTag.invalid_value,
-                    DocumentedException.ErrorSeverity.error);
+                    DocumentedException.ErrorType.APPLICATION,
+                    DocumentedException.ErrorTag.INVALID_VALUE,
+                    DocumentedException.ErrorSeverity.ERROR);
         }
     }
 
@@ -522,12 +522,7 @@ public final class XmlElement {
     }
 
     public boolean hasNamespace() {
-        if (!getNamespaceAttributeOptionally().isPresent()) {
-            if (!getNamespaceOptionally().isPresent()) {
-                return false;
-            }
-        }
-        return true;
+        return getNamespaceAttributeOptionally().isPresent() || getNamespaceOptionally().isPresent();
     }
 
     private interface ElementFilteringStrategy {
index 3065ef0..e896772 100644 (file)
@@ -9,9 +9,6 @@ package org.opendaylight.controller.config.util.xml;
 
 public final class XmlMappingConstants {
 
-
-    private XmlMappingConstants() {}
-
     public static final String RPC_REPLY_KEY = "rpc-reply";
     public static final String TYPE_KEY = "type";
     public static final String MODULE_KEY = "module";
@@ -27,4 +24,7 @@ public final class XmlMappingConstants {
 
     public static final String URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0 = "urn:ietf:params:xml:ns:netconf:base:1.0";
     public static final String URN_OPENDAYLIGHT_PARAMS_XML_NS_YANG_CONTROLLER_CONFIG = "urn:opendaylight:params:xml:ns:yang:controller:config";
+
+    private XmlMappingConstants() {
+    }
 }