2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2019 Nordix Foundation.
4 * ================================================================================
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 * SPDX-License-Identifier: Apache-2.0
17 * ============LICENSE_END=========================================================
20 package org.onap.so.asdc.installer;
22 import java.io.UnsupportedEncodingException;
23 import java.util.HashMap;
25 import org.onap.sdc.api.IDistributionClient;
26 import org.onap.sdc.api.notification.IArtifactInfo;
27 import org.onap.sdc.api.notification.INotificationData;
28 import org.onap.sdc.api.notification.IResourceInstance;
29 import org.onap.sdc.api.results.IDistributionClientDownloadResult;
30 import org.onap.so.asdc.client.exceptions.ArtifactInstallerException;
31 import org.slf4j.Logger;
32 import org.slf4j.LoggerFactory;
35 * Abstract class to represent the resource structure.
37 * This structure exists to avoid having issues if the order of the resource artifact of tree structure is not good.
39 public abstract class ResourceStructure {
42 * Flag to indicate whether the resource is deployed successfully.
44 protected boolean isDeployedSuccessfully = false;
47 * Flag to indicate whether the resource is already deployed.
49 protected boolean isAlreadyDeployed = false;
54 protected ResourceType resourceType;
57 * The Raw notification data.
59 protected INotificationData notificationData;
62 * The resource we will try to deploy.
64 protected IResourceInstance resourceInstance;
67 * Number of resources provided by the resource structure.
69 protected int NumberOfResources;
72 * The list of artifacts existing in this resource hashed by UUID.
74 protected final Map<String, VfModuleArtifact> artifactsMapByUUID;
76 public ResourceStructure(INotificationData notificationData, IResourceInstance resourceInstance) {
77 this.notificationData = notificationData;
78 this.resourceInstance = resourceInstance;
79 artifactsMapByUUID = new HashMap<>();
83 * Add artifact to the resource structure.
85 * @param distributionClient
88 * @throws UnsupportedEncodingException
90 public abstract void addArtifactToStructure(IDistributionClient distributionClient, IArtifactInfo artifactinfo,
91 IDistributionClientDownloadResult clientResult) throws UnsupportedEncodingException;
94 * Prepare the resource for installation.
96 * @throws ArtifactInstallerException
98 public abstract void prepareInstall() throws ArtifactInstallerException;
100 public boolean isDeployedSuccessfully() {
101 return isDeployedSuccessfully;
104 public void setDeployedSuccessfully(boolean deployedSuccessfully) {
105 isDeployedSuccessfully = deployedSuccessfully;
108 public boolean isAlreadyDeployed() {
109 return isAlreadyDeployed;
112 public void setAlreadyDeployed(boolean alreadyDeployed) {
113 isAlreadyDeployed = alreadyDeployed;
116 public ResourceType getResourceType() {
120 public void setResourceType(ResourceType resourceType) {
121 this.resourceType = resourceType;
124 public INotificationData getNotification() {
125 return notificationData;
128 public void setNotification(INotificationData notificationData) {
129 this.notificationData = notificationData;
132 public IResourceInstance getResourceInstance() {
133 return resourceInstance;
136 public void setResourceInstance(IResourceInstance resourceInstance) {
137 this.resourceInstance = resourceInstance;
140 public int getNumberOfResources() {
141 return NumberOfResources;
144 public void setNumberOfResources(int numberOfResources) {
145 NumberOfResources = numberOfResources;
148 public Map<String, VfModuleArtifact> getArtifactsMapByUUID() {
149 return artifactsMapByUUID;