From 41fa12f651c2520cbf617cb5c4b14f500ee53358 Mon Sep 17 00:00:00 2001 From: Andrew Kim Date: Mon, 10 Mar 2014 14:26:52 -0500 Subject: [PATCH] Add northbound archetype Change-Id: If7b42ddc1e6053450f8a7b17f3944c7ff026c5c4 Signed-off-by: Andrew Kim --- .../archetype-app-northbound/pom.xml | 30 ++++++ .../META-INF/maven/archetype-metadata.xml | 32 +++++++ .../resources/archetype-resources/pom.xml | 63 +++++++++++++ .../src/main/java/Northbound.java | 70 ++++++++++++++ .../src/main/resources/WEB-INF/web.xml | 92 +++++++++++++++++++ .../projects/basic/archetype.properties | 5 + .../test/resources/projects/basic/goal.txt | 0 7 files changed, 292 insertions(+) create mode 100644 opendaylight/northbound/archetype-app-northbound/pom.xml create mode 100644 opendaylight/northbound/archetype-app-northbound/src/main/resources/META-INF/maven/archetype-metadata.xml create mode 100644 opendaylight/northbound/archetype-app-northbound/src/main/resources/archetype-resources/pom.xml create mode 100644 opendaylight/northbound/archetype-app-northbound/src/main/resources/archetype-resources/src/main/java/Northbound.java create mode 100644 opendaylight/northbound/archetype-app-northbound/src/main/resources/archetype-resources/src/main/resources/WEB-INF/web.xml create mode 100644 opendaylight/northbound/archetype-app-northbound/src/test/resources/projects/basic/archetype.properties create mode 100644 opendaylight/northbound/archetype-app-northbound/src/test/resources/projects/basic/goal.txt diff --git a/opendaylight/northbound/archetype-app-northbound/pom.xml b/opendaylight/northbound/archetype-app-northbound/pom.xml new file mode 100644 index 0000000000..558bf41915 --- /dev/null +++ b/opendaylight/northbound/archetype-app-northbound/pom.xml @@ -0,0 +1,30 @@ + + + 4.0.0 + + org.opendaylight.controller + app-northbound + 0.0.1-SNAPSHOT + maven-archetype + + app-northbound + + + + + org.apache.maven.archetype + archetype-packaging + 2.2 + + + + + + + maven-archetype-plugin + 2.2 + + + + + diff --git a/opendaylight/northbound/archetype-app-northbound/src/main/resources/META-INF/maven/archetype-metadata.xml b/opendaylight/northbound/archetype-app-northbound/src/main/resources/META-INF/maven/archetype-metadata.xml new file mode 100644 index 0000000000..3c9223d3c7 --- /dev/null +++ b/opendaylight/northbound/archetype-app-northbound/src/main/resources/META-INF/maven/archetype-metadata.xml @@ -0,0 +1,32 @@ + + + + + src/main/java + + **/*.java + + + + src/main/resources + + **/*.xml + + + + .settings + + **/*.prefs + + + + + + .classpath + .project + + + + diff --git a/opendaylight/northbound/archetype-app-northbound/src/main/resources/archetype-resources/pom.xml b/opendaylight/northbound/archetype-app-northbound/src/main/resources/archetype-resources/pom.xml new file mode 100644 index 0000000000..da1bd41192 --- /dev/null +++ b/opendaylight/northbound/archetype-app-northbound/src/main/resources/archetype-resources/pom.xml @@ -0,0 +1,63 @@ +#set( $dollar = '$' ) + + + 4.0.0 + + org.opendaylight.controller + commons.opendaylight + 1.4.1-SNAPSHOT + ../../commons/opendaylight + + + ${artifactId} + + ${groupId} + bundle + + + + + org.apache.felix + maven-bundle-plugin + ${bundle.plugin.version} + true + + + + org.opendaylight.controller.northbound.commons, + com.sun.jersey.spi.container.servlet, + com.fasterxml.jackson.annotation, + javax.ws.rs, + javax.ws.rs.core, + javax.xml.bind, + javax.xml.bind.annotation, + org.slf4j, + org.apache.catalina.filters, + com.fasterxml.jackson.jaxrs.base, + com.fasterxml.jackson.jaxrs.json, + !org.codehaus.enunciate.jaxrs + /northbound/${artifactId} + ,${dollar}{classes;ANNOTATION;javax.ws.rs.Path} + + ${project.basedir}/src/main/resources/META-INF + + + + + + ${version} + + + org.codehaus.enunciate + enunciate-core-annotations + + + org.opendaylight.controller + commons.northbound + + + junit + junit + + + diff --git a/opendaylight/northbound/archetype-app-northbound/src/main/resources/archetype-resources/src/main/java/Northbound.java b/opendaylight/northbound/archetype-app-northbound/src/main/resources/archetype-resources/src/main/java/Northbound.java new file mode 100644 index 0000000000..788dec855f --- /dev/null +++ b/opendaylight/northbound/archetype-app-northbound/src/main/resources/archetype-resources/src/main/java/Northbound.java @@ -0,0 +1,70 @@ +#set( $symbol_pound = '#' ) +#set( $symbol_dollar = '$' ) +#set( $symbol_escape = '\' ) +package ${package}; + +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.SecurityContext; + +import org.codehaus.enunciate.jaxrs.StatusCodes; +import org.codehaus.enunciate.jaxrs.TypeHint; + +/** + * Northbound REST API + * + *
+ *
+ * Authentication scheme : HTTP Basic
+ * Authentication realm : opendaylight
+ * Transport : HTTP and HTTPS
+ *
+ * HTTPS Authentication is disabled by default. + */ + +@Path("/") +public class Northbound { + + private String username; + + @Context + public void setSecurityContext(SecurityContext context) { + if (context != null && context.getUserPrincipal() != null) { + username = context.getUserPrincipal().getName(); + } + } + + /** + * + * Sample REST API call + * + * @return A response string + * + *
+     * Example:
+     *
+     * Request URL:
+     * http://localhost:8080/northbound/${artifactId}/api
+     *
+     * Response body in XML:
+     * <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+     * Sample Northbound API
+     *
+     * Response body in JSON:
+     * Sample Northbound API
+     * 
+ */ + @Path("/api") + @GET + @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) + @TypeHint(String.class) + @StatusCodes() + public String getWidget() { + String result = "Sample Northbound API - ${artifactId}"; + return result; + } + +} diff --git a/opendaylight/northbound/archetype-app-northbound/src/main/resources/archetype-resources/src/main/resources/WEB-INF/web.xml b/opendaylight/northbound/archetype-app-northbound/src/main/resources/archetype-resources/src/main/resources/WEB-INF/web.xml new file mode 100644 index 0000000000..a1d837610c --- /dev/null +++ b/opendaylight/northbound/archetype-app-northbound/src/main/resources/archetype-resources/src/main/resources/WEB-INF/web.xml @@ -0,0 +1,92 @@ +#set( $symbol_pound = '#' ) +#set( $symbol_dollar = '$' ) +#set( $symbol_escape = '\' ) + + + + JAXRS${artifactId} + com.sun.jersey.spi.container.servlet.ServletContainer + + javax.ws.rs.Application + org.opendaylight.controller.northbound.commons.NorthboundApplication + + 1 + + + + JAXRS${artifactId} + /* + + + + CorsFilter + org.apache.catalina.filters.CorsFilter + + cors.allowed.origins + * + + + cors.allowed.methods + GET,POST,HEAD,OPTIONS,PUT,DELETE + + + cors.allowed.headers + Content-Type,X-Requested-With,accept,authorization, origin,Origin,Access-Control-Request-Method,Access-Control-Request-Headers + + + cors.exposed.headers + Access-Control-Allow-Origin,Access-Control-Allow-Credentials + + + cors.support.credentials + true + + + cors.preflight.maxage + 10 + + + + CorsFilter + /* + + + + + ${artifactId} + /* + POST + GET + PUT + PATCH + DELETE + HEAD + + + System-Admin + Network-Admin + Network-Operator + Container-User + + + + + System-Admin + + + Network-Admin + + + Network-Operator + + + Container-User + + + + BASIC + opendaylight + + diff --git a/opendaylight/northbound/archetype-app-northbound/src/test/resources/projects/basic/archetype.properties b/opendaylight/northbound/archetype-app-northbound/src/test/resources/projects/basic/archetype.properties new file mode 100644 index 0000000000..40d9d656ac --- /dev/null +++ b/opendaylight/northbound/archetype-app-northbound/src/test/resources/projects/basic/archetype.properties @@ -0,0 +1,5 @@ +#Fri Mar 07 21:17:20 CST 2014 +package=it.pkg +version=0.1-SNAPSHOT +groupId=archetype.it +artifactId=basic diff --git a/opendaylight/northbound/archetype-app-northbound/src/test/resources/projects/basic/goal.txt b/opendaylight/northbound/archetype-app-northbound/src/test/resources/projects/basic/goal.txt new file mode 100644 index 0000000000..e69de29bb2 -- 2.36.6