diff options
author | Smokowski, Steven <steve.smokowski@att.com> | 2019-09-24 14:57:51 -0400 |
---|---|---|
committer | Benjamin, Max (mb388a) <mb388a@att.com> | 2019-09-24 17:24:25 -0400 |
commit | 4891eedd15cff1e582d052843eb8c11a14c5d836 (patch) | |
tree | 5f014cdd42f99eef78bd7cd4d3eae80be8d32a02 /bpmn/MSOCommonBPMN/src | |
parent | 96231b3365d378a86b71d93b8a7d64aef8be531c (diff) |
Update Resume Logic and Add Workflow Listeners
Updated with the error log messages
Changed the code to do string compare for eventName
update workflowaction to only persist if not resume
Issue-ID: SO-2363
Signed-off-by: Benjamin, Max (mb388a) <mb388a@att.com>
Change-Id: I139f2427ae0f0253a15cc51003318686568cb514
Diffstat (limited to 'bpmn/MSOCommonBPMN/src')
4 files changed, 142 insertions, 19 deletions
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/validation/WorkflowActionCompletion.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/validation/WorkflowActionCompletion.java new file mode 100644 index 0000000000..1018d7f025 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/validation/WorkflowActionCompletion.java @@ -0,0 +1,25 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2018 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.bpmn.common.listener.validation; + +public interface WorkflowActionCompletion extends WorkflowActionListener { + +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/validation/WorkflowActionListener.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/validation/WorkflowActionListener.java new file mode 100644 index 0000000000..4788c55053 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/validation/WorkflowActionListener.java @@ -0,0 +1,44 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2019 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.bpmn.common.listener.validation; + +import org.camunda.bpm.engine.delegate.DelegateExecution; + +public interface WorkflowActionListener { + + /** + * Should this listener run for given bb + * + * @return + * + */ + public boolean shouldRunFor(String bbName, String eventName); + + /** + * Determines whether or not the listener should be executed + * + * + * @param execution + * @return + */ + public void executeListener(DelegateExecution execution); + +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/validation/WorkflowActionListenerRunner.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/validation/WorkflowActionListenerRunner.java new file mode 100644 index 0000000000..806c1b835d --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/validation/WorkflowActionListenerRunner.java @@ -0,0 +1,64 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2018 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.bpmn.common.listener.validation; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Optional; +import javax.annotation.PostConstruct; +import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.onap.so.listener.ListenerRunner; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Component; + + + +@Component +public class WorkflowActionListenerRunner extends ListenerRunner { + + private static Logger logger = LoggerFactory.getLogger(WorkflowActionListenerRunner.class); + + protected List<WorkflowActionListener> workflowActionListeners; + + @PostConstruct + protected void init() { + workflowActionListeners = new ArrayList<>(Optional + .ofNullable(context.getBeansOfType(WorkflowActionListener.class)).orElse(new HashMap<>()).values()); + } + + public void executeAsyncListeners(String bbName, DelegateExecution execution, String eventName) { + try { + logger.info("NotifyingWorkflowActionListeners"); + runNotifications(workflowActionListeners, bbName, execution, eventName); + } catch (Exception e) { + logger.error("Error in Notifying Workflow Action Listeners", e); + } + } + + protected void runNotifications(List<? extends WorkflowActionListener> listeners, String bbName, + DelegateExecution execution, String eventName) { + List<? extends WorkflowActionListener> filtered = + filterListeners(listeners, (item -> item.shouldRunFor(bbName, eventName))); + filtered.forEach(item -> item.executeListener(execution)); + } +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtils.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtils.java index dcb9e08d0b..fcac86b251 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtils.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtils.java @@ -23,9 +23,7 @@ package org.onap.so.bpmn.servicedecomposition.tasks; import java.io.IOException; -import java.io.ObjectOutputStream; import java.util.ArrayList; -import java.util.Arrays; import java.util.List; import java.util.Map; import java.util.Optional; @@ -76,12 +74,11 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; -import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.DeserializationFeature; -import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.SerializationFeature; +import com.fasterxml.jackson.databind.type.TypeFactory; @Component("BBInputSetupUtils") public class BBInputSetupUtils { @@ -177,39 +174,32 @@ public class BBInputSetupUtils { } public InfraActiveRequests loadOriginalInfraActiveRequestById(String requestId) { - return this.requestsDbClient.getInfraActiveRequestbyRequestId( this.requestsDbClient.getInfraActiveRequestbyRequestId(requestId).getOriginalRequestId()); } public List<ExecuteBuildingBlock> loadOriginalFlowExecutionPath(String requestId) { - - List<ExecuteBuildingBlock> asList = null; if (requestId != null) { - InfraActiveRequests request = loadInfraActiveRequestById(requestId); - if (request.getOriginalRequestId() != null) { - RequestProcessingData requestProcessingData = this.requestsDbClient.getRequestProcessingDataBySoRequestIdAndName( request.getOriginalRequestId(), PROCESSING_DATA_NAME_EXECUTION_FLOWS); - - ObjectMapper om = new ObjectMapper(); try { - ExecuteBuildingBlock[] asArray = - om.readValue(requestProcessingData.getValue(), ExecuteBuildingBlock[].class); - asList = Arrays.asList(asArray); + ObjectMapper om = new ObjectMapper(); + TypeFactory typeFactory = objectMapper.getTypeFactory(); + return om.readValue(requestProcessingData.getValue(), + typeFactory.constructCollectionType(List.class, ExecuteBuildingBlock.class)); } catch (Exception e) { logger.error(DATA_LOAD_ERROR, e); + throw new RuntimeException("Error Loading Original Request Data", e); } + } else { + throw new RuntimeException("Original Request Id is null for record: " + requestId); } - } else { - logger.debug(REQUEST_ERROR); + throw new RuntimeException("Null Request Id Passed in"); } - - return asList; } public Service getCatalogServiceByModelUUID(String modelUUID) { |