Skip to content

Commit

Permalink
[WFCORE-6503]: Adding WARNING traces
Browse files Browse the repository at this point in the history
Signed-off-by: Emmanuel Hugonnet <[email protected]>
  • Loading branch information
ehsavoie committed Mar 1, 2024
1 parent a549626 commit 3d5976c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -3755,4 +3755,10 @@ OperationFailedRuntimeException capabilityAlreadyRegisteredInContext(String capa

@Message(id = 505, value = "Unsuported deployment yaml file %s with attributes %s")
IllegalArgumentException unsupportedDeployment(String deployment, Set<String> attribues);

@Message(id = 506, value = "The yaml element \"%s\" and its sub-elements are ignored.")
String ignoreYamlElement(String element);

@Message(id = NONE, value = "Thus ignoring element \"%s\".")
String ignoreYamlSubElement(String element);
}
Original file line number Diff line number Diff line change
Expand Up @@ -103,18 +103,25 @@ private void load() {
for (Path file : files) {
if (file != null && Files.exists(file) && Files.isRegularFile(file)) {
Map<String, Object> yamlConfig = Collections.emptyMap();
Yaml yaml = new Yaml(new OperationConstructor(new LoaderOptions()));
try (InputStream inputStream = Files.newInputStream(file)) {
Yaml yaml = new Yaml(new OperationConstructor(new LoaderOptions()));
yamlConfig = yaml.load(inputStream);
} catch (IOException ioex) {
throw MGMT_OP_LOGGER.failedToParseYamlConfigurationFile(file.toAbsolutePath().toString(), ioex);
}
if (yamlConfig.containsKey(CONFIGURATION_ROOT_KEY)) {
Map<String, Object> config = (Map<String, Object>) yamlConfig.get(CONFIGURATION_ROOT_KEY);
for (String excluded : EXCLUDED_ELEMENTS) {
boolean isPresent = config.containsKey(excluded);
Object value = config.remove(excluded);
if(value != null && value instanceof Map && DEPLOYMENT.equals(excluded)) {
deployments.putAll((Map<String, Object>) value);
} else if (isPresent) {
String message = MGMT_OP_LOGGER.ignoreYamlElement(excluded);
if(value != null) {
message = message + MGMT_OP_LOGGER.ignoreYamlSubElement(yaml.dump(value).trim());
}
MGMT_OP_LOGGER.warn(message);
}
}
parsedFiles.add(file.toAbsolutePath().toString());
Expand Down

0 comments on commit 3d5976c

Please sign in to comment.