diff options
author | Benjamin, Max <max.benjamin@att.com> | 2019-06-14 10:12:35 -0400 |
---|---|---|
committer | Benjamin, Max (mb388a) <mb388a@us.att.com> | 2019-06-14 10:12:40 -0400 |
commit | d482d74260ca80cceb8b9d965b54970dfea9526d (patch) | |
tree | 39960168f0011bbebc2817d294a1a2e03e185da8 /bpmn/MSOCommonBPMN | |
parent | 1f8aa8ef6deade96a53fa57c28d1aacab6cf7e5e (diff) |
update multi stage code to accurately skip bbs
moved around classes to packages that make more sense
updated license headers in java files
converted MultiStage logic to FlowManipulator
moved tests to new package location and fixed issues
allow for custom listeners before flowsToExecute
moved validation classes to listener.validation
Change-Id: Ic5416812ef9c5611fe19bf9b6aa316373b110ec6
Issue-ID: SO-2021
Signed-off-by: Benjamin, Max (mb388a) <mb388a@us.att.com>
Diffstat (limited to 'bpmn/MSOCommonBPMN')
32 files changed, 374 insertions, 79 deletions
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/BBConstants.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/BBConstants.java new file mode 100644 index 0000000000..49ccc7b4a8 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/BBConstants.java @@ -0,0 +1,35 @@ +/*- + * ============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; + +public class BBConstants { + public static final String G_ORCHESTRATION_FLOW = "gOrchestrationFlow"; + public static final String G_ACTION = "requestAction"; + public static final String G_CURRENT_SEQUENCE = "gCurrentSequence"; + public static final String G_REQUEST_ID = "mso-request-id"; + public static final String G_BPMN_REQUEST = "bpmnRequest"; + public static final String G_ALACARTE = "aLaCarte"; + public static final String G_APIVERSION = "apiVersion"; + public static final String G_URI = "requestUri"; + public static final String G_ISTOPLEVELFLOW = "isTopLevelFlow"; + public static final String G_SERVICE_TYPE = "serviceType"; + +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/BuildingBlockExecution.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/BuildingBlockExecution.java index 83a44cfe8b..248f3b5f1a 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/BuildingBlockExecution.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/BuildingBlockExecution.java @@ -39,4 +39,6 @@ public interface BuildingBlockExecution { public Map<ResourceKey, String> getLookupMap(); public String getFlowToBeCalled(); + + public int getCurrentSequence(); } diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/DelegateExecutionImpl.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/DelegateExecutionImpl.java index 734262aa55..9aed5e9408 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/DelegateExecutionImpl.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/DelegateExecutionImpl.java @@ -112,6 +112,11 @@ public class DelegateExecutionImpl implements BuildingBlockExecution, Serializab return this.get("flowToBeCalled"); } + @JsonIgnore + @Override + public int getCurrentSequence() { + return this.get("gCurrentSequence"); + } public void setDelegateExecution(final DelegateExecution execution) { this.execution = execution; diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/ListenerRunner.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/ListenerRunner.java new file mode 100644 index 0000000000..3c36052dca --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/ListenerRunner.java @@ -0,0 +1,60 @@ +/*- + * ============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; + +import java.lang.annotation.Annotation; +import java.util.Comparator; +import java.util.List; +import java.util.Optional; +import java.util.function.Predicate; +import java.util.stream.Collectors; +import javax.annotation.Priority; +import org.onap.so.client.exception.ExceptionBuilder; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.ApplicationContext; + +public abstract class ListenerRunner { + + @Autowired + protected ApplicationContext context; + + @Autowired + protected ExceptionBuilder exceptionBuilder; + + protected <T> List<T> filterListeners(List<T> validators, Predicate<T> predicate) { + return validators.stream().filter(item -> { + return !item.getClass().isAnnotationPresent(Skip.class) && predicate.test(item); + }).sorted(Comparator.comparing(item -> { + Priority p = Optional.ofNullable(item.getClass().getAnnotation(Priority.class)).orElse(new Priority() { + public int value() { + return 1000; + } + + @Override + public Class<? extends Annotation> annotationType() { + return Priority.class; + } + }); + return p.value(); + })).collect(Collectors.toList()); + } + +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/validation/Skip.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/Skip.java index fe03a10795..a0543fd3cc 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/validation/Skip.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/Skip.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.so.bpmn.common.validation; +package org.onap.so.bpmn.common.listener; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/flowmanipulator/FlowManipulator.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/flowmanipulator/FlowManipulator.java new file mode 100644 index 0000000000..5e2882cb5b --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/flowmanipulator/FlowManipulator.java @@ -0,0 +1,33 @@ +/*- + * ============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.flowmanipulator; + +import java.util.List; +import org.onap.so.bpmn.common.BuildingBlockExecution; +import org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock; + +public interface FlowManipulator { + + public boolean shouldRunFor(String currentBBName, boolean isFirst, BuildingBlockExecution execution); + + public void run(List<ExecuteBuildingBlock> flowsToExecute, ExecuteBuildingBlock currentBB, + BuildingBlockExecution execution); +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/flowmanipulator/FlowManipulatorListenerRunner.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/flowmanipulator/FlowManipulatorListenerRunner.java new file mode 100644 index 0000000000..5f4dc871fb --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/flowmanipulator/FlowManipulatorListenerRunner.java @@ -0,0 +1,65 @@ +/*- + * ============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.flowmanipulator; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Optional; +import java.util.stream.Collectors; +import javax.annotation.PostConstruct; +import org.onap.so.bpmn.common.BuildingBlockExecution; +import org.onap.so.bpmn.common.listener.ListenerRunner; +import org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Component; + +@Component +public class FlowManipulatorListenerRunner extends ListenerRunner { + + private static Logger logger = LoggerFactory.getLogger(FlowManipulatorListenerRunner.class); + + protected List<FlowManipulator> flowManipulators; + + @PostConstruct + protected void init() { + + flowManipulators = new ArrayList<>( + Optional.ofNullable(context.getBeansOfType(FlowManipulator.class)).orElse(new HashMap<>()).values()); + + } + + public void modifyFlows(List<ExecuteBuildingBlock> flowsToExecute, BuildingBlockExecution execution) { + + ExecuteBuildingBlock currentBB = flowsToExecute.get(execution.getCurrentSequence()); + List<FlowManipulator> filtered = filterListeners(flowManipulators, + (item -> item.shouldRunFor(currentBB.getBuildingBlock().getBpmnFlowName(), + execution.getCurrentSequence() == 0, execution))); + + logger.info("Running flow manipulators:\n{}", + filtered.stream().map(item -> item.getClass().getName()).collect(Collectors.joining("\n"))); + filtered.forEach(item -> item.run(flowsToExecute, currentBB, execution)); + + } + + +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/validation/BuildingBlockValidatorRunner.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/validation/BuildingBlockValidatorRunner.java index 7777584b80..78d897fd87 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/validation/BuildingBlockValidatorRunner.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/validation/BuildingBlockValidatorRunner.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.so.bpmn.common.validation; +package org.onap.so.bpmn.common.listener.validation; import java.util.ArrayList; import java.util.HashMap; @@ -32,9 +32,9 @@ import org.springframework.stereotype.Component; * Controls running all pre and post validation for building blocks. * * To define a validation you must make it a spring bean and implement either - * {@link org.onap.so.bpmn.common.validation.PreBuildingBlockValidator} or - * {@link org.onap.so.bpmn.common.validation.PostBuildingBlockValidator} your validation will automatically be run by - * this class. + * {@link org.onap.so.bpmn.common.listener.validation.PreBuildingBlockValidator} or + * {@link org.onap.so.bpmn.common.listener.validation.PostBuildingBlockValidator} your validation will automatically be + * run by this class. * */ @Component diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/validation/FlowValidator.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/validation/FlowValidator.java index 05d7a1f417..657e1d9539 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/validation/FlowValidator.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/validation/FlowValidator.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.so.bpmn.common.validation; +package org.onap.so.bpmn.common.listener.validation; import java.util.Optional; import org.onap.so.bpmn.common.BuildingBlockExecution; diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/validation/FlowValidatorRunner.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/validation/FlowValidatorRunner.java index 0bdf4e35a2..040522b576 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/validation/FlowValidatorRunner.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/validation/FlowValidatorRunner.java @@ -18,25 +18,19 @@ * ============LICENSE_END========================================================= */ -package org.onap.so.bpmn.common.validation; +package org.onap.so.bpmn.common.listener.validation; -import java.lang.annotation.Annotation; import java.util.ArrayList; -import java.util.Comparator; import java.util.List; import java.util.Optional; import java.util.stream.Collectors; -import javax.annotation.Priority; import org.camunda.bpm.engine.delegate.DelegateExecution; import org.javatuples.Pair; import org.onap.so.bpmn.common.BuildingBlockExecution; import org.onap.so.bpmn.common.DelegateExecutionImpl; -import org.onap.so.client.exception.ExceptionBuilder; -import org.reflections.Reflections; +import org.onap.so.bpmn.common.listener.ListenerRunner; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.ApplicationContext; import org.springframework.stereotype.Component; @@ -49,14 +43,9 @@ import org.springframework.stereotype.Component; * */ @Component -public abstract class FlowValidatorRunner<S extends FlowValidator, E extends FlowValidator> { +public abstract class FlowValidatorRunner<S extends FlowValidator, E extends FlowValidator> extends ListenerRunner { private static Logger logger = LoggerFactory.getLogger(FlowValidatorRunner.class); - @Autowired - protected ApplicationContext context; - - @Autowired - protected ExceptionBuilder exceptionBuilder; protected List<S> preFlowValidators; protected List<E> postFlowValidators; @@ -114,7 +103,7 @@ public abstract class FlowValidatorRunner<S extends FlowValidator, E extends Flo protected List<Pair<String, Optional<String>>> runValidations(List<? extends FlowValidator> validators, String bbName, BuildingBlockExecution execution) { - List<FlowValidator> filtered = filterValidators(validators, bbName); + List<? extends FlowValidator> filtered = filterListeners(validators, (item -> item.shouldRunFor(bbName))); List<Pair<String, Optional<String>>> results = new ArrayList<>(); filtered.forEach(item -> results.add(new Pair<>(item.getClass().getName(), item.validate(execution)))); @@ -122,38 +111,6 @@ public abstract class FlowValidatorRunner<S extends FlowValidator, E extends Flo return results.stream().filter(item -> item.getValue1().isPresent()).collect(Collectors.toList()); } - protected List<FlowValidator> filterValidators(List<? extends FlowValidator> validators, String bbName) { - return validators.stream().filter(item -> { - return !item.getClass().isAnnotationPresent(Skip.class) && item.shouldRunFor(bbName); - }).sorted(Comparator.comparing(item -> { - Priority p = Optional.ofNullable(item.getClass().getAnnotation(Priority.class)).orElse(new Priority() { - public int value() { - return 1000; - } - - @Override - public Class<? extends Annotation> annotationType() { - return Priority.class; - } - }); - return p.value(); - })).collect(Collectors.toList()); - } - - protected <T> List<T> buildalidatorList(Reflections reflections, Class<T> clazz) { - List<T> result = new ArrayList<>(); - try { - for (Class<? extends T> klass : reflections.getSubTypesOf(clazz)) { - result.add(klass.newInstance()); - } - } catch (InstantiationException | IllegalAccessException e) { - logger.error("failed to build validator list for {}", clazz.getName(), e); - throw new RuntimeException(e); - } - - return result; - } - protected abstract List<S> getPreFlowValidators(); protected abstract List<E> getPostFlowValidators(); diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/validation/PostBuildingBlockValidator.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/validation/PostBuildingBlockValidator.java index f26a2ee479..75dc75de43 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/validation/PostBuildingBlockValidator.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/validation/PostBuildingBlockValidator.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.so.bpmn.common.validation; +package org.onap.so.bpmn.common.listener.validation; public interface PostBuildingBlockValidator extends FlowValidator { diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/validation/PostWorkflowValidator.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/validation/PostWorkflowValidator.java index 9070615a7a..7d5f68a482 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/validation/PostWorkflowValidator.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/validation/PostWorkflowValidator.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.so.bpmn.common.validation; +package org.onap.so.bpmn.common.listener.validation; public interface PostWorkflowValidator extends FlowValidator { diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/validation/PreBuildingBlockValidator.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/validation/PreBuildingBlockValidator.java index fda687e072..fda2d264d8 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/validation/PreBuildingBlockValidator.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/validation/PreBuildingBlockValidator.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.so.bpmn.common.validation; +package org.onap.so.bpmn.common.listener.validation; public interface PreBuildingBlockValidator extends FlowValidator { diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/validation/PreWorkflowValidator.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/validation/PreWorkflowValidator.java index 0bfbf5602f..a8e8642058 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/validation/PreWorkflowValidator.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/validation/PreWorkflowValidator.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.so.bpmn.common.validation; +package org.onap.so.bpmn.common.listener.validation; public interface PreWorkflowValidator extends FlowValidator { diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/validation/WorkflowValidatorRunner.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/validation/WorkflowValidatorRunner.java index 493bb0e89b..c6afa16ec2 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/validation/WorkflowValidatorRunner.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/validation/WorkflowValidatorRunner.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.so.bpmn.common.validation; +package org.onap.so.bpmn.common.listener.validation; import java.util.ArrayList; import java.util.HashMap; @@ -32,9 +32,9 @@ import org.springframework.stereotype.Component; * Controls running all pre and post validation for workflows. * * To define a validation you must make it a spring bean and implement either - * {@link org.onap.so.bpmn.common.validation.PreWorkflowValidator} or - * {@link org.onap.so.bpmn.common.validation.PostWorkflowValidator} your validation will automatically be run by this - * class. + * {@link org.onap.so.bpmn.common.listener.validation.PreWorkflowValidator} or + * {@link org.onap.so.bpmn.common.listener.validation.PostWorkflowValidator} your validation will automatically be run + * by this class. * */ @Component diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/Vnfc.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/Vnfc.java index 087edff7c0..08b1124726 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/Vnfc.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/Vnfc.java @@ -1,3 +1,23 @@ +/*- + * ============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.servicedecomposition.bbobjects; import java.io.Serializable; diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/wrappers/ServiceInstanceWrapper.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/wrappers/ServiceInstanceWrapper.java index 40ffe7356c..1f7f970058 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/wrappers/ServiceInstanceWrapper.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/wrappers/ServiceInstanceWrapper.java @@ -1,3 +1,23 @@ +/*- + * ============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.servicedecomposition.bbobjects.wrappers; import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/wrappers/exceptions/ServiceProxyNotFoundException.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/wrappers/exceptions/ServiceProxyNotFoundException.java index 924d9eda87..046299bb13 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/wrappers/exceptions/ServiceProxyNotFoundException.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/wrappers/exceptions/ServiceProxyNotFoundException.java @@ -1,3 +1,23 @@ +/*- + * ============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.servicedecomposition.bbobjects.wrappers.exceptions; public class ServiceProxyNotFoundException extends Exception { diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/entities/ExecuteBuildingBlock.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/entities/ExecuteBuildingBlock.java index af9eb525aa..f1de0cc6f6 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/entities/ExecuteBuildingBlock.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/entities/ExecuteBuildingBlock.java @@ -35,7 +35,7 @@ public class ExecuteBuildingBlock implements Serializable { private String requestAction; private String vnfType; private Boolean aLaCarte; - private Boolean homing; + private Boolean homing = false; private WorkflowResourceIds workflowResourceIds; private RequestDetails requestDetails; private ConfigurationResourceKeys configurationResourceKeys; diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/exception/ExpectedDataException.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/exception/ExpectedDataException.java index 12ab165c3a..9ead1576cb 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/exception/ExpectedDataException.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/exception/ExpectedDataException.java @@ -1,3 +1,23 @@ +/*- + * ============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.client.exception; diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/exception/UnexpectedDataException.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/exception/UnexpectedDataException.java index 84cf491355..9ae14a0162 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/exception/UnexpectedDataException.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/exception/UnexpectedDataException.java @@ -1,3 +1,23 @@ +/*- + * ============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.client.exception; diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/BuildingBlockValidatorRunnerTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/listener/BuildingBlockValidatorRunnerTest.java index f13bcb8a93..2c0377d11c 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/BuildingBlockValidatorRunnerTest.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/listener/BuildingBlockValidatorRunnerTest.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.so.bpmn.common.validation; +package org.onap.so.bpmn.common.listener; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; @@ -34,6 +34,12 @@ import org.junit.rules.ExpectedException; import org.junit.runner.RunWith; import org.onap.so.bpmn.common.BuildingBlockExecution; import org.onap.so.bpmn.common.DelegateExecutionImpl; +import org.onap.so.bpmn.common.listener.validation.BuildingBlockValidatorRunner; +import org.onap.so.bpmn.common.listener.validation.FlowValidator; +import org.onap.so.bpmn.common.listener.validation.MyPreValidatorOne; +import org.onap.so.bpmn.common.listener.validation.MyPreValidatorThree; +import org.onap.so.bpmn.common.listener.validation.MyPreValidatorTwo; +import org.onap.so.bpmn.common.listener.validation.ValidationConfig; import org.onap.so.bpmn.core.WorkflowException; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; @@ -57,7 +63,7 @@ public class BuildingBlockValidatorRunnerTest { MyPreValidatorThree three = new MyPreValidatorThree(); List<FlowValidator> validators = Arrays.asList(one, two, three); - List<FlowValidator> result = runner.filterValidators(validators, "test"); + List<FlowValidator> result = runner.filterListeners(validators, (item -> item.shouldRunFor("test"))); List<FlowValidator> expected = Arrays.asList(two, one); @@ -75,7 +81,7 @@ public class BuildingBlockValidatorRunnerTest { } catch (BpmnError e) { WorkflowException workflowException = (WorkflowException) execution.getVariable("WorkflowException"); assertEquals( - "Failed Validations:\norg.onap.so.bpmn.common.validation.MyPreValidatorTwo: my-error-two\norg.onap.so.bpmn.common.validation.MyPreValidatorOne: my-error-one", + "Failed Validations:\norg.onap.so.bpmn.common.listener.validation.MyPreValidatorTwo: my-error-two\norg.onap.so.bpmn.common.listener.validation.MyPreValidatorOne: my-error-one", workflowException.getErrorMessage()); } runner.preValidate("test2", mock(BuildingBlockExecution.class)); diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/WorkflowValidatorRunnerTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/listener/WorkflowValidatorRunnerTest.java index 07cd790ed1..0143e567af 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/WorkflowValidatorRunnerTest.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/listener/WorkflowValidatorRunnerTest.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.so.bpmn.common.validation; +package org.onap.so.bpmn.common.listener; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; @@ -33,7 +33,11 @@ import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; import org.junit.runner.RunWith; -import org.onap.so.bpmn.common.BuildingBlockExecution; +import org.onap.so.bpmn.common.listener.validation.FlowValidator; +import org.onap.so.bpmn.common.listener.validation.ValidationConfig; +import org.onap.so.bpmn.common.listener.validation.WorkflowPreValidatorOne; +import org.onap.so.bpmn.common.listener.validation.WorkflowPreValidatorTwo; +import org.onap.so.bpmn.common.listener.validation.WorkflowValidatorRunner; import org.onap.so.bpmn.core.WorkflowException; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; @@ -56,7 +60,7 @@ public class WorkflowValidatorRunnerTest { WorkflowPreValidatorTwo two = new WorkflowPreValidatorTwo(); List<FlowValidator> validators = Arrays.asList(one, two); - List<FlowValidator> result = runner.filterValidators(validators, "test"); + List<FlowValidator> result = runner.filterListeners(validators, (item -> item.shouldRunFor("test"))); List<FlowValidator> expected = Arrays.asList(two, one); @@ -74,7 +78,7 @@ public class WorkflowValidatorRunnerTest { } catch (BpmnError e) { WorkflowException workflowException = (WorkflowException) execution.getVariable("WorkflowException"); assertEquals( - "Failed Validations:\norg.onap.so.bpmn.common.validation.WorkflowPreValidatorTwo: my-error-two\norg.onap.so.bpmn.common.validation.WorkflowPreValidatorOne: my-error-one", + "Failed Validations:\norg.onap.so.bpmn.common.listener.validation.WorkflowPreValidatorTwo: my-error-two\norg.onap.so.bpmn.common.listener.validation.WorkflowPreValidatorOne: my-error-one", workflowException.getErrorMessage()); } runner.preValidate("test2", mock(DelegateExecution.class)); diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/MyDisabledValidator.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/listener/validation/MyDisabledValidator.java index 7572e930cd..af64ed2de6 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/MyDisabledValidator.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/listener/validation/MyDisabledValidator.java @@ -18,11 +18,13 @@ * ============LICENSE_END========================================================= */ -package org.onap.so.bpmn.common.validation; +package org.onap.so.bpmn.common.listener.validation; import java.util.Collections; import java.util.Optional; import org.onap.so.bpmn.common.BuildingBlockExecution; +import org.onap.so.bpmn.common.listener.Skip; +import org.onap.so.bpmn.common.listener.validation.PreBuildingBlockValidator; import org.springframework.stereotype.Component; @Component diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/MyPreValidatorFour.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/listener/validation/MyPreValidatorFour.java index 85531719d5..f0f27172a5 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/MyPreValidatorFour.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/listener/validation/MyPreValidatorFour.java @@ -18,12 +18,13 @@ * ============LICENSE_END========================================================= */ -package org.onap.so.bpmn.common.validation; +package org.onap.so.bpmn.common.listener.validation; import java.util.Collections; import java.util.Optional; import java.util.Set; import org.onap.so.bpmn.common.BuildingBlockExecution; +import org.onap.so.bpmn.common.listener.validation.PreBuildingBlockValidator; import org.springframework.stereotype.Component; @Component diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/MyPreValidatorOne.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/listener/validation/MyPreValidatorOne.java index 989a65fe47..e705bafafe 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/MyPreValidatorOne.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/listener/validation/MyPreValidatorOne.java @@ -18,12 +18,13 @@ * ============LICENSE_END========================================================= */ -package org.onap.so.bpmn.common.validation; +package org.onap.so.bpmn.common.listener.validation; import java.util.Collections; import java.util.Optional; import java.util.Set; import org.onap.so.bpmn.common.BuildingBlockExecution; +import org.onap.so.bpmn.common.listener.validation.PreBuildingBlockValidator; import org.springframework.stereotype.Component; @Component diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/MyPreValidatorThree.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/listener/validation/MyPreValidatorThree.java index a51d3836da..3c747dd20f 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/MyPreValidatorThree.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/listener/validation/MyPreValidatorThree.java @@ -18,12 +18,13 @@ * ============LICENSE_END========================================================= */ -package org.onap.so.bpmn.common.validation; +package org.onap.so.bpmn.common.listener.validation; import java.util.Collections; import java.util.Optional; import java.util.Set; import org.onap.so.bpmn.common.BuildingBlockExecution; +import org.onap.so.bpmn.common.listener.validation.PreBuildingBlockValidator; import org.springframework.stereotype.Component; @Component diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/MyPreValidatorTwo.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/listener/validation/MyPreValidatorTwo.java index 1276d8f1d2..3fb3485c39 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/MyPreValidatorTwo.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/listener/validation/MyPreValidatorTwo.java @@ -18,13 +18,14 @@ * ============LICENSE_END========================================================= */ -package org.onap.so.bpmn.common.validation; +package org.onap.so.bpmn.common.listener.validation; import java.util.Collections; import java.util.Optional; import java.util.Set; import javax.annotation.Priority; import org.onap.so.bpmn.common.BuildingBlockExecution; +import org.onap.so.bpmn.common.listener.validation.PreBuildingBlockValidator; import org.springframework.stereotype.Component; @Priority(1) diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/ValidationConfig.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/listener/validation/ValidationConfig.java index 90d094ce41..068f433dd5 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/ValidationConfig.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/listener/validation/ValidationConfig.java @@ -18,16 +18,16 @@ * ============LICENSE_END========================================================= */ -package org.onap.so.bpmn.common.validation; +package org.onap.so.bpmn.common.listener.validation; import org.onap.so.bpmn.common.DefaultToShortClassNameBeanNameGenerator; +import org.onap.so.bpmn.common.listener.ListenerRunner; import org.onap.so.client.exception.ExceptionBuilder; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Profile; @Configuration -@ComponentScan(basePackages = {"org.onap.so.bpmn.common.validation"}, basePackageClasses = {ExceptionBuilder.class}, +@ComponentScan(basePackageClasses = {ExceptionBuilder.class, ListenerRunner.class}, nameGenerator = DefaultToShortClassNameBeanNameGenerator.class) public class ValidationConfig { diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/WorkflowPreValidatorOne.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/listener/validation/WorkflowPreValidatorOne.java index 485aae2fcc..f7aedcfd6f 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/WorkflowPreValidatorOne.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/listener/validation/WorkflowPreValidatorOne.java @@ -18,12 +18,13 @@ * ============LICENSE_END========================================================= */ -package org.onap.so.bpmn.common.validation; +package org.onap.so.bpmn.common.listener.validation; import java.util.Collections; import java.util.Optional; import java.util.Set; import org.onap.so.bpmn.common.BuildingBlockExecution; +import org.onap.so.bpmn.common.listener.validation.PreWorkflowValidator; import org.springframework.stereotype.Component; @Component diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/WorkflowPreValidatorTwo.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/listener/validation/WorkflowPreValidatorTwo.java index 9596524a56..99a7e161a9 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/WorkflowPreValidatorTwo.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/listener/validation/WorkflowPreValidatorTwo.java @@ -18,13 +18,14 @@ * ============LICENSE_END========================================================= */ -package org.onap.so.bpmn.common.validation; +package org.onap.so.bpmn.common.listener.validation; import java.util.Collections; import java.util.Optional; import java.util.Set; import javax.annotation.Priority; import org.onap.so.bpmn.common.BuildingBlockExecution; +import org.onap.so.bpmn.common.listener.validation.PreWorkflowValidator; import org.springframework.stereotype.Component; @Priority(1) diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/bbobjects/wrappers/ServiceInstanceWrapperTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/bbobjects/wrappers/ServiceInstanceWrapperTest.java index bcee62013f..fa8de7ff23 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/bbobjects/wrappers/ServiceInstanceWrapperTest.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/bbobjects/wrappers/ServiceInstanceWrapperTest.java @@ -1,3 +1,23 @@ +/*- + * ============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.servicedecomposition.bbobjects.wrappers; import static org.junit.Assert.assertEquals; |