Fixed style errors in alto-model. 54/17454/1
authorGao Kai <gaok12@mails.tsinghua.edu.cn>
Tue, 31 Mar 2015 14:41:42 +0000 (22:41 +0800)
committerGao Kai <gaok12@mails.tsinghua.edu.cn>
Tue, 31 Mar 2015 14:41:42 +0000 (22:41 +0800)
Put some constants in commons.

Change-Id: I3a2c94b5df1393c9beba061dd1e4e2fb3f28ebbc
Signed-off-by: Gao Kai <gaok12@mails.tsinghua.edu.cn>
alto-model/pom.xml
alto-model/src/main/yang/alto-service-did.yang
alto-model/src/main/yang/alto-service-types.yang
alto-model/src/main/yang/alto-service.yang
alto-northbound/pom.xml
alto-northbound/src/main/java/org/opendaylight/alto/northbound/AltoNorthbound.java
commons/pom.xml [new file with mode: 0644]
commons/src/main/java/org/opendaylight/alto/commons/RFC7285MediaType.java [new file with mode: 0644]
commons/src/main/java/org/opendaylight/alto/commons/YangModelMediaType.java [new file with mode: 0644]
pom.xml

index 059246301697acb294ab9dee6f74f8455b32c4d6..bd7573a759caf86fcff4e457af2b4104c7fd51dc 100644 (file)
                 </executions>
                 <configuration>
                     <failsOnError>true</failsOnError>
-                    <configLocation>../checkstyle.xml</configLocation>
+                    <configLocation>controller/checkstyle.xml</configLocation>
                     <consoleOutput>true</consoleOutput>
                     <includeTestSourceDirectory>true</includeTestSourceDirectory>
                     <sourceDirectory>${project.basedir}</sourceDirectory>
                     <includes>**\/*.yang</includes>
                     <excludes>**\/target\/,**\/bin\/,**\/third-party,**\/yang-gen-sal</excludes>
                 </configuration>
+
+                <dependencies>
+                  <dependency>
+                    <groupId>org.opendaylight.controller</groupId>
+                    <artifactId>checkstyle</artifactId>
+                    <version>${controller.checkstyle.version}</version>
+                  </dependency>
+                </dependencies>
             </plugin>
             <plugin>
                 <groupId>org.apache.maven.plugins</groupId>
index 5823640dd988b34d5a02f2fe520f9919584f02fe..1ea255e60d907f00ecb6796d1068649222cb9d56 100644 (file)
@@ -1,6 +1,6 @@
 module alto-service-did {
   yang-version 1;
-  
+
   namespace "urn:opendaylight:alto-service-did";
   // TODO: replace with IANA namespace when assigned
 
@@ -13,9 +13,9 @@ module alto-service-did {
   organization "ALTO WG";
   contact "alto@ietf.org";
 
-  description 
-    "This module defines the data instance descriptions (DID) of a 
-     semantically equivalent data model for the ALTO services 
+  description
+    "This module defines the data instance descriptions (DID) of a
+     semantically equivalent data model for the ALTO services
      defined in RFC7285.";
 
   revision 2014-11-01 {
index e815602aa56d11546e1402d0fc4f6a0ece89a9ec..35f4e2580591ea54391fc6a9327afb551f327e62 100644 (file)
@@ -1,6 +1,6 @@
 module alto-service-types {
   yang-version 1;
-  
+
   namespace "urn:opendaylight:alto-service-types";
   // TODO: replace with IANA namespace when assigned
 
@@ -13,7 +13,7 @@ module alto-service-types {
   organization "ALTO WG";
   contact "alto@ietf.org";
 
-  description 
+  description
     "This module defines the data types and groupings for a semantically
      equivalent data model for the ALTO services defined in RFC7285.";
 
@@ -24,7 +24,7 @@ module alto-service-types {
   revision 2014-10-24 {
     description "Initial version.";
   }
-  
+
   /********************
    * TYPE DEFINITIONS *
    ********************/
@@ -56,11 +56,11 @@ module alto-service-types {
          ]
 
    To handle the proceeding, we need the following definitions:
-      ipv4-address (e.g., 192.0.2.0, already defined in rfc6991), 
-      ipv6-address (already defined in rfc6991), 
-      ipv4-prefix (e.g., 192.0.2.0/24, already defined in rfc6991), 
-      ipv6-prefix (defined in rfc6991), 
-      typed-ipv4-address (e.g., ipv4:192.0.2.1, to be defined below) 
+      ipv4-address (e.g., 192.0.2.0, already defined in rfc6991),
+      ipv6-address (already defined in rfc6991),
+      ipv4-prefix (e.g., 192.0.2.0/24, already defined in rfc6991),
+      ipv6-prefix (defined in rfc6991),
+      typed-ipv4-address (e.g., ipv4:192.0.2.1, to be defined below)
       typed-ipv6-address
       typed-ipv4-prefix-list (e.g., "ipv4": [
            "192.0.2.0/24",
@@ -69,7 +69,7 @@ module alto-service-types {
 
   *******************************************************************/
 
-  /* 
+  /*
      First define typed-ipv4-address and typed-ipv6-address, as used
      by endpoint services.
 
@@ -127,7 +127,7 @@ module alto-service-types {
      } EndpointAddrGroup;
 
      There are two challenges:
+
      1) To specify that AddressType is key, we must use the list type,
      which is the only type that one can specify key. However, the
      current JSON-YANG encoding generates an array, instead of a
@@ -188,7 +188,7 @@ module alto-service-types {
    *   cost-metric,
    *   cost-mode
    *
-   * We group their definitions together below.       
+   * We group their definitions together below.
    **************************************************************/
 
   typedef valid-id-string {
@@ -366,7 +366,7 @@ module alto-service-types {
     }
     description
       "Global endpoint property. RFC7285 Sec. 10.8.2." +
-      "'priv:' for Private Use " + 
+      "'priv:' for Private Use " +
       " length 1..32; ‘.’ is not allowed";
   }
 
@@ -408,7 +408,7 @@ module alto-service-types {
   typedef media-type {
     type union {
       type string {
-        pattern "application/alto\-.*";   
+        pattern "application/alto\-.*";
       }
       type enumeration {
         enum alto-directory; //+json
@@ -576,7 +576,7 @@ module alto-service-types {
       }
       uses endpoint-address-group;
       description
-        "RFC7285 Sec. 11.2.1.6." + 
+        "RFC7285 Sec. 11.2.1.6." +
         " object-map {
             PIDName -> EndpointAddrGroup;
           } NetworkMapData;";
@@ -621,7 +621,7 @@ module alto-service-types {
           " object-map {
               PIDName -> JSONValue;
             } DstCosts;";
-      }         
+      }
       description
         "The list represents the outer part of the cost matrix." +
         "CostMapData. RFC7285 Sec. 11.2.3.6." +
index 571876c71c1ace391bf11bed7416e1d5d8d50357..82a377737cbf51ced9772ade853d991d0f608cb1 100644 (file)
@@ -2,7 +2,7 @@ module alto-service {
   //alto-service-restconf
 
   yang-version 1;
-  
+
   namespace "urn:opendaylight:alto";
   // TODO: replace with IANA namespace when assigned
 
@@ -19,7 +19,7 @@ module alto-service {
   organization "ALTO WG";
   contact "alto@ietf.org";
 
-  description 
+  description
     "This module defines a data model for the ALTO services
      using restconf. Note this is not interop with RFC7285.";
 
index e5310fa82ed3cafa7328d4a5a0835fddedfc2d30..cdef005d9e64a7d41688c0ad299523bac1489fa1 100644 (file)
@@ -26,6 +26,7 @@
           </dependency>
         </dependencies>
       </plugin>
+
       <plugin>
         <groupId>org.apache.felix</groupId>
         <artifactId>maven-bundle-plugin</artifactId>
@@ -36,6 +37,7 @@
             <Import-Package>
               org.codehaus.jettison.json,
               org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924,
+              org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev141101,
               org.apache.commons.logging,
               com.sun.jersey.spi.container.servlet,
               org.opendaylight.controller.northbound.commons,
               org.apache.catalina.filters,
               com.fasterxml.jackson.jaxrs.base,
               com.fasterxml.jackson.jaxrs.json,
+              !org.codehaus.enunciate.jaxrs
             </Import-Package>
             <Web-ContextPath>/controller/nb/v2/alto</Web-ContextPath>
           </instructions>
           <manifestLocation>${project.basedir}/src/main/resources/META-INF</manifestLocation>
         </configuration>
       </plugin>
+
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-checkstyle-plugin</artifactId>
+        <version>${checkstyle.version}</version>
+
+        <executions>
+          <execution>
+            <phase>process-sources</phase>
+            <goals>
+              <goal>check</goal>
+            </goals>
+          </execution>
+        </executions>
+
+        <configuration>
+          <failsOnError>true</failsOnError>
+          <configLocation>controller/checkstyle.xml</configLocation>
+          <consoleOutput>true</consoleOutput>
+          <includeTestSourceDirectory>true</includeTestSourceDirectory>
+          <sourceDirectory>${project.basedir}</sourceDirectory>
+          <excludes>**\/target\/,**\/bin\/,**\/third-party,**\/yang-gen-sal</excludes>
+        </configuration>
+
+        <dependencies>
+          <dependency>
+            <groupId>org.opendaylight.controller</groupId>
+            <artifactId>checkstyle</artifactId>
+            <version>${controller.checkstyle.version}</version>
+          </dependency>
+        </dependencies>
+      </plugin>
+
     </plugins>
   </build>
+
   <dependencies>
     <dependency>
       <groupId>org.opendaylight.controller.thirdparty</groupId>
       <artifactId>com.sun.jersey.jersey-servlet</artifactId>
       <version>1.17</version>
     </dependency>
+
     <dependency>
       <groupId>org.opendaylight.controller</groupId>
       <artifactId>commons.northbound</artifactId>
       <version>0.4.2-SNAPSHOT</version>
     </dependency>
+
     <dependency>
       <groupId>org.codehaus.enunciate</groupId>
       <artifactId>enunciate-core-annotations</artifactId>
       <version>${enunciate.version}</version>
     </dependency>
+
     <dependency>
       <groupId>org.opendaylight.controller.thirdparty</groupId>
       <artifactId>org.apache.catalina.filters.CorsFilter</artifactId>
       <version>7.0.42</version>
     </dependency>
+
     <dependency>
       <groupId>org.codehaus.jettison</groupId>
       <artifactId>jettison</artifactId>
       <version>1.3.7</version>
     </dependency>
+
+    <dependency>
+      <groupId>${project.groupId}</groupId>
+      <artifactId>commons</artifactId>
+      <version>${project.version}</version>
+    </dependency>
+
   </dependencies>
 </project>
 
index 848dd54a182a5fd8df95c023b37d75e4b9b9ece6..cd31068c103d98041a3fc362c077f575a5a9aa5f 100644 (file)
@@ -7,12 +7,12 @@
  */
 package org.opendaylight.alto.northbound;
 
-import org.codehaus.jettison.json.JSONObject;
+import org.opendaylight.alto.commons.RFC7285MediaType;
 
+import org.codehaus.jettison.json.JSONObject;
 import javax.ws.rs.Path;
 import javax.ws.rs.GET;
 import javax.ws.rs.Produces;
-import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.Response;
 
 import org.slf4j.Logger;
@@ -23,57 +23,6 @@ public class AltoNorthbound {
 
     private static final Logger mLogger = LoggerFactory.getLogger(AltoNorthbound.class);
 
-    /* TODO
-     *
-     * Move them to AltoServiceAPI
-     *
-     * */
-
-    /** The media types defined in [RFC7285]
-     * */
-    public static final class AltoMediaType {
-        public static final String ALTO_DIRECTORY
-                                = "application/alto-directory+json";
-        public static final MediaType ALTO_DIRECTORY_TYPE
-                                = MediaType.valueOf(ALTO_DIRECTORY);
-        public static final String ALTO_NETWORKMAP
-                                = "application/alto-networkmap+json";
-        public static final MediaType ALTO_NETWORKMAP_TYPE
-                                = MediaType.valueOf(ALTO_NETWORKMAP);
-        public static final String ALTO_NETWORKMAP_FILTER
-                                = "application/alto-networkmapfilter+json";
-        public static final MediaType ALTO_NETWORKMAP_FILTER_TYPE
-                                = MediaType.valueOf(ALTO_NETWORKMAP_FILTER);
-        public static final String ALTO_COSTMAP
-                                = "application/alto-costmap+json";
-        public static final MediaType ALTO_COSTMAP_TYPE
-                                = MediaType.valueOf(ALTO_COSTMAP);
-        public static final String ALTO_COSTMAP_FILTER
-                                = "application/alto-costmapfilter+json";
-        public static final MediaType ALTO_COSTMAP_FILTER_TYPE
-                                = MediaType.valueOf(ALTO_COSTMAP_FILTER);
-        public static final String ALTO_ENDPOINT_PROP
-                                = "application/alto-endpointprop+json";
-        public static final MediaType ALTO_ENDPOINT_PROP_TYPE
-                                = MediaType.valueOf(ALTO_ENDPOINT_PROP);
-        public static final String ALTO_ENDPOINT_PROPPARAMS
-                                = "application/alto-endpointpropparams+json";
-        public static final MediaType ALTO_ENDPOINT_PROPPARAMS_TYPE
-                                = MediaType.valueOf(ALTO_ENDPOINT_PROPPARAMS);
-        public static final String ALTO_ENDPOINT_COST
-                                = "application/alto-endpointcost+json";
-        public static final MediaType ALTO_ENDPOINT_COST_TYPE
-                                = MediaType.valueOf(ALTO_ENDPOINT_COST);
-        public static final String ALTO_ENDPOINT_COSTPARAMS
-                                = "application/alto-endpointcostparams+json";
-        public static final MediaType ALTO_ENDPOINT_COSTPARAMS_TYPE
-                                = MediaType.valueOf(ALTO_ENDPOINT_COSTPARAMS);
-        public static final String ALTO_ERROR
-                                = "application/alto-error+json";
-        public static final MediaType ALTO_ERROR_TYPE
-                                = MediaType.valueOf(ALTO_ERROR);
-    }
-
     public class AltoError {
         public static final String E_SYNTAX = "syntax-error";
         public static final String E_MISSING_FIELD = "missing-field";
@@ -82,14 +31,14 @@ public class AltoNorthbound {
     }
 
     @GET
-    @Produces({AltoMediaType.ALTO_DIRECTORY, AltoMediaType.ALTO_ERROR})
+    @Produces({RFC7285MediaType.ALTO_DIRECTORY, RFC7285MediaType.ALTO_ERROR})
     public Response retrieveIRD() {
         JSONObject ird = new JSONObject();
         try {
             ird.put("test", "ok");
         } catch (Exception e) {
         }
-        return Response.ok(ird.toString(), AltoMediaType.ALTO_ERROR).build();
+        return Response.ok(ird.toString(), RFC7285MediaType.ALTO_ERROR).build();
     }
 
     @Path("/hello")
diff --git a/commons/pom.xml b/commons/pom.xml
new file mode 100644 (file)
index 0000000..0c302b6
--- /dev/null
@@ -0,0 +1,65 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+
+  <parent>
+    <groupId>org.opendaylight.alto</groupId>
+    <artifactId>alto-parent</artifactId>
+    <version>1.0.0-SNAPSHOT</version>
+    <relativePath>..</relativePath>
+  </parent>
+
+  <groupId>org.opendaylight.alto</groupId>
+  <artifactId>commons</artifactId>
+  <packaging>jar</packaging>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-checkstyle-plugin</artifactId>
+        <version>${checkstyle.version}</version>
+
+        <executions>
+          <execution>
+            <phase>process-sources</phase>
+            <goals>
+              <goal>check</goal>
+            </goals>
+          </execution>
+        </executions>
+
+        <configuration>
+          <failsOnError>true</failsOnError>
+          <configLocation>controller/checkstyle.xml</configLocation>
+          <consoleOutput>true</consoleOutput>
+          <includeTestSourceDirectory>true</includeTestSourceDirectory>
+          <sourceDirectory>${project.basedir}</sourceDirectory>
+          <excludes>**\/target\/,**\/bin\/,**\/third-party,**\/yang-gen-sal</excludes>
+        </configuration>
+
+        <dependencies>
+          <dependency>
+            <groupId>org.opendaylight.controller</groupId>
+            <artifactId>checkstyle</artifactId>
+            <version>${controller.checkstyle.version}</version>
+          </dependency>
+        </dependencies>
+      </plugin>
+
+    </plugins>
+  </build>
+
+  <dependencies>
+
+    <dependency>
+      <groupId>${project.groupId}</groupId>
+      <artifactId>alto-model</artifactId>
+      <version>${project.version}</version>
+    </dependency>
+
+  </dependencies>
+</project>
+
diff --git a/commons/src/main/java/org/opendaylight/alto/commons/RFC7285MediaType.java b/commons/src/main/java/org/opendaylight/alto/commons/RFC7285MediaType.java
new file mode 100644 (file)
index 0000000..68280c9
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2015 Yale University 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.alto.commons;
+
+public class RFC7285MediaType {
+
+    /** The media types defined in [RFC7285]
+     *
+     *  The media types defined here should be identical to those
+     *  generated by alto-model, the main reason we need this is
+     *  the ones defined here are *STRING LITERALS*.
+     * */
+
+    public static final String ALTO_DIRECTORY
+                            = "application/alto-directory+json";
+    public static final String ALTO_NETWORKMAP
+                            = "application/alto-networkmap+json";
+    public static final String ALTO_NETWORKMAP_FILTER
+                            = "application/alto-networkmapfilter+json";
+    public static final String ALTO_COSTMAP
+                            = "application/alto-costmap+json";
+    public static final String ALTO_COSTMAP_FILTER
+                            = "application/alto-costmapfilter+json";
+    public static final String ALTO_ENDPOINT_PROP
+                            = "application/alto-endpointprop+json";
+    public static final String ALTO_ENDPOINT_PROPPARAMS
+                            = "application/alto-endpointpropparams+json";
+    public static final String ALTO_ENDPOINT_COST
+                            = "application/alto-endpointcost+json";
+    public static final String ALTO_ENDPOINT_COSTPARAMS
+                            = "application/alto-endpointcostparams+json";
+    public static final String ALTO_ERROR
+                            = "application/alto-error+json";
+}
+
diff --git a/commons/src/main/java/org/opendaylight/alto/commons/YangModelMediaType.java b/commons/src/main/java/org/opendaylight/alto/commons/YangModelMediaType.java
new file mode 100644 (file)
index 0000000..d73be98
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2015 Yale University 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.alto.commons;
+
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.service.types.rev141101.MediaType;
+
+class YangModelMediaType {
+
+    /** The media types generated by alto-model
+     * */
+
+    public static final String ALTO_DIRECTORY
+                            = new MediaType(MediaType.Enumeration.AltoDirectory).toString();
+    public static final String ALTO_NETWORKMAP
+                            = new MediaType(MediaType.Enumeration.AltoNetworkmap).toString();
+    public static final String ALTO_NETWORKMAP_FILTER
+                            = new MediaType(MediaType.Enumeration.AltoNetworkmapfilter).toString();
+    public static final String ALTO_COSTMAP
+                            = new MediaType(MediaType.Enumeration.AltoCostmap).toString();
+    public static final String ALTO_COSTMAP_FILTER
+                            = new MediaType(MediaType.Enumeration.AltoCostmapfilter).toString();
+    public static final String ALTO_ENDPOINT_PROP
+                            = new MediaType(MediaType.Enumeration.AltoEndpointprop).toString();
+    public static final String ALTO_ENDPOINT_PROPPARAMS
+                            = new MediaType(MediaType.Enumeration.AltoEndpointpropparams).toString();
+    public static final String ALTO_ENDPOINT_COST
+                            = new MediaType(MediaType.Enumeration.AltoEndpointcost).toString();
+    public static final String ALTO_ENDPOST_COSTPARAMS
+                            = new MediaType(MediaType.Enumeration.AltoEndpointcostparams).toString();
+    public static final String ALTO_ERROR
+                            = new MediaType(MediaType.Enumeration.AltoError).toString();
+}
diff --git a/pom.xml b/pom.xml
index c74796f80611fbb66a4da1d7a29c86d02ecb4181..50e09a6fec3f020145b11d18088aa1127bba99f1 100644 (file)
--- a/pom.xml
+++ b/pom.xml
@@ -71,6 +71,7 @@
         <karaf.resources.version>1.5.0-SNAPSHOT</karaf.resources.version>
         <feature.test.version>1.5.0-SNAPSHOT</feature.test.version>
         <karaf.empty.version>1.5.0-SNAPSHOT</karaf.empty.version>
+        <controller.checkstyle.version>0.1.0-SNAPSHOT</controller.checkstyle.version>
 
         <!-- Test Libraries -->
         <powermock.version>1.5.6</powermock.version>
         <module>alto-northbound</module>
         <module>alto-artifacts</module>
         <module>features</module>
+        <module>commons</module>
         <module>alto-karaf</module>
     </modules>