diff options
Diffstat (limited to 'bpmn/MSOCommonBPMN/src')
6 files changed, 72 insertions, 19 deletions
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/util/CommonTimestampGenerator.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/util/CommonTimestampGenerator.java new file mode 100644 index 0000000000..02ce540265 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/util/CommonTimestampGenerator.java @@ -0,0 +1,26 @@ +package org.onap.so.bpmn.common.util; + +import java.time.Instant; +import java.time.ZoneId; +import java.time.format.DateTimeFormatter; + +public class CommonTimestampGenerator { + + private final DateTimeFormatter formatter; + + public CommonTimestampGenerator(String format) { + this.formatter = DateTimeFormatter.ofPattern(format).withZone(ZoneId.systemDefault()); + } + + public CommonTimestampGenerator() { + this.formatter = null; + } + + public String generateCurrentTimestamp() { + if (formatter != null) { + return formatter.format(Instant.now()); + } else { + return Instant.now().toString(); + } + } +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/util/TimestampGeneratorUtil.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/util/TimestampGeneratorUtil.java new file mode 100644 index 0000000000..f74bd57c00 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/util/TimestampGeneratorUtil.java @@ -0,0 +1,19 @@ +package org.onap.so.bpmn.common.util; + +public final class TimestampGeneratorUtil { + + private static final String APPC_FORMAT = "yyyy-MM-dd'T'HH:mm:ss'.0Z'"; + private static final CommonTimestampGenerator APPC_TIMESTAMP_GENERATOR = new CommonTimestampGenerator(APPC_FORMAT); + + public static final CommonTimestampGenerator COMMON_GENERATOR = new CommonTimestampGenerator(); + + private TimestampGeneratorUtil() {} + + public static String generateCurrentTimestamp(String contollerType) { + if (contollerType.equals("APPC")) { + return APPC_TIMESTAMP_GENERATOR.generateCurrentTimestamp(); + } else { + return COMMON_GENERATOR.generateCurrentTimestamp(); + } + } +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java index 5cbadd6b75..83d1f5249f 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java @@ -1054,8 +1054,18 @@ public class BBInputSetup implements JavaDelegate { if (requestDetails.getOwningEntity() != null) owningEntity = mapperLayer.mapRequestOwningEntity(requestDetails.getOwningEntity()); - Service service = - bbInputSetupUtils.getCatalogServiceByModelUUID(requestDetails.getModelInfo().getModelVersionId()); + String modelVersionId = requestDetails.getModelInfo().getModelVersionId(); + + if (ModelType.vnf == requestDetails.getModelInfo().getModelType()) { + for (RelatedInstanceList relatedInstanceList : requestDetails.getRelatedInstanceList()) { + if (ModelType.service == relatedInstanceList.getRelatedInstance().getModelInfo().getModelType()) { + modelVersionId = relatedInstanceList.getRelatedInstance().getModelInfo().getModelVersionId(); + break; + } + } + } + + Service service = bbInputSetupUtils.getCatalogServiceByModelUUID(modelVersionId); if (service == null) { service = bbInputSetupUtils.getCatalogServiceByModelVersionAndModelInvariantUUID( requestDetails.getModelInfo().getModelVersion(), diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/appc/ApplicationControllerClient.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/appc/ApplicationControllerClient.java index e810fc0259..c73299ffc3 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/appc/ApplicationControllerClient.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/appc/ApplicationControllerClient.java @@ -7,9 +7,9 @@ * 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. @@ -20,15 +20,12 @@ package org.onap.so.client.appc; +import static org.onap.so.bpmn.common.util.TimestampGeneratorUtil.generateCurrentTimestamp; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; -import java.time.Instant; import java.util.Properties; import java.util.UUID; import java.util.concurrent.ConcurrentHashMap; -import org.onap.so.bpmn.core.UrnPropertiesReader; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import org.onap.appc.client.lcm.api.AppcClientServiceFactoryProvider; import org.onap.appc.client.lcm.api.AppcLifeCycleManagerServiceFactory; import org.onap.appc.client.lcm.api.ApplicationContext; @@ -43,6 +40,9 @@ import org.onap.appc.client.lcm.model.Flags.Mode; import org.onap.appc.client.lcm.model.Payload; import org.onap.appc.client.lcm.model.Status; import org.onap.appc.client.lcm.model.ZULU; +import org.onap.so.bpmn.core.UrnPropertiesReader; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class ApplicationControllerClient { @@ -77,7 +77,7 @@ public class ApplicationControllerClient { /** * Creates an ApplicationControllerClient for the specified controller type. - * + * * @param controllerType the controller type: "appc" or "sdnc". */ public ApplicationControllerClient(String controllerType) { @@ -90,7 +90,7 @@ public class ApplicationControllerClient { /** * Gets the controller type. - * + * * @return the controllertype */ public String getControllerType() { @@ -100,11 +100,11 @@ public class ApplicationControllerClient { /** * Returns the AppC client object associated with this ApplicationControllerClient. AppC client objects are shared * objects. One is created if it does not exist. - * + * * @return the client object, or null if creation failed */ public LifeCycleManagerStateful getAppCClient() { - return appCClients.computeIfAbsent(controllerType, k -> createAppCClient(k)); + return appCClients.computeIfAbsent(controllerType, this::createAppCClient); } protected LifeCycleManagerStateful createAppCClient(String controllerType) { @@ -194,8 +194,7 @@ public class ApplicationControllerClient { flags.setForce(force); flags.setTtl(FLAGS_TTL); commonHeader.setFlags(flags); - Instant timestamp = Instant.now(); - ZULU zulu = new ZULU(timestamp.toString()); + ZULU zulu = new ZULU(generateCurrentTimestamp(this.controllerType)); commonHeader.setTimestamp(zulu); return commonHeader; } diff --git a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterTest.groovy b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterTest.groovy index 3438c7957c..235b6219d1 100644 --- a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterTest.groovy +++ b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterTest.groovy @@ -22,7 +22,6 @@ package org.onap.so.bpmn.common.scripts import static org.mockito.Mockito.* - import org.camunda.bpm.engine.ProcessEngineServices import org.camunda.bpm.engine.RepositoryService import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity @@ -48,10 +47,10 @@ public class SDNCAdapterTest { } - String workflowResponse = """<sdncadapterworkflow:SDNCAdapterWorkflowResponse xmlns:sdncadapterworkflow="http://org.onap/so/workflow/schema/v1" + String workflowResponse = """<sdncadapterworkflow:SDNCAdapterWorkflowResponse xmlns="com:att:sdnctl:l3api" + xmlns:sdncadapterworkflow="http://org.onap/so/workflow/schema/v1" xmlns:tag0="http://org.onap/workflow/sdnc/adapter/schema/v1" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xmlns="com:att:sdnctl:l3api"> + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <sdncadapterworkflow:response-data> <tag0:CallbackHeader> <tag0:RequestId>testRequestId</tag0:RequestId> diff --git a/bpmn/MSOCommonBPMN/src/test/resources/logback-test.xml b/bpmn/MSOCommonBPMN/src/test/resources/logback-test.xml index 9088d1a844..90f73dc419 100644 --- a/bpmn/MSOCommonBPMN/src/test/resources/logback-test.xml +++ b/bpmn/MSOCommonBPMN/src/test/resources/logback-test.xml @@ -24,7 +24,7 @@ <root level="WARN"> <appender-ref ref="STDOUT" /> </root> - + <logger name="org.reflections" level="ERROR" /> <logger name="wiremock.org" level="ERROR" /> </configuration>
\ No newline at end of file |