diff options
author | mark.j.leonard <mark.j.leonard@gmail.com> | 2018-06-27 11:46:19 +0100 |
---|---|---|
committer | mark.j.leonard <mark.j.leonard@gmail.com> | 2018-06-27 11:46:37 +0100 |
commit | dc94e09008ba0eb9dce7541d2c898ddc5c500814 (patch) | |
tree | 8bf2edf12dcf5062f120210be85d1e4f337ece2e /src/main/java/org/onap | |
parent | f3bf5dd360b93fd7ef6cc8d871a9903de9f27e5a (diff) |
Remove the Generator Constants class
Move the String constants out of a common class and into the individual
classes where they are used. This eliminates a set of Sonar code smells
relating to non-standard ordering of declarations. It simplifies the
code by removing the need for an empty private constructor in the static
class (i.e. containing static methods only).
Additionally, simplify the AaiModelGenerator interface by removing the
static factory method (which is not currently required). If multiple
implementations are needed we can use Spring annotations in the future.
Issue-ID: AAI-1242
Change-Id: Ica03b66ae2fd899977093d11d3e23dc3f3c8f194
Signed-off-by: mark.j.leonard <mark.j.leonard@gmail.com>
Diffstat (limited to 'src/main/java/org/onap')
6 files changed, 71 insertions, 197 deletions
diff --git a/src/main/java/org/onap/aai/babel/parser/ArtifactGeneratorToscaParser.java b/src/main/java/org/onap/aai/babel/parser/ArtifactGeneratorToscaParser.java index 70e78ec..c769e9a 100644 --- a/src/main/java/org/onap/aai/babel/parser/ArtifactGeneratorToscaParser.java +++ b/src/main/java/org/onap/aai/babel/parser/ArtifactGeneratorToscaParser.java @@ -18,12 +18,8 @@ * limitations under the License. * ============LICENSE_END========================================================= */ -package org.onap.aai.babel.parser; -import static org.onap.aai.babel.xml.generator.data.GeneratorConstants.GENERATOR_AAI_CONFIGFILE_NOT_FOUND; -import static org.onap.aai.babel.xml.generator.data.GeneratorConstants.GENERATOR_AAI_CONFIGLOCATION_NOT_FOUND; -import static org.onap.aai.babel.xml.generator.data.GeneratorConstants.GENERATOR_AAI_PROVIDING_SERVICE_METADATA_MISSING; -import static org.onap.aai.babel.xml.generator.data.GeneratorConstants.GENERATOR_AAI_PROVIDING_SERVICE_MISSING; +package org.onap.aai.babel.parser; import java.io.File; import java.io.FileInputStream; @@ -33,9 +29,7 @@ import java.util.List; import java.util.Map; import java.util.Properties; import java.util.stream.Collectors; - import org.onap.aai.babel.logging.LogHelper; -import org.onap.aai.babel.xml.generator.data.GeneratorConstants; import org.onap.aai.babel.xml.generator.data.WidgetConfigurationUtil; import org.onap.aai.babel.xml.generator.model.AllotedResource; import org.onap.aai.babel.xml.generator.model.L3NetworkWidget; @@ -55,11 +49,26 @@ import org.onap.sdc.toscaparser.api.Property; public class ArtifactGeneratorToscaParser { - public static final String GENERATOR_AAI_ERROR_INVALID_ID = - "Invalid value for mandatory attribute <%s> in Artifact: <%s>"; + private static Logger log = LogHelper.INSTANCE; + + public static final String PROPERTY_ARTIFACT_GENERATOR_CONFIG_FILE = "artifactgenerator.config"; + + private static final String GENERATOR_AAI_CONFIGFILE_NOT_FOUND = + "Cannot generate artifacts. Artifact Generator Configuration file not found at %s"; + private static final String GENERATOR_AAI_CONFIGLOCATION_NOT_FOUND = + "Cannot generate artifacts. artifactgenerator.config system property not configured"; + private static final String GENERATOR_AAI_PROVIDING_SERVICE_METADATA_MISSING = + "Cannot generate artifacts. Providing Service Metadata is missing for allotted resource %s"; + private static final String GENERATOR_AAI_PROVIDING_SERVICE_MISSING = + "Cannot generate artifacts. Providing Service is missing for allotted resource %s"; + + // Metadata properties + private static final String CATEGORY = "category"; private static final String ALLOTTED_RESOURCE = "Allotted Resource"; + private static final String SUBCATEGORY = "subcategory"; private static final String TUNNEL_XCONNECT = "Tunnel XConnect"; - private static Logger log = LogHelper.INSTANCE; + + private static final String VERSION = "version"; private ISdcCsarHelper csarHelper; @@ -95,7 +104,7 @@ public class ArtifactGeneratorToscaParser { */ public static void initWidgetConfiguration() throws IOException { log.debug("Getting Widget Configuration"); - String configLocation = System.getProperty(GeneratorConstants.PROPERTY_ARTIFACT_GENERATOR_CONFIG_FILE); + String configLocation = System.getProperty(PROPERTY_ARTIFACT_GENERATOR_CONFIG_FILE); if (configLocation != null) { File file = new File(configLocation); if (file.exists()) { @@ -111,7 +120,7 @@ public class ArtifactGeneratorToscaParser { } /** - * Generates a Resource List using input Service Node Templates + * Generates a Resource List using input Service Node Templates. * * @param serviceNodes input Service Node Templates * @param idTypeStore ID->Type mapping @@ -254,11 +263,11 @@ public class ArtifactGeneratorToscaParser { } private boolean hasAllottedResource(Map<String, String> metadata) { - return ALLOTTED_RESOURCE.equals(metadata.get(GeneratorConstants.CATEGORY)); + return ALLOTTED_RESOURCE.equals(metadata.get(CATEGORY)); } private boolean hasSubCategoryTunnelXConnect(Map<String, String> metadata) { - return TUNNEL_XCONNECT.equals(metadata.get(GeneratorConstants.SUBCATEGORY)); + return TUNNEL_XCONNECT.equals(metadata.get(SUBCATEGORY)); } /** @@ -286,7 +295,7 @@ public class ArtifactGeneratorToscaParser { String.format(GENERATOR_AAI_PROVIDING_SERVICE_METADATA_MISSING, model.getModelId())); } Map<String, String> properties = populateStringProperties(nodeProperties); - properties.put(GeneratorConstants.VERSION, "1.0"); + properties.put(VERSION, "1.0"); resourceNode.populateModelIdentificationInformation(properties); model.addResource((Resource) resourceNode); } else if (resourceNode instanceof Resource && !(resourceNode.getWidgetType().equals(Widget.Type.L3_NET))) { diff --git a/src/main/java/org/onap/aai/babel/xml/generator/api/AaiArtifactGenerator.java b/src/main/java/org/onap/aai/babel/xml/generator/api/AaiArtifactGenerator.java index c6ca460..79c7492 100644 --- a/src/main/java/org/onap/aai/babel/xml/generator/api/AaiArtifactGenerator.java +++ b/src/main/java/org/onap/aai/babel/xml/generator/api/AaiArtifactGenerator.java @@ -1,5 +1,5 @@ /** - * ============LICENSE_START======================================================= + * ============LICENSE_START======================================================= * org.onap.aai * ================================================================================ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved. @@ -26,7 +26,6 @@ import java.nio.file.Path; import java.util.HashMap; import java.util.List; import java.util.Map; - import org.apache.commons.io.FileUtils; import org.onap.aai.babel.logging.ApplicationMsgs; import org.onap.aai.babel.logging.LogHelper; @@ -35,7 +34,6 @@ import org.onap.aai.babel.xml.generator.data.AdditionalParams; import org.onap.aai.babel.xml.generator.data.Artifact; import org.onap.aai.babel.xml.generator.data.ArtifactType; import org.onap.aai.babel.xml.generator.data.GenerationData; -import org.onap.aai.babel.xml.generator.data.GeneratorConstants; import org.onap.aai.babel.xml.generator.data.GeneratorUtil; import org.onap.aai.babel.xml.generator.data.GroupType; import org.onap.aai.babel.xml.generator.model.Model; @@ -49,10 +47,16 @@ import org.slf4j.MDC; public class AaiArtifactGenerator implements ArtifactGenerator { - private static final String ARTIFACT_MODEL_INFO = "ARTIFACT_MODEL_INFO"; - private static Logger log = LogHelper.INSTANCE; + private static final String MDC_PARAM_MODEL_INFO = "ARTIFACT_MODEL_INFO"; + private static final String GENERATOR_AAI_GENERATED_ARTIFACT_EXTENSION = "xml"; + private static final String GENERATOR_AAI_ERROR_MISSING_SERVICE_TOSCA = "Service tosca missing from list of input artifacts"; + private static final String GENERATOR_AAI_ERROR_MISSING_SERVICE_VERSION = "Cannot generate artifacts. Service version is not specified"; + private static final String GENERATOR_AAI_INVALID_SERVICE_VERSION = "Cannot generate artifacts. Service version is incorrect"; + + private AaiModelGenerator modelGenerator = new AaiModelGeneratorImpl(); + @Override public GenerationData generateArtifact(byte[] csarArchive, List<Artifact> input, Map<String, String> additionalParams) { @@ -65,15 +69,14 @@ public class AaiArtifactGenerator implements ArtifactGenerator { path = createTempFile(csarArchive); if (path != null) { - ISdcCsarHelper csarHelper = - SdcToscaParserFactory.getInstance().getSdcCsarHelper(path.toAbsolutePath().toString()); + ISdcCsarHelper csarHelper = SdcToscaParserFactory.getInstance() + .getSdcCsarHelper(path.toAbsolutePath().toString()); - List<NodeTemplate> serviceNodes = - csarHelper.getServiceNodeTemplates(); + List<NodeTemplate> serviceNodes = csarHelper.getServiceNodeTemplates(); Map<String, String> serviceMetaData = csarHelper.getServiceMetadataAllProperties(); if (serviceNodes == null) { - throw new IllegalArgumentException(GeneratorConstants.GENERATOR_AAI_ERROR_MISSING_SERVICE_TOSCA); + throw new IllegalArgumentException(GENERATOR_AAI_ERROR_MISSING_SERVICE_TOSCA); } // Populate basic service model metadata @@ -91,15 +94,13 @@ public class AaiArtifactGenerator implements ArtifactGenerator { // Process the resource TOSCA files List<Resource> resources = parser.processResourceToscas(serviceNodes, idTypeStore); - // Generate AAI XML service model - AaiModelGenerator modelGenerator = AaiModelGenerator.getInstance(); - MDC.put(ARTIFACT_MODEL_INFO, serviceModel.getModelName() + "," + getArtifactLabel(serviceModel)); + MDC.put(MDC_PARAM_MODEL_INFO, serviceModel.getModelName() + "," + getArtifactLabel(serviceModel)); String aaiServiceModel = modelGenerator.generateModelFor(serviceModel); generationData.add(getServiceArtifact(serviceModel, aaiServiceModel)); // Generate AAI XML resource model for (Resource res : resources) { - MDC.put(ARTIFACT_MODEL_INFO, res.getModelName() + "," + getArtifactLabel(res)); + MDC.put(MDC_PARAM_MODEL_INFO, res.getModelName() + "," + getArtifactLabel(res)); String aaiResourceModel = modelGenerator.generateModelFor(res); generationData.add(getResourceArtifact(res, aaiResourceModel)); @@ -149,7 +150,8 @@ public class AaiArtifactGenerator implements ArtifactGenerator { /** * Method to generate the artifact name for an AAI model. * - * @param model AAI artifact model + * @param model + * AAI artifact model * @return Model artifact name */ private String getArtifactName(Model model) { @@ -165,15 +167,17 @@ public class AaiArtifactGenerator implements ArtifactGenerator { artifactName.append(model.getModelVersion()); artifactName.append("."); - artifactName.append(GeneratorConstants.GENERATOR_AAI_GENERATED_ARTIFACT_EXTENSION); + artifactName.append(GENERATOR_AAI_GENERATED_ARTIFACT_EXTENSION); return artifactName.toString(); } /** * Create Resource artifact model from the AAI xml model string. * - * @param resourceModel Model of the resource artifact - * @param aaiResourceModel AAI model as string + * @param resourceModel + * Model of the resource artifact + * @param aaiResourceModel + * AAI model as string * @return Generated {@link Artifact} model for the resource */ private Artifact getResourceArtifact(Model resourceModel, String aaiResourceModel) { @@ -191,8 +195,10 @@ public class AaiArtifactGenerator implements ArtifactGenerator { /** * Create Service artifact model from the AAI xml model string. * - * @param serviceModel Model of the service artifact - * @param aaiServiceModel AAI model as string + * @param serviceModel + * Model of the service artifact + * @param aaiServiceModel + * AAI model as string * @return Generated {@link Artifact} model for the service */ private Artifact getServiceArtifact(Service serviceModel, String aaiServiceModel) { @@ -227,12 +233,12 @@ public class AaiArtifactGenerator implements ArtifactGenerator { String serviceVersion; serviceVersion = additionalParams.get(AdditionalParams.SERVICE_VERSION.getName()); if (serviceVersion == null) { - throw new IllegalArgumentException(GeneratorConstants.GENERATOR_AAI_ERROR_MISSING_SERVICE_VERSION); + throw new IllegalArgumentException(GENERATOR_AAI_ERROR_MISSING_SERVICE_VERSION); } else { String versionRegex = "^[1-9]\\d*(\\.0)$"; if (!(serviceVersion.matches(versionRegex))) { throw new IllegalArgumentException( - String.format(GeneratorConstants.GENERATOR_AAI_INVALID_SERVICE_VERSION)); + String.format(GENERATOR_AAI_INVALID_SERVICE_VERSION)); } } return serviceVersion; diff --git a/src/main/java/org/onap/aai/babel/xml/generator/api/AaiModelGenerator.java b/src/main/java/org/onap/aai/babel/xml/generator/api/AaiModelGenerator.java index 409dbc2..daf9d36 100644 --- a/src/main/java/org/onap/aai/babel/xml/generator/api/AaiModelGenerator.java +++ b/src/main/java/org/onap/aai/babel/xml/generator/api/AaiModelGenerator.java @@ -1,5 +1,5 @@ /** - * ============LICENSE_START======================================================= + * ============LICENSE_START======================================================= * org.onap.aai * ================================================================================ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved. @@ -20,44 +20,11 @@ */ package org.onap.aai.babel.xml.generator.api; -import static org.onap.aai.babel.xml.generator.data.GeneratorConstants.ERROR_CATEGORY; -import static org.onap.aai.babel.xml.generator.data.GeneratorConstants.ERROR_CODE; -import static org.onap.aai.babel.xml.generator.data.GeneratorConstants.ERROR_DESCRIPTION; -import static org.onap.aai.babel.xml.generator.data.GeneratorConstants.GENERATOR_ERROR_CODE; -import static org.onap.aai.babel.xml.generator.data.GeneratorConstants.GENERATOR_ERROR_SERVICE_INSTANTIATION_FAILED; -import static org.onap.aai.babel.xml.generator.data.GeneratorConstants.GENERATOR_PARTNER_NAME; -import static org.onap.aai.babel.xml.generator.data.GeneratorConstants.PARTNER_NAME; - -import org.onap.aai.babel.logging.ApplicationMsgs; -import org.onap.aai.babel.logging.LogHelper; -import org.onap.aai.babel.xml.generator.logging.CategoryLogLevel; import org.onap.aai.babel.xml.generator.model.Resource; import org.onap.aai.babel.xml.generator.model.Service; -import org.onap.aai.cl.api.Logger; -import org.slf4j.MDC; public interface AaiModelGenerator { - /** - * Gets instance. - * - * @return the instance - */ - public static AaiModelGenerator getInstance() { - Logger log = LogHelper.INSTANCE; - try { - return AaiModelGenerator.class - .cast(Class.forName("org.onap.aai.babel.xml.generator.api.AaiModelGeneratorImpl").newInstance()); - } catch (Exception exception) { - MDC.put(PARTNER_NAME, GENERATOR_PARTNER_NAME); - MDC.put(ERROR_CATEGORY, CategoryLogLevel.ERROR.name()); - MDC.put(ERROR_CODE, GENERATOR_ERROR_CODE); - MDC.put(ERROR_DESCRIPTION, GENERATOR_ERROR_SERVICE_INSTANTIATION_FAILED); - log.error(ApplicationMsgs.PROCESS_REQUEST_ERROR, exception); - } - return null; - } - public String generateModelFor(Service service); public String generateModelFor(Resource resource); diff --git a/src/main/java/org/onap/aai/babel/xml/generator/data/GeneratorConstants.java b/src/main/java/org/onap/aai/babel/xml/generator/data/GeneratorConstants.java deleted file mode 100644 index b9d8cb2..0000000 --- a/src/main/java/org/onap/aai/babel/xml/generator/data/GeneratorConstants.java +++ /dev/null @@ -1,92 +0,0 @@ -/** - * ============LICENSE_START======================================================= - * org.onap.aai - * ================================================================================ - * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved. - * Copyright © 2017-2018 European Software Marketing Ltd. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ -package org.onap.aai.babel.xml.generator.data; - -public class GeneratorConstants { - - /* - * Private constructor to prevent instantiation - */ - private GeneratorConstants() { - throw new UnsupportedOperationException("This static class should not be instantiated!"); - } - - public static final String PROPERTY_ARTIFACT_GENERATOR_CONFIG_FILE = "artifactgenerator.config"; - - public static final String VERSION = "version"; - public static final String CATEGORY = "category"; - public static final String SUBCATEGORY = "subcategory"; - public static final int ID_LENGTH = 36; - - public static final String GENERATOR_AAI_GENERATED_ARTIFACT_EXTENSION = "xml"; - - // Error codes - public static final String GENERATOR_INVOCATION_ERROR_CODE = "ARTIFACT_GENERATOR_INVOCATION_ERROR"; - - // Error Constants - public static final String GENERATOR_ERROR_INVALID_CLIENT_CONFIGURATION = "Invalid Client Configuration"; - public static final String GENERATOR_ERROR_ARTIFACT_GENERATION_FAILED = - "Unable to generate artifacts for the provided input"; - public static final String GENERATOR_ERROR_SERVICE_INSTANTIATION_FAILED = - "Artifact Generation Service Instantiation failed"; - - // AAI Generator Error Messages - public static final String GENERATOR_AAI_ERROR_CHECKSUM_MISMATCH = "Checksum Mismatch for file : %s"; - public static final String GENERATOR_AAI_ERROR_INVALID_TOSCA = "Invalid format for Tosca YML : %s"; - public static final String GENERATOR_AAI_ERROR_UNSUPPORTED_WIDGET_OPERATION = "Operation Not Supported for Widgets"; - public static final String GENERATOR_AAI_ERROR_MISSING_SERVICE_TOSCA = - "Service tosca missing from list of input artifacts"; - public static final String GENERATOR_AAI_ERROR_NULL_RESOURCE_VERSION_IN_SERVICE_TOSCA = - "Invalid Service definition mandatory attribute version missing for resource with UUID: <%s>"; - - public static final String GENERATOR_AAI_ERROR_INVALID_RESOURCE_VERSION_IN_SERVICE_TOSCA = - "Cannot generate artifacts. Invalid Resource version in Service tosca for resource with " + "UUID: " - + "<%s>"; - public static final String GENERATOR_AAI_ERROR_MISSING_RESOURCE_TOSCA = - "Cannot generate artifacts. Resource Tosca missing for resource with UUID: <%s>"; - - public static final String GENERATOR_AAI_ERROR_MISSING_SERVICE_VERSION = - "Cannot generate artifacts. Service version is not specified"; - - public static final String GENERATOR_AAI_INVALID_SERVICE_VERSION = - "Cannot generate artifacts. Service version is incorrect"; - - // Logging constants - public static final String PARTNER_NAME = "userId"; - public static final String ERROR_CATEGORY = "ErrorCategory"; - public static final String ERROR_CODE = "ErrorCode"; - public static final String ERROR_DESCRIPTION = "ErrorDescription"; - - public static final String GENERATOR_ERROR_CODE = "300F"; - public static final String GENERATOR_PARTNER_NAME = "SDC Catalog"; - - // AAI Generator Error Messages for Logging - public static final String GENERATOR_AAI_CONFIGFILE_NOT_FOUND = - "Cannot generate artifacts. Artifact Generator Configuration file not found at %s"; - public static final String GENERATOR_AAI_CONFIGLOCATION_NOT_FOUND = - "Cannot generate artifacts. artifactgenerator.config system property not configured"; - public static final String GENERATOR_AAI_CONFIGLPROP_NOT_FOUND = - "Cannot generate artifacts. Widget configuration not found for %s"; - public static final String GENERATOR_AAI_PROVIDING_SERVICE_MISSING = - "Cannot generate artifacts. Providing Service is missing for allotted resource %s"; - public static final String GENERATOR_AAI_PROVIDING_SERVICE_METADATA_MISSING = - "Cannot generate artifacts. Providing Service Metadata is missing for allotted resource %s"; -} diff --git a/src/main/java/org/onap/aai/babel/xml/generator/model/Model.java b/src/main/java/org/onap/aai/babel/xml/generator/model/Model.java index 0a8f0b1..0ee0838 100644 --- a/src/main/java/org/onap/aai/babel/xml/generator/model/Model.java +++ b/src/main/java/org/onap/aai/babel/xml/generator/model/Model.java @@ -24,12 +24,12 @@ import java.util.HashSet; import java.util.Iterator; import java.util.Map; import java.util.Set; -import org.onap.aai.babel.xml.generator.data.GeneratorConstants; import org.onap.aai.babel.xml.generator.error.IllegalAccessException; import org.onap.aai.babel.xml.generator.types.Cardinality; import org.onap.aai.babel.xml.generator.types.ModelType; public abstract class Model { + public static final String GENERATOR_AAI_ERROR_UNSUPPORTED_WIDGET_OPERATION = "Operation Not Supported for Widgets"; protected Set<Resource> resources = new HashSet<>(); protected Set<Widget> widgets = new HashSet<>(); @@ -242,7 +242,7 @@ public abstract class Model { private void checkSupported() { if (this instanceof Widget) { - throw new IllegalAccessException(GeneratorConstants.GENERATOR_AAI_ERROR_UNSUPPORTED_WIDGET_OPERATION); + throw new IllegalAccessException(GENERATOR_AAI_ERROR_UNSUPPORTED_WIDGET_OPERATION); } } } diff --git a/src/main/java/org/onap/aai/babel/xml/generator/model/Widget.java b/src/main/java/org/onap/aai/babel/xml/generator/model/Widget.java index 2a85e27..be58844 100644 --- a/src/main/java/org/onap/aai/babel/xml/generator/model/Widget.java +++ b/src/main/java/org/onap/aai/babel/xml/generator/model/Widget.java @@ -1,5 +1,5 @@ /** - * ============LICENSE_START======================================================= + * ============LICENSE_START======================================================= * org.onap.aai * ================================================================================ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved. @@ -20,15 +20,12 @@ */ package org.onap.aai.babel.xml.generator.model; -import static org.onap.aai.babel.xml.generator.data.GeneratorConstants.GENERATOR_AAI_CONFIGLPROP_NOT_FOUND; - import java.util.Collections; import java.util.HashSet; import java.util.List; import java.util.Properties; import java.util.Set; import org.onap.aai.babel.xml.generator.data.ArtifactType; -import org.onap.aai.babel.xml.generator.data.GeneratorConstants; import org.onap.aai.babel.xml.generator.data.WidgetConfigurationUtil; import org.onap.aai.babel.xml.generator.error.IllegalAccessException; import org.onap.aai.babel.xml.generator.types.ModelType; @@ -36,16 +33,22 @@ import org.onap.aai.babel.xml.generator.types.ModelWidget; public abstract class Widget extends Model { + public static final String GENERATOR_AAI_CONFIGLPROP_NOT_FOUND = "Cannot generate artifacts. Widget configuration not found for %s"; + + public enum Type { + SERVICE, VF, VFC, VSERVER, VOLUME, FLAVOR, TENANT, VOLUME_GROUP, LINT, L3_NET, VFMODULE, IMAGE, OAM_NETWORK, ALLOTTED_RESOURCE, TUNNEL_XCONNECT; + } + private Set<String> keys = new HashSet<>(); /** * Gets widget. * - * @param type the type + * @param type + * the type * @return the widget */ public static Widget getWidget(Type type) { - switch (type) { case SERVICE: return new ServiceWidget(); @@ -82,11 +85,6 @@ public abstract class Widget extends Model { } } - /** - * Gets id. - * - * @return the id - */ public String getId() { Properties properties = WidgetConfigurationUtil.getConfig(); String id = properties.getProperty(ArtifactType.AAI.name() + ".model-version-id." + getName()); @@ -136,7 +134,8 @@ public abstract class Widget extends Model { /** * Equals. * - * @param obj Object + * @param obj + * Object * @return the boolean */ @Override @@ -159,7 +158,8 @@ public abstract class Widget extends Model { /** * Member of boolean. * - * @param keys the keys + * @param keys + * the keys * @return the boolean */ public boolean memberOf(List<String> keys) { @@ -172,7 +172,8 @@ public abstract class Widget extends Model { /** * All instances used boolean. * - * @param collection the collection + * @param collection + * the collection * @return the boolean */ public boolean allInstancesUsed(Set<String> collection) { @@ -183,7 +184,7 @@ public abstract class Widget extends Model { @Override public boolean addResource(Resource resource) { - throw new IllegalAccessException(GeneratorConstants.GENERATOR_AAI_ERROR_UNSUPPORTED_WIDGET_OPERATION); + throw new IllegalAccessException(Model.GENERATOR_AAI_ERROR_UNSUPPORTED_WIDGET_OPERATION); } @Override @@ -191,21 +192,4 @@ public abstract class Widget extends Model { return true; } - public enum Type { - SERVICE, - VF, - VFC, - VSERVER, - VOLUME, - FLAVOR, - TENANT, - VOLUME_GROUP, - LINT, - L3_NET, - VFMODULE, - IMAGE, - OAM_NETWORK, - ALLOTTED_RESOURCE, - TUNNEL_XCONNECT - } } |