aboutsummaryrefslogtreecommitdiffstats
path: root/asdc-controller/src/main/java/org/onap/so/asdc/installer/ASDCElementInfo.java
diff options
context:
space:
mode:
Diffstat (limited to 'asdc-controller/src/main/java/org/onap/so/asdc/installer/ASDCElementInfo.java')
-rw-r--r--asdc-controller/src/main/java/org/onap/so/asdc/installer/ASDCElementInfo.java354
1 files changed, 180 insertions, 174 deletions
diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/installer/ASDCElementInfo.java b/asdc-controller/src/main/java/org/onap/so/asdc/installer/ASDCElementInfo.java
index 1e227aefa1..043055e23c 100644
--- a/asdc-controller/src/main/java/org/onap/so/asdc/installer/ASDCElementInfo.java
+++ b/asdc-controller/src/main/java/org/onap/so/asdc/installer/ASDCElementInfo.java
@@ -25,7 +25,6 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
-
import org.onap.sdc.api.notification.IArtifactInfo;
import org.onap.sdc.api.notification.IResourceInstance;
import org.onap.so.asdc.client.ASDCConfiguration;
@@ -35,177 +34,184 @@ import org.onap.so.asdc.client.ASDCConfiguration;
*/
public class ASDCElementInfo {
- /**
- * A default, empty instance used in case a source element was not correctly provided.
- */
- public static final ASDCElementInfo EMPTY_INSTANCE = new ASDCElementInfo();
-
- /**
- * Used to define the other possible ASDC Element types (usually in addition to existing artifact types, etc.).<br/>
- * <br/>
- * Possible types allowed:<br/>
- * <ul>
- * <li>{@link ASDCElementTypeEnum#VNF_RESOURCE}</li>
- * <ul>
- */
- public static enum ASDCElementTypeEnum {
- /**
- * The type VNF_RESOURCE. Represents a VNF_RESOURCE element.
- */
- VNF_RESOURCE
- };
-
- /**
- * The map of element information fields useful for logging. The complete contents of this list will be concatenated.
- */
- private final Map<String, String> elementInfoMap = new HashMap<>();
-
- /**
- * The type of this element.
- */
- private final String type;
-
- private ASDCElementInfo () {
- // Private parameterless constructor. Not visible, only used for EMPTY_INSTANCE.
- this.type = "";
- }
-
- /**
- * Artifact-type based constructor. Requires a valid artifact type.
- * @param artifactType The artifact type
- */
- private ASDCElementInfo (String artifactType) {
- // We need the exact type name here...
- this.type = artifactType;
- }
-
- /**
- * 'Other element type'-based constructor. Requires a valid element type.
- * @param elementType An ASDCElementTypeEnum entry. This will usually contain enumerated types not in the existing
- */
- private ASDCElementInfo (ASDCElementTypeEnum elementType) {
- // We need the exact type name here...
- this.type = elementType.name();
- }
-
- /**
- * Add an information entry (name, UUID, etc.) from an artifact/resource/..., once a at time.
- *
- * @param key The key (name) of the information entry (Artifact UUID, Resource Name, etc.)
- * @param value The value bound to the information entry.
- */
- public final void addElementInfo(String key, String value) {
- if ((key != null) && (value != null)) {
- this.getElementInfoMap().put(key, value);
- }
- }
-
- /**
- * Returns an aggregated, formatted list of the expected details about an ASDC element.
- * (non-Javadoc)
- * @return An aggregated list of element information entries, comma-separated.
- * @see java.lang.Object#toString()
- */
- @Override
- public final String toString() {
- StringBuilder sb = new StringBuilder();
- List<String> aggregatedElements = new ArrayList<>();
- for (Entry<String, String> entry : this.getElementInfoMap().entrySet()) {
- aggregatedElements.add(entry.getKey() + ": " + entry.getValue());
- }
- sb.append(aggregatedElements.size() > 0 ? aggregatedElements.get(0) : "");
- if (aggregatedElements.size() > 1) {
- for (int i = 1; i < aggregatedElements.size(); ++i) {
- sb.append (", ");
- sb.append(aggregatedElements.get(i));
- }
- }
- return sb.toString();
- }
-
- /**
- * The type that was defined at creation time. This is typically VNF_RESOURCE, VF_MODULE_METADATA, HEAT_ENV, etc.
- * @return The type of this element information type. This will usually be either an ArtifactTypeEnum entry name or an ASDCElementTypeEnum entry name.
- * @see ASDCElementInfo.ASDCElementTypeEnum
- */
- public String getType() {
- return type;
- }
-
- /**
- * Provides the map of all element information entries for this type.
- * @return A map of all element information entries which will be used by the toString() method.
- * @see ASDCElementInfo#toString()
- */
- protected Map<String, String> getElementInfoMap() {
- return elementInfoMap;
- }
-
- /**
- * Create an ASDCElementInfo object from a VNF Resource.<br/>
- * <br/>
- * <b>Used information:</b><br/>
- * <ul>
- * <li>Resource Instance Name</li>
- * <li>Resource Instance UUID</li>
- * </ul>
- *
- * @param vfResourceStructure The VfResourceStructure to use as source of information (see {@link VfResourceStructure}).
- * @return an ASDCElementInfo using the information held in the VNF Resource.
- */
- public static final ASDCElementInfo createElementFromVfResourceStructure (VfResourceStructure vfResourceStructure) {
- if (vfResourceStructure == null) {
- return EMPTY_INSTANCE;
- }
- ASDCElementInfo elementInfo = new ASDCElementInfo(ASDCElementTypeEnum.VNF_RESOURCE);
- IResourceInstance resourceInstance = vfResourceStructure.getResourceInstance();
- elementInfo.addElementInfo("Resource Instance Name", resourceInstance.getResourceInstanceName());
- elementInfo.addElementInfo("Resource Instance Invariant UUID", resourceInstance.getResourceInvariantUUID());
- return elementInfo;
- }
-
- /**
- * Create an ASDCElementInfo object from a VF Module.<br/>
- * <br/>
- * <b>Used information:</b><br/>
- * <ul>
- * <li>Module Model Name</li>
- * <li>Module Model UUID</li>
- * </ul>
- *
- * @param vfModuleStructure The VfModuleStructure to use as source of information (see {@link VfModuleStructure}).
- * @return an ASDCElementInfo using the information held in the VF Module.
- */
- public static final ASDCElementInfo createElementFromVfModuleStructure (VfModuleStructure vfModuleStructure) {
- if (vfModuleStructure == null) {
- return EMPTY_INSTANCE;
- }
- ASDCElementInfo elementInfo = new ASDCElementInfo(ASDCConfiguration.VF_MODULES_METADATA);
- IVfModuleData moduleMetadata = vfModuleStructure.getVfModuleMetadata();
- elementInfo.addElementInfo("Module Model Name", moduleMetadata.getVfModuleModelName());
- elementInfo.addElementInfo("Module Model Invariant UUID", moduleMetadata.getVfModuleModelInvariantUUID());
- return elementInfo;
- }
-
- /**
- * Create an ASDCElementInfo object from an IArtfiactInfo instance.<br/>
- * <br/>
- * <b>Used information:</b><br/>
- * <ul>
- * <li>IArtifactInfo Name</li>
- * <li>IArtifactInfo UUID</li>
- * </ul>
- *
- * @param artifactInfo The VfModuleStructure to use as source of information (see {@link IArtifactInfo}).
- * @return an ASDCElementInfo using the information held in the IArtifactInfo instance.
- */
- public static final ASDCElementInfo createElementFromVfArtifactInfo (IArtifactInfo artifactInfo) {
- if (artifactInfo == null) {
- return EMPTY_INSTANCE;
- }
- ASDCElementInfo elementInfo = new ASDCElementInfo(artifactInfo.getArtifactType());
- elementInfo.addElementInfo(elementInfo.getType() + " Name", artifactInfo.getArtifactName());
- elementInfo.addElementInfo(elementInfo.getType() + " UUID", artifactInfo.getArtifactUUID());
- return elementInfo;
- }
+ /**
+ * A default, empty instance used in case a source element was not correctly provided.
+ */
+ public static final ASDCElementInfo EMPTY_INSTANCE = new ASDCElementInfo();
+
+ /**
+ * Used to define the other possible ASDC Element types (usually in addition to existing artifact types, etc.).<br/>
+ * <br/>
+ * Possible types allowed:<br/>
+ * <ul>
+ * <li>{@link ASDCElementTypeEnum#VNF_RESOURCE}</li>
+ * <ul>
+ */
+ public static enum ASDCElementTypeEnum {
+ /**
+ * The type VNF_RESOURCE. Represents a VNF_RESOURCE element.
+ */
+ VNF_RESOURCE
+ };
+
+ /**
+ * The map of element information fields useful for logging. The complete contents of this list will be
+ * concatenated.
+ */
+ private final Map<String, String> elementInfoMap = new HashMap<>();
+
+ /**
+ * The type of this element.
+ */
+ private final String type;
+
+ private ASDCElementInfo() {
+ // Private parameterless constructor. Not visible, only used for EMPTY_INSTANCE.
+ this.type = "";
+ }
+
+ /**
+ * Artifact-type based constructor. Requires a valid artifact type.
+ *
+ * @param artifactType The artifact type
+ */
+ private ASDCElementInfo(String artifactType) {
+ // We need the exact type name here...
+ this.type = artifactType;
+ }
+
+ /**
+ * 'Other element type'-based constructor. Requires a valid element type.
+ *
+ * @param elementType An ASDCElementTypeEnum entry. This will usually contain enumerated types not in the existing
+ */
+ private ASDCElementInfo(ASDCElementTypeEnum elementType) {
+ // We need the exact type name here...
+ this.type = elementType.name();
+ }
+
+ /**
+ * Add an information entry (name, UUID, etc.) from an artifact/resource/..., once a at time.
+ *
+ * @param key The key (name) of the information entry (Artifact UUID, Resource Name, etc.)
+ * @param value The value bound to the information entry.
+ */
+ public final void addElementInfo(String key, String value) {
+ if ((key != null) && (value != null)) {
+ this.getElementInfoMap().put(key, value);
+ }
+ }
+
+ /**
+ * Returns an aggregated, formatted list of the expected details about an ASDC element. (non-Javadoc)
+ *
+ * @return An aggregated list of element information entries, comma-separated.
+ * @see java.lang.Object#toString()
+ */
+ @Override
+ public final String toString() {
+ StringBuilder sb = new StringBuilder();
+ List<String> aggregatedElements = new ArrayList<>();
+ for (Entry<String, String> entry : this.getElementInfoMap().entrySet()) {
+ aggregatedElements.add(entry.getKey() + ": " + entry.getValue());
+ }
+ sb.append(aggregatedElements.size() > 0 ? aggregatedElements.get(0) : "");
+ if (aggregatedElements.size() > 1) {
+ for (int i = 1; i < aggregatedElements.size(); ++i) {
+ sb.append(", ");
+ sb.append(aggregatedElements.get(i));
+ }
+ }
+ return sb.toString();
+ }
+
+ /**
+ * The type that was defined at creation time. This is typically VNF_RESOURCE, VF_MODULE_METADATA, HEAT_ENV, etc.
+ *
+ * @return The type of this element information type. This will usually be either an ArtifactTypeEnum entry name or
+ * an ASDCElementTypeEnum entry name.
+ * @see ASDCElementInfo.ASDCElementTypeEnum
+ */
+ public String getType() {
+ return type;
+ }
+
+ /**
+ * Provides the map of all element information entries for this type.
+ *
+ * @return A map of all element information entries which will be used by the toString() method.
+ * @see ASDCElementInfo#toString()
+ */
+ protected Map<String, String> getElementInfoMap() {
+ return elementInfoMap;
+ }
+
+ /**
+ * Create an ASDCElementInfo object from a VNF Resource.<br/>
+ * <br/>
+ * <b>Used information:</b><br/>
+ * <ul>
+ * <li>Resource Instance Name</li>
+ * <li>Resource Instance UUID</li>
+ * </ul>
+ *
+ * @param vfResourceStructure The VfResourceStructure to use as source of information (see
+ * {@link VfResourceStructure}).
+ * @return an ASDCElementInfo using the information held in the VNF Resource.
+ */
+ public static final ASDCElementInfo createElementFromVfResourceStructure(VfResourceStructure vfResourceStructure) {
+ if (vfResourceStructure == null) {
+ return EMPTY_INSTANCE;
+ }
+ ASDCElementInfo elementInfo = new ASDCElementInfo(ASDCElementTypeEnum.VNF_RESOURCE);
+ IResourceInstance resourceInstance = vfResourceStructure.getResourceInstance();
+ elementInfo.addElementInfo("Resource Instance Name", resourceInstance.getResourceInstanceName());
+ elementInfo.addElementInfo("Resource Instance Invariant UUID", resourceInstance.getResourceInvariantUUID());
+ return elementInfo;
+ }
+
+ /**
+ * Create an ASDCElementInfo object from a VF Module.<br/>
+ * <br/>
+ * <b>Used information:</b><br/>
+ * <ul>
+ * <li>Module Model Name</li>
+ * <li>Module Model UUID</li>
+ * </ul>
+ *
+ * @param vfModuleStructure The VfModuleStructure to use as source of information (see {@link VfModuleStructure}).
+ * @return an ASDCElementInfo using the information held in the VF Module.
+ */
+ public static final ASDCElementInfo createElementFromVfModuleStructure(VfModuleStructure vfModuleStructure) {
+ if (vfModuleStructure == null) {
+ return EMPTY_INSTANCE;
+ }
+ ASDCElementInfo elementInfo = new ASDCElementInfo(ASDCConfiguration.VF_MODULES_METADATA);
+ IVfModuleData moduleMetadata = vfModuleStructure.getVfModuleMetadata();
+ elementInfo.addElementInfo("Module Model Name", moduleMetadata.getVfModuleModelName());
+ elementInfo.addElementInfo("Module Model Invariant UUID", moduleMetadata.getVfModuleModelInvariantUUID());
+ return elementInfo;
+ }
+
+ /**
+ * Create an ASDCElementInfo object from an IArtfiactInfo instance.<br/>
+ * <br/>
+ * <b>Used information:</b><br/>
+ * <ul>
+ * <li>IArtifactInfo Name</li>
+ * <li>IArtifactInfo UUID</li>
+ * </ul>
+ *
+ * @param artifactInfo The VfModuleStructure to use as source of information (see {@link IArtifactInfo}).
+ * @return an ASDCElementInfo using the information held in the IArtifactInfo instance.
+ */
+ public static final ASDCElementInfo createElementFromVfArtifactInfo(IArtifactInfo artifactInfo) {
+ if (artifactInfo == null) {
+ return EMPTY_INSTANCE;
+ }
+ ASDCElementInfo elementInfo = new ASDCElementInfo(artifactInfo.getArtifactType());
+ elementInfo.addElementInfo(elementInfo.getType() + " Name", artifactInfo.getArtifactName());
+ elementInfo.addElementInfo(elementInfo.getType() + " UUID", artifactInfo.getArtifactUUID());
+ return elementInfo;
+ }
}