Put some constants in commons.
Change-Id: I3a2c94b5df1393c9beba061dd1e4e2fb3f28ebbc
Signed-off-by: Gao Kai <gaok12@mails.tsinghua.edu.cn>
</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>
module alto-service-did {
yang-version 1;
-
+
namespace "urn:opendaylight:alto-service-did";
// TODO: replace with IANA namespace when assigned
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 {
module alto-service-types {
yang-version 1;
-
+
namespace "urn:opendaylight:alto-service-types";
// TODO: replace with IANA namespace when assigned
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.";
revision 2014-10-24 {
description "Initial version.";
}
-
+
/********************
* TYPE DEFINITIONS *
********************/
]
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",
*******************************************************************/
- /*
+ /*
First define typed-ipv4-address and typed-ipv6-address, as used
by endpoint services.
} 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
* cost-metric,
* cost-mode
*
- * We group their definitions together below.
+ * We group their definitions together below.
**************************************************************/
typedef valid-id-string {
}
description
"Global endpoint property. RFC7285 Sec. 10.8.2." +
- "'priv:' for Private Use " +
+ "'priv:' for Private Use " +
" length 1..32; ‘.’ is not allowed";
}
typedef media-type {
type union {
type string {
- pattern "application/alto\-.*";
+ pattern "application/alto\-.*";
}
type enumeration {
enum alto-directory; //+json
}
uses endpoint-address-group;
description
- "RFC7285 Sec. 11.2.1.6." +
+ "RFC7285 Sec. 11.2.1.6." +
" object-map {
PIDName -> EndpointAddrGroup;
} NetworkMapData;";
" object-map {
PIDName -> JSONValue;
} DstCosts;";
- }
+ }
description
"The list represents the outer part of the cost matrix." +
"CostMapData. RFC7285 Sec. 11.2.3.6." +
//alto-service-restconf
yang-version 1;
-
+
namespace "urn:opendaylight:alto";
// TODO: replace with IANA namespace when assigned
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.";
</dependency>
</dependencies>
</plugin>
+
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<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>
*/
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;
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";
}
@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")
--- /dev/null
+<?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>
+
--- /dev/null
+/*
+ * 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";
+}
+
--- /dev/null
+/*
+ * 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();
+}
<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>