Example usage for org.apache.commons.lang NullArgumentException NullArgumentException

List of usage examples for org.apache.commons.lang NullArgumentException NullArgumentException

Introduction

In this page you can find the example usage for org.apache.commons.lang NullArgumentException NullArgumentException.

Prototype

public NullArgumentException(String argName) 

Source Link

Document

Instantiates with the given argument name.

Usage

From source file:net.ymate.module.oauth.impl.DefaultOAuthStorageAdapter.java

@Override
public OAuthClientUserBean findUserByRefreshToken(String clientId, String refreshToken) throws Exception {
    if (StringUtils.isBlank(clientId)) {
        throw new NullArgumentException("clientId");
    }//from  www.j ava  2  s  . co  m
    if (StringUtils.isBlank(refreshToken)) {
        throw new NullArgumentException("refreshToken");
    }
    OAuthUser _user = OAuthUser.builder().clientId(clientId).refreshToken(refreshToken).build().findFirst();
    if (_user != null) {
        return toOAuthClientUserBean(_user);
    }
    return null;
}

From source file:net.ymate.module.oauth.impl.ImplicitGrantProcessor.java

public ImplicitGrantProcessor(IOAuth owner, ResponseType responseType) {
    super(owner);
    ///*from   w  ww .  j  av  a2s  .  c  o m*/
    if (responseType == null) {
        throw new NullArgumentException("responseType");
    }
    __responseType = responseType;
}

From source file:net.ymate.module.webproxy.impl.DefaultModuleCfg.java

public DefaultModuleCfg(YMP owner) {
    Map<String, String> _moduleCfgs = owner.getConfig().getModuleConfigs(IWebProxy.MODULE_NAME);
    ///*from   ww  w . j a  va 2  s. co m*/
    __serviceBaseUrl = _moduleCfgs.get("service_base_url");
    if (StringUtils.isBlank(__serviceBaseUrl)) {
        throw new NullArgumentException("service_base_url");
    }
    if (!StringUtils.startsWithIgnoreCase(__serviceBaseUrl, "http://")
            && !StringUtils.startsWithIgnoreCase(__serviceBaseUrl, "https://")) {
        throw new IllegalArgumentException("Argument service_base_url must be start with http or https");
    } else if (StringUtils.endsWith(__serviceBaseUrl, "/")) {
        __serviceBaseUrl = StringUtils.substringBeforeLast(__serviceBaseUrl, "/");
    }
    //
    __serviceRequestPrefix = StringUtils.trimToEmpty(_moduleCfgs.get("service_request_prefix"));
    if (StringUtils.isNotBlank(__serviceRequestPrefix)
            && !StringUtils.startsWith(__serviceRequestPrefix, "/")) {
        __serviceRequestPrefix = "/" + __serviceRequestPrefix;
    }
    //
    __useProxy = BlurObject.bind(_moduleCfgs.get("use_proxy")).toBooleanValue();
    if (__useProxy) {
        Proxy.Type _proxyType = Proxy.Type
                .valueOf(StringUtils.defaultIfBlank(_moduleCfgs.get("proxy_type"), "HTTP").toUpperCase());
        int _proxyPrort = BlurObject.bind(StringUtils.defaultIfBlank(_moduleCfgs.get("proxy_port"), "80"))
                .toIntValue();
        String _proxyHost = _moduleCfgs.get("proxy_host");
        if (StringUtils.isBlank(_proxyHost)) {
            throw new NullArgumentException("proxy_host");
        }
        __proxy = new Proxy(_proxyType, new InetSocketAddress(_proxyHost, _proxyPrort));
    }
    //
    __useCaches = BlurObject.bind(_moduleCfgs.get("use_caches")).toBooleanValue();
    __instanceFollowRedirects = BlurObject.bind(_moduleCfgs.get("instance_follow_redirects")).toBooleanValue();
    //
    __connectTimeout = BlurObject.bind(_moduleCfgs.get("connect_timeout")).toIntValue();
    __readTimeout = BlurObject.bind(_moduleCfgs.get("read_timeout")).toIntValue();
    //
    __transferBlackList = Arrays
            .asList(StringUtils.split(StringUtils.trimToEmpty(_moduleCfgs.get("transfer_blacklist")), "|"));
    //
    __transferHeaderEnabled = BlurObject.bind(_moduleCfgs.get("transfer_header_enabled")).toBooleanValue();
    //
    if (__transferHeaderEnabled) {
        String[] _filters = StringUtils
                .split(StringUtils.lowerCase(_moduleCfgs.get("transfer_header_whitelist")), "|");
        if (_filters != null && _filters.length > 0) {
            __transferHeaderWhiteList = Arrays.asList(_filters);
        } else {
            __transferHeaderWhiteList = Collections.emptyList();
        }
        //
        _filters = StringUtils.split(StringUtils.lowerCase(_moduleCfgs.get("transfer_header_blacklist")), "|");
        if (_filters != null && _filters.length > 0) {
            __transferHeaderBlackList = Arrays.asList(_filters);
        } else {
            __transferHeaderBlackList = Collections.emptyList();
        }
        //
        _filters = StringUtils.split(StringUtils.lowerCase(_moduleCfgs.get("response_header_whitelist")), "|");
        if (_filters != null && _filters.length > 0) {
            __responseHeaderWhiteList = Arrays.asList(_filters);
        } else {
            __responseHeaderWhiteList = Collections.emptyList();
        }
    } else {
        __transferHeaderWhiteList = Collections.emptyList();
        __transferHeaderBlackList = Collections.emptyList();
        //
        __responseHeaderWhiteList = Collections.emptyList();
    }
}

From source file:net.ymate.platform.commons.lang.TreeObject.java

public static final TreeObject fromJson(JSONObject json) {
    if (json == null) {
        throw new NullArgumentException("json");
    }/* w ww  .  j  ava2s  .co  m*/
    if (!json.containsKey(KEY_CLASS)) {
        throw new IllegalArgumentException();
    }
    int _class = json.getIntValue(KEY_CLASS);
    TreeObject _target = new TreeObject();
    if (_class == TYPE_MAP) { // MAP
        JSONObject _value = json.getJSONObject(KEY_VALUE);
        Iterator<String> _valueIt = _value.keySet().iterator();
        while (_valueIt.hasNext()) {
            String _key = _valueIt.next();
            _target.put(_key, fromJson(_value.getJSONObject(_key)));
        }
    } else if (_class == TYPE_COLLECTION) { // COLLECTION
        JSONArray _value = json.getJSONArray(KEY_VALUE);
        for (int _idx = 0; _idx < _value.size(); _idx++) {
            _target.add(fromJson(_value.getJSONObject(_idx)));
        }
    } else { // VALUE
        Object _value = json.get(KEY_VALUE);
        if (_class == TYPE_MIX_STRING) {
            _value = new String(Base64.decodeBase64((String) _value));
        } else if (_class == TYPE_BYTES) {
            _value = Base64.decodeBase64((String) _value);
        }
        _target = new TreeObject(_value, _class);
    }
    return _target;
}

From source file:net.ymate.platform.configuration.impl.DefaultConfigurationProvider.java

public void load(String cfgFileName) throws Exception {
    if (StringUtils.isBlank(cfgFileName)) {
        throw new NullArgumentException("cfgFileName");
    }// w w w  . j av  a  2 s  . c  o m
    if ((__config = __CONFIG_CACHE_MAPS.get(cfgFileName)) == null) {
        this.__cfgFileName = cfgFileName;
        __config = new XMLConfigFileHandler(FileUtils.toURL(cfgFileName)).load(true);
        __CONFIG_CACHE_MAPS.put(cfgFileName, __config);
    }
}

From source file:net.ymate.platform.configuration.impl.PropertyConfigurationProvider.java

public void load(String cfgFileName) throws Exception {
    if (StringUtils.isBlank(cfgFileName)) {
        throw new NullArgumentException("cfgFileName");
    }//from   www .  j  a v  a 2s  .com
    if ((__config = __CONFIG_CACHE_MAPS.get(cfgFileName)) == null) {
        this.__cfgFileName = cfgFileName;
        __config = new PropertyConfigFileHandler(FileUtils.toURL(cfgFileName)).load(true);
        __CONFIG_CACHE_MAPS.put(cfgFileName, __config);
    }
}

From source file:net.ymate.platform.core.beans.BeanMeta.java

/**
 * /*from   w  w  w  .  j a v  a 2 s .c  om*/
 *
 * @param beanClass  ?Bean
 * @param singleton  ???
 * @param beanObject ????
 */
public BeanMeta(Class<?> beanClass, boolean singleton, Object beanObject) {
    __beanClass = beanClass;
    __singleton = singleton;
    __beanObject = beanObject;
    if (singleton && beanObject == null) {
        throw new NullArgumentException("beanObject");
    }
}

From source file:net.ymate.platform.core.beans.BeanMeta.java

public void setBeanObject(Object beanObject) {
    if (!__singleton || beanObject == null) {
        throw new NullArgumentException("Not singleton Or beanObject was null");
    }//from   www  .j  av  a 2  s . c o  m
    __beanObject = beanObject;
}

From source file:net.ymate.platform.core.lang.TreeObject.java

public static TreeObject fromJson(JSONObject json) {
    if (json == null) {
        throw new NullArgumentException("json");
    }/*from   www .j  av a 2s  . c om*/
    if (!json.containsKey(KEY_CLASS)) {
        throw new IllegalArgumentException();
    }
    int _class = json.getIntValue(KEY_CLASS);
    TreeObject _target = new TreeObject();
    if (_class == TYPE_MAP) { // MAP
        JSONObject _value = json.getJSONObject(KEY_VALUE);
        for (String _key : _value.keySet()) {
            _target.put(_key, fromJson(_value.getJSONObject(_key)));
        }
    } else if (_class == TYPE_COLLECTION) { // COLLECTION
        JSONArray _value = json.getJSONArray(KEY_VALUE);
        for (int _idx = 0; _idx < _value.size(); _idx++) {
            _target.add(fromJson(_value.getJSONObject(_idx)));
        }
    } else { // VALUE
        Object _value = json.get(KEY_VALUE);
        if (_class == TYPE_MIX_STRING) {
            _value = new String(Base64.decodeBase64((String) _value));
        } else if (_class == TYPE_BYTES) {
            _value = Base64.decodeBase64((String) _value);
        }
        _target = new TreeObject(_value, _class);
    }
    return _target;
}

From source file:net.ymate.platform.core.util.FileUtils.java

/**
 * @param filePath //  w  w w.  j av  a 2  s. c o m
 * @return ??URL, ?NULL, jarURL.toString()?filePath??"jar:"
 */
public static URL toURL(String filePath) {
    if (StringUtils.isBlank(filePath)) {
        throw new NullArgumentException("filePath");
    }
    try {
        if (!filePath.startsWith("jar:") && !filePath.startsWith("file:") && !filePath.startsWith("zip:")
                && !filePath.startsWith("http:") && !filePath.startsWith("ftp:")) {

            return new File(filePath).toURI().toURL();
        }
        return new URL(filePath);
    } catch (MalformedURLException e) {
        // DO NOTHING...
    }
    return null;
}