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;
72 * The list of workflow artifacts existing in this resource
74 protected final Map<String, WorkflowArtifact> workflowArtifactsMapByUUID;
76 public ResourceStructure(INotificationData notificationData, IResourceInstance resourceInstance) {
77 this.notificationData = notificationData;
78 this.resourceInstance = resourceInstance;
79 artifactsMapByUUID = new HashMap<>();
80 workflowArtifactsMapByUUID = new HashMap<>();
84 * Add artifact to the resource structure.
86 * @param distributionClient
89 * @throws UnsupportedEncodingException
91 public abstract void addArtifactToStructure(IDistributionClient distributionClient, IArtifactInfo artifactinfo,
92 IDistributionClientDownloadResult clientResult) throws UnsupportedEncodingException;
94 public abstract void addWorkflowArtifactToStructure(IArtifactInfo artifactinfo,
95 IDistributionClientDownloadResult clientResult) throws UnsupportedEncodingException;
98 * Prepare the resource for installation.
100 * @throws ArtifactInstallerException
102 public abstract void prepareInstall() throws ArtifactInstallerException;
104 public boolean isDeployedSuccessfully() {
105 return isDeployedSuccessfully;
108 public void setDeployedSuccessfully(boolean deployedSuccessfully) {
109 isDeployedSuccessfully = deployedSuccessfully;
112 public boolean isAlreadyDeployed() {
113 return isAlreadyDeployed;
116 public void setAlreadyDeployed(boolean alreadyDeployed) {
117 isAlreadyDeployed = alreadyDeployed;
120 public ResourceType getResourceType() {
124 public void setResourceType(ResourceType resourceType) {
125 this.resourceType = resourceType;
128 public INotificationData getNotification() {
129 return notificationData;
132 public void setNotification(INotificationData notificationData) {
133 this.notificationData = notificationData;
136 public IResourceInstance getResourceInstance() {
137 return resourceInstance;
140 public void setResourceInstance(IResourceInstance resourceInstance) {
141 this.resourceInstance = resourceInstance;
144 public int getNumberOfResources() {
145 return NumberOfResources;
148 public void setNumberOfResources(int numberOfResources) {
149 NumberOfResources = numberOfResources;
152 public Map<String, VfModuleArtifact> getArtifactsMapByUUID() {
153 return artifactsMapByUUID;
156 public Map<String, WorkflowArtifact> getWorkflowArtifactsMapByUUID() {
157 return workflowArtifactsMapByUUID;