Java Code Examples for org.nutz.lang.Strings#sBlank()

The following examples show how to use org.nutz.lang.Strings#sBlank() . 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: LoachClient.java    From nutzcloud with Apache License 2.0 6 votes vote down vote up
protected boolean _ping() {
    try {
        String pingURL = url + "/ping/" + getServiceName() + "/" + id;
        if (isDebug())
            log.debug("Ping URL=" + pingURL);
        Request req = Request.create(pingURL, METHOD.GET);
        req.getHeader().clear();
        req.getHeader().set("If-None-Match", lastPingETag);
        Response resp = Sender.create(req, conf.getInt("loach.client.ping.timeout", 1000)).setConnTimeout(1000).send();
        String cnt = resp.getContent();
        if (isDebug())
            log.debug("Ping result : " + cnt);
        if (resp.isOK()) {
            lastPingETag = Strings.sBlank(resp.getHeader().get("ETag"), "ABC");
            NutMap re = Json.fromJson(NutMap.class, cnt);
            if (re != null && re.getBoolean("ok", false))
                return true;
        } else if (resp.getStatus() == 304) {
            return true;
        }
    }
    catch (Throwable e) {
        log.debugf("bad url? %s %s", url, e.getMessage());
    }
    return false;
}
 
Example 2
Source File: LoachClient.java    From nutzcloud with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
public void updateServiceList() {
    try {
        String listURL = url + "/list";
        Request req = Request.create(listURL, METHOD.GET);
        req.getHeader().clear();
        req.getHeader().set("If-None-Match", lastListETag);
        Response resp = Sender.create(req).setConnTimeout(1000).setTimeout(3000).send();
        if (resp.isOK()) {
            serviceList = (Map<String, List<NutMap>>) Json.fromJson(NutMap.class, resp.getReader()).get("data");
            for (UpdateListener listener : listeners) {
                listener.onUpdate(serviceList);
            }
            lastChecked = System.currentTimeMillis();
            lastListETag = Strings.sBlank(resp.getHeader().get("ETag", "ABC"));
        } else if (resp.getStatus() == 304) {
            // ok
            lastChecked = System.currentTimeMillis();
        }
    }
    catch (Throwable e) {
        log.debugf("bad url? %s %s", url, e.getMessage());
    }
}
 
Example 3
Source File: WechatAPIImpl.java    From mpsdk4j with Apache License 2.0 6 votes vote down vote up
@Override
public Follower getWebOauth2User(String openId, String lang) {
    lang = Strings.sBlank(lang, "zh_CN");
    WebOauth2Result result = _oath2.get(openId);
    if (result == null){
       throw Lang.wrapThrow(new WechatAPIException("用户未授权"));
    } else if (!result.isAvailable()){
        result = refreshWebOauth2Result(result.getRefreshToken());
    }

    String url = mergeAPIUrl(oauth2UserURL, result.getAccessToken(), openId, lang);
    APIResult ar = wechatServerResponse(url,
            HTTP_GET,
            NONE_BODY,
            "以网页授权方式获取公众号[%s]的用户[%s-%s]信息失败.",
            openId,
            lang);
    return Json.fromJson(Follower.class, ar.getJson());
}
 
Example 4
Source File: WechatAPIImpl.java    From mpsdk4j with Apache License 2.0 5 votes vote down vote up
@Override
public Follower getFollower(String openId, String lang) {
    lang = Strings.sBlank(lang, "zh_CN");
    String url = mergeCgiBinUrl(userInfoURL, getAccessToken(), openId, lang);
    APIResult ar = wechatServerResponse(url,
            HTTP_GET,
            NONE_BODY,
            "获取公众号[%s]关注用户[%s-%s]信息失败.",
            openId,
            lang);
    return Json.fromJson(Follower.class, ar.getJson());
}
 
Example 5
Source File: WxLoginImpl.java    From nutzwx with Apache License 2.0 5 votes vote down vote up
public WxLoginImpl configure(PropertiesProxy conf, String prefix) {
    prefix = Strings.sBlank(prefix);
    appid = conf.get(prefix + "appid");
    appsecret = conf.get(prefix + "appsecret");
    host = conf.get(prefix + "host");
    return this;
}
 
Example 6
Source File: BasicWxHandler.java    From nutzwx with Apache License 2.0 5 votes vote down vote up
public BasicWxHandler configure(PropertiesProxy conf, String prefix){
    prefix = Strings.sBlank(prefix);
    token = conf.check(prefix+"token");
    aeskey = conf.get(prefix+"aes");
    appid = conf.get(prefix+"appid");
    return this;
}
 
Example 7
Source File: AbstractWxApi2.java    From nutzwx with Apache License 2.0 5 votes vote down vote up
public WxApi2 configure(PropertiesProxy conf, String prefix) {
    prefix = Strings.sBlank(prefix);
    token = conf.check(prefix + "token");
    appid = conf.get(prefix + "appid");
    appsecret = conf.get(prefix + "appsecret");
    openid = conf.get(prefix + "openid");
    encodingAesKey = conf.get(prefix + "aes");
    return this;
}
 
Example 8
Source File: WxTemplateData.java    From nutzwx with Apache License 2.0 5 votes vote down vote up
public void set(Object value, Object color) {
    this.value = Strings.sBlank(value);
    this.color = Strings.sBlank(color);

    // if (Strings.isBlank(this.value)) {
    // //throw Lang.makeThrow("blank value");
    // }

    if (Strings.isBlank(this.color)) {
        this.color = DFT_COLOR;
    }
}