2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 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.mso.asdc.installer;
24 import java.util.HashMap;
25 import java.util.LinkedList;
26 import java.util.List;
28 import org.openecomp.sdc.api.notification.IVfModuleMetadata;
29 import org.openecomp.mso.asdc.client.ASDCConfiguration;
30 import org.openecomp.mso.asdc.client.exceptions.ArtifactInstallerException;
31 import org.openecomp.mso.db.catalog.beans.VfModule;
33 public final class VfModuleStructure {
35 private final IVfModuleData vfModuleMetadata;
37 private final VfResourceStructure parentVfResource;
39 private VfModule catalogVfModule;
41 * The list of artifact existing in this resource hashed by artifactType.
43 private final Map<String, List<VfModuleArtifact>> artifactsMap;
45 public VfModuleStructure(VfResourceStructure vfParentResource,IVfModuleData vfmoduleMetadata) throws ArtifactInstallerException {
47 vfModuleMetadata = vfmoduleMetadata;
48 parentVfResource = vfParentResource;
50 artifactsMap = new HashMap<String, List<VfModuleArtifact>>();
52 for (String artifactUUID:this.vfModuleMetadata.getArtifacts()) {
53 if (vfParentResource.getArtifactsMapByUUID().containsKey(artifactUUID)) {
54 this.addToStructure(vfParentResource.getArtifactsMapByUUID().get(artifactUUID));
56 throw new ArtifactInstallerException("Artifact (UUID:"+artifactUUID+ ") referenced in the VFModule UUID list has not been downloaded, cancelling the Resource deployment");
61 private void addToStructure(VfModuleArtifact vfModuleArtifact) {
63 if (artifactsMap.containsKey(vfModuleArtifact.getArtifactInfo().getArtifactType())) {
64 artifactsMap.get(vfModuleArtifact.getArtifactInfo().getArtifactType()).add(vfModuleArtifact);
67 List<VfModuleArtifact> nestedList = new LinkedList<VfModuleArtifact>();
68 nestedList.add(vfModuleArtifact);
70 artifactsMap.put(vfModuleArtifact.getArtifactInfo().getArtifactType(), nestedList);
74 public List<VfModuleArtifact> getOrderedArtifactList() {
76 List <VfModuleArtifact> artifactsList = new LinkedList <VfModuleArtifact>();
78 artifactsList.addAll(artifactsMap.get(ASDCConfiguration.HEAT));
79 artifactsList.addAll(artifactsMap.get(ASDCConfiguration.HEAT_ENV));
80 artifactsList.addAll(artifactsMap.get(ASDCConfiguration.HEAT_VOL));
82 for (VfModuleArtifact artifact:(artifactsMap.get(ASDCConfiguration.HEAT_NESTED))) {
83 artifactsList.add(artifact);
86 for (VfModuleArtifact artifact:(artifactsMap.get(ASDCConfiguration.HEAT_ARTIFACT))) {
87 artifactsList.add(artifact);
90 artifactsList.addAll(artifactsMap.get(ASDCConfiguration.HEAT_VOL));
95 public IVfModuleData getVfModuleMetadata() {
96 return vfModuleMetadata;
99 public VfResourceStructure getParentVfResource() {
100 return parentVfResource;
103 public Map<String, List<VfModuleArtifact>> getArtifactsMap() {
108 public VfModule getCatalogVfModule() {
109 return catalogVfModule;
112 public void setCatalogVfModule(VfModule catalogVfModule) {
113 this.catalogVfModule = catalogVfModule;