From cbf2a87d94e7fadfd82ba2c8c42568588dd3a56c Mon Sep 17 00:00:00 2001 From: YuanHu Date: Fri, 2 Feb 2018 16:51:31 +0800 Subject: Setup Micro-Service for WF Designer SDC Adapter Use the dropwizard application develop framework to setup the mirco-service for the WF Designer SDC Adapter Issue-ID: SDC-981 Change-Id: Icaf39c08d7bf537c65c15fb8a4f3f0668eb6e0da Signed-off-by: YuanHu --- sdc-workflow-designer-server/pom.xml | 146 ++++++++++++++++++--- .../sdc/workflowdesigner/WorkflowDesignerApp.java | 94 +++++++++++++ .../WorkflowDesignerConfiguration.java | 48 +++++++ 3 files changed, 268 insertions(+), 20 deletions(-) create mode 100644 sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/WorkflowDesignerApp.java create mode 100644 sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/WorkflowDesignerConfiguration.java (limited to 'sdc-workflow-designer-server') diff --git a/sdc-workflow-designer-server/pom.xml b/sdc-workflow-designer-server/pom.xml index beceff7a..9a4591e7 100644 --- a/sdc-workflow-designer-server/pom.xml +++ b/sdc-workflow-designer-server/pom.xml @@ -16,30 +16,144 @@ org.onap.sdc.sdc-workflow-designer sdc-workflow-designer - 1.0.0 + 1.1.0-SNAPSHOT 4.0.0 org.onap.sdc.sdc-workflow-designer sdc-workflow-designer-server sdc-workflow-designer-server - 1.0.0 jar + - 1.7.25 2.9.1 1.6.2 4.10 - 1.1.3 - 1.1.3 + 1.2.2 + 1.5.3 + 2.16 + 2.4 + 1.16.4 - + + + + + org.apache.maven.plugins + maven-shade-plugin + + true + + + *:* + + META-INF/*.SF + META-INF/*.DSA + META-INF/*.RSA + + + + + + + package + + shade + + + + + + org.onap.sdc.workflowdesigner.WorkflowDesignerApp + + + + + + + + + org.apache.maven.plugins + maven-dependency-plugin + + + copy-dependencies + package + + copy-dependencies + + + + + io.dropwizard + dropwizard-core + ${dropwizard.version} + true + + + + + + + + + + + + + io.dropwizard + dropwizard-core + ${dropwizard.version} + + + io.dropwizard + dropwizard-assets + ${dropwizard.version} + + + io.dropwizard + dropwizard-migrations + ${dropwizard.version} + + + + + io.swagger + swagger-jersey2-jaxrs + ${swagger.version} + + + + + org.glassfish.jersey.core + jersey-server + ${jersey.version} + - org.slf4j - slf4j-api - ${slf4j.version} + org.glassfish.jersey.media + jersey-media-multipart + ${jersey.version} + + org.glassfish.jersey.containers + jersey-container-servlet-core + ${jersey.version} + + + + commons-io + commons-io + ${commons-io.version} + + + + + org.projectlombok + lombok + ${lombok.version} + + com.fasterxml.jackson.core jackson-core @@ -50,26 +164,18 @@ jackson-databind ${jackson.version} + org.apache.velocity velocity ${velocity.version} + junit junit ${junit.version} - - ch.qos.logback - logback-core - ${logback.version} - - - ch.qos.logback - logback-classic - ${logback-classic.version} - - + diff --git a/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/WorkflowDesignerApp.java b/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/WorkflowDesignerApp.java new file mode 100644 index 00000000..002da23b --- /dev/null +++ b/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/WorkflowDesignerApp.java @@ -0,0 +1,94 @@ +/** + * Copyright (c) 2017 ZTE Corporation. + * All rights reserved. This program and the accompanying materials + * are made available under the Apache License, Version 2.0 + * and the Eclipse Public License v1.0 which both accompany this distribution, + * and are available at http://www.eclipse.org/legal/epl-v10.html + * and http://www.apache.org/licenses/LICENSE-2.0 + * + * Contributors: + * ZTE - initial API and implementation and/or initial documentation + */ + +package org.onap.sdc.workflowdesigner; + +import org.glassfish.jersey.media.multipart.MultiPartFeature; +// import org.onap.sdc.workflowdesigner.resources.ExtendActivityResource; +// import org.onap.sdc.workflowdesigner.resources.WorkflowModelerResource; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.fasterxml.jackson.annotation.JsonInclude; + +import io.dropwizard.Application; +import io.dropwizard.assets.AssetsBundle; +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; + +public class WorkflowDesignerApp extends Application { + + private static final Logger LOGGER = LoggerFactory.getLogger(WorkflowDesignerApp.class); + + public static void main(String[] args) throws Exception { + new WorkflowDesignerApp().run(args); + } + + @Override + public String getName() { + return "Workflow Designer"; + } + + @Override + public void initialize(Bootstrap bootstrap) { + bootstrap.addBundle(new AssetsBundle("/api-doc", "/api-doc", "index.html", "api-doc")); + } + + @Override + public void run(WorkflowDesignerConfiguration configuration, Environment environment) { + LOGGER.info("Start to initialize Workflow Designer."); + + // environment.jersey().register(new WorkflowModelerResource()); + // environment.jersey().register(new ExtendActivityResource()); + + // register rest interface + environment.jersey().packages("org.onap.sdc.workflowdesigner.resources"); + // upload file by inputstream need to register MultiPartFeature + environment.jersey().register(MultiPartFeature.class); + + initSwaggerConfig(environment, configuration); + + LOGGER.info("Initialize catalogue finished."); + } + + /** + * initialize swagger configuration. + * + * @param environment environment information + * @param configuration catalogue configuration + */ + private void initSwaggerConfig(Environment environment, + WorkflowDesignerConfiguration configuration) { + environment.jersey().register(new ApiListingResource()); + environment.getObjectMapper().setSerializationInclusion(JsonInclude.Include.NON_NULL); + + BeanConfig config = new BeanConfig(); + config.setTitle("Workflow Designer rest API"); + config.setVersion("1.0.0"); + config.setResourcePackage("org.onap.sdc.workflowdesigner.resources"); + + // set rest api basepath in swagger + 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); + } + +} diff --git a/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/WorkflowDesignerConfiguration.java b/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/WorkflowDesignerConfiguration.java new file mode 100644 index 00000000..16f807ea --- /dev/null +++ b/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/WorkflowDesignerConfiguration.java @@ -0,0 +1,48 @@ +/** + * Copyright (c) 2017 ZTE Corporation. + * All rights reserved. This program and the accompanying materials + * are made available under the Apache License, Version 2.0 + * and the Eclipse Public License v1.0 which both accompany this distribution, + * and are available at http://www.eclipse.org/legal/epl-v10.html + * and http://www.apache.org/licenses/LICENSE-2.0 + * + * Contributors: + * ZTE - initial API and implementation and/or initial documentation + */ + +package org.onap.sdc.workflowdesigner; + +import org.hibernate.validator.constraints.NotEmpty; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import io.dropwizard.Configuration; + +public class WorkflowDesignerConfiguration extends Configuration { + @NotEmpty + private String template; + + @NotEmpty + private String defaultName = "Workflow Designer"; + + @JsonProperty + public String getTemplate() { + return template; + } + + @JsonProperty + public void setTemplate(String template) { + this.template = template; + } + + @JsonProperty + public String getDefaultName() { + return defaultName; + } + + @JsonProperty + public void setDefaultName(String name) { + this.defaultName = name; + } + +} -- cgit 1.2.3-korg