2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.openecomp.sdc.model.impl.zusammen;
23 import com.amdocs.zusammen.adaptor.inbound.api.types.item.ZusammenElement;
24 import com.amdocs.zusammen.datatypes.SessionContext;
25 import com.amdocs.zusammen.datatypes.item.Action;
26 import com.amdocs.zusammen.datatypes.item.ElementContext;
27 import org.openecomp.core.model.dao.EnrichedServiceModelDao;
28 import org.openecomp.core.model.types.ServiceArtifact;
29 import org.openecomp.core.model.types.ServiceElement;
30 import org.openecomp.core.utilities.file.FileUtils;
31 import org.openecomp.core.zusammen.api.ZusammenAdaptor;
32 import org.openecomp.core.zusammen.api.ZusammenUtil;
33 import org.openecomp.sdc.datatypes.model.ElementType;
34 import org.openecomp.sdc.logging.api.Logger;
35 import org.openecomp.sdc.logging.api.LoggerFactory;
36 import org.openecomp.sdc.tosca.datatypes.ToscaServiceModel;
38 import static org.openecomp.core.zusammen.api.ZusammenUtil.buildStructuralElement;
40 public class EnrichedServiceModelDaoZusammenImpl extends ServiceModelDaoZusammenImpl implements
41 EnrichedServiceModelDao<ToscaServiceModel, ServiceElement> {
43 private static final Logger logger =
44 LoggerFactory.getLogger(EnrichedServiceModelDaoZusammenImpl.class);
46 public EnrichedServiceModelDaoZusammenImpl(ZusammenAdaptor zusammenAdaptor) {
47 super(zusammenAdaptor);
48 this.elementType = ElementType.EnrichedServiceModel;
52 public void storeExternalArtifact(ServiceArtifact serviceArtifact) {
53 ZusammenElement artifact = buildArtifactElement(serviceArtifact.getName(),
54 FileUtils.toByteArray(serviceArtifact.getContent()), Action.CREATE);
56 ZusammenElement artifacts = buildStructuralElement(ElementType.Artifacts, Action.IGNORE);
57 artifacts.addSubElement(artifact);
59 ZusammenElement enrichedServiceModel = buildStructuralElement(elementType, Action.IGNORE);
60 enrichedServiceModel.addSubElement(artifacts);
62 ZusammenElement vspModel = buildStructuralElement(ElementType.VspModel, Action.IGNORE);
63 vspModel.addSubElement(enrichedServiceModel);
65 SessionContext context = ZusammenUtil.createSessionContext();
66 ElementContext elementContext =
67 new ElementContext(serviceArtifact.getVspId(), serviceArtifact.getVersion().getId());
69 .saveElement(context, elementContext, vspModel, "add service external artifact.");
72 "Finished adding artifact to enriched service model for VendorSoftwareProduct id -> {}",
73 elementContext.getItemId().getValue());