From 65191548cbde2d5c1c3bcbfc279141745b117489 Mon Sep 17 00:00:00 2001 From: Priyanshu Date: Wed, 6 Jun 2018 16:18:44 +0530 Subject: Align workflow studio to Activity Spec SDC-WF: Align Workflow studio implementation with Activity Spec implementation in SDC Change-Id: I83fbf51a6399459c0e99c11f150616ceca69111a Issue-ID: SDC-1402 Signed-off-by: priyanshu --- .../src/main/assembly/conf/workflow-designer.yml | 8 +- .../ActivitySpecServiceProxyInfo.java | 97 ++++++++++++++++++++++ .../sdc/workflowdesigner/WorkflowDesignerApp.java | 1 + .../WorkflowDesignerConfiguration.java | 19 +++++ .../common/ActivitySpecProxyException.java | 34 ++++++++ .../sdc/workflowdesigner/config/AppConfig.java | 16 ++++ .../externalservice/sdc/ActivitySpecService.java | 16 +++- .../sdc/ActivitySpecServiceProxy.java | 45 +++++++--- .../externalservice/sdc/entity/ActivitySpec.java | 6 +- .../sdc/entity/GenericCollectionWrapper.java | 61 ++++++++++++++ .../resources/ExtendActivityResource.java | 11 +-- .../sdc/entity/ActivitySpecTest.java | 2 +- 12 files changed, 290 insertions(+), 26 deletions(-) create mode 100644 sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/ActivitySpecServiceProxyInfo.java create mode 100644 sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/common/ActivitySpecProxyException.java create mode 100644 sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/externalservice/sdc/entity/GenericCollectionWrapper.java 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 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 implements Serializable { + private static final long serialVersionUID = 1L; + + private transient List results; + private int listCount; + + public GenericCollectionWrapper() { + this.results = new ArrayList<>(); + } + + /** + * Instantiates a new Generic collection wrapper. + * + * @param list the list + */ + public GenericCollectionWrapper(List list) { + if (!list.isEmpty()) { + this.results = list; + this.listCount = list.size(); + } + } + + public List getResults() { + return results; + } + + public void setResults(List 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]; -- cgit 1.2.3-korg