Merge "Reduce informations from logging.bridge"
authorEd Warnicke <eaw@cisco.com>
Fri, 24 Jan 2014 14:17:02 +0000 (14:17 +0000)
committerGerrit Code Review <gerrit@opendaylight.org>
Fri, 24 Jan 2014 14:17:02 +0000 (14:17 +0000)
opendaylight/clustering/integrationtest/src/test/java/org/opendaylight/controller/clustering/services_implementation/internal/ClusteringServicesIT.java
opendaylight/configuration/api/src/main/java/org/opendaylight/controller/configuration/ConfigurationObject.java [new file with mode: 0644]
opendaylight/containermanager/api/pom.xml
opendaylight/containermanager/api/src/main/java/org/opendaylight/controller/containermanager/ContainerConfig.java
opendaylight/containermanager/api/src/main/java/org/opendaylight/controller/containermanager/ContainerFlowConfig.java
opendaylight/forwarding/staticrouting/src/main/java/org/opendaylight/controller/forwarding/staticrouting/StaticRouteConfig.java
opendaylight/forwardingrulesmanager/api/src/main/java/org/opendaylight/controller/forwardingrulesmanager/FlowConfig.java
opendaylight/md-sal/pom.xml
opendaylight/md-sal/sal-remoterpc-connector/implementation/pom.xml
opendaylight/md-sal/topology-lldp-discovery/pom.xml
opendaylight/switchmanager/api/src/main/java/org/opendaylight/controller/switchmanager/SubnetConfig.java

index fa2e2ee8fa1cc01aca369e1327c2fc7e2652772d..9c9831f4f5776245e564294e9f39d896ef8e051b 100644 (file)
@@ -99,6 +99,7 @@ public class ClusteringServicesIT {
             mavenBundle("org.opendaylight.controller", "sal").versionAsInProject(),\r
             mavenBundle("org.opendaylight.controller",\r
                         "sal.implementation").versionAsInProject(),\r
+            mavenBundle("org.opendaylight.controller", "configuration").versionAsInProject(),\r
             mavenBundle("org.opendaylight.controller", "containermanager").versionAsInProject(),\r
             mavenBundle("org.opendaylight.controller",\r
                         "containermanager.it.implementation").versionAsInProject(),\r
@@ -133,10 +134,10 @@ public class ClusteringServicesIT {
         assertNotNull(bc);\r
         boolean debugit = false;\r
         Bundle b[] = bc.getBundles();\r
-        for (int i = 0; i < b.length; i++) {\r
-            int state = b[i].getState();\r
+        for (Bundle element : b) {\r
+            int state = element.getState();\r
             if (state != Bundle.ACTIVE && state != Bundle.RESOLVED) {\r
-                log.debug("Bundle:" + b[i].getSymbolicName() + " state:"\r
+                log.debug("Bundle:" + element.getSymbolicName() + " state:"\r
                           + stateToString(state));\r
                 debugit = true;\r
             }\r
diff --git a/opendaylight/configuration/api/src/main/java/org/opendaylight/controller/configuration/ConfigurationObject.java b/opendaylight/configuration/api/src/main/java/org/opendaylight/controller/configuration/ConfigurationObject.java
new file mode 100644 (file)
index 0000000..34542de
--- /dev/null
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2013 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.configuration;
+
+import java.io.Serializable;
+
+public abstract class ConfigurationObject implements Serializable {
+    private static final long serialVersionUID = 1L;
+    private static final String DEFAULT_REGEX = "^[\\w-\\+\\*\\/\\.\\(\\)\\[\\]\\@]{1,256}$";
+    private static final String REGEX_PROP_NAME = "resourceNameRegularExpression";
+    private static String regex;
+
+    static {
+        String customRegex = System.getProperty(REGEX_PROP_NAME);
+        regex = (customRegex != null) ? customRegex : DEFAULT_REGEX;
+    }
+
+    /**
+     * Checks if the provided resource name matches the controller resource name
+     * regular expression
+     *
+     * @param name
+     *            The resource name to test
+     * @return true if the resource name is not null and matches the controller
+     *         resource name regular expression, false otherwise
+     */
+    protected boolean isValidResourceName(String name) {
+        return (name != null) ? name.matches(regex) : false;
+    }
+
+    /**
+     * Return the regular expression currently in use for testing the controller
+     * resource names
+     *
+     * @return The regular expression
+     */
+    public static String getRegularExpression() {
+        return regex;
+    }
+}
index 744198acf87e34b7502e7bc1ac025e369d287321..b6c4d4c2a3662cd72f91caf187e739d264d3b493 100644 (file)
@@ -28,6 +28,7 @@
         <configuration>
           <instructions>
             <Import-Package>
+              org.opendaylight.controller.configuration,
               org.opendaylight.controller.sal.authorization,
               org.opendaylight.controller.sal.utils,
               org.opendaylight.controller.sal.core,
@@ -55,5 +56,9 @@
       <groupId>org.opendaylight.controller</groupId>
       <artifactId>sal</artifactId>
     </dependency>
+    <dependency>
+      <groupId>org.opendaylight.controller</groupId>
+      <artifactId>configuration</artifactId>
+    </dependency>
   </dependencies>
 </project>
index 99568dfcce886fb89de47fba5cc775b00a24530a..3c086cbce0cd8934653e4f4cab512e87e7a21433 100644 (file)
@@ -20,6 +20,7 @@ import javax.xml.bind.annotation.XmlAccessorType;
 import javax.xml.bind.annotation.XmlElement;
 import javax.xml.bind.annotation.XmlRootElement;
 
+import org.opendaylight.controller.configuration.ConfigurationObject;
 import org.opendaylight.controller.sal.core.ContainerFlow;
 import org.opendaylight.controller.sal.core.NodeConnector;
 import org.opendaylight.controller.sal.match.Match;
@@ -37,7 +38,7 @@ import org.opendaylight.controller.sal.utils.StatusCode;
  */
 @XmlRootElement(name = "containerConfig")
 @XmlAccessorType(XmlAccessType.NONE)
-public class ContainerConfig implements Serializable {
+public class ContainerConfig extends ConfigurationObject implements Serializable {
     private static final long serialVersionUID = 2L;
     private static final String regexName = "^\\w+$";
     private static final String containerProfile = System.getProperty("container.profile") == null ? "Container"
@@ -227,7 +228,7 @@ public class ContainerConfig implements Serializable {
      */
     private Status validateName() {
         // No Container configuration allowed to container default
-        return ((container != null) && container.matches(regexName) && !container.equalsIgnoreCase(GlobalConstants.DEFAULT.toString())) ?
+        return (isValidResourceName(container) && !container.equalsIgnoreCase(GlobalConstants.DEFAULT.toString())) ?
                 new Status(StatusCode.SUCCESS) : new Status(StatusCode.BADREQUEST, "Invalid container name");
     }
 
index 9d65ad343c4c540e2d93d750524becac00a3e9b8..6abd1acd404956db9f3c0819109154ac85b1717d 100644 (file)
@@ -24,6 +24,7 @@ import javax.xml.bind.annotation.XmlAccessorType;
 import javax.xml.bind.annotation.XmlElement;
 import javax.xml.bind.annotation.XmlRootElement;
 
+import org.opendaylight.controller.configuration.ConfigurationObject;
 import org.opendaylight.controller.sal.match.Match;
 import org.opendaylight.controller.sal.match.MatchType;
 import org.opendaylight.controller.sal.packet.BitBufferHelper;
@@ -44,15 +45,12 @@ import org.slf4j.LoggerFactory;
  */
 @XmlRootElement (name = "flow-spec-config")
 @XmlAccessorType(XmlAccessType.NONE)
-public class ContainerFlowConfig implements Serializable {
+public class ContainerFlowConfig extends ConfigurationObject implements Serializable {
     private static Logger log = LoggerFactory.getLogger(ContainerFlowConfig.class);
 
     /** The Constant serialVersionUID. */
     private static final long serialVersionUID = 1L;
 
-    /** The Constant regexName. */
-    private static final String regexName = "^[\\w-+.@]+$";
-
     /** Flow Spec name. */
     @XmlElement
     private String name;
@@ -596,7 +594,7 @@ public class ContainerFlowConfig implements Serializable {
      * @return true, if is valid
      */
     public Status validate() {
-        if (!hasValidName()) {
+        if (!isValidResourceName(name)) {
             return new Status(StatusCode.BADREQUEST, "Invalid name");
         }
         Status status = validateVlan();
@@ -619,15 +617,6 @@ public class ContainerFlowConfig implements Serializable {
         return new Status(StatusCode.SUCCESS);
     }
 
-    /**
-     * Checks if this flow specification configuration has a valid name.
-     *
-     * @return true, if successful
-     */
-    private boolean hasValidName() {
-        return (name != null && !name.isEmpty() && name.matches(regexName));
-    }
-
     /**
      * Validates the vlan number
      *
index a4505c8b1c8e6a732127de0aebbb4746874aacee..7726c0f4e78c3bc9684e0384e13da23fb1e9d9b2 100644 (file)
@@ -18,6 +18,7 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
+import org.opendaylight.controller.configuration.ConfigurationObject;
 import org.opendaylight.controller.sal.utils.GUIField;
 import org.opendaylight.controller.sal.utils.Status;
 import org.opendaylight.controller.sal.utils.StatusCode;
@@ -25,7 +26,7 @@ import org.opendaylight.controller.sal.utils.StatusCode;
 /**
  * This class defines all the necessary configuration information for a static route.
  */
-public class StaticRouteConfig implements Serializable {
+public class StaticRouteConfig extends ConfigurationObject implements Serializable {
     private static final long serialVersionUID = 1L;
     private static final String regexSubnet = "^([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\."
             + "([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\."
@@ -150,7 +151,7 @@ public class StaticRouteConfig implements Serializable {
      * @return SUCCESS if the config is valid
      */
     public Status isValid() {
-        if ((name == null) || (name.trim().length() < 1)) {
+        if (!isValidResourceName(name)) {
             return new Status(StatusCode.BADREQUEST,
                         "Invalid Static Route name");
         }
@@ -207,8 +208,9 @@ public class StaticRouteConfig implements Serializable {
         if (getNextHopType().equalsIgnoreCase(
                 StaticRoute.NextHopType.SWITCHPORT.toString())) {
             String pieces[] = nextHop.split("/");
-            if (pieces.length < 2)
+            if (pieces.length < 2) {
                 return false;
+            }
             return isValidSwitchId(pieces[0]);
         }
         return false;
@@ -350,20 +352,26 @@ public class StaticRouteConfig implements Serializable {
         }
         StaticRouteConfig other = (StaticRouteConfig) obj;
         if (name == null) {
-            if (other.name != null)
+            if (other.name != null) {
                 return false;
-        } else if (!name.equals(other.name))
+            }
+        } else if (!name.equals(other.name)) {
             return false;
+        }
         if (nextHop == null) {
-            if (other.nextHop != null)
+            if (other.nextHop != null) {
                 return false;
-        } else if (!nextHop.equals(other.nextHop))
+            }
+        } else if (!nextHop.equals(other.nextHop)) {
             return false;
+        }
         if (staticRoute == null) {
-            if (other.staticRoute != null)
+            if (other.staticRoute != null) {
                 return false;
-        } else if (!staticRoute.equals(other.staticRoute))
+            }
+        } else if (!staticRoute.equals(other.staticRoute)) {
             return false;
+        }
         return true;
     }
 
index de6b8182b07c71c8975cd5fcfa49e3326197ef9e..c56eb60a6b47d7f4093e56ade0a4d0b1d3262583 100644 (file)
@@ -8,6 +8,7 @@
 
 package org.opendaylight.controller.forwardingrulesmanager;
 
+import org.opendaylight.controller.configuration.ConfigurationObject;
 import org.opendaylight.controller.sal.action.Action;
 import org.opendaylight.controller.sal.action.ActionType;
 import org.opendaylight.controller.sal.action.Controller;
@@ -67,10 +68,9 @@ import java.util.regex.Pattern;
  */
 @XmlRootElement
 @XmlAccessorType(XmlAccessType.NONE)
-public class FlowConfig implements Serializable {
+public class FlowConfig extends ConfigurationObject implements Serializable {
     private static final long serialVersionUID = 1L;
     private static final Logger log = LoggerFactory.getLogger(FlowConfig.class);
-    private static final String NAMEREGEX = "^[a-zA-Z0-9]+$";
     public static final String STATICFLOWGROUP = "__StaticFlows__";
     public static final String INTERNALSTATICFLOWGROUP = "__InternalStaticFlows__";
     public static final String INTERNALSTATICFLOWBEGIN = "__";
@@ -687,7 +687,8 @@ public class FlowConfig implements Serializable {
 
         Switch sw = null;
         try {
-            if (name == null || name.trim().isEmpty() || !name.matches(FlowConfig.NAMEREGEX)) {
+            // Flow name cannot be internal flow signature
+            if (!isValidResourceName(name) || isInternalFlow()) {
                 return new Status(StatusCode.BADREQUEST, "Invalid name");
             }
 
index bcbd48014d45bb3d3e9f96a848d3ed680e5f085c..d383162748b327a8dc794621099f3b282caaf126 100644 (file)
         <guava.version>14.0.1</guava.version>
         <osgi.core.version>5.0.0</osgi.core.version>
         <junit.version>4.8.1</junit.version>
-        <powermock.version>1.5.1</powermock.version>
         <mockito.version>1.9.5</mockito.version>
         <xtend.version>2.4.3</xtend.version>
         <maven.clean.plugin.version>2.5</maven.clean.plugin.version>
         <jacoco.version>0.5.3.201107060350</jacoco.version>
-        <sal.version>0.5.1-SNAPSHOT</sal.version>  <!-- AD Sal version -->
 
         <!-- Sonar properties using jacoco to retrieve integration test results -->
         <sonar.java.coveragePlugin>jacoco</sonar.java.coveragePlugin>
                 <version>${mockito.version}</version>
                 <scope>test</scope>
             </dependency>
-            <dependency>
-                <groupId>org.powermock</groupId>
-                <artifactId>powermock-module-junit4</artifactId>
-                <version>${powermock.version}</version>
-                <scope>test</scope>
-            </dependency>
-            <dependency>
-                <groupId>org.powermock</groupId>
-                <artifactId>powermock-api-mockito</artifactId>
-                <version>${powermock.version}</version>
-                <scope>test</scope>
-            </dependency>
-            <dependency>
-                <groupId>org.powermock</groupId>
-                <artifactId>powermock-core</artifactId>
-                <version>${powermock.version}</version>
-                <scope>test</scope>
-            </dependency>
             <dependency>
                 <groupId>org.opendaylight.yangtools</groupId>
                 <artifactId>binding-generator-impl</artifactId>
index 28f0ef7d9f5290bb1d618cb891320af7758fd17f..cb2f5482d6ad3ea683ddf38a6e39c5db385d4c1b 100644 (file)
       <groupId>org.mockito</groupId>
       <artifactId>mockito-all</artifactId>
     </dependency>
-    <dependency>
-      <groupId>org.powermock</groupId>
-      <artifactId>powermock-module-junit4</artifactId>
-    </dependency>
-    <dependency>
-      <groupId>org.powermock</groupId>
-      <artifactId>powermock-api-mockito</artifactId>
-    </dependency>
-    <dependency>
-      <groupId>org.powermock</groupId>
-      <artifactId>powermock-core</artifactId>
-    </dependency>
-
   </dependencies>
 
 
index 36c4f621380d1b415b5e9b090eb89230a4e32141..aa4210ee578718c7a7c29d6f02a2f56b97aec00c 100644 (file)
@@ -62,7 +62,7 @@
              <dependency>
             <groupId>commons-lang</groupId>
             <artifactId>commons-lang</artifactId>
-            <version>2.6</version>
+            <version>2.4</version>
           </dependency>
           <dependency>
             <groupId>com.google.guava</groupId>
index 4f06b79f490c55ddd530924cab3f75705255c8bc..b3dead5fa4e40f8f7c56ef5008d40addf9285272 100644 (file)
@@ -20,6 +20,7 @@ import javax.xml.bind.annotation.XmlAccessorType;
 import javax.xml.bind.annotation.XmlElement;
 import javax.xml.bind.annotation.XmlRootElement;
 
+import org.opendaylight.controller.configuration.ConfigurationObject;
 import org.opendaylight.controller.sal.core.NodeConnector;
 import org.opendaylight.controller.sal.packet.BitBufferHelper;
 import org.opendaylight.controller.sal.utils.GUIField;
@@ -32,7 +33,7 @@ import org.opendaylight.controller.sal.utils.StatusCode;
  */
 @XmlRootElement
 @XmlAccessorType(XmlAccessType.NONE)
-public class SubnetConfig implements Cloneable, Serializable {
+public class SubnetConfig extends ConfigurationObject implements Cloneable, Serializable {
     private static final long serialVersionUID = 1L;
     private static final String prettyFields[] = { GUIField.NAME.toString(), GUIField.GATEWAYIP.toString(),
             GUIField.NODEPORTS.toString() };
@@ -148,7 +149,7 @@ public class SubnetConfig implements Cloneable, Serializable {
     }
 
     private Status validateName() {
-        if (name == null || name.trim().isEmpty()) {
+        if (!isValidResourceName(name)) {
             return new Status(StatusCode.BADREQUEST, "Invalid name");
         }
         return new Status(StatusCode.SUCCESS);