summaryrefslogtreecommitdiffstats
path: root/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src
diff options
context:
space:
mode:
Diffstat (limited to 'openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src')
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ManualVspToscaManagerImpl.java9
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/OrchestrationUtil.java6
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/SOL004MetaDirectoryValidator.java10
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/process/OrchestrationTemplateProcessCsarHandler.java35
4 files changed, 44 insertions, 16 deletions
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ManualVspToscaManagerImpl.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ManualVspToscaManagerImpl.java
index 1d8c0b430d..58cb2cf2d6 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ManualVspToscaManagerImpl.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ManualVspToscaManagerImpl.java
@@ -21,6 +21,8 @@ import org.openecomp.sdc.generator.core.services.ManualVspToscaGenerationService
import org.openecomp.sdc.generator.datatypes.tosca.DeploymentFlavorModel;
import org.openecomp.sdc.generator.datatypes.tosca.MultiFlavorVfcImage;
import org.openecomp.sdc.generator.datatypes.tosca.VspModelInfo;
+import org.openecomp.sdc.logging.api.Logger;
+import org.openecomp.sdc.logging.api.LoggerFactory;
import org.openecomp.sdc.tosca.datatypes.ToscaServiceModel;
import org.openecomp.sdc.vendorsoftwareproduct.ManualVspToscaManager;
import org.openecomp.sdc.vendorsoftwareproduct.services.ManualVspDataCollectionService;
@@ -33,6 +35,8 @@ import java.util.Optional;
public class ManualVspToscaManagerImpl implements ManualVspToscaManager {
+ private static final Logger LOGGER = LoggerFactory.getLogger(ManualVspToscaManagerImpl.class);
+
private final ManualVspDataCollectionService
manualVspDataCollectionService = new ManualVspDataCollectionService();
@@ -45,6 +49,7 @@ public class ManualVspToscaManagerImpl implements ManualVspToscaManager {
releaseVendor = manualVspDataCollectionService.getReleaseVendor(vspId, version);
} catch (Exception ex) {
releaseVendor = Optional.empty();
+ LOGGER.error("Failed to get release vendor: {}", ex.getMessage(), ex);
}
releaseVendor.ifPresent(vspModelInfo::setReleaseVendor);
@@ -54,6 +59,7 @@ public class ManualVspToscaManagerImpl implements ManualVspToscaManager {
allowedFlavors = manualVspDataCollectionService.getAllowedFlavors(vspId, version);
} catch (Exception ex) {
allowedFlavors = null;
+ LOGGER.error("Failed to get allowed flavours: {}", ex.getMessage(), ex);
}
if (MapUtils.isNotEmpty(allowedFlavors)) {
vspModelInfo.setAllowedFlavors(allowedFlavors);
@@ -66,6 +72,7 @@ public class ManualVspToscaManagerImpl implements ManualVspToscaManager {
manualVspDataCollectionService.getVspComponentImages(vspId, version);
} catch (Exception ex) {
vspComponentImages = null;
+ LOGGER.error("Failed to get VSP components Images: {}", ex.getMessage(), ex);
}
if (MapUtils.isNotEmpty(vspComponentImages)) {
vspModelInfo.setMultiFlavorVfcImages(vspComponentImages);
@@ -77,6 +84,7 @@ public class ManualVspToscaManagerImpl implements ManualVspToscaManager {
vspComponents = manualVspDataCollectionService.getVspComponents(vspId, version);
} catch (Exception ex) {
vspComponents = null;
+ LOGGER.error("Failed to get VSP components: {}", ex.getMessage(), ex);
}
if (MapUtils.isNotEmpty(vspComponents)) {
vspModelInfo.setComponents(vspComponents);
@@ -88,6 +96,7 @@ public class ManualVspToscaManagerImpl implements ManualVspToscaManager {
vspComponentNics = manualVspDataCollectionService.getVspComponentNics(vspId, version);
} catch (Exception ex) {
vspComponentNics = null;
+ LOGGER.error("Failed to get VSP component NIC data: {}", ex.getMessage(), ex);
}
if (MapUtils.isNotEmpty(vspComponentNics)) {
vspModelInfo.setNics(vspComponentNics);
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/OrchestrationUtil.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/OrchestrationUtil.java
index c78e0001bf..3dfe3a25c2 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/OrchestrationUtil.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/OrchestrationUtil.java
@@ -36,6 +36,8 @@ import org.openecomp.sdc.heat.datatypes.structure.HeatStructureTree;
import org.openecomp.sdc.heat.datatypes.structure.ValidationStructureList;
import org.openecomp.sdc.heat.services.tree.HeatTreeManager;
import org.openecomp.sdc.heat.services.tree.HeatTreeManagerUtil;
+import org.openecomp.sdc.logging.api.Logger;
+import org.openecomp.sdc.logging.api.LoggerFactory;
import org.openecomp.sdc.tosca.datatypes.ToscaServiceModel;
import org.openecomp.sdc.vendorsoftwareproduct.CompositionEntityDataManager;
import org.openecomp.sdc.vendorsoftwareproduct.CompositionEntityDataManagerFactory;
@@ -56,6 +58,7 @@ import static org.openecomp.sdc.vendorsoftwareproduct.VendorSoftwareProductConst
public class OrchestrationUtil {
+ private static final Logger LOGGER = LoggerFactory.getLogger(OrchestrationUtil.class);
public static final String ORCHESTRATION_CONFIG_NAMESPACE = "orchestration";
public static final String ORCHESTRATION_IMPL_KEY = "orchestration_impl";
@@ -112,9 +115,12 @@ public class OrchestrationUtil {
uploadFileResponse.addStructureError(
SdcCommon.UPLOAD_FILE,
new ErrorMessage(ErrorLevel.ERROR, Messages.INVALID_ZIP_FILE.getErrorMessage()));
+ LOGGER.error("{}\n{}", Messages.INVALID_ZIP_FILE.getErrorMessage(),
+ exception.getMessage(), exception);
} catch (CoreException coreException) {
uploadFileResponse.addStructureError(
SdcCommon.UPLOAD_FILE, new ErrorMessage(ErrorLevel.ERROR, coreException.getMessage()));
+ LOGGER.error(coreException.getMessage(), coreException);
}
return Optional.ofNullable(contentMap);
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/SOL004MetaDirectoryValidator.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/SOL004MetaDirectoryValidator.java
index 49233c4ff9..a76acf5177 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/SOL004MetaDirectoryValidator.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/SOL004MetaDirectoryValidator.java
@@ -288,9 +288,9 @@ class SOL004MetaDirectoryValidator implements Validator{
}
private boolean isPnfMetadata(Map<String, String> metadata) {
- String metadataType = null;
+ String metadataType = "";
for(String key: metadata.keySet()) {
- if(metadataType == null){
+ if(metadataType.isEmpty()){
metadataType = key.contains(TOSCA_TYPE_PNF) ? TOSCA_TYPE_PNF : TOSCA_TYPE_VNF;
}else if(!key.contains(metadataType)){
throw new InvalidManifestMetadataException(Messages.MANIFEST_METADATA_INVALID_ENTRY.getErrorMessage());
@@ -300,9 +300,9 @@ class SOL004MetaDirectoryValidator implements Validator{
}
private void handleVnfMetadataEntries(Map<String, String> metadata) {
- for (String requiredPnfEntry : MANIFEST_VNF_METADATA) {
- if (!metadata.containsKey(requiredPnfEntry)) {
- reportError(ErrorLevel.ERROR, String.format(Messages.MANIFEST_METADATA_MISSING_ENTRY.getErrorMessage(), requiredPnfEntry));
+ for (String requiredVnfEntry : MANIFEST_VNF_METADATA) {
+ if (!metadata.containsKey(requiredVnfEntry)) {
+ reportError(ErrorLevel.ERROR, String.format(Messages.MANIFEST_METADATA_MISSING_ENTRY.getErrorMessage(), requiredVnfEntry));
}
}
}
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 28eb7f143d..7be3eb9fdb 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
@@ -18,12 +18,12 @@ package org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.process;
import org.apache.commons.collections4.MapUtils;
import org.openecomp.core.impl.ToscaConverterImpl;
+import org.openecomp.core.impl.ToscaSolConverterImpl;
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.common.utils.SdcCommon;
import org.openecomp.sdc.datatypes.error.ErrorLevel;
import org.openecomp.sdc.datatypes.error.ErrorMessage;
import org.openecomp.sdc.heat.datatypes.structure.HeatStructureTree;
@@ -39,6 +39,8 @@ import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails;
import org.openecomp.sdc.vendorsoftwareproduct.factory.CandidateServiceFactory;
import org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.OrchestrationUtil;
import org.openecomp.sdc.vendorsoftwareproduct.services.filedatastructuremodule.CandidateService;
+import org.openecomp.sdc.vendorsoftwareproduct.services.impl.etsi.ETSIService;
+import org.openecomp.sdc.vendorsoftwareproduct.services.impl.etsi.ETSIServiceImpl;
import org.openecomp.sdc.vendorsoftwareproduct.types.OrchestrationTemplateActionResponse;
import org.openecomp.sdc.vendorsoftwareproduct.types.UploadFileResponse;
@@ -46,12 +48,12 @@ import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.util.*;
-public class OrchestrationTemplateProcessCsarHandler
- implements OrchestrationTemplateProcessHandler {
- private static final Logger LOGGER = LoggerFactory
- .getLogger(OrchestrationTemplateProcessCsarHandler.class);
- private final CandidateService candidateService = CandidateServiceFactory
- .getInstance().createInterface();
+public class OrchestrationTemplateProcessCsarHandler implements OrchestrationTemplateProcessHandler {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(OrchestrationTemplateProcessCsarHandler.class);
+ private static final String SDC_ONBOARDED_PACKAGE_DIR = "ONBOARDED_PACKAGE/";
+ private static final String EXT_SEPARATOR = ".";
+ private final CandidateService candidateService = CandidateServiceFactory.getInstance().createInterface();
private final ToscaTreeManager toscaTreeManager = new ToscaTreeManager();
@Override
@@ -69,8 +71,11 @@ public class OrchestrationTemplateProcessCsarHandler
FileContentHandler fileContentHandler = fileContent.get();
processCsar(vspDetails, fileContentHandler, candidateData, response);
} catch (CoreException e) {
- LOGGER.error(e.getMessage());
+ LOGGER.error(e.getMessage(), e);
response.addErrorMessageToMap(e.code().id(), e.code().message(),ErrorLevel.ERROR);
+ }catch (IOException e){
+ LOGGER.error(e.getMessage(), e);
+ response.addErrorMessageToMap(SdcCommon.PROCESS_FILE, e.getMessage(), ErrorLevel.ERROR);
}
} else {
if (!uploadFileResponse.getErrors().isEmpty()) {
@@ -83,7 +88,7 @@ public class OrchestrationTemplateProcessCsarHandler
private void processCsar(VspDetails vspDetails,
FileContentHandler fileContentHandler,
OrchestrationTemplateCandidateData candidateData,
- OrchestrationTemplateActionResponse response) {
+ OrchestrationTemplateActionResponse response) throws IOException{
response.setFileNames(new ArrayList<>(fileContentHandler.getFileList()));
Map<String, List<ErrorMessage>> errors = validateCsar(fileContentHandler);
toscaTreeManager.createTree();
@@ -117,7 +122,15 @@ public class OrchestrationTemplateProcessCsarHandler
.saveUploadData(vspDetails, candidateData, byteArrayInputStream,
fileContentHandler, tree));
- ToscaServiceModel toscaServiceModel = new ToscaConverterImpl().convert(fileContentHandler);
+ ETSIService etsiService = new ETSIServiceImpl();
+ ToscaServiceModel toscaServiceModel;
+ if(etsiService.isSol004WithToscaMetaDirectory(fileContentHandler)){
+ fileContentHandler.addFile(SDC_ONBOARDED_PACKAGE_DIR + candidateData.getFileName() +
+ EXT_SEPARATOR + candidateData.getFileSuffix(), candidateData.getContentData().array());
+ toscaServiceModel = new ToscaSolConverterImpl().convert(fileContentHandler);
+ }else{
+ toscaServiceModel = new ToscaConverterImpl().convert(fileContentHandler);
+ }
orchestrationUtil.saveServiceModel(vspDetails.getId(),
vspDetails.getVersion(), toscaServiceModel,
toscaServiceModel);