From 6876eba3d0b43b01eb303a0d530fe45712f33d74 Mon Sep 17 00:00:00 2001 From: Eylon Malin Date: Mon, 13 Jan 2020 12:07:45 +0200 Subject: clear isFailed and statusMessage when get it from frontend request Issue-ID: VID-724 Change-Id: I1bc33513250b220a063742233592388c7a108958 Signed-off-by: Eylon Malin --- .../AsyncInstantiationBusinessLogicImpl.java | 28 +++++++++++++++------- 1 file changed, 19 insertions(+), 9 deletions(-) (limited to 'vid-app-common/src/main/java/org/onap') diff --git a/vid-app-common/src/main/java/org/onap/vid/services/AsyncInstantiationBusinessLogicImpl.java b/vid-app-common/src/main/java/org/onap/vid/services/AsyncInstantiationBusinessLogicImpl.java index 2cc76492f..07c2d1593 100644 --- a/vid-app-common/src/main/java/org/onap/vid/services/AsyncInstantiationBusinessLogicImpl.java +++ b/vid-app-common/src/main/java/org/onap/vid/services/AsyncInstantiationBusinessLogicImpl.java @@ -170,7 +170,9 @@ public class AsyncInstantiationBusinessLogicImpl implements int bulkSize = request.getBulkSize(); UUID templateId = UUID.randomUUID(); for (int i = 0; i < bulkSize; i++) { - ServiceInstantiation requestPerJob = prepareServiceToBeUnique(request); + ServiceInstantiation clonedServiceInstantiation = cloneServiceInstantiation(request); + ServiceInstantiation requestPerJob = prepareServiceToBeUnique(clonedServiceInstantiation); + requestPerJob = clearStatusFromRequest(requestPerJob); ServiceInfo.ServiceAction serviceAction = getAction(requestPerJob); JobType jobType = getJobType(requestPerJob); final String optimisticUniqueServiceInstanceName = bulkSize>1 ? //only bulk with more than 1 service need to get multiple names @@ -561,20 +563,28 @@ public class AsyncInstantiationBusinessLogicImpl implements @Override public ServiceInstantiation prepareServiceToBeUnique(ServiceInstantiation serviceInstantiation) { + serviceInstantiation.setBulkSize(1); + return replaceAllTrackById(serviceInstantiation); + } + private T replaceAllTrackById(T resource) { + resource.setTrackById(UUID.randomUUID().toString()); + resource.getChildren().forEach(this::replaceAllTrackById); + return resource; + } + + private ServiceInstantiation cloneServiceInstantiation(ServiceInstantiation serviceInstantiation) { try { - ServiceInstantiation clonedServiceInstantiation = JACKSON_OBJECT_MAPPER.readValue( - JACKSON_OBJECT_MAPPER.writeValueAsBytes(serviceInstantiation), ServiceInstantiation.class); - clonedServiceInstantiation.setBulkSize(1); - return replaceAllTrackById(clonedServiceInstantiation); + return JACKSON_OBJECT_MAPPER.readValue( + JACKSON_OBJECT_MAPPER.writeValueAsBytes(serviceInstantiation), ServiceInstantiation.class); } catch (IOException e) { throw new GenericUncheckedException(e); } - } - private T replaceAllTrackById(T resource) { - resource.setTrackById(UUID.randomUUID().toString()); - resource.getChildren().forEach(this::replaceAllTrackById); + T clearStatusFromRequest(T resource) { + resource.setIsFailed(false); + resource.setStatusMessage(null); + resource.getChildren().forEach(this::clearStatusFromRequest); return resource; } -- cgit 1.2.3-korg