diff options
Diffstat (limited to 'openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main')
7 files changed, 66 insertions, 65 deletions
diff --git a/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/EnricherHandlerImpl.java b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/EnricherHandlerImpl.java index a5eeece2b3..c9d89ee38f 100644 --- a/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/EnricherHandlerImpl.java +++ b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/EnricherHandlerImpl.java @@ -20,12 +20,12 @@ package org.openecomp.sdc.enrichment.impl; -import org.openecomp.sdc.logging.api.Logger; -import org.openecomp.sdc.logging.api.LoggerFactory; import org.openecomp.sdc.enrichment.impl.external.artifact.ExternalArtifactEnricher; import org.openecomp.sdc.enrichment.impl.tosca.ToscaEnricher; import org.openecomp.sdc.enrichment.inter.Enricher; import org.openecomp.sdc.enrichment.inter.EnricherHandler; +import org.openecomp.sdc.logging.api.Logger; +import org.openecomp.sdc.logging.api.LoggerFactory; import java.util.ArrayList; import java.util.List; diff --git a/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/external/artifact/ProcessArtifactEnricher.java b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/external/artifact/ProcessArtifactEnricher.java index a5f6529bbb..828de7244c 100644 --- a/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/external/artifact/ProcessArtifactEnricher.java +++ b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/external/artifact/ProcessArtifactEnricher.java @@ -10,10 +10,10 @@ import org.openecomp.sdc.datatypes.error.ErrorMessage; import org.openecomp.sdc.enrichment.EnrichmentInfo; import org.openecomp.sdc.enrichment.inter.ExternalArtifactEnricherInterface; import org.openecomp.sdc.logging.context.impl.MdcDataDebugMessage; +import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentDao; +import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentDaoFactory; import org.openecomp.sdc.vendorsoftwareproduct.dao.ProcessDao; import org.openecomp.sdc.vendorsoftwareproduct.dao.ProcessDaoFactory; -import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductDao; -import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductDaoFactory; import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentEntity; import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ProcessEntity; import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ProcessType; @@ -28,7 +28,7 @@ import java.util.Map; public class ProcessArtifactEnricher implements ExternalArtifactEnricherInterface { - private VendorSoftwareProductDao vendorSoftwareProductDao; + private ComponentDao componentDao; //private ProcessArtifactDao processArtifactDao; private ProcessDao processDao; private static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage(); @@ -41,10 +41,9 @@ public class ProcessArtifactEnricher implements ExternalArtifactEnricherInterfac Version version = enrichmentInfo.getVersion(); Collection<ComponentEntity> components = - getVendorSoftwareProductDao().listComponents(vspId, version); - components.stream() - .forEach(componentEntry -> errors.putAll(enrichComponent(componentEntry, - vspId, version))); + getComponentDao().list(new ComponentEntity(vspId, version, null)); + components.forEach(componentEntry -> errors.putAll(enrichComponent(componentEntry, + vspId, version))); return errors; } @@ -79,10 +78,9 @@ public class ProcessArtifactEnricher implements ExternalArtifactEnricherInterfac ProcessArtifactEntity artifactEntity = new ProcessArtifactEntity(vspId, version, componentId, entity.getId());*/ - processes.stream() - .forEach(entity -> { - ProcessEntity artifactEntity = new ProcessEntity(vspId, version, - componentId, entity.getId()); + processes.forEach(entity -> { + ProcessEntity artifactEntity = new ProcessEntity(vspId, version, + componentId, entity.getId()); ProcessEntity artifactProcessEntity = getProcessDao().get(artifactEntity); //ProcessArtifactEntity artifact = getProcessArtifactDao().get(artifactEntity); @@ -105,7 +103,7 @@ public class ProcessArtifactEnricher implements ExternalArtifactEnricherInterfac } }); - mdcDataDebugMessage.debugExitMessage(null, null); + mdcDataDebugMessage.debugExitMessage(null); } void enrichServiceArtifact(ComponentProcessInfo componentProcessInfo, @@ -113,19 +111,19 @@ public class ProcessArtifactEnricher implements ExternalArtifactEnricherInterfac Map<String, List<ErrorMessage>> errors) { - mdcDataDebugMessage.debugEntryMessage(null, null); + mdcDataDebugMessage.debugEntryMessage(null); processServiceArtifact.setName(componentProcessInfo.getName()); processServiceArtifact.setContentData(FileUtils.toByteArray(componentProcessInfo.getContent())); getEnrichedServiceModelDao().storeExternalArtifact(processServiceArtifact); - mdcDataDebugMessage.debugExitMessage(null, null); + mdcDataDebugMessage.debugExitMessage(null); } - private VendorSoftwareProductDao getVendorSoftwareProductDao() { - if (vendorSoftwareProductDao == null) { - vendorSoftwareProductDao = VendorSoftwareProductDaoFactory.getInstance().createInterface(); + private ComponentDao getComponentDao() { + if (componentDao == null) { + componentDao = ComponentDaoFactory.getInstance().createInterface(); } - return vendorSoftwareProductDao; + return componentDao; } private ProcessDao getProcessDao() { diff --git a/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/external/artifact/VspInformationArtifactEnricher.java b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/external/artifact/VspInformationArtifactEnricher.java index b7da22bdfb..9e46a5c33d 100644 --- a/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/external/artifact/VspInformationArtifactEnricher.java +++ b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/external/artifact/VspInformationArtifactEnricher.java @@ -32,8 +32,6 @@ import org.openecomp.sdc.enrichment.EnrichmentInfo; import org.openecomp.sdc.enrichment.inter.ExternalArtifactEnricherInterface; import org.openecomp.sdc.logging.context.impl.MdcDataDebugMessage; import org.openecomp.sdc.vendorsoftwareproduct.VendorSoftwareProductConstants; -import org.openecomp.sdc.vendorsoftwareproduct.dao.OrchestrationTemplateDao; -import org.openecomp.sdc.vendorsoftwareproduct.dao.OrchestrationTemplateDaoFactory; import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDao; import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDaoFactory; import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails; @@ -61,8 +59,6 @@ public class VspInformationArtifactEnricher implements ExternalArtifactEnricherI EnrichedServiceModelDaoFactory.getInstance().createInterface(); private VendorSoftwareProductInfoDao vspInfoDao = VendorSoftwareProductInfoDaoFactory .getInstance().createInterface(); - private OrchestrationTemplateDao orchestrationTemplateDataDao = - OrchestrationTemplateDaoFactory.getInstance().createInterface(); public VspInformationArtifactEnricher() { } @@ -81,7 +77,7 @@ public class VspInformationArtifactEnricher implements ExternalArtifactEnricherI throws IOException { - mdcDataDebugMessage.debugEntryMessage(null, null); + mdcDataDebugMessage.debugEntryMessage(null); Map<String, List<ErrorMessage>> errors = new HashMap<>(); ByteBuffer infoArtifactByteBuffer = ByteBuffer.wrap(informationArtifactGenerator.generate( @@ -94,13 +90,13 @@ public class VspInformationArtifactEnricher implements ExternalArtifactEnricherI vspId, version.toString()))); //TODO: add error to map (what is the key?) - mdcDataDebugMessage.debugExitMessage(null, null); + mdcDataDebugMessage.debugExitMessage(null); return errors; } enrichInformationArtifact(vspId, version, infoArtifactByteBuffer); - mdcDataDebugMessage.debugExitMessage(null, null); + mdcDataDebugMessage.debugExitMessage(null); return errors; } @@ -108,10 +104,7 @@ public class VspInformationArtifactEnricher implements ExternalArtifactEnricherI ByteBuffer infoArtifactByteBuffer) { ServiceArtifact infoArtifactServiceArtifact = new ServiceArtifact(); - VspDetails vspDetails = getVspDetails(vspId, version); - - String vspName = vspDetails.getName(); - + String vspName = vspInfoDao.get(new VspDetails(vspId, version)).getName(); infoArtifactServiceArtifact.setVspId(vspId); infoArtifactServiceArtifact.setVersion(version); @@ -126,9 +119,5 @@ public class VspInformationArtifactEnricher implements ExternalArtifactEnricherI enrichedServiceModelDao.storeExternalArtifact(infoArtifactServiceArtifact); } - public VspDetails getVspDetails(String vspId,Version version){ - VspDetails vspDetails = vspInfoDao.get(new VspDetails(vspId,version)); - vspDetails.setValidationData(orchestrationTemplateDataDao.getValidationData(vspId,version)); - return vspDetails; - } + } diff --git a/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/tosca/ComponentQuestionnaireData.java b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/tosca/ComponentQuestionnaireData.java index f49c53d79b..9ebe9e5e67 100644 --- a/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/tosca/ComponentQuestionnaireData.java +++ b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/tosca/ComponentQuestionnaireData.java @@ -26,36 +26,35 @@ import static org.openecomp.sdc.enrichment.impl.util.EnrichmentConstants.MIN_INS import static org.openecomp.sdc.enrichment.impl.util.EnrichmentConstants.VFC_NAMING_CODE; - public class ComponentQuestionnaireData { ComponentDao componentDao = ComponentDaoFactory.getInstance().createInterface(); - ComponentDependencyModelDao componentDependencyModelDao = ComponentDependencyModelDaoFactory.getInstance() - .createInterface(); + ComponentDependencyModelDao componentDependencyModelDao = + ComponentDependencyModelDaoFactory.getInstance().createInterface(); - private Map<String,String> sourceToTargetComponent; + private Map<String, String> sourceToTargetComponent; - public Map<String,String> getSourceToTargetComponent() { + public Map<String, String> getSourceToTargetComponent() { return sourceToTargetComponent; } - public void setSourceToTargetComponent(Map<String,String> sourceToTargetComponent) { + public void setSourceToTargetComponent(Map<String, String> sourceToTargetComponent) { this.sourceToTargetComponent = sourceToTargetComponent; } public Map<String, Map<String, Object>> getPropertiesfromCompQuestionnaire(String key, Version version) { - Map<String, Map<String,Object>> componentProperties = - new HashMap<String, Map<String,Object>>(); + Map<String, Map<String, Object>> componentProperties = + new HashMap<String, Map<String, Object>>(); ComponentEntity entity = new ComponentEntity(key, version, null); final Collection<ComponentEntity> componentEntities = componentDao.listCompositionAndQuestionnaire(key, version); - Map<String,String> sourceToTarget = new HashMap<String, String>(); + Map<String, String> sourceToTarget = new HashMap<>(); for (ComponentEntity component : componentEntities) { - Map<String, Object> questionnaireParams = new HashMap<String, Object>(); + Map<String, Object> questionnaireParams = new HashMap<>(); final ComponentQuestionnaire componentQuestionnaire = JsonUtil.json2Object(component.getQuestionnaireData(), ComponentQuestionnaire.class); @@ -77,7 +76,7 @@ public class ComponentQuestionnaireData { questionnaireParams.put(EnrichmentConstants.VFC_FUNCTION, vfcDescription); - if (componentQuestionnaire.getHighAvailabilityAndLoadBalancing() != null ) { + if (componentQuestionnaire.getHighAvailabilityAndLoadBalancing() != null) { String mandatory = componentQuestionnaire.getHighAvailabilityAndLoadBalancing() .getIsComponentMandatory(); questionnaireParams.put(MANDATORY, mandatory); @@ -91,19 +90,20 @@ public class ComponentQuestionnaireData { final Integer maxVms = componentQuestionnaire.getCompute() != null ? (componentQuestionnaire.getCompute() .getNumOfVMs() != null ? componentQuestionnaire.getCompute().getNumOfVMs() - .getMaximum(): null) : null; + .getMaximum() : null) : null; final Integer minVms = componentQuestionnaire.getCompute() != null ? (componentQuestionnaire.getCompute() .getNumOfVMs() != null ? componentQuestionnaire.getCompute().getNumOfVMs() - .getMinimum(): null) : null; + .getMinimum() : null) : null; - questionnaireParams.put(MIN_INSTANCES,minVms != null && minVms == 0 ? null : minVms); - questionnaireParams.put(MAX_INSTANCES,maxVms != null && maxVms == 0 ? null : maxVms); + questionnaireParams.put(MIN_INSTANCES, minVms != null && minVms == 0 ? null : minVms); + questionnaireParams.put(MAX_INSTANCES, maxVms != null && maxVms == 0 ? null : maxVms); - if (! questionnaireParams.isEmpty()) + if (!questionnaireParams.isEmpty()) { componentProperties.put(JsonUtil.json2Object(component.getCompositionData(), ComponentData.class).getDisplayName(), questionnaireParams); + } } setSourceToTargetComponent(sourceToTarget); @@ -111,12 +111,12 @@ public class ComponentQuestionnaireData { return componentProperties; } - public Map<String,List<String>> populateDependencies(String vspId, Version version, Map<String, - String> componentNameData) { + public Map<String, List<String>> populateDependencies(String vspId, Version version, Map<String, + String> componentNameData) { Collection<ComponentDependencyModelEntity> componentDependencies = componentDependencyModelDao.list(new ComponentDependencyModelEntity(vspId, version, null)); - Map<String,List<String>> sourceToTargetComponent = new HashMap<String, List<String>>(); + Map<String, List<String>> sourceToTargetComponent = new HashMap<String, List<String>>(); List<String> targetComponents = null; for (ComponentDependencyModelEntity dependency : componentDependencies) { String sourceComponentName = componentNameData.get(dependency.getSourceComponentId()); diff --git a/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/tosca/PortMirroringEnricher.java b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/tosca/PortMirroringEnricher.java index 705773d1fc..a855a7477f 100644 --- a/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/tosca/PortMirroringEnricher.java +++ b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/tosca/PortMirroringEnricher.java @@ -1,9 +1,5 @@ package org.openecomp.sdc.enrichment.impl.tosca; -import static org.openecomp.sdc.tosca.services.DataModelUtil.getClonedObject; -import static org.openecomp.sdc.tosca.services.ToscaConstants.PORT_MIRRORING_CAPABILITY_CP_PROPERTY_NAME; -import static org.openecomp.sdc.tosca.services.ToscaConstants.PORT_MIRRORING_CAPABILITY_ID; - import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.MapUtils; import org.openecomp.sdc.datatypes.error.ErrorMessage; @@ -39,6 +35,10 @@ import java.util.Optional; import java.util.Set; import java.util.stream.Collectors; +import static org.openecomp.sdc.tosca.services.DataModelUtil.getClonedObject; +import static org.openecomp.sdc.tosca.services.ToscaConstants.PORT_MIRRORING_CAPABILITY_CP_PROPERTY_NAME; +import static org.openecomp.sdc.tosca.services.ToscaConstants.PORT_MIRRORING_CAPABILITY_ID; + public class PortMirroringEnricher { //Map of service template file name and map of all port node template ids, node template private Map<String, Map<String, NodeTemplate>> portNodeTemplates = new HashMap<>(); diff --git a/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/tosca/ToscaEnricher.java b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/tosca/ToscaEnricher.java index 090c3ae101..5ea1176e48 100644 --- a/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/tosca/ToscaEnricher.java +++ b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/tosca/ToscaEnricher.java @@ -20,11 +20,13 @@ package org.openecomp.sdc.enrichment.impl.tosca; +import org.openecomp.sdc.datatypes.error.ErrorLevel; import org.openecomp.sdc.datatypes.error.ErrorMessage; import org.openecomp.sdc.enrichment.inter.Enricher; import org.openecomp.sdc.logging.context.impl.MdcDataDebugMessage; import org.openecomp.sdc.tosca.datatypes.ToscaServiceModel; +import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -45,13 +47,19 @@ public class ToscaEnricher extends Enricher { private Map<String, List<ErrorMessage>> enrichAbstractSubstitute() { mdcDataDebugMessage.debugEntryMessage(null, null); - Map<String, List<ErrorMessage>> enrichErrors; + Map<String, List<ErrorMessage>> enrichErrors = new HashMap<>(); ToscaServiceModel toscaModel = (ToscaServiceModel) model; AbstractSubstituteToscaEnricher abstractSubstituteToscaEnricher = new AbstractSubstituteToscaEnricher(); - enrichErrors = abstractSubstituteToscaEnricher.enrich(toscaModel, data.getKey(), - data.getVersion()); + + try { + enrichErrors = abstractSubstituteToscaEnricher.enrich(toscaModel, data.getKey(), + data.getVersion()); + }catch (Exception e){ + enrichErrors.put("Tosca Enrich", Arrays.asList(new ErrorMessage(ErrorLevel.ERROR, e + .getMessage()))); + } mdcDataDebugMessage.debugExitMessage(null, null); return enrichErrors; @@ -59,10 +67,16 @@ public class ToscaEnricher extends Enricher { private Map<String, List<ErrorMessage>> enrichPortMirroring() { mdcDataDebugMessage.debugEntryMessage(null, null); - Map<String, List<ErrorMessage>> enrichErrors; + Map<String, List<ErrorMessage>> enrichErrors = new HashMap<>(); ToscaServiceModel toscaModel = (ToscaServiceModel) model; PortMirroringEnricher portMirroringEnricher = new PortMirroringEnricher(); - enrichErrors = portMirroringEnricher.enrich(toscaModel); + + try { + enrichErrors = portMirroringEnricher.enrich(toscaModel); + }catch (Exception e){ + enrichErrors.put("Tosca Enrich", Arrays.asList(new ErrorMessage(ErrorLevel.ERROR, e + .getMessage()))); + } mdcDataDebugMessage.debugExitMessage(null, null); return enrichErrors; } diff --git a/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/inter/ExternalArtifactEnricherInterface.java b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/inter/ExternalArtifactEnricherInterface.java index 49b424ef05..bd250bb8f4 100644 --- a/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/inter/ExternalArtifactEnricherInterface.java +++ b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/inter/ExternalArtifactEnricherInterface.java @@ -32,5 +32,5 @@ import java.util.Map; * Created by Talio on 11/24/2016. */ public interface ExternalArtifactEnricherInterface { - public Map<String, List<ErrorMessage>> enrich(EnrichmentInfo enrichmentInfo) throws IOException; + Map<String, List<ErrorMessage>> enrich(EnrichmentInfo enrichmentInfo) throws IOException; } |