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