diff options
36 files changed, 685 insertions, 46 deletions
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/validation/PostWorkflowValidator.java new file mode 100644 index 0000000000..46b3c571d5 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/validation/PostWorkflowValidator.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.validation; + +public interface PostWorkflowValidator extends WorkflowValidator { + +} 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/validation/PreWorkflowValidator.java new file mode 100644 index 0000000000..4dad1eafc4 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/validation/PreWorkflowValidator.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.validation; + +public interface PreWorkflowValidator extends WorkflowValidator { + +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/validation/WorkflowValidator.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/validation/WorkflowValidator.java new file mode 100644 index 0000000000..348f91321c --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/validation/WorkflowValidator.java @@ -0,0 +1,44 @@ +/*- + * ============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.validation; + +import java.util.Set; + +import org.camunda.bpm.engine.delegate.DelegateExecution; + +public interface WorkflowValidator { + + + /** + * Name of the workflow action to be validated + * @return + */ + public Set<String> forWorkflowAction(); + + /** + * Determines whether or not the workflow should be executed + * + * @param execution + * @return + */ + public boolean validate(DelegateExecution execution); + +} 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/validation/WorkflowValidatorRunner.java new file mode 100644 index 0000000000..44fbc6d629 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/validation/WorkflowValidatorRunner.java @@ -0,0 +1,149 @@ +/*- + * ============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.validation; + +import java.lang.annotation.Annotation; +import java.util.ArrayList; +import java.util.Comparator; +import java.util.HashMap; +import java.util.List; +import java.util.Optional; +import java.util.stream.Collectors; + +import javax.annotation.PostConstruct; +import javax.annotation.Priority; + +import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.javatuples.Pair; +import org.onap.so.client.exception.ExceptionBuilder; +import org.reflections.Reflections; +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; + + +/** + * 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. + * + */ +@Component +public class WorkflowValidatorRunner { + + private static Logger logger = LoggerFactory.getLogger(WorkflowValidatorRunner.class); + @Autowired + private ApplicationContext context; + + @Autowired + private ExceptionBuilder exceptionBuilder; + + private List<PreWorkflowValidator> preWorkflowValidators; + private List<PostWorkflowValidator> postWorkflowValidators; + + + @PostConstruct + protected void init() { + + preWorkflowValidators = new ArrayList<>( + Optional.ofNullable(context.getBeansOfType(PreWorkflowValidator.class)).orElse(new HashMap<>()).values()); + postWorkflowValidators = new ArrayList<>( + Optional.ofNullable(context.getBeansOfType(PostWorkflowValidator.class)).orElse(new HashMap<>()).values()); + } + + public boolean preValidate(String workflow, DelegateExecution execution) { + return validate(preWorkflowValidators, workflow, execution); + } + + + public boolean postValidate(String workflow, DelegateExecution execution) { + return validate(postWorkflowValidators, workflow, execution); + } + + + protected boolean validate(List<? extends WorkflowValidator> validators, String workflow, DelegateExecution execution) { + List<Pair<String, Boolean>> results = runValidations(validators, workflow, execution); + + if (!results.isEmpty()) { + exceptionBuilder.buildAndThrowWorkflowException(execution, 7000, + "Failed Validations:\n" + results.stream().map(item -> item.getValue0()).collect(Collectors.joining("\n"))); + } + + return true; + + } + protected List<Pair<String, Boolean>> runValidations(List<? extends WorkflowValidator> validators, String workflow, DelegateExecution execution) { + + List<WorkflowValidator> filtered = filterValidators(validators, workflow); + + List<Pair<String,Boolean>> results = new ArrayList<>(); + filtered.forEach(item -> results.add(new Pair<>(item.getClass().getName(), item.validate(execution)))); + + return results.stream().filter(item -> item.getValue1().equals(false)).collect(Collectors.toList()); + } + + protected List<WorkflowValidator> filterValidators(List<? extends WorkflowValidator> validators, String workflow) { + return validators.stream() + .filter(item -> { + return item.forWorkflowAction().contains(workflow); + }) + .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 List<PreWorkflowValidator> getPreWorkflowValidators() { + return this.preWorkflowValidators; + } + + protected List<PostWorkflowValidator> getPostWorkflowValidators() { + return this.postWorkflowValidators; + } + +} 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/validation/WorkflowPreValidatorOne.java new file mode 100644 index 0000000000..9ad87b5aeb --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/WorkflowPreValidatorOne.java @@ -0,0 +1,43 @@ +/*- + * ============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.validation; + +import java.util.Collections; +import java.util.Set; + +import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.springframework.stereotype.Component; + +@Component +public class WorkflowPreValidatorOne implements PreWorkflowValidator { + + @Override + public Set<String> forWorkflowAction() { + + return Collections.singleton("test"); + } + + @Override + public boolean validate(DelegateExecution exeuction) { + return false; + } + +} 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/validation/WorkflowPreValidatorTwo.java new file mode 100644 index 0000000000..2157c673dc --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/WorkflowPreValidatorTwo.java @@ -0,0 +1,45 @@ +/*- + * ============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.validation; + +import java.util.Collections; +import java.util.Set; + +import javax.annotation.Priority; + +import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.springframework.stereotype.Component; + +@Priority(1) +@Component +public class WorkflowPreValidatorTwo implements PreWorkflowValidator { + + @Override + public Set<String> forWorkflowAction() { + return Collections.singleton("test"); + } + + @Override + public boolean validate(DelegateExecution execution) { + return false; + } + +} 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/validation/WorkflowValidatorRunnerTest.java new file mode 100644 index 0000000000..313fe6b0c3 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/WorkflowValidatorRunnerTest.java @@ -0,0 +1,90 @@ +/*- + * ============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.validation; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; +import static org.mockito.Mockito.mock; + +import java.util.Arrays; +import java.util.List; + +import org.camunda.bpm.engine.delegate.BpmnError; +import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.camunda.bpm.extension.mockito.delegate.DelegateExecutionFake; +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.DelegateExecutionImpl; +import org.onap.so.bpmn.core.WorkflowException; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; + +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = {ValidationConfig.class}) +public class WorkflowValidatorRunnerTest { + + @Rule + public ExpectedException thrown= ExpectedException.none(); + + @Autowired + private WorkflowValidatorRunner runner; + + @Test + public void filterValidatorTest() { + + WorkflowPreValidatorOne one = new WorkflowPreValidatorOne(); + WorkflowPreValidatorTwo two = new WorkflowPreValidatorTwo(); + List<WorkflowValidator> validators = Arrays.asList(one, two); + + List<WorkflowValidator> result = runner.filterValidators(validators, "test"); + + List<WorkflowValidator> expected = Arrays.asList(two, one); + + assertEquals(expected, result); + } + + @Test + public void testValidate() { + + DelegateExecution execution = new DelegateExecutionFake(); + execution.setVariable("testProcessKey", "1234"); + try { + runner.preValidate("test", execution); + fail("exception not thrown"); + } catch (BpmnError e) { + WorkflowException workflowException = (WorkflowException) execution.getVariable("WorkflowException"); + assertEquals("Failed Validations:\norg.onap.so.bpmn.common.validation.WorkflowPreValidatorTwo\norg.onap.so.bpmn.common.validation.WorkflowPreValidatorOne", workflowException.getErrorMessage()); + } + runner.preValidate("test2", mock(DelegateExecution.class)); + } + + @Test + public void testEmptyList() { + boolean result = runner.preValidate("test3", mock(DelegateExecution.class)); + + assertTrue(result); + } +} diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/ActivateNetworkBB.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/ActivateNetworkBB.bpmn index 78a389a67d..19845c4e8d 100644 --- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/ActivateNetworkBB.bpmn +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/ActivateNetworkBB.bpmn @@ -21,6 +21,8 @@ <bpmn2:extensionElements> <camunda:in source="SDNCRequest" target="SDNCRequest" /> <camunda:out source="SDNCResponse" target="SDNCResponse" /> + <camunda:out source="WorkflowException" target="WorkflowException" /> + <camunda:in source="mso-request-id" target="mso-request-id" /> </bpmn2:extensionElements> <bpmn2:incoming>SequenceFlow_0zzlwi7</bpmn2:incoming> <bpmn2:outgoing>SequenceFlow_0wb238v</bpmn2:outgoing> diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/ActivateVfModuleBB.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/ActivateVfModuleBB.bpmn index 259a3341c2..ef19e6e35b 100644 --- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/ActivateVfModuleBB.bpmn +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/ActivateVfModuleBB.bpmn @@ -21,6 +21,8 @@ <bpmn:extensionElements> <camunda:in source="SDNCRequest" target="SDNCRequest" /> <camunda:out source="SDNCResponse" target="SDNCResponse" /> + <camunda:out source="WorkflowException" target="WorkflowException" /> + <camunda:in source="mso-request-id" target="mso-request-id" /> </bpmn:extensionElements> <bpmn:incoming>SequenceFlow_1a495wm</bpmn:incoming> <bpmn:outgoing>SequenceFlow_1j4x1ej</bpmn:outgoing> diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/ActivateVnfBB.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/ActivateVnfBB.bpmn index e1f80dc77a..198b8d97e5 100644 --- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/ActivateVnfBB.bpmn +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/ActivateVnfBB.bpmn @@ -21,6 +21,8 @@ <bpmn:extensionElements> <camunda:in source="SDNCRequest" target="SDNCRequest" /> <camunda:out source="SDNCResponse" target="SDNCResponse" /> + <camunda:out source="WorkflowException" target="WorkflowException" /> + <camunda:in source="mso-request-id" target="mso-request-id" /> </bpmn:extensionElements> <bpmn:incoming>SequenceFlow_0wk5e4o</bpmn:incoming> <bpmn:outgoing>SequenceFlow_0ho00ja</bpmn:outgoing> diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/AssignNetworkBB.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/AssignNetworkBB.bpmn index 967e01885c..7c86e964ec 100644 --- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/AssignNetworkBB.bpmn +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/AssignNetworkBB.bpmn @@ -66,6 +66,8 @@ <bpmn2:extensionElements> <camunda:in source="SDNCRequest" target="SDNCRequest" /> <camunda:out source="SDNCResponse" target="SDNCResponse" /> + <camunda:out source="WorkflowException" target="WorkflowException" /> + <camunda:in source="mso-request-id" target="mso-request-id" /> </bpmn2:extensionElements> <bpmn2:incoming>SequenceFlow_0rt36co</bpmn2:incoming> <bpmn2:outgoing>SequenceFlow_1mvf7b9</bpmn2:outgoing> diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/AssignServiceInstanceBB.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/AssignServiceInstanceBB.bpmn index a98db3ac7b..7368f35d31 100644 --- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/AssignServiceInstanceBB.bpmn +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/AssignServiceInstanceBB.bpmn @@ -41,6 +41,8 @@ <bpmn:extensionElements> <camunda:in source="SDNCRequest" target="SDNCRequest" /> <camunda:out source="SDNCResponse" target="SDNCResponse" /> + <camunda:out source="WorkflowException" target="WorkflowException" /> + <camunda:in source="mso-request-id" target="mso-request-id" /> </bpmn:extensionElements> <bpmn:incoming>SequenceFlow_1vmf5yv</bpmn:incoming> <bpmn:outgoing>SequenceFlow_0c6u1cp</bpmn:outgoing> diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/AssignVfModuleBB.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/AssignVfModuleBB.bpmn index 7dee0f709d..1109e9cd9d 100644 --- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/AssignVfModuleBB.bpmn +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/AssignVfModuleBB.bpmn @@ -31,6 +31,8 @@ <bpmn:extensionElements> <camunda:in source="SDNCRequest" target="SDNCRequest" /> <camunda:out source="SDNCResponse" target="SDNCResponse" /> + <camunda:out source="WorkflowException" target="WorkflowException" /> + <camunda:in source="mso-request-id" target="mso-request-id" /> </bpmn:extensionElements> <bpmn:incoming>SequenceFlow_0269euz</bpmn:incoming> <bpmn:outgoing>SequenceFlow_1dttbxh</bpmn:outgoing> diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/AssignVnfBB.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/AssignVnfBB.bpmn index f4db92ba5c..ce4d2e1dab 100644 --- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/AssignVnfBB.bpmn +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/AssignVnfBB.bpmn @@ -87,6 +87,8 @@ <bpmn:extensionElements> <camunda:in source="SDNCRequest" target="SDNCRequest" /> <camunda:out source="SDNCResponse" target="SDNCResponse" /> + <camunda:out source="WorkflowException" target="WorkflowException" /> + <camunda:in source="mso-request-id" target="mso-request-id" /> </bpmn:extensionElements> <bpmn:incoming>SequenceFlow_1qkhm79</bpmn:incoming> <bpmn:outgoing>SequenceFlow_1vw20wu</bpmn:outgoing> diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/ChangeModelServiceInstanceBB.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/ChangeModelServiceInstanceBB.bpmn index c2e960364c..044ab840db 100644 --- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/ChangeModelServiceInstanceBB.bpmn +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/ChangeModelServiceInstanceBB.bpmn @@ -21,6 +21,8 @@ <bpmn2:extensionElements> <camunda:in source="SDNCRequest" target="SDNCRequest" /> <camunda:out source="SDNCResponse" target="SDNCResponse" /> + <camunda:out source="WorkflowException" target="WorkflowException" /> + <camunda:in source="mso-request-id" target="mso-request-id" /> </bpmn2:extensionElements> <bpmn2:incoming>SequenceFlow_1q3rjt4</bpmn2:incoming> <bpmn2:outgoing>SequenceFlow_0ycnbyf</bpmn2:outgoing> diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/ChangeModelVfModuleBB.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/ChangeModelVfModuleBB.bpmn index 28957c6197..82c7e8d8b2 100644 --- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/ChangeModelVfModuleBB.bpmn +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/ChangeModelVfModuleBB.bpmn @@ -21,6 +21,8 @@ <bpmn:extensionElements> <camunda:in source="SDNCRequest" target="SDNCRequest" /> <camunda:out source="SDNCResponse" target="SDNCResponse" /> + <camunda:out source="WorkflowException" target="WorkflowException" /> + <camunda:in source="mso-request-id" target="mso-request-id" /> </bpmn:extensionElements> <bpmn:incoming>SequenceFlow_0m403q5</bpmn:incoming> <bpmn:outgoing>SequenceFlow_0rpp4hi</bpmn:outgoing> diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/ChangeModelVnfBB.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/ChangeModelVnfBB.bpmn index 59c35c3c5b..ea7167247e 100644 --- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/ChangeModelVnfBB.bpmn +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/ChangeModelVnfBB.bpmn @@ -32,6 +32,8 @@ <bpmn2:extensionElements> <camunda:in source="SDNCRequest" target="SDNCRequest" /> <camunda:out source="SDNCResponse" target="SDNCResponse" /> + <camunda:out source="WorkflowException" target="WorkflowException" /> + <camunda:in source="mso-request-id" target="mso-request-id" /> </bpmn2:extensionElements> <bpmn2:incoming>SequenceFlow_17yjhsl</bpmn2:incoming> <bpmn2:outgoing>SequenceFlow_1h1zrcl</bpmn2:outgoing> diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/DeactivateNetworkBB.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/DeactivateNetworkBB.bpmn index 29a03c4e6b..f4bd6c2953 100644 --- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/DeactivateNetworkBB.bpmn +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/DeactivateNetworkBB.bpmn @@ -21,6 +21,8 @@ <bpmn2:extensionElements> <camunda:in source="SDNCRequest" target="SDNCRequest" /> <camunda:out source="SDNCResponse" target="SDNCResponse" /> + <camunda:out source="WorkflowException" target="WorkflowException" /> + <camunda:in source="mso-request-id" target="mso-request-id" /> </bpmn2:extensionElements> <bpmn2:incoming>SequenceFlow_0hfjdl4</bpmn2:incoming> <bpmn2:outgoing>SequenceFlow_0cu0wy4</bpmn2:outgoing> diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/DeactivateServiceInstanceBB.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/DeactivateServiceInstanceBB.bpmn index 41517871d0..d03d17db03 100644 --- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/DeactivateServiceInstanceBB.bpmn +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/DeactivateServiceInstanceBB.bpmn @@ -21,6 +21,8 @@ <bpmn:extensionElements> <camunda:in source="SDNCRequest" target="SDNCRequest" /> <camunda:out source="SDNCResponse" target="SDNCResponse" /> + <camunda:out source="WorkflowException" target="WorkflowException" /> + <camunda:in source="mso-request-id" target="mso-request-id" /> </bpmn:extensionElements> <bpmn:incoming>SequenceFlow_1j9qa4p</bpmn:incoming> <bpmn:outgoing>SequenceFlow_1ck1p4o</bpmn:outgoing> diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/DeactivateVfModuleBB.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/DeactivateVfModuleBB.bpmn index 37fd2dbd98..48243881dc 100644 --- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/DeactivateVfModuleBB.bpmn +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/DeactivateVfModuleBB.bpmn @@ -21,6 +21,8 @@ <bpmn:extensionElements> <camunda:in source="SDNCRequest" target="SDNCRequest" /> <camunda:out source="SDNCResponse" target="SDNCResponse" /> + <camunda:out source="WorkflowException" target="WorkflowException" /> + <camunda:in source="mso-request-id" target="mso-request-id" /> </bpmn:extensionElements> <bpmn:incoming>SequenceFlow_15ep3y7</bpmn:incoming> <bpmn:outgoing>SequenceFlow_1gx4xce</bpmn:outgoing> diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/DeactivateVnfBB.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/DeactivateVnfBB.bpmn index c627789119..11aa52ab86 100644 --- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/DeactivateVnfBB.bpmn +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/DeactivateVnfBB.bpmn @@ -21,6 +21,8 @@ <bpmn:extensionElements> <camunda:in source="SDNCRequest" target="SDNCRequest" /> <camunda:out source="SDNCResponse" target="SDNCResponse" /> + <camunda:out source="WorkflowException" target="WorkflowException" /> + <camunda:in source="mso-request-id" target="mso-request-id" /> </bpmn:extensionElements> <bpmn:incoming>SequenceFlow_000o6c2</bpmn:incoming> <bpmn:outgoing>SequenceFlow_1ageldf</bpmn:outgoing> diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/UnassignNetworkBB.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/UnassignNetworkBB.bpmn index 8e4c8501b5..128135d808 100644 --- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/UnassignNetworkBB.bpmn +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/UnassignNetworkBB.bpmn @@ -31,6 +31,8 @@ <bpmn:extensionElements> <camunda:in source="SDNCRequest" target="SDNCRequest" /> <camunda:out source="SDNCResponse" target="SDNCResponse" /> + <camunda:out source="WorkflowException" target="WorkflowException" /> + <camunda:in source="mso-request-id" target="mso-request-id" /> </bpmn:extensionElements> <bpmn:incoming>SequenceFlow_1woj6rc</bpmn:incoming> <bpmn:outgoing>SequenceFlow_15oc7ot</bpmn:outgoing> diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/UnassignServiceInstanceBB.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/UnassignServiceInstanceBB.bpmn index 08f17469da..e44be1a19e 100644 --- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/UnassignServiceInstanceBB.bpmn +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/UnassignServiceInstanceBB.bpmn @@ -21,6 +21,8 @@ <bpmn:extensionElements> <camunda:in source="SDNCRequest" target="SDNCRequest" /> <camunda:out source="SDNCResponse" target="SDNCResponse" /> + <camunda:out source="WorkflowException" target="WorkflowException" /> + <camunda:in source="mso-request-id" target="mso-request-id" /> </bpmn:extensionElements> <bpmn:incoming>SequenceFlow_00dyi16</bpmn:incoming> <bpmn:outgoing>SequenceFlow_0uzdp0c</bpmn:outgoing> diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/UnassignVfModuleBB.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/UnassignVfModuleBB.bpmn index dd00078fb5..7de68db4cf 100644 --- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/UnassignVfModuleBB.bpmn +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/UnassignVfModuleBB.bpmn @@ -21,6 +21,8 @@ <bpmn:extensionElements> <camunda:in source="SDNCRequest" target="SDNCRequest" /> <camunda:out source="SDNCResponse" target="SDNCResponse" /> + <camunda:out source="WorkflowException" target="WorkflowException" /> + <camunda:in source="mso-request-id" target="mso-request-id" /> </bpmn:extensionElements> <bpmn:incoming>SequenceFlow_152ntu2</bpmn:incoming> <bpmn:outgoing>SequenceFlow_0py9tf7</bpmn:outgoing> diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/UnassignVnfBB.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/UnassignVnfBB.bpmn index dec5681c9d..7ac8f9db76 100644 --- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/UnassignVnfBB.bpmn +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/UnassignVnfBB.bpmn @@ -26,6 +26,8 @@ <bpmn:extensionElements> <camunda:in source="SDNCRequest" target="SDNCRequest" /> <camunda:out source="SDNCResponse" target="SDNCResponse" /> + <camunda:out source="WorkflowException" target="WorkflowException" /> + <camunda:in source="mso-request-id" target="mso-request-id" /> </bpmn:extensionElements> <bpmn:incoming>SequenceFlow_0ielrmh</bpmn:incoming> <bpmn:outgoing>SequenceFlow_1cpzq86</bpmn:outgoing> diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/WorkflowActionBB.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/WorkflowActionBB.bpmn index bbb2a8a23d..38a1ccdf35 100644 --- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/WorkflowActionBB.bpmn +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/WorkflowActionBB.bpmn @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8"?> -<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="1.8.2"> +<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="1.4.0"> <bpmn:process id="WorkflowActionBB" name="WorkflowActionBB" isExecutable="true"> <bpmn:startEvent id="Start_WorkflowActionBB" name="start"> <bpmn:outgoing>SequenceFlow_15s0okp</bpmn:outgoing> @@ -29,9 +29,8 @@ <bpmn:sequenceFlow id="SequenceFlow_0mqrkxv" sourceRef="Task_SelectBB" targetRef="ServiceTask_0e2p0xs" /> <bpmn:serviceTask id="Task_SelectBB" name="Select BB" camunda:expression="${WorkflowActionBBTasks.selectBB(execution)}"> <bpmn:incoming>SequenceFlow_1atzsgn</bpmn:incoming> - <bpmn:incoming>SequenceFlow_1wb59ic</bpmn:incoming> <bpmn:incoming>SequenceFlow_005hi8o</bpmn:incoming> - <bpmn:incoming>SequenceFlow_0unbew4</bpmn:incoming> + <bpmn:incoming>SequenceFlow_1tfizxf</bpmn:incoming> <bpmn:outgoing>SequenceFlow_0mqrkxv</bpmn:outgoing> </bpmn:serviceTask> <bpmn:exclusiveGateway id="ExclusiveGateway_Finished" default="SequenceFlow_01j184u"> @@ -113,7 +112,7 @@ <bpmn:incoming>SequenceFlow_1r570x3</bpmn:incoming> </bpmn:endEvent> <bpmn:sequenceFlow id="SequenceFlow_1p8yxu6" sourceRef="Task_AbortAndCallErrorHandling" targetRef="EndEvent_0lzz1ya" /> - <bpmn:sequenceFlow id="SequenceFlow_1wb59ic" sourceRef="Task_SendSync" targetRef="Task_SelectBB" /> + <bpmn:sequenceFlow id="SequenceFlow_1wb59ic" sourceRef="Task_SendSync" targetRef="Task_PreValidateWorkflow" /> <bpmn:sequenceFlow id="SequenceFlow_01j184u" sourceRef="ExclusiveGateway_Finished" targetRef="Task_0a31dkf" /> <bpmn:sequenceFlow id="SequenceFlow_005hi8o" sourceRef="Task_0a31dkf" targetRef="Task_SelectBB" /> <bpmn:serviceTask id="Task_0a31dkf" name="Check Retry Status" camunda:expression="${WorkflowActionBBTasks.checkRetryStatus(execution)}"> @@ -126,7 +125,7 @@ <bpmn:outgoing>SequenceFlow_0unbew4</bpmn:outgoing> </bpmn:exclusiveGateway> <bpmn:sequenceFlow id="SequenceFlow_0sckerv" name="yes" sourceRef="ExclusiveGateway_isTopLevelFlow" targetRef="Task_SendSync" /> - <bpmn:sequenceFlow id="SequenceFlow_0unbew4" name="no" sourceRef="ExclusiveGateway_isTopLevelFlow" targetRef="Task_SelectBB"> + <bpmn:sequenceFlow id="SequenceFlow_0unbew4" name="no" sourceRef="ExclusiveGateway_isTopLevelFlow" targetRef="Task_PreValidateWorkflow"> <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression"><![CDATA[${execution.getVariable("isTopLevelFlow")==false}]]></bpmn:conditionExpression> </bpmn:sequenceFlow> <bpmn:exclusiveGateway id="ExclusiveGateway_isTopLevelFlowAbort" name="Is Top-Level Flow?" default="SequenceFlow_02ksbt0"> @@ -182,14 +181,20 @@ </bpmn:serviceTask> <bpmn:sequenceFlow id="SequenceFlow_0mew9im" sourceRef="ServiceTask_0e2p0xs" targetRef="Call_ExecuteBB" /> <bpmn:sequenceFlow id="SequenceFlow_0kf5sen" name="yes" sourceRef="ExclusiveGateway_isTopLevelFlowC" targetRef="Task_UpdateRequestComplete" /> + <bpmn:sequenceFlow id="SequenceFlow_1tfizxf" sourceRef="Task_PreValidateWorkflow" targetRef="Task_SelectBB" /> + <bpmn:serviceTask id="Task_PreValidateWorkflow" name="PreValidate Workflow" camunda:expression="${WorkflowValidatorRunner.preValidate(execution.getVariable("requestAction"), execution)}"> + <bpmn:incoming>SequenceFlow_0unbew4</bpmn:incoming> + <bpmn:incoming>SequenceFlow_1wb59ic</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_1tfizxf</bpmn:outgoing> + </bpmn:serviceTask> </bpmn:process> <bpmn:error id="Error_0kd2o2a" name="java.lang.Exception" errorCode="java.lang.Exception" /> <bpmndi:BPMNDiagram id="BPMNDiagram_1"> <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="WorkflowActionBB"> <bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="Start_WorkflowActionBB"> - <dc:Bounds x="-241" y="102" width="36" height="36" /> + <dc:Bounds x="-434" y="102" width="36" height="36" /> <bpmndi:BPMNLabel> - <dc:Bounds x="-234" y="138" width="23" height="12" /> + <dc:Bounds x="-426" y="138" width="22" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="EndEvent_1uv6erv_di" bpmnElement="End_WorkflowActionBB"> @@ -199,10 +204,10 @@ </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_15s0okp_di" bpmnElement="SequenceFlow_15s0okp"> - <di:waypoint xsi:type="dc:Point" x="-205" y="120" /> - <di:waypoint xsi:type="dc:Point" x="-172" y="120" /> + <di:waypoint xsi:type="dc:Point" x="-398" y="120" /> + <di:waypoint xsi:type="dc:Point" x="-365" y="120" /> <bpmndi:BPMNLabel> - <dc:Bounds x="-233" y="99" width="90" height="13" /> + <dc:Bounds x="-381" y="99" width="0" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="CallActivity_03m7z4y_di" bpmnElement="Call_ExecuteBB"> @@ -240,10 +245,10 @@ </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="ServiceTask_0kn8jt8_di" bpmnElement="Task_RetrieveBBExectuionList"> - <dc:Bounds x="-172" y="80" width="100" height="80" /> + <dc:Bounds x="-365" y="80" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="ServiceTask_0654g3m_di" bpmnElement="Task_SendSync"> - <dc:Bounds x="46" y="-7" width="100" height="80" /> + <dc:Bounds x="-132" y="-6" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="ServiceTask_0wzh11j_di" bpmnElement="Task_UpdateRequestComplete"> <dc:Bounds x="942" y="206" width="100" height="80" /> @@ -290,10 +295,10 @@ <dc:Bounds x="239" y="222" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_0vc9go9_di" bpmnElement="SequenceFlow_0vc9go9"> - <di:waypoint xsi:type="dc:Point" x="-72" y="120" /> - <di:waypoint xsi:type="dc:Point" x="-39" y="120" /> + <di:waypoint xsi:type="dc:Point" x="-265" y="120" /> + <di:waypoint xsi:type="dc:Point" x="-228" y="120" /> <bpmndi:BPMNLabel> - <dc:Bounds x="-100" y="105" width="90" height="0" /> + <dc:Bounds x="-246" y="105" width="0" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_11530ei_di" bpmnElement="SequenceFlow_11530ei"> @@ -323,12 +328,12 @@ </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_1wb59ic_di" bpmnElement="SequenceFlow_1wb59ic"> - <di:waypoint xsi:type="dc:Point" x="146" y="33" /> - <di:waypoint xsi:type="dc:Point" x="193" y="33" /> - <di:waypoint xsi:type="dc:Point" x="193" y="120" /> - <di:waypoint xsi:type="dc:Point" x="239" y="120" /> + <di:waypoint xsi:type="dc:Point" x="-32" y="34" /> + <di:waypoint xsi:type="dc:Point" x="32" y="34" /> + <di:waypoint xsi:type="dc:Point" x="32" y="120" /> + <di:waypoint xsi:type="dc:Point" x="80" y="120" /> <bpmndi:BPMNLabel> - <dc:Bounds x="163" y="77" width="90" height="0" /> + <dc:Bounds x="47" y="77" width="0" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_01j184u_di" bpmnElement="SequenceFlow_01j184u"> @@ -352,24 +357,24 @@ <dc:Bounds x="667" y="-76" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="ExclusiveGateway_0ptb1yi_di" bpmnElement="ExclusiveGateway_isTopLevelFlow" isMarkerVisible="true"> - <dc:Bounds x="-39" y="95" width="50" height="50" /> + <dc:Bounds x="-228" y="95" width="50" height="50" /> <bpmndi:BPMNLabel> - <dc:Bounds x="-45" y="145" width="61" height="24" /> + <dc:Bounds x="-235" y="145" width="63" height="24" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_0sckerv_di" bpmnElement="SequenceFlow_0sckerv"> - <di:waypoint xsi:type="dc:Point" x="-13" y="96" /> - <di:waypoint xsi:type="dc:Point" x="-13" y="33" /> - <di:waypoint xsi:type="dc:Point" x="46" y="33" /> + <di:waypoint xsi:type="dc:Point" x="-202" y="96" /> + <di:waypoint xsi:type="dc:Point" x="-202" y="34" /> + <di:waypoint xsi:type="dc:Point" x="-132" y="34" /> <bpmndi:BPMNLabel> - <dc:Bounds x="-7" y="55" width="19" height="12" /> + <dc:Bounds x="-195" y="55.55555555555556" width="18" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_0unbew4_di" bpmnElement="SequenceFlow_0unbew4"> - <di:waypoint xsi:type="dc:Point" x="11" y="120" /> - <di:waypoint xsi:type="dc:Point" x="239" y="120" /> + <di:waypoint xsi:type="dc:Point" x="-178" y="120" /> + <di:waypoint xsi:type="dc:Point" x="80" y="120" /> <bpmndi:BPMNLabel> - <dc:Bounds x="119" y="95" width="12" height="12" /> + <dc:Bounds x="-87" y="99.95468180757382" width="12" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="ExclusiveGateway_001g41v_di" bpmnElement="ExclusiveGateway_isTopLevelFlowAbort" isMarkerVisible="true"> @@ -543,6 +548,18 @@ <dc:Bounds x="872" y="217.6" width="18" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1tfizxf_di" bpmnElement="SequenceFlow_1tfizxf"> + <di:waypoint xsi:type="dc:Point" x="180" y="120" /> + <di:waypoint xsi:type="dc:Point" x="211" y="120" /> + <di:waypoint xsi:type="dc:Point" x="211" y="120" /> + <di:waypoint xsi:type="dc:Point" x="239" y="120" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="226" y="120" width="0" height="0" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="ServiceTask_0m5xr0e_di" bpmnElement="Task_PreValidateWorkflow"> + <dc:Bounds x="80" y="80" width="100" height="80" /> + </bpmndi:BPMNShape> </bpmndi:BPMNPlane> </bpmndi:BPMNDiagram> </bpmn:definitions> diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/namingservice/NamingClient.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/namingservice/NamingClient.java index f91ad44f2b..6bee5a9b1e 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/namingservice/NamingClient.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/namingservice/NamingClient.java @@ -1,5 +1,6 @@ package org.onap.so.client.namingservice; +import java.io.IOException; import java.util.ArrayList; import java.util.List; @@ -17,6 +18,7 @@ import org.springframework.http.HttpMethod; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Component; +import org.springframework.web.client.HttpStatusCodeException; import org.springframework.web.client.RestTemplate; @@ -34,21 +36,31 @@ public class NamingClient{ @Autowired private NamingClientResponseValidator namingClientResponseValidator; - public String postNameGenRequest(NameGenRequest request) throws BadResponseException { + public String postNameGenRequest(NameGenRequest request) throws BadResponseException, IOException { String targetUrl = env.getProperty(ENDPOINT); HttpHeaders headers = setHeaders(env.getProperty(AUTH)); msoLogger.info("Sending postNameGenRequest to url: " + targetUrl); HttpEntity<NameGenRequest> requestEntity = new HttpEntity<>(request, headers); - ResponseEntity<NameGenResponse> response = restTemplate.postForEntity(targetUrl, requestEntity, NameGenResponse.class); + ResponseEntity<NameGenResponse> response; + try{ + response = restTemplate.postForEntity(targetUrl, requestEntity, NameGenResponse.class); + }catch(HttpStatusCodeException e){ + throw new BadResponseException(namingClientResponseValidator.formatError(e)); + } return namingClientResponseValidator.validateNameGenResponse(response); } - public String deleteNameGenRequest(NameGenDeleteRequest request) throws BadResponseException { + public String deleteNameGenRequest(NameGenDeleteRequest request) throws BadResponseException, IOException { String targetUrl = env.getProperty(ENDPOINT); HttpHeaders headers = setHeaders(env.getProperty(AUTH)); msoLogger.info("Sending deleteNameGenRequest to url: " + targetUrl); HttpEntity<NameGenDeleteRequest> requestEntity = new HttpEntity<>(request, headers); - ResponseEntity<NameGenDeleteResponse> response = restTemplate.exchange(targetUrl, HttpMethod.DELETE, requestEntity, NameGenDeleteResponse.class); + ResponseEntity<NameGenDeleteResponse> response; + try{ + response = restTemplate.exchange(targetUrl, HttpMethod.DELETE, requestEntity, NameGenDeleteResponse.class); + }catch(HttpStatusCodeException e){ + throw new BadResponseException(namingClientResponseValidator.formatError(e)); + } return namingClientResponseValidator.validateNameGenDeleteResponse(response); } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/namingservice/NamingClientResponseValidator.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/namingservice/NamingClientResponseValidator.java index ab0639574c..e790fa4b72 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/namingservice/NamingClientResponseValidator.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/namingservice/NamingClientResponseValidator.java @@ -1,5 +1,6 @@ package org.onap.so.client.namingservice; +import java.io.IOException; import java.util.List; import org.apache.http.HttpStatus; @@ -12,6 +13,9 @@ import org.onap.so.logger.MessageEnum; import org.onap.so.logger.MsoLogger; import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Component; +import org.springframework.web.client.HttpStatusCodeException; + +import com.fasterxml.jackson.databind.ObjectMapper; @Component public class NamingClientResponseValidator { @@ -99,5 +103,20 @@ public class NamingClientResponseValidator { private boolean isHttpCodeSuccess(int code) { return code >= HttpStatus.SC_OK && code < HttpStatus.SC_MULTIPLE_CHOICES || code == 0; } + + protected String formatError(HttpStatusCodeException e) throws IOException { + ObjectMapper mapper = new ObjectMapper(); + NameGenResponse errorResponse = mapper.readValue(e.getResponseBodyAsString(), NameGenResponse.class); + NameGenResponseError error = errorResponse.getError(); + + String errorMessageString = null; + if (error != null) { + errorMessageString = error.getMessage(); + } + String errorMessage = String.format(NAMING_SERVICE_ERROR, errorMessageString); + msoLogger.error(MessageEnum.RA_GENERAL_EXCEPTION, errorMessage, "BPMN", MsoLogger.getServiceName(), + MsoLogger.ErrorCode.DataError, errorMessage); + return errorMessage; + } } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/namingservice/NamingRequestObjectBuilder.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/namingservice/NamingRequestObjectBuilder.java index c3f216e288..82bad8db79 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/namingservice/NamingRequestObjectBuilder.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/namingservice/NamingRequestObjectBuilder.java @@ -13,11 +13,11 @@ public class NamingRequestObjectBuilder{ public Element elementMapper(String instanceGroupId, String policyInstanceName, String namingType, String nfNamingCode, String instanceGroupName){ Element element = new Element(); - element.setExternalKey(instanceGroupId); - element.setPolicyInstanceName(policyInstanceName); - element.setNamingType(namingType); - element.setResourceName(instanceGroupName); - element.setNamingIngredientsZeroOrMore(nfNamingCode); + element.put("external-key", instanceGroupId); + element.put("policy-instance-name", policyInstanceName); + element.put("naming-type", namingType); + element.put("resource-name", instanceGroupName); + element.put("nf-naming-code", nfNamingCode); return element; } public Deleteelement deleteElementMapper(String instanceGroupId){ diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/NamingServiceResources.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/NamingServiceResources.java index 8b443a165b..d0bf6da6c9 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/NamingServiceResources.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/NamingServiceResources.java @@ -20,6 +20,7 @@ package org.onap.so.client.orchestration; +import java.io.IOException; import java.util.ArrayList; import java.util.List; @@ -44,14 +45,14 @@ public class NamingServiceResources { @Autowired private NamingRequestObjectBuilder namingRequestObjectBuilder; - public String generateInstanceGroupName(InstanceGroup instanceGroup, String policyInstanceName, String nfNamingCode) throws BadResponseException { + public String generateInstanceGroupName(InstanceGroup instanceGroup, String policyInstanceName, String nfNamingCode) throws BadResponseException, IOException { Element element = namingRequestObjectBuilder.elementMapper(instanceGroup.getId(), policyInstanceName, NAMING_TYPE, nfNamingCode, instanceGroup.getInstanceGroupName()); List<Element> elements = new ArrayList<Element>(); elements.add(element); return(namingClient.postNameGenRequest(namingRequestObjectBuilder.nameGenRequestMapper(elements))); } - public String deleteInstanceGroupName(InstanceGroup instanceGroup) throws BadResponseException { + public String deleteInstanceGroupName(InstanceGroup instanceGroup) throws BadResponseException, IOException { Deleteelement deleteElement = namingRequestObjectBuilder.deleteElementMapper(instanceGroup.getId()); List<Deleteelement> deleteElements = new ArrayList<Deleteelement>(); deleteElements.add(deleteElement); diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/namingservice/NamingClientTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/namingservice/NamingClientTest.java new file mode 100644 index 0000000000..c1769e3680 --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/namingservice/NamingClientTest.java @@ -0,0 +1,99 @@ +package org.onap.so.client.namingservice; + +import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; +import static com.github.tomakehurst.wiremock.client.WireMock.delete; +import static com.github.tomakehurst.wiremock.client.WireMock.post; +import static com.github.tomakehurst.wiremock.client.WireMock.stubFor; +import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo; +import static org.junit.Assert.assertTrue; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +import org.apache.http.HttpStatus; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; +import org.onap.namingservice.model.Deleteelement; +import org.onap.namingservice.model.Element; +import org.onap.namingservice.model.NameGenDeleteRequest; +import org.onap.namingservice.model.NameGenRequest; +import org.onap.so.BaseIntegrationTest; +import org.onap.so.client.exception.BadResponseException; +import org.springframework.beans.factory.annotation.Autowired; + +import com.fasterxml.jackson.core.JsonProcessingException; + +public class NamingClientTest extends BaseIntegrationTest{ + @Autowired + NamingClient client; + @Autowired + NamingRequestObjectBuilder requestBuilder; + @Rule + public ExpectedException thrown = ExpectedException.none(); + + @Test + public void assignNameGenRequest() throws BadResponseException, IOException{ + stubFor(post(urlPathEqualTo("/web/service/v1/genNetworkElementName")) + .willReturn(aResponse().withHeader("Content-Type", "application/json") + .withBodyFile("NamingClient/AssignResponse.json") + .withStatus(HttpStatus.SC_ACCEPTED))); + + NameGenRequest request = assignSetup(); + String response = client.postNameGenRequest(request); + assertTrue(response.equals("$vnf-name")); + } + @Test + public void assignNameGenRequestError() throws BadResponseException, IOException{ + stubFor(post(urlPathEqualTo("/web/service/v1/genNetworkElementName")) + .willReturn(aResponse().withHeader("Content-Type", "application/json") + .withBodyFile("NamingClient/ErrorResponse.json") + .withStatus(HttpStatus.SC_INTERNAL_SERVER_ERROR))); + + thrown.expect(BadResponseException.class); + thrown.expectMessage("Error from Naming Service: External Key is required and must be unique"); + NameGenRequest request = assignSetup(); + client.postNameGenRequest(request); + } + @Test + public void unassignNameGenRequest() throws BadResponseException, IOException{ + stubFor(delete(urlPathEqualTo("/web/service/v1/genNetworkElementName")) + .willReturn(aResponse().withHeader("Content-Type", "application/json") + .withBodyFile("NamingClient/UnassignResponse.json") + .withStatus(HttpStatus.SC_ACCEPTED))); + + String response = client.deleteNameGenRequest(unassignSetup()); + assertTrue(response.equals("")); + } + @Test + public void unassignNameGenRequestError() throws BadResponseException, IOException{ + stubFor(delete(urlPathEqualTo("/web/service/v1/genNetworkElementName")) + .willReturn(aResponse().withHeader("Content-Type", "application/json") + .withBodyFile("NamingClient/ErrorResponse.json") + .withStatus(HttpStatus.SC_INTERNAL_SERVER_ERROR))); + + thrown.expect(BadResponseException.class); + thrown.expectMessage("Error from Naming Service: External Key is required and must be unique"); + client.deleteNameGenRequest(unassignSetup()); + } + + public NameGenRequest assignSetup() throws JsonProcessingException{ + NameGenRequest request = new NameGenRequest(); + List<Element> elements = new ArrayList<>(); + Element testElement = new Element(); + testElement = requestBuilder.elementMapper("SomeUniqueValue", "SDNC_Policy.Config_MS_1806SRIOV_VNATJson.4.xml", "VNF", "nfNamingCode", "vnf_name"); + elements.add(testElement); + request = requestBuilder.nameGenRequestMapper(elements); + return request; + } + public NameGenDeleteRequest unassignSetup() throws JsonProcessingException{ + NameGenDeleteRequest request = new NameGenDeleteRequest(); + List<Deleteelement> deleteElements = new ArrayList<>(); + Deleteelement testElement = new Deleteelement(); + testElement = requestBuilder.deleteElementMapper("instanceGroupId"); + deleteElements.add(testElement); + request = requestBuilder.nameGenDeleteRequestMapper(deleteElements); + return request; + } +}
\ No newline at end of file diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/namingservice/NamingRequestObjectBuilderTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/namingservice/NamingRequestObjectBuilderTest.java index 0a2dc1e4fa..27839d665b 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/namingservice/NamingRequestObjectBuilderTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/namingservice/NamingRequestObjectBuilderTest.java @@ -26,11 +26,11 @@ public class NamingRequestObjectBuilderTest { public void elementMapperTest(){ // Expected element Element expected = new Element(); - expected.setExternalKey(instanceGroupId); - expected.setPolicyInstanceName(policyInstanceName); - expected.setNamingType(namingType); - expected.setResourceName(instanceGroupName); - expected.setNamingIngredientsZeroOrMore(nfNamingCode); + expected.put("external-key", instanceGroupId); + expected.put("policy-instance-name", policyInstanceName); + expected.put("naming-type", namingType); + expected.put("resource-name", instanceGroupName); + expected.put("nf-naming-code", nfNamingCode); // Actual element Element actual = mapper.elementMapper(instanceGroupId, policyInstanceName, namingType, nfNamingCode, instanceGroupName); diff --git a/bpmn/so-bpmn-tasks/src/test/resources/__files/NamingClient/AssignResponse.json b/bpmn/so-bpmn-tasks/src/test/resources/__files/NamingClient/AssignResponse.json new file mode 100644 index 0000000000..b065c21339 --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/test/resources/__files/NamingClient/AssignResponse.json @@ -0,0 +1,14 @@ +{ + "elements": [ + { + "external-key": "$vnf-id", + "resource-name": "instance-group-name", + "resource-value": "$vnf-name" + }, + { + "external-key": "$vnf-id", + "resource-name": "vm-name", + "resource-value": "$vm-name" + } + ] +} diff --git a/bpmn/so-bpmn-tasks/src/test/resources/__files/NamingClient/ErrorResponse.json b/bpmn/so-bpmn-tasks/src/test/resources/__files/NamingClient/ErrorResponse.json new file mode 100644 index 0000000000..8bac7cd1f9 --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/test/resources/__files/NamingClient/ErrorResponse.json @@ -0,0 +1,6 @@ +{ + "error": { + "errorId": "NELGEN-0003", + "message": "External Key is required and must be unique" + } +}
\ No newline at end of file diff --git a/bpmn/so-bpmn-tasks/src/test/resources/__files/NamingClient/UnassignResponse.json b/bpmn/so-bpmn-tasks/src/test/resources/__files/NamingClient/UnassignResponse.json new file mode 100644 index 0000000000..b065c21339 --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/test/resources/__files/NamingClient/UnassignResponse.json @@ -0,0 +1,14 @@ +{ + "elements": [ + { + "external-key": "$vnf-id", + "resource-name": "instance-group-name", + "resource-value": "$vnf-name" + }, + { + "external-key": "$vnf-id", + "resource-name": "vm-name", + "resource-value": "$vm-name" + } + ] +} diff --git a/bpmn/so-bpmn-tasks/src/test/resources/application-test.yaml b/bpmn/so-bpmn-tasks/src/test/resources/application-test.yaml index 3d45caddce..fed2aa69c7 100644 --- a/bpmn/so-bpmn-tasks/src/test/resources/application-test.yaml +++ b/bpmn/so-bpmn-tasks/src/test/resources/application-test.yaml @@ -43,7 +43,7 @@ pnf: mso: naming: endpoint: http://localhost:${wiremock.server.port}/web/service/v1/genNetworkElementName - auth: Basic YnBlbDptc28tZGItMTUwNyE= + auth: Basic YnBlbDptc28tZGItMTUwNyE= adapters: requestDb: auth: Basic YnBlbDptc28tZGItMTUwNyE= |