diff options
author | Seshu Kumar M <seshu.kumar.m@huawei.com> | 2018-04-10 08:37:29 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2018-04-10 08:37:29 +0000 |
commit | c89d0d7d347c96bcfd84971214ab2e4cfe4546ae (patch) | |
tree | f52f066fbd9f1c8a8be4b71b7e9dcfe96fd0faea /bpmn/MSOInfrastructureBPMN/src/main/java/org | |
parent | 5f5b1cefb7f226a637b272ca39d0f05daebdb524 (diff) | |
parent | cafd0137bce8c5f5344a2b8d249904503e0c1af3 (diff) |
Merge "Added creating WorkflowException in pnf-pnp"
Diffstat (limited to 'bpmn/MSOInfrastructureBPMN/src/main/java/org')
4 files changed, 23 insertions, 28 deletions
diff --git a/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/pnf/delegate/CheckAaiForCorrelationIdDelegate.java b/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/pnf/delegate/CheckAaiForCorrelationIdDelegate.java index f4483f5923..417bb4668e 100644 --- a/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/pnf/delegate/CheckAaiForCorrelationIdDelegate.java +++ b/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/pnf/delegate/CheckAaiForCorrelationIdDelegate.java @@ -28,6 +28,7 @@ import java.io.IOException; import org.camunda.bpm.engine.delegate.BpmnError; import org.camunda.bpm.engine.delegate.DelegateExecution; import org.camunda.bpm.engine.delegate.JavaDelegate; +import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil; import org.openecomp.mso.bpmn.infrastructure.pnf.implementation.AaiConnection; import org.openecomp.mso.bpmn.infrastructure.pnf.implementation.AaiResponse; import org.openecomp.mso.bpmn.infrastructure.pnf.implementation.CheckAaiForCorrelationIdImplementation; @@ -58,21 +59,16 @@ public class CheckAaiForCorrelationIdDelegate implements JavaDelegate { public void execute(DelegateExecution execution) throws Exception { String correlationId = (String) execution.getVariable(CORRELATION_ID); if (correlationId == null) { - //todo: fix Execution -> DelegateExecution in ALL groovy scripts -// new ExceptionUtil().buildAndThrowWorkflowException(execution, 500, CORRELATION_ID + " is not set"); - throw new BpmnError("MSOWorkflowException"); + new ExceptionUtil().buildAndThrowWorkflowException(execution, 500, CORRELATION_ID + " is not set"); } try { AaiResponse aaiResponse = implementation.check(correlationId, aaiConnection); execution.setVariableLocal(AAI_CONTAINS_INFO_ABOUT_PNF, aaiResponse.getContainsInfoAboutPnf()); - aaiResponse.getContainsInfoAboutIp().ifPresent( - isIp -> execution.setVariableLocal(AAI_CONTAINS_INFO_ABOUT_IP, isIp) - ); + execution.setVariableLocal(AAI_CONTAINS_INFO_ABOUT_IP, aaiResponse.getContainsInfoAboutIp()); } catch (IOException e) { - //todo: log this - throw new BpmnError("MSOWorkflowException"); + new ExceptionUtil().buildAndThrowWorkflowException(execution, 9999, e.getMessage()); } } } diff --git a/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/pnf/delegate/ExecutionVariableNames.java b/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/pnf/delegate/ExecutionVariableNames.java index 6b49908a0f..0d64f2c8b7 100644 --- a/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/pnf/delegate/ExecutionVariableNames.java +++ b/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/pnf/delegate/ExecutionVariableNames.java @@ -23,6 +23,9 @@ package org.openecomp.mso.bpmn.infrastructure.pnf.delegate; @SuppressWarnings("ALL") public class ExecutionVariableNames { + private ExecutionVariableNames() { + } + public final static String CORRELATION_ID = "correlationId"; public final static String AAI_CONTAINS_INFO_ABOUT_PNF = "aaiContainsInfoAboutPnf"; public final static String AAI_CONTAINS_INFO_ABOUT_IP = "aaiContainsInfoAboutIp"; diff --git a/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/pnf/implementation/AaiResponse.java b/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/pnf/implementation/AaiResponse.java index bbb7adc143..5fb7a43e00 100644 --- a/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/pnf/implementation/AaiResponse.java +++ b/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/pnf/implementation/AaiResponse.java @@ -24,28 +24,25 @@ import java.util.Optional; import javax.annotation.Nullable; import javax.validation.constraints.NotNull; -public class AaiResponse { +public enum AaiResponse { + NO_ENTRY(false, false), + ENTRY_NO_IP(true, false), + ENTRY_WITH_IP(true, true); - private Boolean containsInfoAboutPnf; - private Boolean containsInfoAboutIp; - private String ipAddress; + private boolean containsInfoAboutPnf; + private boolean containsInfoAboutIp; - public AaiResponse(@NotNull Boolean containsInfoAboutPnf, @Nullable Boolean containsInfoAboutIp, - @Nullable String ipAddress) { + AaiResponse(boolean containsInfoAboutPnf, boolean containsInfoAboutIp) { this.containsInfoAboutPnf = containsInfoAboutPnf; this.containsInfoAboutIp = containsInfoAboutIp; - this.ipAddress = ipAddress; } - public Boolean getContainsInfoAboutPnf() { + public boolean getContainsInfoAboutPnf() { return containsInfoAboutPnf; } - public Optional<Boolean> getContainsInfoAboutIp() { - return Optional.ofNullable(containsInfoAboutIp); + public boolean getContainsInfoAboutIp() { + return containsInfoAboutIp; } - public Optional<String> getIpAddress() { - return Optional.ofNullable(ipAddress); - } } diff --git a/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/pnf/implementation/CheckAaiForCorrelationIdImplementation.java b/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/pnf/implementation/CheckAaiForCorrelationIdImplementation.java index 353a3bd5d3..b982a693da 100644 --- a/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/pnf/implementation/CheckAaiForCorrelationIdImplementation.java +++ b/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/pnf/implementation/CheckAaiForCorrelationIdImplementation.java @@ -29,15 +29,14 @@ public class CheckAaiForCorrelationIdImplementation { public AaiResponse check(String correlationId, AaiConnection aaiConnection) throws IOException { Optional<Pnf> pnf = aaiConnection.getEntryFor(correlationId); if (!pnf.isPresent()) { - return new AaiResponse(false, null, null); + return AaiResponse.NO_ENTRY; } - Optional<String> ip = extractIp(pnf.get()); - return ip.map( - s -> new AaiResponse(true, true, s) - ).orElseGet( - () -> new AaiResponse(true, false, null) - ); + if(extractIp(pnf.get()).isPresent()) { + return AaiResponse.ENTRY_WITH_IP; + } else { + return AaiResponse.ENTRY_NO_IP; + } } private Optional<String> extractIp(Pnf pnf) { |