Apply configs' name convention to authorization roles and resource groups 11/5011/5
authorAlessandro Boch <aboch@cisco.com>
Wed, 29 Jan 2014 19:14:32 +0000 (11:14 -0800)
committerAlessandro Boch <aboch@cisco.com>
Tue, 4 Feb 2014 04:51:39 +0000 (20:51 -0800)
- Also include Switch config

Change-Id: If84199a1db6e1fc35c02c4b92493f99aeb8d8af8
Signed-off-by: Alessandro Boch <aboch@cisco.com>
opendaylight/appauth/pom.xml
opendaylight/appauth/src/main/java/org/opendaylight/controller/appauth/authorization/Authorization.java
opendaylight/configuration/api/src/main/java/org/opendaylight/controller/configuration/ConfigurationObject.java
opendaylight/switchmanager/api/src/main/java/org/opendaylight/controller/switchmanager/SwitchConfig.java

index 934fdfa..30879c6 100644 (file)
@@ -27,6 +27,7 @@
                 <configuration>
                     <instructions>
                         <Import-Package>
+                            org.opendaylight.controller.configuration,
                             org.opendaylight.controller.containermanager,
                             org.opendaylight.controller.sal.authorization,
                             org.opendaylight.controller.sal.utils,
     </build>
 
     <dependencies>
+      <dependency>
+        <groupId>org.opendaylight.controller</groupId>
+        <artifactId>configuration</artifactId>
+      </dependency>
       <dependency>
         <groupId>org.opendaylight.controller</groupId>
         <artifactId>sal</artifactId>
index 1992f59..b70a79b 100644 (file)
@@ -16,6 +16,7 @@ import java.util.Map.Entry;
 import java.util.Set;
 import java.util.concurrent.ConcurrentMap;
 
+import org.opendaylight.controller.configuration.ConfigurationObject;
 import org.opendaylight.controller.containermanager.IContainerAuthorization;
 import org.opendaylight.controller.sal.authorization.AppRoleLevel;
 import org.opendaylight.controller.sal.authorization.IResourceAuthorization;
@@ -36,7 +37,7 @@ import org.slf4j.LoggerFactory;
  */
 public abstract class Authorization<T> implements IResourceAuthorization {
 private static final Logger logger = LoggerFactory.getLogger(Authorization.class);
-    private static final String namesRegex = "^[a-zA-Z0-9]+[{\\.|\\_|\\-}[a-zA-Z0-9]]*$";
+    private static final String namesRegex = ConfigurationObject.getRegularExpression();
     /*
      * The configured resource groups
      */
index 34542de..80aed17 100644 (file)
@@ -12,7 +12,7 @@ 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 DEFAULT_REGEX = "^[\\w-\\+\\*\\/\\.\\(\\)\\[\\]\\@\\|]{1,256}$";
     private static final String REGEX_PROP_NAME = "resourceNameRegularExpression";
     private static String regex;
 
@@ -31,7 +31,7 @@ public abstract class ConfigurationObject implements Serializable {
      *         resource name regular expression, false otherwise
      */
     protected boolean isValidResourceName(String name) {
-        return (name != null) ? name.matches(regex) : false;
+        return name != null && name.matches(regex);
     }
 
     /**
index 28c811c..de18b02 100644 (file)
@@ -123,8 +123,8 @@ public class SwitchConfig extends ConfigurationObject implements Cloneable, Seri
     }
 
     private Status validateNodeId() {
-        if (nodeId == null || nodeId.isEmpty()) {
-            return new Status(StatusCode.BADREQUEST, "NodeId cannot be empty");
+        if (!isValidResourceName(nodeId)) {
+            return new Status(StatusCode.BADREQUEST, "Invalid NodeId");
         }
         return new Status(StatusCode.SUCCESS);
     }