aboutsummaryrefslogtreecommitdiffstats
path: root/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/external/artifact
diff options
context:
space:
mode:
Diffstat (limited to 'openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/external/artifact')
-rw-r--r--openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/external/artifact/ExternalArtifactEnricher.java100
-rw-r--r--openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/external/artifact/MonitoringMibEnricher.java236
-rw-r--r--openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/external/artifact/ProcessArtifactEnricher.java144
-rw-r--r--openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/external/artifact/VspInformationArtifactEnricher.java134
4 files changed, 553 insertions, 61 deletions
diff --git a/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/external/artifact/ExternalArtifactEnricher.java b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/external/artifact/ExternalArtifactEnricher.java
index a276cfba7d..3c27a0fac8 100644
--- a/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/external/artifact/ExternalArtifactEnricher.java
+++ b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/external/artifact/ExternalArtifactEnricher.java
@@ -20,87 +20,65 @@
package org.openecomp.sdc.enrichment.impl.external.artifact;
-import org.openecomp.core.enrichment.types.ComponentArtifactType;
-import org.openecomp.core.enrichment.types.MibInfo;
-import org.openecomp.core.model.dao.EnrichedServiceModelDao;
-import org.openecomp.core.model.dao.EnrichedServiceModelDaoFactory;
-import org.openecomp.core.model.types.ServiceArtifact;
-import org.openecomp.core.utilities.file.FileContentHandler;
import org.openecomp.core.utilities.file.FileUtils;
-import org.openecomp.core.validation.errors.Messages;
-import org.openecomp.sdc.datatypes.error.ErrorLevel;
+import org.openecomp.core.utilities.json.JsonUtil;
+import org.openecomp.sdc.common.utils.CommonUtil;
import org.openecomp.sdc.datatypes.error.ErrorMessage;
-import org.openecomp.sdc.enrichment.impl.tosca.ComponentInfo;
import org.openecomp.sdc.enrichment.inter.Enricher;
-import org.openecomp.sdc.versioning.dao.types.Version;
+import org.openecomp.sdc.enrichment.inter.ExternalArtifactEnricherInterface;
+import org.openecomp.sdc.logging.context.impl.MdcDataDebugMessage;
-import java.io.File;
-import java.io.IOException;
+import java.io.InputStream;
+import java.lang.reflect.Constructor;
+import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import java.util.Set;
public class ExternalArtifactEnricher extends Enricher {
+ private MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage();
+ private static String EXTERNAL_ARTIFACT_ENRICH_CONF_FILE = "ExternalArtifactConfiguration.json";
+ private static final String EXTERNAL_ARTIFACT_ENRICH_ERROR = "ERROR_CREATING_EXTERNAL_ARTIFACTS";
+ private static final String EXTERNAL_ARTIFACT_ENRICH_ERROR_MSG =
+ "An Error has occured during enrichment of external artifacts ";
+ private static Collection<String> implementingClasses =
+ getExternalArtifactEnrichedImplClassesList();
- private static EnrichedServiceModelDao enrichedServiceModelDao =
- EnrichedServiceModelDaoFactory.getInstance().createInterface();
+ private static Collection<String> getExternalArtifactEnrichedImplClassesList() {
+ InputStream externalArtifactEnrichConfigurationJson =
+ FileUtils.getFileInputStream(EXTERNAL_ARTIFACT_ENRICH_CONF_FILE);
+ @SuppressWarnings("unchecked")
+ Map<String, String> confFileAsMap =
+ JsonUtil.json2Object(externalArtifactEnrichConfigurationJson, Map.class);
+ return confFileAsMap.values();
+ }
@Override
public Map<String, List<ErrorMessage>> enrich() {
- Map<String, List<ErrorMessage>> errors = new HashMap<>();
- input.getEntityInfo().entrySet().stream().forEach(
- entry -> enrichComponentMib(entry.getKey(), (ComponentInfo) entry.getValue(), errors));
-
- return errors;
- }
+ mdcDataDebugMessage.debugEntryMessage(null, null);
+ Map<String, List<ErrorMessage>> errors = new HashMap<>();
- private void enrichComponentMib(String componentName, ComponentInfo componentInfo,
- Map<String, List<ErrorMessage>> errors) {
-
- String vspId = input.getKey();
- Version version = input.getVersion();
- ServiceArtifact mibServiceArtifact = new ServiceArtifact();
- mibServiceArtifact.setVspId(vspId);
- mibServiceArtifact.setVersion(version);
- enrichMibFiles(mibServiceArtifact, componentInfo, errors);
- }
+ try {
+ for (String implementingClassName : implementingClasses) {
+ ExternalArtifactEnricherInterface externalArtifactEnricherInstance = getExternalArtifactEnricherInstance(implementingClassName);
+ externalArtifactEnricherInstance.enrich(this.data);
+ }
+ } catch (Exception e) {
+ e.printStackTrace(); //// FIXME: 29-Nov-16
+ }
- private void enrichMibFiles(ServiceArtifact mibServiceArtifact, ComponentInfo componentInfo,
- Map<String, List<ErrorMessage>> errors) {
- if (componentInfo.getMibInfo() == null) {
- return;
- }
- enrichMibByType(componentInfo.getMibInfo().getSnmpTrap(), ComponentArtifactType.SNMP_TRAP,
- mibServiceArtifact, errors);
- enrichMibByType(componentInfo.getMibInfo().getSnmpPoll(), ComponentArtifactType.SNMP_POLL,
- mibServiceArtifact, errors);
+ mdcDataDebugMessage.debugExitMessage(null, null);
+ return errors;
}
- private void enrichMibByType(MibInfo mibInfo, ComponentArtifactType type,
- ServiceArtifact mibServiceArtifact,
- Map<String, List<ErrorMessage>> errors) {
- if (mibInfo == null) {
- return;
- }
- FileContentHandler mibs;
- try {
- mibs = FileUtils.getFileContentMapFromZip(FileUtils.toByteArray(mibInfo.getContent()));
- } catch (IOException ioException) {
- ErrorMessage.ErrorMessageUtil
- .addMessage(mibServiceArtifact.getName() + "." + type.name(), errors)
- .add(new ErrorMessage(ErrorLevel.ERROR, Messages.INVALID_ZIP_FILE.getErrorMessage()));
- return;
- }
- Set<String> fileList = mibs.getFileList();
- for (String fileName : fileList) {
- mibServiceArtifact.setContentData(FileUtils.toByteArray(mibs.getFileContent(fileName)));
- mibServiceArtifact.setName(mibInfo.getName() + File.separator + fileName);
- enrichedServiceModelDao.storeExternalArtifact(mibServiceArtifact);
- }
+ private ExternalArtifactEnricherInterface getExternalArtifactEnricherInstance(
+ String implementingClassName) throws Exception {
+ Class<?> clazz = Class.forName(implementingClassName);
+ Constructor<?> constructor = clazz.getConstructor();
+ return (ExternalArtifactEnricherInterface) constructor.newInstance();
}
}
diff --git a/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/external/artifact/MonitoringMibEnricher.java b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/external/artifact/MonitoringMibEnricher.java
new file mode 100644
index 0000000000..3920cc28af
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/external/artifact/MonitoringMibEnricher.java
@@ -0,0 +1,236 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdc.enrichment.impl.external.artifact;
+
+import org.openecomp.core.enrichment.types.ArtifactCategory;
+import org.openecomp.core.enrichment.types.ArtifactType;
+import org.openecomp.core.enrichment.types.ComponentMibInfo;
+import org.openecomp.core.enrichment.types.MibInfo;
+import org.openecomp.core.model.dao.EnrichedServiceModelDao;
+import org.openecomp.core.model.dao.EnrichedServiceModelDaoFactory;
+import org.openecomp.core.model.types.ServiceArtifact;
+import org.openecomp.core.utilities.file.FileContentHandler;
+import org.openecomp.core.utilities.file.FileUtils;
+import org.openecomp.sdc.common.errors.Messages;
+import org.openecomp.sdc.datatypes.error.ErrorLevel;
+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.MibDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.MibDaoFactory;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentDaoFactory;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.MibEntity;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentEntity;
+import org.openecomp.sdc.versioning.dao.types.Version;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+import java.util.Set;
+
+public class MonitoringMibEnricher implements ExternalArtifactEnricherInterface {
+
+ private EnrichedServiceModelDao enrichedServiceModelDao;
+ private ComponentDao componentDao;
+ private MibDao mibDao;
+ private static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage();
+
+ /**
+ * Enrich map.
+ *
+ * @param enrichmentInfo the enrichmentInfo
+ * @return the map
+ */
+ public Map<String, List<ErrorMessage>> enrich(EnrichmentInfo enrichmentInfo) {
+
+ Map<String, List<ErrorMessage>> errors = new HashMap<>();
+ String vspId = enrichmentInfo.getKey();
+ Version version = enrichmentInfo.getVersion();
+
+ Collection<ComponentEntity> components =
+ getComponentDao().list(new ComponentEntity(vspId, version, null));
+ components
+ .forEach(componentEntry -> errors.putAll(enrichComponent(componentEntry, vspId, version)));
+
+ return errors;
+ }
+
+ Map<String, List<ErrorMessage>> enrichComponent(ComponentEntity componentEntry, String vspId,
+ Version version) {
+
+
+ mdcDataDebugMessage.debugEntryMessage(null, null);
+
+ Map<String, List<ErrorMessage>> errors = new HashMap<>();
+ ComponentMibInfo componentMibInfo =
+ extractComponentMibInfo(componentEntry, vspId, version, errors);
+ enrichComponentMib(componentMibInfo, vspId, version, errors);
+
+ mdcDataDebugMessage.debugExitMessage(null, null);
+ return errors;
+ }
+
+ ComponentMibInfo extractComponentMibInfo(ComponentEntity componentEntity, String vspId,
+ Version version,
+ Map<String, List<ErrorMessage>> errors) {
+
+
+ mdcDataDebugMessage.debugEntryMessage(null, null);
+
+ String componentId = componentEntity.getId();
+ MibEntity entity = new MibEntity();
+
+ entity.setVspId(vspId);
+ entity.setVersion(version);
+ entity.setComponentId(componentId);
+ String componentName = componentEntity.getComponentCompositionData().getName();
+ ComponentMibInfo componentMibInfo = new ComponentMibInfo();
+ updComponentMibInfoByType(componentName, ArtifactType.SNMP_POLL, entity, componentMibInfo,
+ errors);
+ updComponentMibInfoByType(componentName, ArtifactType.SNMP_TRAP, entity, componentMibInfo,
+ errors);
+
+ mdcDataDebugMessage.debugExitMessage(null, null);
+ return componentMibInfo;
+ }
+
+ void updComponentMibInfoByType(String componentName, ArtifactType type,
+ MibEntity mibEntity,
+ ComponentMibInfo componentMibInfo,
+ Map<String, List<ErrorMessage>> errors) {
+
+
+ mdcDataDebugMessage.debugEntryMessage(null, null);
+
+ String path;
+ mibEntity.setType(type);
+ Optional<MibEntity> artifact =
+ getMibDao().getByType(mibEntity);
+
+ if (!artifact.isPresent()) {
+ return;
+ }
+ path = componentName + File.separator + ArtifactCategory.DEPLOYMENT.getDisplayName()
+ + File.separator + type.name();
+ MibInfo mibInfo = new MibInfo();
+ mibInfo.setName(path);
+ mibInfo.setContent(artifact.get().getArtifact().array());
+ switch (type) {
+ case SNMP_POLL:
+ componentMibInfo.setSnmpPoll(mibInfo);
+ break;
+ case SNMP_TRAP:
+ componentMibInfo.setSnmpTrap(mibInfo);
+ break;
+ default:
+ break;
+ }
+
+ mdcDataDebugMessage.debugExitMessage(null, null);
+ }
+
+ void enrichComponentMib(ComponentMibInfo componentMibInfo, String vspId, Version version,
+ Map<String, List<ErrorMessage>> errors) {
+
+
+ mdcDataDebugMessage.debugEntryMessage(null, null);
+
+ ServiceArtifact mibServiceArtifact = new ServiceArtifact();
+ mibServiceArtifact.setVspId(vspId);
+ mibServiceArtifact.setVersion(version);
+ enrichMibFiles(mibServiceArtifact, componentMibInfo, errors);
+
+ mdcDataDebugMessage.debugExitMessage(null, null);
+ }
+
+ void enrichMibFiles(ServiceArtifact mibServiceArtifact, ComponentMibInfo componentMibInfo,
+ Map<String, List<ErrorMessage>> errors) {
+
+
+ mdcDataDebugMessage.debugEntryMessage(null, null);
+
+ if (componentMibInfo == null) {
+ return;
+ }
+ enrichMibByType(componentMibInfo.getSnmpTrap(), ArtifactType.SNMP_TRAP, mibServiceArtifact,
+ errors);
+ enrichMibByType(componentMibInfo.getSnmpPoll(), ArtifactType.SNMP_POLL, mibServiceArtifact,
+ errors);
+
+ mdcDataDebugMessage.debugExitMessage(null, null);
+ }
+
+ void enrichMibByType(MibInfo mibInfo, ArtifactType type, ServiceArtifact mibServiceArtifact,
+ Map<String, List<ErrorMessage>> errors) {
+
+
+ mdcDataDebugMessage.debugEntryMessage(null, null);
+
+ if (mibInfo == null) {
+ return;
+ }
+ FileContentHandler mibs;
+ try {
+ mibs = FileUtils.getFileContentMapFromZip(FileUtils.toByteArray(mibInfo.getContent()));
+ } catch (IOException ioException) {
+ ErrorMessage.ErrorMessageUtil
+ .addMessage(mibServiceArtifact.getName() + "." + type.name(), errors)
+ .add(new ErrorMessage(ErrorLevel.ERROR, Messages.INVALID_ZIP_FILE.getErrorMessage()));
+ return;
+ }
+ Set<String> fileList = mibs.getFileList();
+ for (String fileName : fileList) {
+ mibServiceArtifact.setContentData(FileUtils.toByteArray(mibs.getFileContent(fileName)));
+ mibServiceArtifact.setName(mibInfo.getName() + File.separator + fileName);
+ getEnrichedServiceModelDao().storeExternalArtifact(mibServiceArtifact);
+ }
+
+ mdcDataDebugMessage.debugExitMessage(null, null);
+ }
+
+ private EnrichedServiceModelDao getEnrichedServiceModelDao() {
+ if (enrichedServiceModelDao == null) {
+ enrichedServiceModelDao = EnrichedServiceModelDaoFactory.getInstance().createInterface();
+ }
+ return enrichedServiceModelDao;
+ }
+
+ private ComponentDao getComponentDao() {
+ if (componentDao == null) {
+ componentDao = ComponentDaoFactory.getInstance().createInterface();
+ }
+ return componentDao;
+ }
+
+ private MibDao getMibDao() {
+ if (mibDao == null) {
+ mibDao = MibDaoFactory.getInstance().createInterface();
+ }
+ return mibDao;
+ }
+
+}
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
new file mode 100644
index 0000000000..b4a2815d69
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/external/artifact/ProcessArtifactEnricher.java
@@ -0,0 +1,144 @@
+package org.openecomp.sdc.enrichment.impl.external.artifact;
+
+import org.openecomp.core.enrichment.types.ArtifactCategory;
+import org.openecomp.core.enrichment.types.ComponentProcessInfo;
+import org.openecomp.core.model.dao.EnrichedServiceModelDao;
+import org.openecomp.core.model.dao.EnrichedServiceModelDaoFactory;
+import org.openecomp.core.model.types.ServiceArtifact;
+import org.openecomp.core.utilities.file.FileUtils;
+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.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;
+import org.openecomp.sdc.versioning.dao.types.Version;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public class ProcessArtifactEnricher implements ExternalArtifactEnricherInterface {
+
+ private VendorSoftwareProductDao vendorSoftwareProductDao;
+ //private ProcessArtifactDao processArtifactDao;
+ private ProcessDao processDao;
+ private static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage();
+ private EnrichedServiceModelDao enrichedServiceModelDao;
+
+ @Override
+ public Map<String, List<ErrorMessage>> enrich(EnrichmentInfo enrichmentInfo) throws IOException {
+ Map<String, List<ErrorMessage>> errors = new HashMap<>();
+ String vspId = enrichmentInfo.getKey();
+ Version version = enrichmentInfo.getVersion();
+
+ Collection<ComponentEntity> components =
+ getVendorSoftwareProductDao().listComponents(vspId, version);
+ components.stream()
+ .forEach(componentEntry -> errors.putAll(enrichComponent(componentEntry,
+ vspId, version)));
+
+ return errors;
+ }
+
+ Map<String, List<ErrorMessage>> enrichComponent(ComponentEntity componentEntry, String vspId,
+ Version version) {
+ mdcDataDebugMessage.debugEntryMessage("LifeCycleOperationArtifactEnricher vspId ",
+ vspId);
+
+ Map<String, List<ErrorMessage>> errors = new HashMap<>();
+ enrichComponentProcessArtifact(componentEntry, vspId, version, errors);
+
+ mdcDataDebugMessage.debugExitMessage("LifeCycleOperationArtifactEnricher vspId ",
+ vspId);
+ return errors;
+ }
+
+ void enrichComponentProcessArtifact(ComponentEntity componentEntity,
+ String vspId, Version version,
+ Map<String, List<ErrorMessage>> errors) {
+
+
+ mdcDataDebugMessage.debugEntryMessage(null, null);
+
+ String componentId = componentEntity.getId();
+ ProcessEntity processEntity = new ProcessEntity(vspId, version, componentId, null);
+ final Collection<ProcessEntity> processes = getProcessDao().list(processEntity);
+
+ /*processes.stream()
+ .filter(entity -> entity.getType().equals(ProcessType.Lifecycle_Operations))
+ .forEach(entity -> {
+ ProcessArtifactEntity artifactEntity = new ProcessArtifactEntity(vspId, version,
+ componentId, entity.getId());*/
+
+ processes.stream()
+ .filter(entity -> entity.getType().equals(ProcessType.Lifecycle_Operations))
+ .forEach(entity -> {
+ ProcessEntity artifactEntity = new ProcessEntity(vspId, version,
+ componentId, entity.getId());
+
+ ProcessEntity artifactProcessEntity = getProcessDao().get(artifactEntity);
+ //ProcessArtifactEntity artifact = getProcessArtifactDao().get(artifactEntity);
+ if (artifactProcessEntity != null) {
+ String componentName = componentEntity.getComponentCompositionData().getName();
+ String path = componentName + File.separator
+ + ArtifactCategory.DEPLOYMENT.getDisplayName() + File.separator
+ + "Lifecycle Operations" + File.separator + artifactProcessEntity.getArtifactName();
+
+ ComponentProcessInfo componentProcessInfo = new ComponentProcessInfo();
+ componentProcessInfo.setName(path);
+ componentProcessInfo.setContent(artifactProcessEntity.getArtifact().array());
+
+ ServiceArtifact processServiceArtifact = new ServiceArtifact();
+ processServiceArtifact.setVspId(vspId);
+ processServiceArtifact.setVersion(version);
+ enrichServiceArtifact(componentProcessInfo, processServiceArtifact, errors);
+ }
+ });
+
+ mdcDataDebugMessage.debugExitMessage(null, null);
+ }
+
+ void enrichServiceArtifact(ComponentProcessInfo componentProcessInfo,
+ ServiceArtifact processServiceArtifact,
+ Map<String, List<ErrorMessage>> errors) {
+
+
+ mdcDataDebugMessage.debugEntryMessage(null, null);
+
+ processServiceArtifact.setName(componentProcessInfo.getName());
+ processServiceArtifact.setContentData(FileUtils.toByteArray(componentProcessInfo.getContent()));
+ getEnrichedServiceModelDao().storeExternalArtifact(processServiceArtifact);
+ mdcDataDebugMessage.debugExitMessage(null, null);
+ }
+
+ private VendorSoftwareProductDao getVendorSoftwareProductDao() {
+ if (vendorSoftwareProductDao == null) {
+ vendorSoftwareProductDao = VendorSoftwareProductDaoFactory.getInstance().createInterface();
+ }
+ return vendorSoftwareProductDao;
+ }
+
+ private ProcessDao getProcessDao() {
+ if (processDao == null) {
+ processDao = ProcessDaoFactory.getInstance().createInterface();
+ }
+ return processDao;
+ }
+
+ private EnrichedServiceModelDao getEnrichedServiceModelDao() {
+
+ if (enrichedServiceModelDao == null) {
+ enrichedServiceModelDao = EnrichedServiceModelDaoFactory.getInstance().createInterface();
+ }
+ return enrichedServiceModelDao;
+ }
+}
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
new file mode 100644
index 0000000000..b7da22bdfb
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/external/artifact/VspInformationArtifactEnricher.java
@@ -0,0 +1,134 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdc.enrichment.impl.external.artifact;
+
+
+import org.openecomp.core.enrichment.types.ArtifactCategory;
+import org.openecomp.core.enrichment.types.InformationArtifactFolderNames;
+import org.openecomp.core.model.dao.EnrichedServiceModelDao;
+import org.openecomp.core.model.dao.EnrichedServiceModelDaoFactory;
+import org.openecomp.core.model.types.ServiceArtifact;
+import org.openecomp.sdc.datatypes.error.ErrorLevel;
+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.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;
+import org.openecomp.sdc.vendorsoftwareproduct.factory.InformationArtifactGeneratorFactory;
+import org.openecomp.sdc.vendorsoftwareproduct.informationArtifact.InformationArtifactGenerator;
+import org.openecomp.sdc.versioning.dao.types.Version;
+
+import java.io.File;
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+
+/**
+ * Created by Talio on 11/24/2016
+ */
+public class VspInformationArtifactEnricher implements ExternalArtifactEnricherInterface {
+ private static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage();
+ private static InformationArtifactGenerator informationArtifactGenerator =
+ InformationArtifactGeneratorFactory.getInstance().createInterface();
+ private EnrichedServiceModelDao enrichedServiceModelDao =
+ EnrichedServiceModelDaoFactory.getInstance().createInterface();
+ private VendorSoftwareProductInfoDao vspInfoDao = VendorSoftwareProductInfoDaoFactory
+ .getInstance().createInterface();
+ private OrchestrationTemplateDao orchestrationTemplateDataDao =
+ OrchestrationTemplateDaoFactory.getInstance().createInterface();
+
+ public VspInformationArtifactEnricher() {
+ }
+
+ public Map<String, List<ErrorMessage>> enrich(EnrichmentInfo enrichmentInfo)
+ throws IOException {
+
+ String vspId = enrichmentInfo.getKey();
+ Version version = enrichmentInfo.getVersion();
+ Map<String, List<ErrorMessage>> errors = enrichInformationArtifact(vspId, version);
+
+ return errors;
+ }
+
+ private Map<String, List<ErrorMessage>> enrichInformationArtifact(String vspId, Version version)
+ throws IOException {
+
+
+ mdcDataDebugMessage.debugEntryMessage(null, null);
+
+ Map<String, List<ErrorMessage>> errors = new HashMap<>();
+ ByteBuffer infoArtifactByteBuffer = ByteBuffer.wrap(informationArtifactGenerator.generate(
+ vspId, version).getBytes());
+
+ if (Objects.isNull(infoArtifactByteBuffer)) {
+ List<ErrorMessage> errorList = new ArrayList<>();
+ errorList.add(new ErrorMessage(ErrorLevel.ERROR, String.format(
+ "Cannot enrich information artifact for vendor software product with id %s and version %s",
+ vspId, version.toString())));
+ //TODO: add error to map (what is the key?)
+
+ mdcDataDebugMessage.debugExitMessage(null, null);
+ return errors;
+ }
+
+ enrichInformationArtifact(vspId, version, infoArtifactByteBuffer);
+
+ mdcDataDebugMessage.debugExitMessage(null, null);
+ return errors;
+ }
+
+ private void enrichInformationArtifact(String vspId, Version version,
+ ByteBuffer infoArtifactByteBuffer) {
+ ServiceArtifact infoArtifactServiceArtifact = new ServiceArtifact();
+
+ VspDetails vspDetails = getVspDetails(vspId, version);
+
+ String vspName = vspDetails.getName();
+
+
+ infoArtifactServiceArtifact.setVspId(vspId);
+ infoArtifactServiceArtifact.setVersion(version);
+ infoArtifactServiceArtifact
+ .setName(ArtifactCategory.INFORMATIONAL.getDisplayName() + File.separator
+ + InformationArtifactFolderNames.Guide + File.separator + String.format(
+ VendorSoftwareProductConstants
+ .INFORMATION_ARTIFACT_NAME,
+ vspName));
+ infoArtifactServiceArtifact.setContentData(infoArtifactByteBuffer.array());
+
+ 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;
+ }
+}