private static Map<String, String> linkGlobalPropertyMap(String prefix) { Map<String, String> ret = new HashMap<String, String>(); Map<String, String> map = getGlobalPropertiesStartWith(prefix); if (map.isEmpty()) { return ret; } for (Map.Entry<String, String> e : map.entrySet()) { String key = StringDSL.stripStart(e.getKey(), prefix).trim(); ret.put(key, e.getValue().trim()); } return ret; }
private Field getFieldFromMethod(Object o, Method method) { DebugUtils.Assert(method.getName().startsWith("get"), String.format("only getter can be called on KeyValueEntityProxy, but %s is called", method.getName())); String fieldName = StringDSL.stripStart(method.getName(), "get"); fieldName = StringUtils.uncapitalize(fieldName); Field f = FieldUtils.getField(fieldName, o.getClass()); DebugUtils.Assert(f != null, String.format("cannot find field[%s] on class[%s], %s is a wrong getter", fieldName, o.getClass().getName(), method.getName())); return f; }
private static List linkGlobalPropertyList(String name) { Map<String, String> map = getGlobalPropertiesStartWith(name); List<String> ret = new ArrayList<String>(map.size()); if (map.isEmpty()) { return ret; } List<String> orderedKeys = new ArrayList<String>(); orderedKeys.addAll(map.keySet()); Collections.sort(orderedKeys); for (String key : orderedKeys) { String index = StringDSL.stripStart(key, name).trim(); try { Long.valueOf(index); } catch (NumberFormatException e) { throw new IllegalArgumentException(String.format("[Illegal List Definition] %s is an invalid list key" + " definition, the last character must be a number, for example %s1. %s is not a number", key, key, index)); } ret.add(map.get(key)); } return ret; }
private void collectLegacyTimeout() { for (final Map.Entry<String, String> e : Platform.getGlobalProperties().entrySet()) { String key = e.getKey(); if (!key.startsWith("ApiTimeout.")) { continue; } String apiName = StringDSL.stripStart(key, "ApiTimeout.").trim(); Class apiClz; try { apiClz = Class.forName(apiName); } catch (ClassNotFoundException ex) { String errInfo = "The configuration must be in format of \n" + " ApiTimeout.full_api_class_name = timeout::the_value_of_timeout(e.g. 1h, 30m)"; throw new CloudRuntimeException(String.format("Invalid API timeout configuration[invalid key: %s], %s. %s", key, ex.getMessage(), errInfo)); } String value = e.getValue(); Value val = new Value(key, value); long timeout = parseTimeout(val.getValue("timeout")); legacyTimeouts.put(apiClz, timeout); } }
ini.put("defaults", "inventory", AnsibleConstant.INVENTORY_FILE); for (Map.Entry<String, String> e : cfgs.entrySet()) { String key = StringDSL.stripStart(e.getKey(), "Ansible.cfg."); if (!key.contains(".")) { ini.put("defaults", key, e.getValue()); String key = StringDSL.stripStart(e.getKey(), "Ansible.var."); variables.put(key, e.getValue()); logger.debug(String.format("discovered ansible variable[%s=%s]", key, e.getValue()));