Java Code Examples for org.apache.commons.lang3.StringUtils.isAnyBlank()

The following are Jave code examples for showing how to use isAnyBlank() of the org.apache.commons.lang3.StringUtils class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: knowledge-forest-dialogue-recommendation   File: WechatController.java   View Source Code Vote up 7 votes
@GetMapping(produces = "text/plain;charset=utf-8")
public String authGet(
        @RequestParam(name = "signature", required = false) String signature,
        @RequestParam(name = "timestamp", required = false) String timestamp,
        @RequestParam(name = "nonce", required = false) String nonce,
        @RequestParam(name = "echostr", required = false) String echostr) {

    this.logger.info("\n接收到来自微信服务器的认证消息:[{}, {}, {}, {}]", signature,
            timestamp, nonce, echostr);

    if (StringUtils.isAnyBlank(signature, timestamp, nonce, echostr)) {
        throw new IllegalArgumentException("请求参数非法,请核实!");
    }

    if (this.wxService.checkSignature(timestamp, nonce, signature)) {
        return echostr;
    }

    return "非法请求";
}
 
Example 2
Project: mxhsd   File: Homeserver.java   View Source Code Vote up 6 votes
public Homeserver(HomeserverState state) {
    if (StringUtils.isAnyBlank(state.getAppName(), state.getAppVersion())) {
        throw new IllegalArgumentException("Application name and version must be set");
    }

    this.state = state;

    log.info("Homeserver is {}/{}", state.getAppName(), state.getAppVersion());
}
 
Example 3
Project: azeroth   File: OldApiTopicConsumer.java   View Source Code Vote up 6 votes
/**
 * 按上次记录重置offsets
 */
private void resetCorrectOffsets() {
    String kafkaServers = consumerContext.getProperties().getProperty("bootstrap.servers");
    String zkServers = consumerContext.getProperties().getProperty("zookeeper.connect");
    if (StringUtils.isAnyBlank(kafkaServers, zkServers)) {
        logger.warn(
            "resetCorrectOffsets exit。Please check [bootstrap.servers] and [zookeeper.connect] is existing");
        return;
    }
    ZkConsumerCommand command = new ZkConsumerCommand(zkServers, kafkaServers);
    try {
        List<String> topics = command.getSubscribeTopics(consumerContext.getGroupId());
        for (String topic : topics) {
            List<TopicPartitionInfo> partitions = command
                .getTopicOffsets(consumerContext.getGroupId(), topic);
            for (TopicPartitionInfo partition : partitions) {
                //期望的偏移
                long expectOffsets = consumerContext.getLatestProcessedOffsets(topic,
                    partition.getPartition());
                //
                if (expectOffsets >= 0 && expectOffsets < partition.getOffset()) {
                    command.resetTopicOffsets(consumerContext.getGroupId(), topic,
                        partition.getPartition(), expectOffsets);
                    logger.info("seek Topic[{}] partition[{}] from {} to {}", topic,
                        partition.getPartition(), partition.getOffset(), expectOffsets);
                }
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    command.close();
}
 
Example 4
Project: EasyController   File: UserServiceImpl.java   View Source Code Vote up 6 votes
@Override
public User login(String name, String password) throws ServiceException {
    if (StringUtils.isAnyBlank(name, password)) {
        throw new ServiceException("用户名或密码不能为空!");
    }
    User user = userDao.findByName(name);
    if (StringUtils.equals(user.getPassword(), password)) {
        return user;
    }
    throw new ServiceException("用户名或密码错误,登录失败");
}
 
Example 5
Project: azeroth   File: ResourceUtils.java   View Source Code Vote up 5 votes
public synchronized static void add(String key, String value) {
    if (StringUtils.isAnyBlank(key, value)) { return; }
    allProperties.put(key, value);
}
 
Example 6
Project: EasyController   File: Controller.java   View Source Code Vote up 5 votes
/**
 * 验证验证码
 *
 * @param paraName 验证码参数
 */
public boolean validateCaptcha(String paraName) {
    String captcha = request.getParameter(paraName);
    String captchaKey = KaptchaExtend.getCaptcha(request);
    logger.debug("captcha:{}, captchaKey:{}", captcha, captchaKey);

    if (StringUtils.isAnyBlank(captcha, captchaKey)) {
        return false;
    }
    if (StringUtils.equalsIgnoreCase(captcha, captchaKey)) {
        KaptchaExtend.removeCaptcha(request.getSession());
        return true;
    }
    return false;
}