From 2f5ef8c70eca7c17445efb5f6f9e637c60dd180e Mon Sep 17 00:00:00 2001 From: mojahidi Date: Wed, 27 Dec 2017 14:46:35 +0530 Subject: Refactored as per given comment Removed exception handling fixes Change-Id: Ie5a89783a63ebcf4b404db4f2b8be2c7b2140e50 Issue-ID: SDC-343 Signed-off-by: mojahidi --- .../OrchestrationTemplateProcessCsarHandler.java | 36 ++++++++++++++++------ 1 file changed, 27 insertions(+), 9 deletions(-) (limited to 'openecomp-be/backend') diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/process/OrchestrationTemplateProcessCsarHandler.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/process/OrchestrationTemplateProcessCsarHandler.java index b0e1e17f57..1db8875a05 100644 --- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/process/OrchestrationTemplateProcessCsarHandler.java +++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/process/OrchestrationTemplateProcessCsarHandler.java @@ -1,3 +1,19 @@ +/* + * Copyright © 2016-2017 European Support Limited + * + * 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. + */ + package org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.process; import org.apache.commons.collections4.MapUtils; @@ -37,15 +53,15 @@ import java.util.Optional; public class OrchestrationTemplateProcessCsarHandler implements OrchestrationTemplateProcessHandler { - private static final Logger LOGGER = - LoggerFactory.getLogger(OrchestrationTemplateProcessCsarHandler.class); - private CandidateService candidateService = - CandidateServiceFactory.getInstance().createInterface(); - ToscaTreeManager toscaTreeManager = new ToscaTreeManager(); + private static final Logger LOGGER = LoggerFactory + .getLogger(OrchestrationTemplateProcessCsarHandler.class); + private final CandidateService candidateService = CandidateServiceFactory + .getInstance().createInterface(); + private final ToscaTreeManager toscaTreeManager = new ToscaTreeManager(); @Override public OrchestrationTemplateActionResponse process(VspDetails vspDetails, - OrchestrationTemplateCandidateData candidateData) { + OrchestrationTemplateCandidateData candidateData) { LOGGER.audit( AuditMessages.AUDIT_MSG + AuditMessages.CSAR_VALIDATION_STARTED + vspDetails.getId()); @@ -102,11 +118,13 @@ public class OrchestrationTemplateProcessCsarHandler OnboardingTypesEnum.CSAR, errors); orchestrationUtil.deleteUploadDataAndContent(vspDetails.getId(), vspDetails.getVersion()); - orchestrationUtil.saveUploadData(vspDetails, candidateData, zipByteArrayInputStream.get(), - fileContentHandler, tree); + zipByteArrayInputStream.ifPresent(byteArrayInputStream -> orchestrationUtil + .saveUploadData(vspDetails, candidateData, byteArrayInputStream, + fileContentHandler, tree)); ToscaServiceModel toscaServiceModel = new ToscaConverterImpl().convert(fileContentHandler); - orchestrationUtil.saveServiceModel(vspDetails.getId(), vspDetails.getVersion(), toscaServiceModel, + orchestrationUtil.saveServiceModel(vspDetails.getId(), + vspDetails.getVersion(), toscaServiceModel, toscaServiceModel); } -- cgit 1.2.3-korg