sureshanaparti commented on code in PR #5797:
URL: https://github.com/apache/cloudstack/pull/5797#discussion_r847074543


##########
server/src/main/java/com/cloud/configuration/ConfigurationManagerImpl.java:
##########
@@ -7311,6 +7319,82 @@ public String getConfigComponentName() {
         };
     }
 
+    @Override
+    public String getConfigurationType(final String configName) {
+        final ConfigurationVO cfg = _configDao.findByName(configName);
+        if (cfg == null) {
+            s_logger.error("Configuration " + configName + " not found");
+            return Configuration.ValueType.String.name();
+        }
+
+        if (weightBasedParametersForValidation.contains(configName)) {
+            return Configuration.ValueType.Range.name();
+        }
+
+        Class<?> type = null;
+        final Config c = Config.getConfig(configName);
+        if (c == null) {
+            s_logger.warn("Configuration " + configName + " no found. Perhaps 
moved to ConfigDepot");
+            final ConfigKey<?> configKey = _configDepot.get(configName);
+            if (configKey == null) {
+                s_logger.warn("Couldn't find configuration " + configName + " 
in ConfigDepot too.");
+                return null;
+            }
+            type = configKey.type();
+        } else {
+            type = c.getType();
+        }
+
+        return getInputType(type);
+    }
+
+    private String getInputType(Class<?> type) {
+        if (type == null) {
+            return Configuration.ValueType.String.name();
+        }
+
+        if (type == String.class || type == Character.class) {
+            return Configuration.ValueType.String.name();
+        } else if (type == Integer.class || type == Long.class || type == 
Short.class) {
+            return Configuration.ValueType.Number.name();
+        } else if (type == Float.class || type == Double.class) {
+            return Configuration.ValueType.Decimal.name();
+        } else if (type == Boolean.class) {
+            return Configuration.ValueType.Boolean.name();
+        //} else if (type == Date.class) {
+        //    return Configuration.InputType.Date.name();
+        } else {
+            return Configuration.ValueType.String.name();
+        }
+    }
+
+    @Override
+    public Pair<String, String> getConfigurationGroupAndSubGroup(final String 
configName) {
+        if (StringUtils.isNotBlank(configName)) {
+            final ConfigurationVO cfg = _configDao.findByName(configName);
+            if (cfg != null) {
+                ConfigurationSubGroupVO configSubGroup = 
_configSubGroupDao.findById(cfg.getSubGroupId());
+                if (configSubGroup != null) {
+                    String subGroupName = configSubGroup.getName();
+                    ConfigurationGroupVO configGroup = 
_configGroupDao.findById(configSubGroup.getGroupId());
+                    String groupName = configGroup != null ? 
configGroup.getName() : "Miscellaneous";
+                    return new Pair<String, String>(groupName, subGroupName);
+                }
+            } else {
+                s_logger.warn("Configuration " + configName + " not found");
+            }
+        }
+
+        s_logger.debug("Returning default configuration group for config: " + 
configName);

Review Comment:
   keeping default group for now, not to fail the response. will check.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to