summaryrefslogtreecommitdiffstats
path: root/so-admin-cockpit-monitoring-workflow/so-admin-cockpit-monitoring-workflow-service/src/main/java/org
diff options
context:
space:
mode:
authorMukeshKumar <mukeshsharma@est.tech>2021-02-08 17:25:08 +0000
committerMukesh <mukeshsharma@est.tech>2021-02-08 17:25:37 +0000
commit3a940081f52a806d7691bd4e26ebc6ed7ee85815 (patch)
treec424535bcf7f87c1c9802d44a53fd0baa5bdcf55 /so-admin-cockpit-monitoring-workflow/so-admin-cockpit-monitoring-workflow-service/src/main/java/org
parented30115ddf52d32c33e888d3d71cfc9c89056c05 (diff)
Adding monitoring workflow service module
Change-Id: Ib216a687b630baa2f2eaa146213607180cd8438c Issue-ID: SO-3487 Signed-off-by: Mukesh <mukeshsharma@est.tech>
Diffstat (limited to 'so-admin-cockpit-monitoring-workflow/so-admin-cockpit-monitoring-workflow-service/src/main/java/org')
-rw-r--r--so-admin-cockpit-monitoring-workflow/so-admin-cockpit-monitoring-workflow-service/src/main/java/org/onap/so/monitoring/rest/api/JerseyConfiguration.java39
-rw-r--r--so-admin-cockpit-monitoring-workflow/so-admin-cockpit-monitoring-workflow-service/src/main/java/org/onap/so/monitoring/rest/api/SoMonitoringApplication.java38
-rw-r--r--so-admin-cockpit-monitoring-workflow/so-admin-cockpit-monitoring-workflow-service/src/main/java/org/onap/so/monitoring/rest/api/SoMonitoringController.java234
-rw-r--r--so-admin-cockpit-monitoring-workflow/so-admin-cockpit-monitoring-workflow-service/src/main/java/org/onap/so/monitoring/rest/api/WebApplicationConfig.java36
4 files changed, 347 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
new file mode 100644
index 0000000..22a1583
--- /dev/null
+++ b/so-admin-cockpit-monitoring-workflow/so-admin-cockpit-monitoring-workflow-service/src/main/java/org/onap/so/monitoring/rest/api/JerseyConfiguration.java
@@ -0,0 +1,39 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2018 Ericsson. 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.so.monitoring.rest.api;
+
+import javax.annotation.PostConstruct;
+import javax.ws.rs.ApplicationPath;
+import org.glassfish.jersey.server.ResourceConfig;
+import org.springframework.context.annotation.Configuration;
+
+/**
+ * @author waqas.ikram@ericsson.com
+ */
+@Configuration
+@ApplicationPath("/so/monitoring")
+public class JerseyConfiguration extends ResourceConfig {
+
+ @PostConstruct
+ public void setUp() {
+ register(SoMonitoringController.class);
+ }
+
+}
diff --git a/so-admin-cockpit-monitoring-workflow/so-admin-cockpit-monitoring-workflow-service/src/main/java/org/onap/so/monitoring/rest/api/SoMonitoringApplication.java b/so-admin-cockpit-monitoring-workflow/so-admin-cockpit-monitoring-workflow-service/src/main/java/org/onap/so/monitoring/rest/api/SoMonitoringApplication.java
new file mode 100644
index 0000000..aff4fec
--- /dev/null
+++ b/so-admin-cockpit-monitoring-workflow/so-admin-cockpit-monitoring-workflow-service/src/main/java/org/onap/so/monitoring/rest/api/SoMonitoringApplication.java
@@ -0,0 +1,38 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.monitoring.rest.api;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration;
+
+/**
+ * @author waqas.ikram@ericsson.com
+ */
+@SpringBootApplication(scanBasePackages = {"org.onap"}, exclude = SecurityAutoConfiguration.class)
+public class SoMonitoringApplication {
+
+ public static void main(String[] args) {
+ SpringApplication.run(SoMonitoringApplication.class, args);
+
+ }
+
+}
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
new file mode 100644
index 0000000..5a5a414
--- /dev/null
+++ b/so-admin-cockpit-monitoring-workflow/so-admin-cockpit-monitoring-workflow-service/src/main/java/org/onap/so/monitoring/rest/api/SoMonitoringController.java
@@ -0,0 +1,234 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2018 Ericsson. 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.so.monitoring.rest.api;
+
+import com.google.common.base.Optional;
+import java.util.List;
+import java.util.Map;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+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.onap.so.monitoring.db.service.DatabaseServiceProvider;
+import org.onap.so.monitoring.model.ActivityInstanceDetail;
+import org.onap.so.monitoring.model.ProcessDefinitionDetail;
+import org.onap.so.monitoring.model.ProcessInstanceDetail;
+import org.onap.so.monitoring.model.ProcessInstanceIdDetail;
+import org.onap.so.monitoring.model.ProcessInstanceVariableDetail;
+import org.onap.so.monitoring.model.SoInfraRequest;
+import org.onap.so.monitoring.rest.service.CamundaProcessDataServiceProvider;
+import org.onap.so.rest.exceptions.InvalidRestRequestException;
+import org.onap.so.rest.exceptions.HttpResouceNotFoundException;
+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.stereotype.Component;
+
+/**
+ * @author waqas.ikram@ericsson.com
+ */
+@Component
+@Path("/")
+public class SoMonitoringController {
+
+ private static final String INVALID_PROCESS_INSTANCE_ERROR_MESSAGE = "Invalid process instance id: ";
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(SoMonitoringController.class);
+
+ private final DatabaseServiceProvider databaseServiceProvider;
+
+ private final CamundaProcessDataServiceProvider camundaProcessDataServiceProvider;
+
+ @Autowired
+ public SoMonitoringController(final DatabaseServiceProvider databaseServiceProvider,
+ final CamundaProcessDataServiceProvider camundaProcessDataServiceProvider) {
+ this.databaseServiceProvider = databaseServiceProvider;
+ this.camundaProcessDataServiceProvider = camundaProcessDataServiceProvider;
+ }
+
+ @GET
+ @Path("/process-instance-id/{requestId}")
+ @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
+ public Response getProcessInstanceId(final @PathParam("requestId") String requestId) {
+ if (requestId == null || requestId.isEmpty()) {
+ return Response.status(Status.BAD_REQUEST).entity("Invalid Request id: " + requestId).build();
+ }
+ try {
+ final Optional<ProcessInstanceIdDetail> processInstanceId =
+ camundaProcessDataServiceProvider.getProcessInstanceIdDetail(requestId);
+ if (processInstanceId.isPresent()) {
+ return Response.status(Status.OK).entity(processInstanceId.get()).build();
+ }
+
+ LOGGER.error("Unable to find process instance id for : {} ", requestId);
+ return Response.status(Status.NO_CONTENT).build();
+
+ } catch (final InvalidRestRequestException | HttpResouceNotFoundException extensions) {
+ final String message = "Unable to find process instance id for : " + requestId;
+ LOGGER.error(message);
+ return Response.status(Status.BAD_REQUEST).entity(message).build();
+ } catch (final RestProcessingException restProcessingException) {
+ final String message = "Unable to process request for id: " + requestId;
+ LOGGER.error(message);
+ return Response.status(Status.INTERNAL_SERVER_ERROR).entity(message).build();
+ }
+ }
+
+ @GET
+ @Path("/process-instance/{processInstanceId}")
+ @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
+ public Response getSingleProcessInstance(final @PathParam("processInstanceId") String processInstanceId) {
+ if (processInstanceId == null || processInstanceId.isEmpty()) {
+ return Response.status(Status.BAD_REQUEST)
+ .entity(INVALID_PROCESS_INSTANCE_ERROR_MESSAGE + processInstanceId).build();
+ }
+ try {
+ final Optional<ProcessInstanceDetail> processInstanceDetail =
+ camundaProcessDataServiceProvider.getSingleProcessInstanceDetail(processInstanceId);
+ if (processInstanceDetail.isPresent()) {
+ return Response.status(Status.OK).entity(processInstanceDetail.get()).build();
+ }
+
+ LOGGER.error("Unable to find process instance id for : {}", processInstanceId);
+ return Response.status(Status.NO_CONTENT).build();
+
+ } catch (final InvalidRestRequestException | HttpResouceNotFoundException extensions) {
+ final String message = "Unable to find process instance id for : " + processInstanceId;
+ LOGGER.error(message);
+ return Response.status(Status.BAD_REQUEST).entity(message).build();
+ } catch (final RestProcessingException restProcessingException) {
+ final String message = "Unable to process request for id: " + processInstanceId;
+ LOGGER.error(message);
+ return Response.status(Status.INTERNAL_SERVER_ERROR).entity(message).build();
+ }
+ }
+
+ @GET
+ @Path("/process-definition/{processDefinitionId}")
+ @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
+ public Response getProcessDefinitionXml(final @PathParam("processDefinitionId") String processDefinitionId) {
+ if (processDefinitionId == null || processDefinitionId.isEmpty()) {
+ return Response.status(Status.BAD_REQUEST).entity("Invalid process definition id: " + processDefinitionId)
+ .build();
+ }
+ try {
+ final Optional<ProcessDefinitionDetail> response =
+ camundaProcessDataServiceProvider.getProcessDefinition(processDefinitionId);
+ if (response.isPresent()) {
+ final ProcessDefinitionDetail definitionDetail = response.get();
+ return Response.status(Status.OK).entity(definitionDetail).build();
+ }
+ LOGGER.error("Unable to find process definition xml for processDefinitionId: {}", processDefinitionId);
+ return Response.status(Status.NO_CONTENT).build();
+
+ } catch (final InvalidRestRequestException | HttpResouceNotFoundException extensions) {
+ final String message =
+ "Unable to find process definition xml for processDefinitionId: {}" + processDefinitionId;
+ return Response.status(Status.BAD_REQUEST).entity(message).build();
+ } catch (final RestProcessingException restProcessingException) {
+ final String message = "Unable to get process definition xml for id: " + processDefinitionId;
+ LOGGER.error(message);
+ return Response.status(Status.INTERNAL_SERVER_ERROR).entity(message).build();
+ }
+ }
+
+ @GET
+ @Path("/activity-instance/{processInstanceId}")
+ @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
+ public Response getActivityInstanceDetail(final @PathParam("processInstanceId") String processInstanceId) {
+ if (processInstanceId == null || processInstanceId.isEmpty()) {
+ return Response.status(Status.BAD_REQUEST)
+ .entity(INVALID_PROCESS_INSTANCE_ERROR_MESSAGE + processInstanceId).build();
+ }
+ try {
+ final List<ActivityInstanceDetail> activityInstanceDetails =
+ camundaProcessDataServiceProvider.getActivityInstance(processInstanceId);
+ return Response.status(Status.OK).entity(activityInstanceDetails).build();
+ } catch (final InvalidRestRequestException | HttpResouceNotFoundException extensions) {
+ final String message = "Unable to find activity instance for processInstanceId: " + processInstanceId;
+ LOGGER.error(message);
+ return Response.status(Status.BAD_REQUEST).entity(message).build();
+ } catch (final RestProcessingException restProcessingException) {
+ final String message = "Unable to get activity instance detail for id: " + processInstanceId;
+ LOGGER.error(message);
+ return Response.status(Status.INTERNAL_SERVER_ERROR).entity(message).build();
+ }
+ }
+
+ @GET
+ @Path("/variable-instance/{processInstanceId}")
+ @Produces(MediaType.APPLICATION_JSON)
+ public Response getProcessInstanceVariables(final @PathParam("processInstanceId") String processInstanceId) {
+ if (processInstanceId == null || processInstanceId.isEmpty()) {
+ return Response.status(Status.BAD_REQUEST)
+ .entity(INVALID_PROCESS_INSTANCE_ERROR_MESSAGE + processInstanceId).build();
+ }
+ try {
+ final List<ProcessInstanceVariableDetail> processInstanceVariable =
+ camundaProcessDataServiceProvider.getProcessInstanceVariable(processInstanceId);
+ return Response.status(Status.OK).entity(processInstanceVariable).build();
+ } catch (final InvalidRestRequestException | HttpResouceNotFoundException extensions) {
+ final String message =
+ "Unable to find process instance variables for processInstanceId: " + processInstanceId;
+ LOGGER.error(message);
+ return Response.status(Status.BAD_REQUEST).entity(message).build();
+ } catch (final RestProcessingException restProcessingException) {
+ final String message = "Unable to get process instance variables for id: " + processInstanceId;
+ LOGGER.error(message);
+ return Response.status(Status.INTERNAL_SERVER_ERROR).entity(message).build();
+ }
+ }
+
+ @POST
+ @Path("/v1/search")
+ @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
+ public Response getInfraActiveRequests(final Map<String, String[]> filters,
+ @QueryParam("from") final long startTime, @QueryParam("to") final long endTime,
+ @QueryParam("maxResult") final Integer maxResult) {
+
+ if (filters == null) {
+ return Response.status(Status.BAD_REQUEST).entity("Invalid filters: " + filters).build();
+ }
+ try {
+ final List<SoInfraRequest> requests =
+ databaseServiceProvider.getSoInfraRequest(filters, startTime, endTime, maxResult);
+ LOGGER.info("result size: {}", requests.size());
+ return Response.status(Status.OK).entity(requests).build();
+
+ } catch (final InvalidRestRequestException | HttpResouceNotFoundException extensions) {
+ final String message = "Unable to search request for filters: " + filters + ", from: " + startTime
+ + ", to: " + endTime + ", maxResult: " + maxResult;
+ LOGGER.error(message);
+ return Response.status(Status.BAD_REQUEST).entity(message).build();
+ } catch (final RestProcessingException restProcessingException) {
+ final String message = "Unable to search request for filters: " + filters + ", from: " + startTime
+ + ", to: " + endTime + ", maxResult: " + maxResult;
+ LOGGER.error(message);
+ return Response.status(Status.INTERNAL_SERVER_ERROR).entity(message).build();
+ }
+ }
+
+}
diff --git a/so-admin-cockpit-monitoring-workflow/so-admin-cockpit-monitoring-workflow-service/src/main/java/org/onap/so/monitoring/rest/api/WebApplicationConfig.java b/so-admin-cockpit-monitoring-workflow/so-admin-cockpit-monitoring-workflow-service/src/main/java/org/onap/so/monitoring/rest/api/WebApplicationConfig.java
new file mode 100644
index 0000000..cadd60b
--- /dev/null
+++ b/so-admin-cockpit-monitoring-workflow/so-admin-cockpit-monitoring-workflow-service/src/main/java/org/onap/so/monitoring/rest/api/WebApplicationConfig.java
@@ -0,0 +1,36 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2018 Ericsson. 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.so.monitoring.rest.api;
+
+import org.springframework.context.annotation.Configuration;
+import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
+import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
+
+/**
+ * @author waqas.ikram@ericsson.com
+ */
+@Configuration
+public class WebApplicationConfig extends WebMvcConfigurerAdapter {
+ @Override
+ public void addViewControllers(final ViewControllerRegistry registry) {
+ super.addViewControllers(registry);
+ registry.addViewController("/details/**").setViewName("forward:/");
+ }
+}