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.onap.so.asdc.installer;
24 import java.util.HashMap;
25 import java.util.LinkedList;
26 import java.util.List;
29 import org.onap.sdc.api.notification.IVfModuleMetadata;
30 import org.onap.so.asdc.client.ASDCConfiguration;
31 import org.onap.so.asdc.client.exceptions.ArtifactInstallerException;
32 import org.onap.so.db.catalog.beans.VfModule;
34 public final class VfModuleStructure {
36 private final IVfModuleData vfModuleMetadata;
38 private final VfResourceStructure parentVfResource;
40 private VfModule catalogVfModule;
42 * The list of artifact existing in this resource hashed by artifactType.
44 private final Map<String, List<VfModuleArtifact>> artifactsMap;
46 public VfModuleStructure(VfResourceStructure vfParentResource,IVfModuleData vfmoduleMetadata) throws ArtifactInstallerException {
48 vfModuleMetadata = vfmoduleMetadata;
49 parentVfResource = vfParentResource;
51 artifactsMap = new HashMap<>();
53 for (String artifactUUID:this.vfModuleMetadata.getArtifacts()) {
54 if (vfParentResource.getArtifactsMapByUUID().containsKey(artifactUUID)) {
55 this.addToStructure(vfParentResource.getArtifactsMapByUUID().get(artifactUUID));
57 throw new ArtifactInstallerException("Artifact (UUID:"+artifactUUID+ ") referenced in the VFModule UUID list has not been downloaded, cancelling the Resource deployment");
62 private void addToStructure(VfModuleArtifact vfModuleArtifact) {
64 if (artifactsMap.containsKey(vfModuleArtifact.getArtifactInfo().getArtifactType())) {
65 artifactsMap.get(vfModuleArtifact.getArtifactInfo().getArtifactType()).add(vfModuleArtifact);
68 List<VfModuleArtifact> nestedList = new LinkedList<>();
69 nestedList.add(vfModuleArtifact);
71 artifactsMap.put(vfModuleArtifact.getArtifactInfo().getArtifactType(), nestedList);
75 public List<VfModuleArtifact> getOrderedArtifactList() {
77 List <VfModuleArtifact> artifactsList = new LinkedList<>();
79 artifactsList.addAll(artifactsMap.get(ASDCConfiguration.HEAT));
80 artifactsList.addAll(artifactsMap.get(ASDCConfiguration.HEAT_ENV));
81 artifactsList.addAll(artifactsMap.get(ASDCConfiguration.HEAT_VOL));
83 artifactsList.addAll((artifactsMap.get(ASDCConfiguration.HEAT_NESTED)));
85 artifactsList.addAll((artifactsMap.get(ASDCConfiguration.HEAT_ARTIFACT)));
87 artifactsList.addAll(artifactsMap.get(ASDCConfiguration.HEAT_VOL));
92 public IVfModuleData getVfModuleMetadata() {
93 return vfModuleMetadata;
96 public VfResourceStructure getParentVfResource() {
97 return parentVfResource;
100 public Map<String, List<VfModuleArtifact>> getArtifactsMap() {
105 public VfModule getCatalogVfModule() {
106 return catalogVfModule;
109 public void setCatalogVfModule(VfModule catalogVfModule) {
110 this.catalogVfModule = catalogVfModule;