1 package org.openecomp.sdc.model.impl.zusammen;
3 import com.amdocs.zusammen.adaptor.inbound.api.types.item.ZusammenElement;
4 import com.amdocs.zusammen.datatypes.Id;
5 import com.amdocs.zusammen.datatypes.SessionContext;
6 import com.amdocs.zusammen.datatypes.item.Action;
7 import com.amdocs.zusammen.datatypes.item.ElementContext;
8 import org.openecomp.core.model.dao.EnrichedServiceModelDao;
9 import org.openecomp.core.model.types.ServiceArtifact;
10 import org.openecomp.core.model.types.ServiceElement;
11 import org.openecomp.core.utilities.file.FileUtils;
12 import org.openecomp.core.zusammen.api.ZusammenAdaptor;
13 import org.openecomp.core.zusammen.api.ZusammenUtil;
14 import org.openecomp.sdc.logging.api.Logger;
15 import org.openecomp.sdc.logging.api.LoggerFactory;
16 import org.openecomp.sdc.tosca.datatypes.ToscaServiceModel;
18 public class EnrichedServiceModelDaoZusammenImpl extends ServiceModelDaoZusammenImpl implements
19 EnrichedServiceModelDao<ToscaServiceModel, ServiceElement> {
21 private static final Logger logger =
22 LoggerFactory.getLogger(EnrichedServiceModelDaoZusammenImpl.class);
24 public EnrichedServiceModelDaoZusammenImpl(ZusammenAdaptor zusammenAdaptor) {
25 super(zusammenAdaptor);
26 this.name = StructureElement.EnrichedServiceModel.name();
30 public void storeExternalArtifact(ServiceArtifact serviceArtifact) {
31 ZusammenElement artifactElement = buildArtifactElement(serviceArtifact.getName(),
32 FileUtils.toByteArray(serviceArtifact.getContent()), Action.CREATE);
34 ZusammenElement artifactsElement =
35 buildStructuralElement(StructureElement.Artifacts.name(), null);
36 artifactsElement.addSubElement(artifactElement);
38 ZusammenElement enrichedServiceModelElement = buildStructuralElement(name, null);
39 enrichedServiceModelElement.addSubElement(artifactsElement);
41 SessionContext context = ZusammenUtil.createSessionContext();
42 Id itemId = new Id(serviceArtifact.getVspId());
43 ElementContext elementContext = new ElementContext(itemId, getFirstVersionId(context, itemId));
45 .saveElement(context, elementContext, enrichedServiceModelElement, "add service artifact.");
47 logger.info("Finished adding artifact to service model for vsp id -> " +
48 elementContext.getItemId().getValue());