diff options
18 files changed, 458 insertions, 26 deletions
@@ -1,3 +1,5 @@ +.idea/ +*.iml .classpath .project .settings/ diff --git a/distribution/src/main/assembly/conf/workflow-designer.yml b/distribution/src/main/assembly/conf/workflow-designer.yml index 42785fb4..9b35b261 100644 --- a/distribution/src/main/assembly/conf/workflow-designer.yml +++ b/distribution/src/main/assembly/conf/workflow-designer.yml @@ -14,13 +14,19 @@ template: Hello, %s! defaultName: ${DW_DEFAULT_NAME:-Stranger} -adapterType: DEFAULT +adapterType: SDC sdcServiceProxy: serviceAddr: http://127.0.0.1:8080 xEcompInstanceId: workflow authorization: Basic YWFpOktwOGJKNFNYc3pNMFdYbGhhazNlSGxjc2UyZ0F3ODR2YW9HR21KdlV5MlU= +activitySpecServiceProxy: + serviceAddr: http://127.0.0.1:8090 + xEcompInstanceId: workflow + userId: workflow + authorization: Basic YWFpOktwOGJKNFNYc3pNMFdYbGhhazNlSGxjc2UyZ0F3ODR2YW9HR21KdlV5MlU= + # use the simple server factory if you only want to run on a single port server: type: simple diff --git a/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/ActivitySpecServiceProxyInfo.java b/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/ActivitySpecServiceProxyInfo.java new file mode 100644 index 00000000..fb82e506 --- /dev/null +++ b/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/ActivitySpecServiceProxyInfo.java @@ -0,0 +1,97 @@ +/* + * Copyright © 2016-2018 European Support Limited + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onap.sdc.workflowdesigner; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * + */ +public class ActivitySpecServiceProxyInfo { + private String serviceAddr; + + private String xEcompInstanceId; + + private String authorization; + + private String userId; + + /** + * @return the serviceAddr + */ + @JsonProperty + public String getServiceAddr() { + return serviceAddr; + } + + /** + * @param serviceAddr the serviceAddr to set + */ + @JsonProperty + public void setServiceAddr(String serviceAddr) { + this.serviceAddr = serviceAddr; + } + + /** + * @return the xEcompInstanceId + */ + @JsonProperty + public String getxEcompInstanceId() { + return xEcompInstanceId; + } + + /** + * @param xEcompInstanceId the xEcompInstanceId to set + */ + @JsonProperty + public void setxEcompInstanceId(String xEcompInstanceId) { + this.xEcompInstanceId = xEcompInstanceId; + } + + /** + * @return the authorization + */ + @JsonProperty + public String getAuthorization() { + return authorization; + } + + /** + * @param authorization the authorization to set + */ + @JsonProperty + public void setAuthorization(String authorization) { + this.authorization = authorization; + } + + /** + * @return the userId + */ + @JsonProperty + public String getUserId() { + return userId; + } + + /** + * @param userId the userId to set + */ + @JsonProperty + public void setUserId(String userId) { + this.userId = userId; + } + +} 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 index 34a17e70..c9e0c40d 100644 --- 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 @@ -72,6 +72,7 @@ public class WorkflowDesignerApp extends Application<WorkflowDesignerConfigurati private void saveAppConfig(WorkflowDesignerConfiguration configuration) { AppConfig.setAdapterType(AdapterType.valueOf(configuration.getAdapterType())); AppConfig.setSdcServiceProxy(configuration.getSdcServiceProxy()); + AppConfig.setActivitySpecServiceProxy(configuration.getActivitySpecServiceProxy()); } /** 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 index 381e1673..4c6766be 100644 --- 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 @@ -27,6 +27,9 @@ public class WorkflowDesignerConfiguration extends Configuration { @NotNull private SDCServiceProxyInfo sdcServiceProxy; + + @NotNull + private ActivitySpecServiceProxyInfo activitySpecServiceProxy; @JsonProperty @@ -81,4 +84,20 @@ public class WorkflowDesignerConfiguration extends Configuration { this.sdcServiceProxy = sdcServiceProxy; } + /** + * @return the activitySpecServiceProxy + */ + @JsonProperty + public ActivitySpecServiceProxyInfo getActivitySpecServiceProxy() { + return activitySpecServiceProxy; + } + + /** + * @param activitySpecServiceProxy the activitySpecServiceProxy to set + */ + @JsonProperty + public void setActivitySpecServiceProxy(ActivitySpecServiceProxyInfo activitySpecServiceProxy) { + this.activitySpecServiceProxy = activitySpecServiceProxy; + } + } diff --git a/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/common/ActivitySpecProxyException.java b/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/common/ActivitySpecProxyException.java new file mode 100644 index 00000000..bc3cf4b6 --- /dev/null +++ b/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/common/ActivitySpecProxyException.java @@ -0,0 +1,34 @@ +/* + * Copyright © 2016-2018 European Support Limited + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onap.sdc.workflowdesigner.common; + +public class ActivitySpecProxyException extends Exception { + + private static final long serialVersionUID = 1L; + + public ActivitySpecProxyException() { + super(); + } + + public ActivitySpecProxyException(String msg, Exception e) { + super(msg, e); + } + + public ActivitySpecProxyException(String msg) { + super(msg); + } +} diff --git a/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/config/AppConfig.java b/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/config/AppConfig.java index 9a4afb39..a6f72be0 100644 --- a/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/config/AppConfig.java +++ b/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/config/AppConfig.java @@ -16,6 +16,7 @@ package org.onap.sdc.workflowdesigner.config; import org.onap.sdc.workflowdesigner.SDCServiceProxyInfo; +import org.onap.sdc.workflowdesigner.ActivitySpecServiceProxyInfo; /** * @@ -24,6 +25,8 @@ public class AppConfig { private static AdapterType adapterType; private static SDCServiceProxyInfo sdcServiceProxy; + + private static ActivitySpecServiceProxyInfo activitySpecServiceProxy; private AppConfig() {} @@ -62,4 +65,17 @@ public class AppConfig { return adapterType.equals(AdapterType.SDC); } + /** + * @param activitySpecServiceProxy + */ + public static void setActivitySpecServiceProxy(ActivitySpecServiceProxyInfo activitySpecServiceProxy) { + AppConfig.activitySpecServiceProxy = activitySpecServiceProxy; + } + + /** + * @return the activitySpecServiceProxy + */ + public static ActivitySpecServiceProxyInfo getActivitySpecServiceProxy() { + return activitySpecServiceProxy; + } } diff --git a/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/externalservice/sdc/ActivitySpecService.java b/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/externalservice/sdc/ActivitySpecService.java index c1878c0c..b85d6d0b 100644 --- a/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/externalservice/sdc/ActivitySpecService.java +++ b/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/externalservice/sdc/ActivitySpecService.java @@ -19,10 +19,12 @@ import javax.ws.rs.Consumes; import javax.ws.rs.GET; import javax.ws.rs.HeaderParam; import javax.ws.rs.Path; +import javax.ws.rs.PathParam; import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; import org.onap.sdc.workflowdesigner.externalservice.sdc.entity.ActivitySpec; +import org.onap.sdc.workflowdesigner.externalservice.sdc.entity.GenericCollectionWrapper; @Path("") public interface ActivitySpecService { @@ -30,8 +32,20 @@ public interface ActivitySpecService { @Path("/activity-spec?Filter=Certified") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) - public ActivitySpec[] getActivitySpecs( + public GenericCollectionWrapper getActivitySpecs( + @HeaderParam("USER_ID") String userId, @HeaderParam("X-ECOMP-InstanceID") String xEcompInstanceId, @HeaderParam("Authorization") String authorization) throws Exception; + @GET + @Path("/activity-spec/{id}/versions/{versionId}") + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.APPLICATION_JSON) + public ActivitySpec getActivitySpec( + @HeaderParam("USER_ID") String userId, + @HeaderParam("X-ECOMP-InstanceID") String xEcompInstanceId, + @HeaderParam("Authorization") String authorization, + @PathParam("versionId") String versionId, + @PathParam("id") String id) throws Exception; + } diff --git a/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/externalservice/sdc/ActivitySpecServiceProxy.java b/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/externalservice/sdc/ActivitySpecServiceProxy.java index e014b542..e210e872 100644 --- a/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/externalservice/sdc/ActivitySpecServiceProxy.java +++ b/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/externalservice/sdc/ActivitySpecServiceProxy.java @@ -15,10 +15,15 @@ */ package org.onap.sdc.workflowdesigner.externalservice.sdc; +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; import org.glassfish.jersey.client.ClientConfig; -import org.onap.sdc.workflowdesigner.common.SDCProxyException; +import org.onap.sdc.workflowdesigner.common.ActivitySpecProxyException; import org.onap.sdc.workflowdesigner.config.AppConfig; import org.onap.sdc.workflowdesigner.externalservice.sdc.entity.ActivitySpec; +import org.onap.sdc.workflowdesigner.externalservice.sdc.entity.GenericCollectionWrapper; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -28,24 +33,27 @@ import com.eclipsesource.jaxrs.consumer.ConsumerFactory; * */ public class ActivitySpecServiceProxy { - private static final Logger LOGGER = LoggerFactory.getLogger(SDCService.class); + private static final Logger LOGGER = LoggerFactory.getLogger(ActivitySpecServiceProxy.class); - private static final String AUTHORIZATION = AppConfig.getSdcServiceProxy().getAuthorization(); + private static final String AUTHORIZATION = AppConfig.getActivitySpecServiceProxy().getAuthorization(); + + private static final String X_ECOMP_INSTANCE_ID = AppConfig.getActivitySpecServiceProxy().getxEcompInstanceId(); + + private static final String USER_ID = AppConfig.getActivitySpecServiceProxy().getUserId(); - private static final String X_ECOMP_INSTANCE_ID = - AppConfig.getSdcServiceProxy().getxEcompInstanceId(); /** */ - private static final String ACTIVITY_ROOT_PATH = "/activityspec-api/v1.0"; + private static final String ACTIVITY_ROOT_PATH = "/activity-spec-api/v1.0"; + private static final String ACTIVITY_SPEC_VERSION_ID_DEFAULT_VALUE = "latest"; private static String getActivityRootPath() { - return AppConfig.getSdcServiceProxy().getServiceAddr() + ACTIVITY_ROOT_PATH; + return AppConfig.getActivitySpecServiceProxy().getServiceAddr() + ACTIVITY_ROOT_PATH; } /** * @return */ - private ActivitySpecService getActivityServiceProxy() { + private ActivitySpecService getActivitySpecServiceProxy() { ClientConfig config = new ClientConfig(); return ConsumerFactory.createConsumer(getActivityRootPath(), config, ActivitySpecService.class); } @@ -54,16 +62,27 @@ public class ActivitySpecServiceProxy { /** * * @return - * @throws SDCProxyException + * @throws ActivitySpecProxyException */ - public ActivitySpec[] getActivitySpecs() throws SDCProxyException { - ActivitySpecService serviceProxy = getActivityServiceProxy(); + public ActivitySpec[] getActivitySpecs() throws ActivitySpecProxyException { + ActivitySpecService serviceProxy = getActivitySpecServiceProxy(); + List<ActivitySpec> activitySpecList = new ArrayList<>(); try { - return serviceProxy.getActivitySpecs(X_ECOMP_INSTANCE_ID, AUTHORIZATION); + GenericCollectionWrapper activityCollection = serviceProxy.getActivitySpecs(USER_ID, X_ECOMP_INSTANCE_ID, AUTHORIZATION); + for (Object obj : activityCollection.getResults()) { + if (obj instanceof Map){ + Map activitySpecMap = (Map) obj; + String activitySpecId = activitySpecMap.get("id").toString(); + ActivitySpec activitySpec = serviceProxy.getActivitySpec(USER_ID, X_ECOMP_INSTANCE_ID, AUTHORIZATION, ACTIVITY_SPEC_VERSION_ID_DEFAULT_VALUE, activitySpecId); + activitySpec.setId(activitySpecId); + activitySpecList.add(activitySpec); + } + } } catch (Exception e) { LOGGER.error("Get Activity Specifications Failed.", e); - throw new SDCProxyException("Get Activity Specifications Failed.", e); + throw new ActivitySpecProxyException("Get Activity Specifications Failed.", e); } + return activitySpecList.toArray(new ActivitySpec[activitySpecList.size()]); } diff --git a/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/externalservice/sdc/entity/ActivitySpec.java b/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/externalservice/sdc/entity/ActivitySpec.java index 35a1a36e..942afcab 100644 --- a/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/externalservice/sdc/entity/ActivitySpec.java +++ b/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/externalservice/sdc/entity/ActivitySpec.java @@ -25,7 +25,7 @@ public class ActivitySpec { private String type;
- private ActivityContent content = new ActivityContent();
+ private String content;
private String[] categoryList;
@@ -108,14 +108,14 @@ public class ActivitySpec { /**
* @return the content
*/
- public ActivityContent getContent() {
+ public String getContent() {
return content;
}
/**
* @param content the content to set
*/
- public void setContent(ActivityContent content) {
+ public void setContent(String content) {
this.content = content;
}
diff --git a/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/externalservice/sdc/entity/GenericCollectionWrapper.java b/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/externalservice/sdc/entity/GenericCollectionWrapper.java new file mode 100644 index 00000000..59813605 --- /dev/null +++ b/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/externalservice/sdc/entity/GenericCollectionWrapper.java @@ -0,0 +1,61 @@ +/* + * Copyright © 2016-2018 European Support Limited + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onap.sdc.workflowdesigner.externalservice.sdc.entity; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; + +public class GenericCollectionWrapper<T> implements Serializable { + private static final long serialVersionUID = 1L; + + private transient List<T> results; + private int listCount; + + public GenericCollectionWrapper() { + this.results = new ArrayList<>(); + } + + /** + * Instantiates a new Generic collection wrapper. + * + * @param list the list + */ + public GenericCollectionWrapper(List<T> list) { + if (!list.isEmpty()) { + this.results = list; + this.listCount = list.size(); + } + } + + public List<T> getResults() { + return results; + } + + public void setResults(List<T> results) { + this.results = results; + } + + public int getListCount() { + return listCount; + } + + public void setListCount(int listCount) { + this.listCount = listCount; + } + +} diff --git a/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/resources/ExtendActivityResource.java b/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/resources/ExtendActivityResource.java index 99e2f28a..4a40597a 100644 --- a/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/resources/ExtendActivityResource.java +++ b/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/resources/ExtendActivityResource.java @@ -25,7 +25,7 @@ import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import org.eclipse.jetty.http.HttpStatus; -import org.onap.sdc.workflowdesigner.common.SDCProxyException; +import org.onap.sdc.workflowdesigner.common.ActivitySpecProxyException; import org.onap.sdc.workflowdesigner.config.AppConfig; import org.onap.sdc.workflowdesigner.externalservice.sdc.ActivitySpecServiceProxy; import org.onap.sdc.workflowdesigner.externalservice.sdc.entity.ActivitySpec; @@ -121,7 +121,7 @@ public class ExtendActivityResource { ActivitySpec[] activitySpecs = proxy.getActivitySpecs(); ExtActivity[] extActivities = convert2ExtActivities(activitySpecs); return Response.status(Response.Status.OK).entity(extActivities).build(); - } catch (SDCProxyException e) { + } catch (ActivitySpecProxyException e) { LOGGER.error("Get ExtActivities from sdc failed.", e); throw RestUtils.newInternalServerErrorException(e); } @@ -160,10 +160,7 @@ public class ExtendActivityResource { */ private Content buildContent(ActivitySpec activitySpec) { Content content = new Content(); -// content.setClass(activitySpec.getContent().getClazz()); - content.clazz = activitySpec.getContent().clazz; - content.setScript(activitySpec.getContent().getScript()); - content.setScriptFormat(activitySpec.getContent().getScriptFormat()); + content.setScript(activitySpec.getContent()); content.setInputs(convert2InputOutputs(activitySpec.getInputs())); content.setOutputs(convert2InputOutputs(activitySpec.getOutputs())); return content; @@ -240,7 +237,7 @@ public class ExtendActivityResource { ActivitySpec[] activitySpecs = proxy.getActivitySpecs(); ExtActivityDisplayInfo displayInfo = convert2ExtActivityDisplayInfo(activitySpecs); return Response.status(Response.Status.OK).entity(displayInfo).build(); - } catch (SDCProxyException e) { + } catch (ActivitySpecProxyException e) { LOGGER.error("Get Extend Activities DisplayInfo from sdc failed.", e); throw RestUtils.newInternalServerErrorException(e); } diff --git a/sdc-workflow-designer-server/src/test/java/org/onap/sdc/workflowdesigner/externalservice/sdc/entity/ActivitySpecTest.java b/sdc-workflow-designer-server/src/test/java/org/onap/sdc/workflowdesigner/externalservice/sdc/entity/ActivitySpecTest.java index aff131ff..15aefe41 100644 --- a/sdc-workflow-designer-server/src/test/java/org/onap/sdc/workflowdesigner/externalservice/sdc/entity/ActivitySpecTest.java +++ b/sdc-workflow-designer-server/src/test/java/org/onap/sdc/workflowdesigner/externalservice/sdc/entity/ActivitySpecTest.java @@ -41,7 +41,7 @@ public class ActivitySpecTest { String name = "";
String description = "";
String type = "";
- ActivityContent content = new ActivityContent();
+ String content = "";
String[] categoryList = new String[]{"aaa"};
Parameter[] inputs = new Parameter[0];
Parameter[] outputs = new Parameter[0];
diff --git a/workflow-designer-be/pom.xml b/workflow-designer-be/pom.xml new file mode 100644 index 00000000..ddcb9c63 --- /dev/null +++ b/workflow-designer-be/pom.xml @@ -0,0 +1,82 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <groupId>org.onap.sdc.workflow</groupId> + <artifactId>workflow-be</artifactId> + <version>1.3.0-SNAPSHOT</version> + <parent> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-parent</artifactId> + <version>2.0.2.RELEASE</version> + </parent> + <properties> + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> + <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> + <java.version>1.8</java.version> + </properties> + + <dependencies> + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-web</artifactId> + <exclusions> + <exclusion> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-tomcat</artifactId> + </exclusion> + </exclusions> + </dependency> + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-jetty</artifactId> + </dependency> + + <!-- + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-data-cassandra</artifactId> + </dependency> + --> + + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-actuator</artifactId> + </dependency> + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-test</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-devtools</artifactId> + </dependency> + <dependency> + <groupId>io.springfox</groupId> + <artifactId>springfox-swagger-ui</artifactId> + <version>2.8.0</version> + <scope>compile</scope> + </dependency> + <dependency> + <groupId>io.springfox</groupId> + <artifactId>springfox-swagger2</artifactId> + <version>2.8.0</version> + <scope>compile</scope> + </dependency> + + </dependencies> + + <build> + <plugins> + <plugin> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-maven-plugin</artifactId> + </plugin> + </plugins> + </build> + + +</project>
\ No newline at end of file diff --git a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/SpringBootWebApplication.java b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/SpringBootWebApplication.java new file mode 100644 index 00000000..e1bd8eac --- /dev/null +++ b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/SpringBootWebApplication.java @@ -0,0 +1,21 @@ +package org.onap.sdc.workflow; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.web.embedded.jetty.JettyServletWebServerFactory; +import org.springframework.boot.web.servlet.server.ConfigurableServletWebServerFactory; +import org.springframework.context.annotation.Bean; + + +@SpringBootApplication +public class SpringBootWebApplication { + public static void main(String[] args) { + SpringApplication.run(SpringBootWebApplication.class, args); + } + + @Bean + public ConfigurableServletWebServerFactory webServerFactory() { + JettyServletWebServerFactory factory = new JettyServletWebServerFactory(); + return factory; + } +} diff --git a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/WorkflowsController.java b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/WorkflowsController.java new file mode 100644 index 00000000..229bc8c1 --- /dev/null +++ b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/WorkflowsController.java @@ -0,0 +1,23 @@ +package org.onap.sdc.workflow.api; + +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.util.Arrays; +import java.util.Collection; + +@RestController +@RequestMapping("/workflows") +@Api(value = "Workflows kalsjkaj") +public class WorkflowsController { + + @GetMapping + @ApiOperation(value = "List workflows", response = Collection.class) + public Collection<String> list() { + return Arrays.asList("a", "c"); + } + +} diff --git a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/config/SwaggerConfig.java b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/config/SwaggerConfig.java new file mode 100644 index 00000000..ed317f4b --- /dev/null +++ b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/config/SwaggerConfig.java @@ -0,0 +1,38 @@ +package org.onap.sdc.workflow.config; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport; +import springfox.documentation.builders.ApiInfoBuilder; +import springfox.documentation.builders.PathSelectors; +import springfox.documentation.builders.RequestHandlerSelectors; +import springfox.documentation.service.ApiInfo; +import springfox.documentation.service.Contact; +import springfox.documentation.spi.DocumentationType; +import springfox.documentation.spring.web.plugins.Docket; +import springfox.documentation.swagger2.annotations.EnableSwagger2; +import static springfox.documentation.builders.PathSelectors.regex; + +@Configuration +@EnableSwagger2 +public class SwaggerConfig { + + /*@Bean + public Docket api() { + return new Docket(DocumentationType.SWAGGER_2) + .select() + .apis(RequestHandlerSelectors.any()) + .paths(PathSelectors.any()) + .build(); + }*/ + + @Bean + public Docket api() { + return new Docket(DocumentationType.SWAGGER_2) + .select() + .apis(RequestHandlerSelectors.basePackage("org.onap.sdc.workflow.api")) + .paths(regex("/workflows.*")) + .build(); + } +}
\ No newline at end of file diff --git a/workflow-designer-be/src/main/resources/application.properties b/workflow-designer-be/src/main/resources/application.properties new file mode 100644 index 00000000..5df521b5 --- /dev/null +++ b/workflow-designer-be/src/main/resources/application.properties @@ -0,0 +1,2 @@ +server.servlet.context-path=/wf +server.port=8080
\ No newline at end of file |