use of org.apache.servicecomb.config.kie.client.model.ValueType in project java-chassis by ServiceComb.
the class KieClient method processValueType.
private Map<String, Object> processValueType(KVDoc kvDoc) {
ValueType valueType;
try {
valueType = ValueType.valueOf(kvDoc.getValueType());
} catch (IllegalArgumentException e) {
throw new OperationException("value type not support");
}
Properties properties = new Properties();
Map<String, Object> kvMap = new HashMap<>();
try {
switch(valueType) {
case yml:
case yaml:
YamlPropertiesFactoryBean yamlFactory = new YamlPropertiesFactoryBean();
yamlFactory.setResources(new ByteArrayResource(kvDoc.getValue().getBytes()));
return toMap(yamlFactory.getObject());
case properties:
properties.load(new StringReader(kvDoc.getValue()));
return toMap(properties);
case text:
case string:
default:
kvMap.put(kvDoc.getKey(), kvDoc.getValue());
return kvMap;
}
} catch (Exception e) {
LOGGER.error("read config failed");
}
return Collections.emptyMap();
}
Aggregations