Java Code Examples for com.alibaba.dubbo.common.utils.CollectionUtils#split()

The following examples show how to use com.alibaba.dubbo.common.utils.CollectionUtils#split() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RegisterController.java    From open-capacity-platform with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
    protected String doExecute(Map<String, Object> context) throws Exception {
        Map<String, String[]> params = request.getParameterMap();
        if (params == null || params.size() == 0) {
            throw new IllegalArgumentException("The url parameters is null! Usage: " + request.getRequestURL().toString() + "?com.xxx.XxxService=http://" + request.getRemoteAddr() + "/xxxService?application=xxx&foo1=123");
        }
        Map<String, Map<String, String>> map = new HashMap<String, Map<String, String>>();
        for (Map.Entry<String, String[]> entry : params.entrySet()) {
            if (entry.getKey() != null && entry.getKey().length() > 0
                    && entry.getValue() != null && entry.getValue().length > 0
                    && entry.getValue()[0] != null && entry.getValue()[0].length() > 0) {
                if (!currentUser.hasServicePrivilege(entry.getKey())) {
                    throw new IllegalStateException("The user " + currentUser.getUsername() + " have no privilege of service " + entry.getKey());
                }
                String serviceName = entry.getKey();
                Map<String, String> url2query = CollectionUtils.split(Arrays.asList(entry.getValue()), "?");
                // check whether url contain application info
                for (Map.Entry<String, String> e : url2query.entrySet()) {
                    Map<String, String> query = StringUtils.parseQueryString(e.getValue());
                    String app = query.get("application");
                    if (StringUtils.isBlank(app)) {
                        throw new IllegalStateException("No application for service(" + serviceName + "): "
                                + e.getKey() + "?" + e.getValue());
                    }
                }
                map.put(serviceName, url2query);
            }
        }
        if (map.size() > 0) {
//        	providerDAO.register(registryCache.getCurrentRegistry(), request.getRemoteAddr(), operatorAddress, operator, map, false, true);
        }
        return "RegisterController " + map.size() + " services.";
    }
 
Example 2
Source File: Register.java    From dubbox with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
    protected String doExecute(Map<String,Object> context) throws Exception {
    	Map<String, String[]> params = request.getParameterMap();
        if (params == null || params.size() == 0) {
        	throw new IllegalArgumentException("The url parameters is null! Usage: " + request.getRequestURL().toString() + "?com.xxx.XxxService=http://" + request.getRemoteAddr() + "/xxxService?application=xxx&foo1=123");
        }
        Map<String, Map<String, String>> map = new HashMap<String, Map<String, String>>();
        for (Map.Entry<String, String[]> entry : params.entrySet()) {
            if (entry.getKey() != null && entry.getKey().length() > 0
                    && entry.getValue() != null && entry.getValue().length > 0
                    && entry.getValue()[0] != null && entry.getValue()[0].length() > 0) {
            	if (! currentUser.hasServicePrivilege(entry.getKey())) {
					throw new IllegalStateException("The user " + currentUser.getUsername() + " have no privilege of service " + entry.getKey());
				}
            	String serviceName = entry.getKey();
            	Map<String, String> url2query = CollectionUtils.split(Arrays.asList(entry.getValue()), "?");
            	// check whether url contain application info
            	for(Map.Entry<String, String> e : url2query.entrySet()) {
            	   Map<String, String> query = StringUtils.parseQueryString(e.getValue()); 
            	   String app = query.get("application");
            	   if(StringUtils.isBlank(app)) {
            	       throw new IllegalStateException("No application for service(" + serviceName + "): "
            	               + e.getKey() + "?" + e.getValue());
            	   }
            	}
                map.put(serviceName, url2query);
            }
        }
        if (map.size() > 0) {
//        	providerDAO.register(registryCache.getCurrentRegistry(), request.getRemoteAddr(), operatorAddress, operator, map, false, true);
        }
        return "Register " + map.size() + " services.";
    }
 
Example 3
Source File: Register.java    From dubbox-hystrix with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
    protected String doExecute(Map<String,Object> context) throws Exception {
    	Map<String, String[]> params = request.getParameterMap();
        if (params == null || params.size() == 0) {
        	throw new IllegalArgumentException("The url parameters is null! Usage: " + request.getRequestURL().toString() + "?com.xxx.XxxService=http://" + request.getRemoteAddr() + "/xxxService?application=xxx&foo1=123");
        }
        Map<String, Map<String, String>> map = new HashMap<String, Map<String, String>>();
        for (Map.Entry<String, String[]> entry : params.entrySet()) {
            if (entry.getKey() != null && entry.getKey().length() > 0
                    && entry.getValue() != null && entry.getValue().length > 0
                    && entry.getValue()[0] != null && entry.getValue()[0].length() > 0) {
            	if (! currentUser.hasServicePrivilege(entry.getKey())) {
					throw new IllegalStateException("The user " + currentUser.getUsername() + " have no privilege of service " + entry.getKey());
				}
            	String serviceName = entry.getKey();
            	Map<String, String> url2query = CollectionUtils.split(Arrays.asList(entry.getValue()), "?");
            	// check whether url contain application info
            	for(Map.Entry<String, String> e : url2query.entrySet()) {
            	   Map<String, String> query = StringUtils.parseQueryString(e.getValue()); 
            	   String app = query.get("application");
            	   if(StringUtils.isBlank(app)) {
            	       throw new IllegalStateException("No application for service(" + serviceName + "): "
            	               + e.getKey() + "?" + e.getValue());
            	   }
            	}
                map.put(serviceName, url2query);
            }
        }
        if (map.size() > 0) {
//        	providerDAO.register(registryCache.getCurrentRegistry(), request.getRemoteAddr(), operatorAddress, operator, map, false, true);
        }
        return "Register " + map.size() + " services.";
    }
 
Example 4
Source File: Register.java    From dubbo3 with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
    protected String doExecute(Map<String,Object> context) throws Exception {
    	Map<String, String[]> params = request.getParameterMap();
        if (params == null || params.size() == 0) {
        	throw new IllegalArgumentException("The url parameters is null! Usage: " + request.getRequestURL().toString() + "?com.xxx.XxxService=http://" + request.getRemoteAddr() + "/xxxService?application=xxx&foo1=123");
        }
        Map<String, Map<String, String>> map = new HashMap<String, Map<String, String>>();
        for (Map.Entry<String, String[]> entry : params.entrySet()) {
            if (entry.getKey() != null && entry.getKey().length() > 0
                    && entry.getValue() != null && entry.getValue().length > 0
                    && entry.getValue()[0] != null && entry.getValue()[0].length() > 0) {
            	if (! currentUser.hasServicePrivilege(entry.getKey())) {
					throw new IllegalStateException("The user " + currentUser.getUsername() + " have no privilege of service " + entry.getKey());
				}
            	String serviceName = entry.getKey();
            	Map<String, String> url2query = CollectionUtils.split(Arrays.asList(entry.getValue()), "?");
            	// check whether url contain application info
            	for(Map.Entry<String, String> e : url2query.entrySet()) {
            	   Map<String, String> query = StringUtils.parseQueryString(e.getValue()); 
            	   String app = query.get("application");
            	   if(StringUtils.isBlank(app)) {
            	       throw new IllegalStateException("No application for service(" + serviceName + "): "
            	               + e.getKey() + "?" + e.getValue());
            	   }
            	}
                map.put(serviceName, url2query);
            }
        }
        if (map.size() > 0) {
//        	providerDAO.register(registryCache.getCurrentRegistry(), request.getRemoteAddr(), operatorAddress, operator, map, false, true);
        }
        return "Register " + map.size() + " services.";
    }
 
Example 5
Source File: Register.java    From dubbox with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
    protected String doExecute(Map<String,Object> context) throws Exception {
    	Map<String, String[]> params = request.getParameterMap();
        if (params == null || params.size() == 0) {
        	throw new IllegalArgumentException("The url parameters is null! Usage: " + request.getRequestURL().toString() + "?com.xxx.XxxService=http://" + request.getRemoteAddr() + "/xxxService?application=xxx&foo1=123");
        }
        Map<String, Map<String, String>> map = new HashMap<String, Map<String, String>>();
        for (Map.Entry<String, String[]> entry : params.entrySet()) {
            if (entry.getKey() != null && entry.getKey().length() > 0
                    && entry.getValue() != null && entry.getValue().length > 0
                    && entry.getValue()[0] != null && entry.getValue()[0].length() > 0) {
            	if (! currentUser.hasServicePrivilege(entry.getKey())) {
					throw new IllegalStateException("The user " + currentUser.getUsername() + " have no privilege of service " + entry.getKey());
				}
            	String serviceName = entry.getKey();
            	Map<String, String> url2query = CollectionUtils.split(Arrays.asList(entry.getValue()), "?");
            	// check whether url contain application info
            	for(Map.Entry<String, String> e : url2query.entrySet()) {
            	   Map<String, String> query = StringUtils.parseQueryString(e.getValue()); 
            	   String app = query.get("application");
            	   if(StringUtils.isBlank(app)) {
            	       throw new IllegalStateException("No application for service(" + serviceName + "): "
            	               + e.getKey() + "?" + e.getValue());
            	   }
            	}
                map.put(serviceName, url2query);
            }
        }
        if (map.size() > 0) {
//        	providerDAO.register(registryCache.getCurrentRegistry(), request.getRemoteAddr(), operatorAddress, operator, map, false, true);
        }
        return "Register " + map.size() + " services.";
    }
 
Example 6
Source File: Register.java    From dubbox with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
    protected String doExecute(Map<String,Object> context) throws Exception {
    	Map<String, String[]> params = request.getParameterMap();
        if (params == null || params.size() == 0) {
        	throw new IllegalArgumentException("The url parameters is null! Usage: " + request.getRequestURL().toString() + "?com.xxx.XxxService=http://" + request.getRemoteAddr() + "/xxxService?application=xxx&foo1=123");
        }
        Map<String, Map<String, String>> map = new HashMap<String, Map<String, String>>();
        for (Map.Entry<String, String[]> entry : params.entrySet()) {
            if (entry.getKey() != null && entry.getKey().length() > 0
                    && entry.getValue() != null && entry.getValue().length > 0
                    && entry.getValue()[0] != null && entry.getValue()[0].length() > 0) {
            	if (! currentUser.hasServicePrivilege(entry.getKey())) {
					throw new IllegalStateException("The user " + currentUser.getUsername() + " have no privilege of service " + entry.getKey());
				}
            	String serviceName = entry.getKey();
            	Map<String, String> url2query = CollectionUtils.split(Arrays.asList(entry.getValue()), "?");
            	// check whether url contain application info
            	for(Map.Entry<String, String> e : url2query.entrySet()) {
            	   Map<String, String> query = StringUtils.parseQueryString(e.getValue()); 
            	   String app = query.get("application");
            	   if(StringUtils.isBlank(app)) {
            	       throw new IllegalStateException("No application for service(" + serviceName + "): "
            	               + e.getKey() + "?" + e.getValue());
            	   }
            	}
                map.put(serviceName, url2query);
            }
        }
        if (map.size() > 0) {
//        	providerDAO.register(registryCache.getCurrentRegistry(), request.getRemoteAddr(), operatorAddress, operator, map, false, true);
        }
        return "Register " + map.size() + " services.";
    }