X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fadsal%2Fnorthbound%2Farchetype-app-northbound%2Fsrc%2Fmain%2Fresources%2Farchetype-resources%2Fsrc%2Fmain%2Fjava%2FNorthbound.java;fp=opendaylight%2Fadsal%2Fnorthbound%2Farchetype-app-northbound%2Fsrc%2Fmain%2Fresources%2Farchetype-resources%2Fsrc%2Fmain%2Fjava%2FNorthbound.java;h=788dec855ffd2a38f3e8c77f82e9c4b1eead5b53;hb=42c32160bfd41de57189bb246fec5ffb48ed8e9e;hp=0000000000000000000000000000000000000000;hpb=edf5bfcee83c750853253ccfd991ba7000f5f65b;p=controller.git
diff --git a/opendaylight/adsal/northbound/archetype-app-northbound/src/main/resources/archetype-resources/src/main/java/Northbound.java b/opendaylight/adsal/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/adsal/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; + } + +}