diff options
author | Priyanshu <pagarwal@amdocs.com> | 2018-06-06 16:18:44 +0530 |
---|---|---|
committer | priyanshu <pagarwal@amdocs.com> | 2018-06-06 16:18:44 +0530 |
commit | 65191548cbde2d5c1c3bcbfc279141745b117489 (patch) | |
tree | e5d963fb62e89d963c049e199d809086af4a7dcb /sdc-workflow-designer-server | |
parent | 41d8ff7b8796491cb3d85d098257811767616782 (diff) |
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 <pagarwal@amdocs.com>
Diffstat (limited to 'sdc-workflow-designer-server')
11 files changed, 283 insertions, 25 deletions
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];
|