aboutsummaryrefslogtreecommitdiffstats
path: root/catalog-be
diff options
context:
space:
mode:
authoraribeiro <anderson.ribeiro@est.tech>2020-09-15 08:20:39 +0100
committerAnderson Ribeiro <anderson.ribeiro@est.tech>2020-09-29 06:33:44 +0000
commit0fa53516c409ac136f654475c1e41c77cad9cf09 (patch)
treeed7fc3e956fe8a1a12a0726fa81c673f4eb72951 /catalog-be
parentf2d671f77248730e10d925ae5f8c02abc09de6e1 (diff)
Allow hot reloading of specific config properties
getGlobalCsarImports and getDefaultImports entries are now not static which will allow to get new values if the config file change during runtime. Issue-ID: SDC-3303 Signed-off-by: aribeiro <anderson.ribeiro@est.tech> Change-Id: I870c13aec5d386aa3c87d6a335b5fb5948073954
Diffstat (limited to 'catalog-be')
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/tosca/CsarUtils.java12
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java24
2 files changed, 19 insertions, 17 deletions
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/CsarUtils.java b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/CsarUtils.java
index e19ea21c74..61068f26a8 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/CsarUtils.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/CsarUtils.java
@@ -22,13 +22,14 @@ package org.openecomp.sdc.be.tosca;
import static org.openecomp.sdc.be.tosca.ComponentCache.MergeStrategy.overwriteIfSameVersions;
+import static org.openecomp.sdc.be.tosca.FJToVavrHelper.Try0.fromEither;
import fj.F;
import fj.data.Either;
import java.text.SimpleDateFormat;
import io.vavr.Tuple2;
-import io.vavr.control.Try;
import io.vavr.control.Option;
+import io.vavr.control.Try;
import java.io.BufferedOutputStream;
import java.io.ByteArrayInputStream;
import java.io.File;
@@ -68,7 +69,6 @@ import org.apache.commons.lang3.tuple.ImmutableTriple;
import org.apache.commons.lang3.tuple.Triple;
import org.onap.sdc.tosca.services.YamlUtil;
import org.openecomp.sdc.be.components.impl.ImportUtils;
-import org.openecomp.sdc.be.components.impl.ImportUtils.Constants;
import org.openecomp.sdc.be.components.impl.exceptions.ByResponseFormatComponentException;
import org.openecomp.sdc.be.config.ArtifactConfigManager;
import org.openecomp.sdc.be.config.ArtifactConfiguration;
@@ -96,7 +96,6 @@ import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
import org.openecomp.sdc.be.model.operations.impl.DaoStatusConverter;
import org.openecomp.sdc.be.plugins.CsarEntryGenerator;
import org.openecomp.sdc.be.resources.data.DAOArtifactData;
-import org.openecomp.sdc.be.tosca.model.ToscaTemplate;
import org.openecomp.sdc.be.tosca.utils.OperationArtifactUtil;
import org.openecomp.sdc.be.utils.TypeUtils.ToscaTagNamesEnum;
import org.openecomp.sdc.common.api.ArtifactGroupTypeEnum;
@@ -113,8 +112,6 @@ import org.openecomp.sdc.exception.ResponseFormat;
import org.springframework.beans.factory.annotation.Autowired;
import org.yaml.snakeyaml.Yaml;
-import static org.openecomp.sdc.be.tosca.FJToVavrHelper.Try0.fromEither;
-
/**
* @author tg851x
*
@@ -139,8 +136,6 @@ public class CsarUtils {
@Autowired(required = false)
private List<CsarEntryGenerator> generators;
- private static final List<String> globalCsarImports = ConfigurationManager.getConfigurationManager()
- .getConfiguration().getGlobalCsarImports();
private static final String CONFORMANCE_LEVEL = ConfigurationManager.getConfigurationManager().getConfiguration().getToscaConformanceLevel();
private static final String SDC_VERSION = ExternalConfiguration.getAppVersion();
public static final String ARTIFACTS_PATH = "Artifacts/";
@@ -618,7 +613,8 @@ public class CsarUtils {
* @return true if the zip entry should be handled
*/
private boolean shouldZipEntryBeHandled(final String entryName) {
- return globalCsarImports.stream()
+ return ConfigurationManager.getConfigurationManager().getConfiguration()
+ .getGlobalCsarImports().stream()
.anyMatch(entry -> entry.contains(entryName));
}
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java
index b59930e6c3..533ed7a6f0 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java
@@ -166,8 +166,6 @@ public class ToscaExportHandler {
public static final String ASSET_TOSCA_TEMPLATE = "assettoscatemplate";
private static final String FAILED_TO_GET_DEFAULT_IMPORTS_CONFIGURATION = "convertToToscaTemplate - failed to get Default Imports section from configuration";
private static final String NOT_SUPPORTED_COMPONENT_TYPE = "Not supported component type {}";
- private static final List<Map<String, Map<String, String>>> DEFAULT_IMPORTS = ConfigurationManager
- .getConfigurationManager().getConfiguration().getDefaultImports();
private static final String NATIVE_ROOT = "tosca.nodes.Root";
private static YamlUtil yamlUtil = new YamlUtil();
@@ -180,7 +178,8 @@ public class ToscaExportHandler {
public Either<ToscaRepresentation, ToscaError> exportComponentInterface(final Component component,
final boolean isAssociatedComponent) {
- if (null == DEFAULT_IMPORTS) {
+ final List<Map<String, Map<String, String>>> defaultToscaImportConfig = getDefaultToscaImportConfig();
+ if (CollectionUtils.isEmpty(defaultToscaImportConfig)) {
log.debug(FAILED_TO_GET_DEFAULT_IMPORTS_CONFIGURATION);
return Either.right(ToscaError.GENERAL_ERROR);
}
@@ -190,7 +189,7 @@ public class ToscaExportHandler {
toscaVersion = ((Resource) component).getToscaVersion();
}
ToscaTemplate toscaTemplate = new ToscaTemplate(toscaVersion != null ? toscaVersion : TOSCA_VERSION);
- toscaTemplate.setImports(new ArrayList<>(DEFAULT_IMPORTS));
+ toscaTemplate.setImports(new ArrayList<>(defaultToscaImportConfig));
final Map<String, ToscaNodeType> nodeTypes = new HashMap<>();
final Either<ToscaTemplate, ToscaError> toscaTemplateRes =
convertInterfaceNodeType(new HashMap<>(), component, toscaTemplate, nodeTypes, isAssociatedComponent);
@@ -238,7 +237,8 @@ public class ToscaExportHandler {
}
public Either<ToscaTemplate, ToscaError> convertToToscaTemplate(final Component component) {
- if (null == DEFAULT_IMPORTS) {
+ final List<Map<String, Map<String, String>>> defaultToscaImportConfig = getDefaultToscaImportConfig();
+ if (CollectionUtils.isEmpty(defaultToscaImportConfig)) {
log.debug(FAILED_TO_GET_DEFAULT_IMPORTS_CONFIGURATION);
return Either.right(ToscaError.GENERAL_ERROR);
}
@@ -249,7 +249,7 @@ public class ToscaExportHandler {
}
final ToscaTemplate toscaTemplate = new ToscaTemplate(toscaVersion != null ? toscaVersion : TOSCA_VERSION);
toscaTemplate.setMetadata(convertMetadata(component));
- toscaTemplate.setImports(new ArrayList<>(DEFAULT_IMPORTS));
+ toscaTemplate.setImports(new ArrayList<>(defaultToscaImportConfig));
final Map<String, ToscaNodeType> nodeTypes = new HashMap<>();
if (ModelConverter.isAtomicComponent(component)) {
log.trace("convert component as node type");
@@ -487,15 +487,17 @@ public class ToscaExportHandler {
private Either<ImmutablePair<ToscaTemplate, Map<String, Component>>, ToscaError> fillImports(Component component,
ToscaTemplate toscaTemplate) {
- if (null == DEFAULT_IMPORTS) {
+ final List<Map<String, Map<String, String>>> defaultToscaImportConfig = getDefaultToscaImportConfig();
+ if (CollectionUtils.isEmpty(defaultToscaImportConfig)) {
log.debug(FAILED_TO_GET_DEFAULT_IMPORTS_CONFIGURATION);
return Either.right(ToscaError.GENERAL_ERROR);
}
Map<String, Component> componentCache = new HashMap<>();
if (!ModelConverter.isAtomicComponent(component)) {
- List<Map<String, Map<String, String>>> additionalImports = toscaTemplate.getImports() == null
- ? new ArrayList<>(DEFAULT_IMPORTS) : new ArrayList<>(toscaTemplate.getImports());
+ final List<Map<String, Map<String, String>>> additionalImports =
+ toscaTemplate.getImports() == null ? new ArrayList<>(defaultToscaImportConfig)
+ : new ArrayList<>(toscaTemplate.getImports());
List<Triple<String, String, Component>> dependecies = new ArrayList<>();
@@ -525,6 +527,10 @@ public class ToscaExportHandler {
return Either.left(new ImmutablePair<>(toscaTemplate, componentCache));
}
+ private List<Map<String, Map<String, String>>> getDefaultToscaImportConfig() {
+ return ConfigurationManager.getConfigurationManager().getConfiguration().getDefaultImports();
+ }
+
private void createDependency(final Map<String, Component> componentCache,
final List<Map<String, Map<String, String>>> imports,
final List<Triple<String, String, Component>> dependencies,