@Test public void testSubscribe2() { String key = "dubbo.test.api.HelloService"; Map<String, String> subscribe = new HashMap<String, String>(); subscribe.put(key, "version=1.0.0&group=test&dubbo.version=2.0.0"); Map<String, String> newSubscribe = UrlUtils.convertSubscribe(subscribe); assertEquals("dubbo.version=2.0.0&group=test&version=1.0.0", newSubscribe.get("test/dubbo.test.api.HelloService:1.0.0")); }
public static Map<String, String> convertSubscribe(Map<String, String> subscribe) { Map<String, String> newSubscribe = new HashMap<String, String>(); for (Map.Entry<String, String> entry : subscribe.entrySet()) { String serviceName = entry.getKey(); String serviceQuery = entry.getValue(); if (!serviceName.contains(":") && !serviceName.contains("/")) { Map<String, String> params = StringUtils.parseQueryString(serviceQuery); String group = params.get("group"); String version = params.get("version"); String name = serviceName; if (group != null && group.length() > 0) { name = group + "/" + name; } if (version != null && version.length() > 0) { name = name + ":" + version; } newSubscribe.put(name, StringUtils.toQueryString(params)); } else { newSubscribe.put(serviceName, serviceQuery); } } return newSubscribe; }
UrlUtils { public static Map<String, String> convertSubscribe(Map<String, String> subscribe) { Map<String, String> newSubscribe = new HashMap<String, String>(); for (Map.Entry<String, String> entry : subscribe.entrySet()) { String serviceName = entry.getKey(); String serviceQuery = entry.getValue(); if (!serviceName.contains(":") && !serviceName.contains("/")) { Map<String, String> params = StringUtils.parseQueryString(serviceQuery); String group = params.get("group"); String version = params.get("version"); String name = serviceName; if (group != null && group.length() > 0) { name = group + "/" + name; } if (version != null && version.length() > 0) { name = name + ":" + version; } newSubscribe.put(name, StringUtils.toQueryString(params)); } else { newSubscribe.put(serviceName, serviceQuery); } } return newSubscribe; } }
UrlUtils { public static Map<String, String> convertSubscribe(Map<String, String> subscribe) { Map<String, String> newSubscribe = new HashMap<String, String>(); for (Map.Entry<String, String> entry : subscribe.entrySet()) { String serviceName = entry.getKey(); String serviceQuery = entry.getValue(); if (!serviceName.contains(":") && !serviceName.contains("/")) { Map<String, String> params = StringUtils.parseQueryString(serviceQuery); String group = params.get("group"); String version = params.get("version"); String name = serviceName; if (group != null && group.length() > 0) { name = group + "/" + name; } if (version != null && version.length() > 0) { name = name + ":" + version; } newSubscribe.put(name, StringUtils.toQueryString(params)); } else { newSubscribe.put(serviceName, serviceQuery); } } return newSubscribe; }  }
UrlUtils { public static Map<String, String> convertSubscribe(Map<String, String> subscribe) { Map<String, String> newSubscribe = new HashMap<String, String>(); for (Map.Entry<String, String> entry : subscribe.entrySet()) { String serviceName = entry.getKey(); String serviceQuery = entry.getValue(); if (!serviceName.contains(":") && !serviceName.contains("/")) { Map<String, String> params = StringUtils.parseQueryString(serviceQuery); String group = params.get("group"); String version = params.get("version"); String name = serviceName; if (group != null && group.length() > 0) { name = group + "/" + name; } if (version != null && version.length() > 0) { name = name + ":" + version; } newSubscribe.put(name, StringUtils.toQueryString(params)); } else { newSubscribe.put(serviceName, serviceQuery); } } return newSubscribe; }  static URL parseURL(String address, Map<String, String> defaults); static List<URL> parseURLs(String address, Map<String, String> defaults); static Map<String, Map<String, String>> convertRegister(Map<String, Map<String, String>> register); static Map<String, String> convertSubscribe(Map<String, String> subscribe); static Map<String, Map<String, String>> revertRegister(Map<String, Map<String, String>> register); static Map<String, String> revertSubscribe(Map<String, String> subscribe); static Map<String, Map<String, String>> revertNotify(Map<String, Map<String, String>> notify); static List<String> revertForbid(List<String> forbid, Set<URL> subscribed); static URL getEmptyUrl(String service, String category); static boolean isMatchCategory(String category, String categories); static boolean isMatch(URL consumerUrl, URL providerUrl); static boolean isMatchGlobPattern(String pattern, String value, URL param); static boolean isMatchGlobPattern(String pattern, String value); static boolean isServiceKeyMatch(URL pattern, URL value); }
UrlUtils { public static Map<String, String> convertSubscribe(Map<String, String> subscribe) { Map<String, String> newSubscribe = new HashMap<String, String>(); for (Map.Entry<String, String> entry : subscribe.entrySet()) { String serviceName = entry.getKey(); String serviceQuery = entry.getValue(); if (!serviceName.contains(":") && !serviceName.contains("/")) { Map<String, String> params = StringUtils.parseQueryString(serviceQuery); String group = params.get("group"); String version = params.get("version"); String name = serviceName; if (group != null && group.length() > 0) { name = group + "/" + name; } if (version != null && version.length() > 0) { name = name + ":" + version; } newSubscribe.put(name, StringUtils.toQueryString(params)); } else { newSubscribe.put(serviceName, serviceQuery); } } return newSubscribe; }  static URL parseURL(String address, Map<String, String> defaults); static List<URL> parseURLs(String address, Map<String, String> defaults); static Map<String, Map<String, String>> convertRegister(Map<String, Map<String, String>> register); static Map<String, String> convertSubscribe(Map<String, String> subscribe); static Map<String, Map<String, String>> revertRegister(Map<String, Map<String, String>> register); static Map<String, String> revertSubscribe(Map<String, String> subscribe); static Map<String, Map<String, String>> revertNotify(Map<String, Map<String, String>> notify); static List<String> revertForbid(List<String> forbid, Set<URL> subscribed); static URL getEmptyUrl(String service, String category); static boolean isMatchCategory(String category, String categories); static boolean isMatch(URL consumerUrl, URL providerUrl); static boolean isMatchGlobPattern(String pattern, String value, URL param); static boolean isMatchGlobPattern(String pattern, String value); static boolean isServiceKeyMatch(URL pattern, URL value);  }