aboutsummaryrefslogtreecommitdiffstats
path: root/sdc-workflow-designer-server/src/main
diff options
context:
space:
mode:
authorYuanHu <yuan.hu1@zte.com.cn>2018-02-02 16:51:31 +0800
committerYuanHu <yuan.hu1@zte.com.cn>2018-02-02 16:51:31 +0800
commitcbf2a87d94e7fadfd82ba2c8c42568588dd3a56c (patch)
tree4e905b30f312f8b1e59715597fc3e4f60fb37939 /sdc-workflow-designer-server/src/main
parenta5a126ce50c1a353084611bd3d85228442ede2e5 (diff)
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 <yuan.hu1@zte.com.cn>
Diffstat (limited to 'sdc-workflow-designer-server/src/main')
-rw-r--r--sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/WorkflowDesignerApp.java94
-rw-r--r--sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/WorkflowDesignerConfiguration.java48
2 files changed, 142 insertions, 0 deletions
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<WorkflowDesignerConfiguration> {
+
+ 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<WorkflowDesignerConfiguration> 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;
+ }
+
+}