summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ems/boco/pom.xml49
-rw-r--r--ems/boco/src/main/java/org/onap/vfc/nfvo/emsdriver/EmsDriverApplication.java26
-rw-r--r--ems/boco/src/main/java/org/onap/vfc/nfvo/emsdriver/northbound/service/CommandResource.java6
3 files changed, 76 insertions, 5 deletions
diff --git a/ems/boco/pom.xml b/ems/boco/pom.xml
index ac890c5..413cff0 100644
--- a/ems/boco/pom.xml
+++ b/ems/boco/pom.xml
@@ -31,6 +31,8 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ <jersey.version>2.16</jersey.version>
+ <swagger.version>1.5.3</swagger.version>
</properties>
<build>
@@ -160,15 +162,52 @@
<version>1.0.6</version>
</dependency>
<dependency>
+ <groupId>io.dropwizard</groupId>
+ <artifactId>dropwizard-assets</artifactId>
+ <version>1.0.5</version>
+ </dependency>
+ <dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.2</version>
</dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>4.12</version>
- <scope>test</scope>
+ <dependency>
+ <groupId>org.glassfish.jersey.media</groupId>
+ <artifactId>jersey-media-multipart</artifactId>
+ <version>${jersey.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.glassfish.jersey.containers</groupId>
+ <artifactId>jersey-container-servlet-core</artifactId>
+ <version>${jersey.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.glassfish.jersey.containers</groupId>
+ <artifactId>jersey-container-servlet</artifactId>
+ <version>2.16</version>
+ </dependency>
+ <dependency>
+ <groupId>org.glassfish.jersey.core</groupId>
+ <artifactId>jersey-client</artifactId>
+ <version>2.16</version>
</dependency>
+ <dependency>
+ <groupId>org.glassfish.jersey.core</groupId>
+ <artifactId>jersey-common</artifactId>
+ <version>2.16</version>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.12</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>io.swagger</groupId>
+ <artifactId>swagger-jersey2-jaxrs</artifactId>
+ <version>${swagger.version}</version>
+ </dependency>
</dependencies>
</project>
diff --git a/ems/boco/src/main/java/org/onap/vfc/nfvo/emsdriver/EmsDriverApplication.java b/ems/boco/src/main/java/org/onap/vfc/nfvo/emsdriver/EmsDriverApplication.java
index dabf203..6ae160f 100644
--- a/ems/boco/src/main/java/org/onap/vfc/nfvo/emsdriver/EmsDriverApplication.java
+++ b/ems/boco/src/main/java/org/onap/vfc/nfvo/emsdriver/EmsDriverApplication.java
@@ -16,11 +16,14 @@
package org.onap.vfc.nfvo.emsdriver;
import io.dropwizard.Application;
+import io.dropwizard.assets.AssetsBundle;
import io.dropwizard.jetty.HttpConnectorFactory;
import io.dropwizard.server.DefaultServerFactory;
import io.dropwizard.server.SimpleServerFactory;
import io.dropwizard.setup.Bootstrap;
import io.dropwizard.setup.Environment;
+import io.swagger.jaxrs.config.BeanConfig;
+import io.swagger.jaxrs.listing.ApiListingResource;
import java.net.InetAddress;
import java.net.UnknownHostException;
@@ -39,6 +42,8 @@ import org.onap.vfc.nfvo.emsdriver.serviceregister.model.ServiceNodeVo;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.FileSystemXmlApplicationContext;
+import com.fasterxml.jackson.annotation.JsonInclude;
+
public class EmsDriverApplication extends Application<EmsDriverConfiguration> {
protected static Log log = LogFactory.getLog(EmsDriverApplication.class);
@@ -57,6 +62,7 @@ public class EmsDriverApplication extends Application<EmsDriverConfiguration> {
public void initialize(Bootstrap<EmsDriverConfiguration> bootstrap) {
// nothing to do yet
context = new FileSystemXmlApplicationContext("file:" + Constant.SYS_CFG+ "spring.xml");
+ bootstrap.addBundle(new AssetsBundle("/api-doc", "/api-doc", "index.html", "api-doc"));
}
@Override
@@ -71,6 +77,7 @@ public class EmsDriverApplication extends Application<EmsDriverConfiguration> {
}
//Start workThread
this.startThread();
+ initSwaggerConfig(environment, configuration);
}
private void startThread(){
@@ -86,7 +93,26 @@ public class EmsDriverApplication extends Application<EmsDriverConfiguration> {
thread.start();
}
}
+ // init swagger
+ private void initSwaggerConfig(Environment environment, EmsDriverConfiguration configuration)
+ {
+ environment.jersey().register(new ApiListingResource());
+ environment.getObjectMapper().setSerializationInclusion(JsonInclude.Include.NON_NULL);
+ BeanConfig config = new BeanConfig();
+ config.setTitle(" Console Service rest API");
+ config.setVersion("1.0.0");
+ config.setResourcePackage("org.onap.vfc.nfvo.emsdriver.northbound.service");
+ //swagger rest api basepath
+ SimpleServerFactory simpleServerFactory = (SimpleServerFactory)configuration.getServerFactory();
+ String basePath = simpleServerFactory.getApplicationContextPath();
+ String rootPath = simpleServerFactory.getJerseyRootPath().get();
+ rootPath = rootPath.substring(0, rootPath.indexOf("/*"));
+ basePath = basePath.equals("/") ? rootPath : (new StringBuilder()).append(basePath).append(rootPath).toString();
+ config.setBasePath(basePath);
+ config.setScan(true);
+ }
+
private void msbRegisteEmsDriverService(EmsDriverConfiguration configuration) {
SimpleServerFactory simpleServerFactory = (SimpleServerFactory)configuration.getServerFactory();
HttpConnectorFactory connector = (HttpConnectorFactory)simpleServerFactory.getConnector();
diff --git a/ems/boco/src/main/java/org/onap/vfc/nfvo/emsdriver/northbound/service/CommandResource.java b/ems/boco/src/main/java/org/onap/vfc/nfvo/emsdriver/northbound/service/CommandResource.java
index 4a807b8..44c23b4 100644
--- a/ems/boco/src/main/java/org/onap/vfc/nfvo/emsdriver/northbound/service/CommandResource.java
+++ b/ems/boco/src/main/java/org/onap/vfc/nfvo/emsdriver/northbound/service/CommandResource.java
@@ -15,21 +15,27 @@
*/
package org.onap.vfc.nfvo.emsdriver.northbound.service;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
import com.codahale.metrics.annotation.Timed;
@Path("/ems-driver")
@Produces(MediaType.APPLICATION_JSON)
+@Api(tags = {"ems-driver TestResource"})
public class CommandResource {
@GET
@Timed
+ @ApiOperation(value = "get ems-driver Info")
public String executeCommand(@QueryParam("command") String command) {
System.out.println("receiver command = "+command);