From 1cb8197e56c91deba3168aa42f4943e42cedf294 Mon Sep 17 00:00:00 2001 From: shrek2000 Date: Wed, 15 Nov 2017 10:14:43 +0200 Subject: Error message is not reported to calling functions Issue-ID: SDC-657 Change-Id: I31e56d1e8d1423b8942fa2e11ebf71c656b670a4 Signed-off-by: shrek2000 --- .../OrchestrationTemplateProcessCsarHandler.java | 26 ++++++++++++---------- 1 file changed, 14 insertions(+), 12 deletions(-) (limited to 'openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main') 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 3dd118e8ec..d217c31f65 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 @@ -7,6 +7,8 @@ import org.openecomp.core.utilities.file.FileContentHandler; import org.openecomp.core.utilities.orchestration.OnboardingTypesEnum; import org.openecomp.core.validation.util.MessageContainerUtil; import org.openecomp.sdc.common.errors.CoreException; +import org.openecomp.sdc.common.errors.ErrorCode; +import org.openecomp.sdc.common.errors.GeneralErrorBuilder; import org.openecomp.sdc.datatypes.error.ErrorLevel; import org.openecomp.sdc.datatypes.error.ErrorMessage; import org.openecomp.sdc.heat.datatypes.structure.HeatStructureTree; @@ -37,11 +39,8 @@ import java.util.Optional; public class OrchestrationTemplateProcessCsarHandler implements OrchestrationTemplateProcessHandler { - private static Logger logger = - LoggerFactory.getLogger(OrchestrationTemplateProcessCsarHandler.class); - private ToscaConverter toscaConverter = new ToscaConverterImpl(); - private CandidateService candidateService = - CandidateServiceFactory.getInstance().createInterface(); + private static final Logger logger = LoggerFactory.getLogger(OrchestrationTemplateProcessCsarHandler.class); + private CandidateService candidateService = CandidateServiceFactory.getInstance().createInterface(); ToscaTreeManager toscaTreeManager = new ToscaTreeManager(); @Override @@ -64,12 +63,17 @@ public class OrchestrationTemplateProcessCsarHandler implements OrchestrationTem processCsar(vspId, version, fileContentHandler, candidateData, response); } catch (CoreException e){ logger.error(e.getMessage()); - throw e; - } catch (Exception e){ - logger.error(e.getMessage()); + response.addErrorMessageToMap(e.code().id(), e.code().message(),ErrorLevel.ERROR); + } catch (IOException ioe) { + logger.error(ioe.getMessage()); + ErrorCode errorCode = new GeneralErrorBuilder(ioe.getMessage()).build(); + response.addErrorMessageToMap(errorCode.id(), errorCode.message(),ErrorLevel.ERROR); + } + } else { + if (!uploadFileResponse.getErrors().isEmpty()) { + response.addStructureErrors(uploadFileResponse.getErrors()); } } - return response; } @@ -77,8 +81,6 @@ public class OrchestrationTemplateProcessCsarHandler implements OrchestrationTem FileContentHandler fileContentHandler, OrchestrationTemplateCandidateData candidateData, OrchestrationTemplateActionResponse response) throws IOException { - - response.setFileNames(new ArrayList<>(fileContentHandler.getFileList())); Map> errors = validateCsar(fileContentHandler, response); if(!isValid(errors)){ @@ -104,7 +106,7 @@ public class OrchestrationTemplateProcessCsarHandler implements OrchestrationTem orchestrationUtil.saveUploadData( vspId, version, zipByteArrayInputStream.get(), fileContentHandler, tree); - ToscaServiceModel toscaServiceModel = toscaConverter.convert(fileContentHandler); + ToscaServiceModel toscaServiceModel = new ToscaConverterImpl().convert(fileContentHandler); orchestrationUtil.saveServiceModel(vspId, version, toscaServiceModel, toscaServiceModel); } -- cgit 1.2.3-korg