diff options
author | Eylon Malin <eylon.malin@intl.att.com> | 2020-01-13 12:07:45 +0200 |
---|---|---|
committer | Eylon Malin <eylon.malin@intl.att.com> | 2020-01-13 14:16:52 +0200 |
commit | 6876eba3d0b43b01eb303a0d530fe45712f33d74 (patch) | |
tree | 7f6808357cc2d89405f6003cd5bd8dbe78d6c741 /vid-app-common/src/main | |
parent | 9d0eee5eee868aaee3cf169a4a6716dc1530e4e3 (diff) |
clear isFailed and statusMessage when get it from frontend request
Issue-ID: VID-724
Change-Id: I1bc33513250b220a063742233592388c7a108958
Signed-off-by: Eylon Malin <eylon.malin@intl.att.com>
Diffstat (limited to 'vid-app-common/src/main')
-rw-r--r-- | vid-app-common/src/main/java/org/onap/vid/services/AsyncInstantiationBusinessLogicImpl.java | 28 |
1 files changed, 19 insertions, 9 deletions
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 extends BaseResource> 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 extends BaseResource> T replaceAllTrackById(T resource) { - resource.setTrackById(UUID.randomUUID().toString()); - resource.getChildren().forEach(this::replaceAllTrackById); + <T extends BaseResource> T clearStatusFromRequest(T resource) { + resource.setIsFailed(false); + resource.setStatusMessage(null); + resource.getChildren().forEach(this::clearStatusFromRequest); return resource; } |