aboutsummaryrefslogtreecommitdiffstats
path: root/so-admin-cockpit-monitoring-workflow/so-admin-cockpit-monitoring-workflow-service/src
diff options
context:
space:
mode:
authorMukesh Paliwal <mukesh.paliwal1@huawei.com>2021-06-24 11:54:21 +0530
committerMukesh Paliwal <mukesh.paliwal1@huawei.com>2021-06-24 11:54:21 +0530
commita5778f6f60d56686656411fbe927ba6ef472a4b4 (patch)
treeb0494235cf7a8b8cc6f7ed5bc25b17981cef4819 /so-admin-cockpit-monitoring-workflow/so-admin-cockpit-monitoring-workflow-service/src
parent8f8791fb45cd9c135fa269dc15be2c39ab5817c4 (diff)
Dynamic BPMN workflow GUI
Issue-ID: SO-3681 Signed-off-by: mukesh.paliwal <mukesh.paliwal1@huawei.com> Change-Id: Ia9e64dbb12fc45c0da73d67f64abb0ff0147d783
Diffstat (limited to 'so-admin-cockpit-monitoring-workflow/so-admin-cockpit-monitoring-workflow-service/src')
-rw-r--r--so-admin-cockpit-monitoring-workflow/so-admin-cockpit-monitoring-workflow-service/src/main/java/org/onap/so/monitoring/rest/api/JerseyConfiguration.java2
-rw-r--r--so-admin-cockpit-monitoring-workflow/so-admin-cockpit-monitoring-workflow-service/src/main/java/org/onap/so/monitoring/rest/api/ServiceRecipe.java95
-rw-r--r--so-admin-cockpit-monitoring-workflow/so-admin-cockpit-monitoring-workflow-service/src/main/java/org/onap/so/monitoring/rest/api/SoMonitoringController.java205
-rw-r--r--so-admin-cockpit-monitoring-workflow/so-admin-cockpit-monitoring-workflow-service/src/main/resources/application.yaml2
4 files changed, 304 insertions, 0 deletions
diff --git a/so-admin-cockpit-monitoring-workflow/so-admin-cockpit-monitoring-workflow-service/src/main/java/org/onap/so/monitoring/rest/api/JerseyConfiguration.java b/so-admin-cockpit-monitoring-workflow/so-admin-cockpit-monitoring-workflow-service/src/main/java/org/onap/so/monitoring/rest/api/JerseyConfiguration.java
index 22a1583..2a6bb81 100644
--- a/so-admin-cockpit-monitoring-workflow/so-admin-cockpit-monitoring-workflow-service/src/main/java/org/onap/so/monitoring/rest/api/JerseyConfiguration.java
+++ b/so-admin-cockpit-monitoring-workflow/so-admin-cockpit-monitoring-workflow-service/src/main/java/org/onap/so/monitoring/rest/api/JerseyConfiguration.java
@@ -21,6 +21,7 @@ package org.onap.so.monitoring.rest.api;
import javax.annotation.PostConstruct;
import javax.ws.rs.ApplicationPath;
+import org.glassfish.jersey.media.multipart.MultiPartFeature;
import org.glassfish.jersey.server.ResourceConfig;
import org.springframework.context.annotation.Configuration;
@@ -34,6 +35,7 @@ public class JerseyConfiguration extends ResourceConfig {
@PostConstruct
public void setUp() {
register(SoMonitoringController.class);
+ register(MultiPartFeature.class);
}
}
diff --git a/so-admin-cockpit-monitoring-workflow/so-admin-cockpit-monitoring-workflow-service/src/main/java/org/onap/so/monitoring/rest/api/ServiceRecipe.java b/so-admin-cockpit-monitoring-workflow/so-admin-cockpit-monitoring-workflow-service/src/main/java/org/onap/so/monitoring/rest/api/ServiceRecipe.java
new file mode 100644
index 0000000..f31438d
--- /dev/null
+++ b/so-admin-cockpit-monitoring-workflow/so-admin-cockpit-monitoring-workflow-service/src/main/java/org/onap/so/monitoring/rest/api/ServiceRecipe.java
@@ -0,0 +1,95 @@
+/**
+ * Copyright (C) 2020 Huawei, Inc. and others. All rights reserved.
+ *
+ * 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.so.monitoring.rest.api;
+
+import com.fasterxml.jackson.annotation.*;
+import java.util.HashMap;
+import java.util.Map;
+
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@JsonPropertyOrder({"warFile", "savetoDB", "modelName", "modelVersionId", "operation", "orchestrationFlow",
+ "modelType"})
+public class ServiceRecipe {
+ @JsonProperty("warFile")
+ private String warFile;
+ @JsonProperty("savetoDB")
+ private String savetoDB;
+ @JsonProperty("modelName")
+ private String modelName;
+ @JsonProperty("modelVersionId")
+ private String modelVersionId;
+ @JsonProperty("operation")
+ private String operation;
+ @JsonProperty("orchestrationFlow")
+ private String orchestrationFlow;
+ @JsonProperty("modelType")
+ private String modelType;
+
+ public String getWarFile() {
+ return warFile;
+ }
+
+ public void setWarFile(String warFile) {
+ this.warFile = warFile;
+ }
+
+ public String getSavetoDB() {
+ return savetoDB;
+ }
+
+ public void setSavetoDB(String savetoDB) {
+ this.savetoDB = savetoDB;
+ }
+
+ public String getModelName() {
+ return modelName;
+ }
+
+ public void setModelName(String modelName) {
+ this.modelName = modelName;
+ }
+
+ public String getModelVersionId() {
+ return modelVersionId;
+ }
+
+ public void setModelVersionId(String modelVersionId) {
+ this.modelVersionId = modelVersionId;
+ }
+
+ public String getOperation() {
+ return operation;
+ }
+
+ public void setOperation(String operation) {
+ this.operation = operation;
+ }
+
+ public String getOrchestrationFlow() {
+ return orchestrationFlow;
+ }
+
+ public void setOrchestrationFlow(String orchestrationFlow) {
+ this.orchestrationFlow = orchestrationFlow;
+ }
+
+ public String getModelType() {
+ return modelType;
+ }
+
+ public void setModelType(String modelType) {
+ this.modelType = modelType;
+ }
+}
+
+
diff --git a/so-admin-cockpit-monitoring-workflow/so-admin-cockpit-monitoring-workflow-service/src/main/java/org/onap/so/monitoring/rest/api/SoMonitoringController.java b/so-admin-cockpit-monitoring-workflow/so-admin-cockpit-monitoring-workflow-service/src/main/java/org/onap/so/monitoring/rest/api/SoMonitoringController.java
index 5a5a414..c2514c3 100644
--- a/so-admin-cockpit-monitoring-workflow/so-admin-cockpit-monitoring-workflow-service/src/main/java/org/onap/so/monitoring/rest/api/SoMonitoringController.java
+++ b/so-admin-cockpit-monitoring-workflow/so-admin-cockpit-monitoring-workflow-service/src/main/java/org/onap/so/monitoring/rest/api/SoMonitoringController.java
@@ -19,9 +19,15 @@
*/
package org.onap.so.monitoring.rest.api;
+import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.base.Optional;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
import java.util.List;
import java.util.Map;
+import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
@@ -31,6 +37,8 @@ import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.Response.Status;
+import org.glassfish.jersey.media.multipart.FormDataContentDisposition;
+import org.glassfish.jersey.media.multipart.FormDataParam;
import org.onap.so.monitoring.db.service.DatabaseServiceProvider;
import org.onap.so.monitoring.model.ActivityInstanceDetail;
import org.onap.so.monitoring.model.ProcessDefinitionDetail;
@@ -45,7 +53,13 @@ import org.onap.so.rest.exceptions.RestProcessingException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.core.io.FileSystemResource;
+import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Component;
+import org.springframework.util.LinkedMultiValueMap;
+import org.springframework.util.MultiValueMap;
+import org.springframework.web.client.RestTemplate;
/**
* @author waqas.ikram@ericsson.com
@@ -63,6 +77,12 @@ public class SoMonitoringController {
private final CamundaProcessDataServiceProvider camundaProcessDataServiceProvider;
@Autowired
+ RestTemplate restTemplate;
+
+ @Value("${bpmn.url}")
+ private String bpmnBaseUrl;
+
+ @Autowired
public SoMonitoringController(final DatabaseServiceProvider databaseServiceProvider,
final CamundaProcessDataServiceProvider camundaProcessDataServiceProvider) {
this.databaseServiceProvider = databaseServiceProvider;
@@ -231,4 +251,189 @@ public class SoMonitoringController {
}
}
+ /**
+ * upload a workflow package to the server
+ *
+ * @param uploadInputStream upload stream
+ * @param disposition
+ * @return
+ */
+ @POST
+ @Path("/workflowPackages/onboard")
+ @Consumes("multipart/form-data")
+ @Produces("application/json")
+ public Response onboardWorkflowPackage(@FormDataParam("file") InputStream uploadedInputStream,
+ @FormDataParam("file") FormDataContentDisposition fileDetail) {
+ try {
+ LOGGER.info("SoMonitoringController onboardWorkflowPackage inputs {} ,:{}", uploadedInputStream,
+ fileDetail);
+
+ File file = new File(fileDetail.getFileName());
+ copyInputStreamToFile(uploadedInputStream, file);
+
+ RestTemplate rest = new RestTemplate();
+ org.springframework.http.HttpHeaders headers = new org.springframework.http.HttpHeaders();
+ headers.setContentType(org.springframework.http.MediaType.MULTIPART_FORM_DATA);
+
+ MultiValueMap<String, Object> body = new LinkedMultiValueMap<>();
+
+ FileSystemResource value = new FileSystemResource(file);
+ body.add("file", value);
+
+ org.springframework.http.HttpEntity<MultiValueMap<String, Object>> requestEntity =
+ new org.springframework.http.HttpEntity<>(body, headers);
+ LOGGER.info("SoMonitoringController onboardWorkflowPackage request to be send :{}", requestEntity);
+
+ ResponseEntity<String> responseEntity =
+ rest.postForEntity(bpmnBaseUrl + "/workflowPackages/onboard", requestEntity, String.class);
+
+ LOGGER.info("SoMonitoringController onboardWorkflowPackage response recieved ::{}", responseEntity);
+
+ return Response.status(200).header("Access-Control-Allow-Origin", "*").entity(responseEntity.getBody())
+ .build();
+ } catch (Exception e) {
+ LOGGER.info("SoMonitoringController onboardWorkflowPackage error {} ", e.getMessage());
+ return Response.status(200).header("Access-Control-Allow-Origin", "*")
+ .entity("{\"errMsg\":\"Unable to process.\"}").build();
+ }
+ }
+
+
+ private static void copyInputStreamToFile(InputStream inputStream, File file) throws IOException {
+
+ try (FileOutputStream outputStream = new FileOutputStream(file)) {
+
+ int read;
+ byte[] bytes = new byte[1024];
+
+ while ((read = inputStream.read(bytes)) != -1) {
+ outputStream.write(bytes, 0, read);
+
+ }
+
+ }
+
+ }
+
+ @POST
+ @Path("/serviceRecipes")
+ @Produces({MediaType.APPLICATION_JSON})
+ public Response setServiceRecipes(final ServiceRecipe requestBody) {
+ ObjectMapper objectMapper = new ObjectMapper();
+ String requestBodyJson = null;
+ try {
+ requestBodyJson = objectMapper.writeValueAsString(requestBody);
+ LOGGER.info(" SoMonitoringController setServiceRecipes request recieved {}", requestBodyJson);
+
+ org.springframework.http.HttpHeaders headers = new org.springframework.http.HttpHeaders();
+ headers.setContentType(org.springframework.http.MediaType.APPLICATION_JSON);
+ org.springframework.http.HttpEntity<String> requestEntity =
+ new org.springframework.http.HttpEntity<>(requestBodyJson, headers);
+
+ LOGGER.info("SoMonitoringController setServiceRecipes request to be send :{}", requestEntity);
+
+ ResponseEntity<String> responseEntity =
+ restTemplate.postForEntity(bpmnBaseUrl + "/serviceRecipes", requestEntity, String.class);
+ LOGGER.info("setServiceRecipes respone :{}", responseEntity);
+
+ return Response.status(200).header("Access-Control-Allow-Origin", "*").entity(responseEntity.getBody())
+ .build();
+
+ } catch (Exception e) {
+ LOGGER.info("SoMonitoringController setServiceRecipes error: {}", e.getMessage());
+ return Response.status(200).header("Access-Control-Allow-Origin", "*")
+ .entity("{\"errMsg\":\"Unable to process.\"}").build();
+ }
+ }
+
+ @GET
+ @Path("/serviceRecipes")
+ @Produces({MediaType.APPLICATION_JSON})
+ public Response getServiceRecipes() {
+ ObjectMapper objectMapper = new ObjectMapper();
+ String requestBodyJson = null;
+ try {
+ LOGGER.info(" SoMonitoringController setServiceRecipes request recieved");
+
+ org.springframework.http.HttpHeaders headers = new org.springframework.http.HttpHeaders();
+ headers.setContentType(org.springframework.http.MediaType.APPLICATION_JSON);
+ org.springframework.http.HttpEntity<String> requestEntity =
+ new org.springframework.http.HttpEntity<>(headers);
+
+ LOGGER.info("SoMonitoringController getServiceRecipes request to be send ");
+
+ ResponseEntity<String> responseEntity =
+ restTemplate.getForEntity(bpmnBaseUrl + "/serviceRecipes", String.class);
+ LOGGER.info("getServiceRecipes respone :{}", responseEntity);
+
+ return Response.status(200).header("Access-Control-Allow-Origin", "*").entity(responseEntity.getBody())
+ .build();
+
+ } catch (Exception e) {
+ LOGGER.info("SoMonitoringController setServiceRecipes error: {}", e.getMessage());
+ return Response.status(200).header("Access-Control-Allow-Origin", "*")
+ .entity("{\"errMsg\":\"Unable to process.\"}").build();
+ }
+ }
+
+ @GET
+ @Path("/networkRecipes")
+ @Produces({MediaType.APPLICATION_JSON})
+ public Response getNetworkRecipes() {
+ ObjectMapper objectMapper = new ObjectMapper();
+ String requestBodyJson = null;
+ try {
+ LOGGER.info(" SoMonitoringController setNetworkRecipes request recieved");
+
+ org.springframework.http.HttpHeaders headers = new org.springframework.http.HttpHeaders();
+ headers.setContentType(org.springframework.http.MediaType.APPLICATION_JSON);
+ org.springframework.http.HttpEntity<String> requestEntity =
+ new org.springframework.http.HttpEntity<>(headers);
+
+ LOGGER.info("SoMonitoringController getNetworkRecipes request to be send ");
+
+ ResponseEntity<String> responseEntity =
+ restTemplate.getForEntity(bpmnBaseUrl + "/networkRecipes", String.class);
+ LOGGER.info("getNetworkRecipes respone :{}", responseEntity);
+
+ return Response.status(200).header("Access-Control-Allow-Origin", "*").entity(responseEntity.getBody())
+ .build();
+
+ } catch (Exception e) {
+ LOGGER.info("SoMonitoringController getNetworkRecipes error: {}", e.getMessage());
+ return Response.status(200).header("Access-Control-Allow-Origin", "*")
+ .entity("{\"errMsg\":\"Unable to process.\"}").build();
+ }
+ }
+
+ @GET
+ @Path("/vnfRecipes")
+ @Produces({MediaType.APPLICATION_JSON})
+ public Response getVnfRecipes() {
+ ObjectMapper objectMapper = new ObjectMapper();
+ String requestBodyJson = null;
+ try {
+ LOGGER.info(" SoMonitoringController getVnfRecipes request recieved");
+
+ org.springframework.http.HttpHeaders headers = new org.springframework.http.HttpHeaders();
+ headers.setContentType(org.springframework.http.MediaType.APPLICATION_JSON);
+ org.springframework.http.HttpEntity<String> requestEntity =
+ new org.springframework.http.HttpEntity<>(headers);
+
+ LOGGER.info("SoMonitoringController getVnfRecipes request to be send ");
+
+ ResponseEntity<String> responseEntity =
+ restTemplate.getForEntity(bpmnBaseUrl + "/vnfRecipes", String.class);
+ LOGGER.info("getVnfRecipes respone :{}", responseEntity);
+
+ return Response.status(200).header("Access-Control-Allow-Origin", "*").entity(responseEntity.getBody())
+ .build();
+
+ } catch (Exception e) {
+ LOGGER.info("SoMonitoringController getVnfRecipes error: {}", e.getMessage());
+ return Response.status(200).header("Access-Control-Allow-Origin", "*")
+ .entity("{\"errMsg\":\"Unable to process.\"}").build();
+ }
+ }
+
}
diff --git a/so-admin-cockpit-monitoring-workflow/so-admin-cockpit-monitoring-workflow-service/src/main/resources/application.yaml b/so-admin-cockpit-monitoring-workflow/so-admin-cockpit-monitoring-workflow-service/src/main/resources/application.yaml
index c57d79c..2b83fcf 100644
--- a/so-admin-cockpit-monitoring-workflow/so-admin-cockpit-monitoring-workflow-service/src/main/resources/application.yaml
+++ b/so-admin-cockpit-monitoring-workflow/so-admin-cockpit-monitoring-workflow-service/src/main/resources/application.yaml
@@ -29,3 +29,5 @@ spring:
username: demo
password: '$2a$10$ndkDhATUid4a3g0JJVRv2esX4rtB.vzCn7iBhKyR1qZ/wDdvNzjTS'
role: GUI-Client
+bpmn:
+ url: http://so-bpmn-infra.onap:8081/mso/hotmanagement