Java Code Examples for org.thymeleaf.util.StringUtils#isEmpty()

The following examples show how to use org.thymeleaf.util.StringUtils#isEmpty() . 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: GoodsController.java    From SecKillShop with MIT License 6 votes vote down vote up
@RequestMapping("/to_list")
@ResponseBody
public String toList(Model model, MiaoshaUser user, HttpServletRequest request, HttpServletResponse response) {
    model.addAttribute("user", user);
    //取缓存
    String html = redisService.get(GoodsKey.getGoodList, "", String.class);
    if (!StringUtils.isEmpty(html)) {
        return html;
    }
    List<GoodsVo> listGoodsVo = goodsService.listGoodsVo();
    model.addAttribute("listGoodsVo", listGoodsVo);

    WebContext ctx = new WebContext(request, response, request.getServletContext(), request.getLocale(), model.asMap());
    html = thymeleafViewResolver.getTemplateEngine().process("goodlist", ctx);
    if (!StringUtils.isEmpty(html)) {
        redisService.set(GoodsKey.getGoodList, "", html);
    }
    return html;
}
 
Example 2
Source File: RestPreconditionsUtil.java    From alcor with Apache License 2.0 5 votes vote down vote up
public static void populateResourceSegmentId(CustomerResource resource, String segmentId) {
    String resourceSegmentId = null;
    if (resource instanceof SegmentEntity) {
        resourceSegmentId = resource.getId();
    }

    if (StringUtils.isEmpty(resourceSegmentId)) {
        resource.setId(segmentId);
    } else if (!resourceSegmentId.equalsIgnoreCase(segmentId)) {
        logger.log(Level.INFO, "Resource segment id not matched " + resourceSegmentId + " : " + segmentId);
        resource.setId(segmentId);
    }
}
 
Example 3
Source File: RestPreconditionsUtil.java    From alcor with Apache License 2.0 5 votes vote down vote up
public static void populateResourceProjectId(CustomerResource resource, String projectId) {
    String resourceProjectId = resource.getProjectId();
    if (StringUtils.isEmpty(resourceProjectId)) {
        resource.setProjectId(projectId);
    } else if (!resourceProjectId.equalsIgnoreCase(projectId)) {
        System.out.println("Resource id not matched " + resourceProjectId + " : " + projectId);
        resource.setProjectId(projectId);
    }
}
 
Example 4
Source File: UserArgumentResolver.java    From SecKillShop with MIT License 5 votes vote down vote up
@Override
public Object resolveArgument(MethodParameter methodParameter, ModelAndViewContainer modelAndViewContainer, NativeWebRequest nativeWebRequest, WebDataBinderFactory webDataBinderFactory) throws Exception {
    HttpServletRequest request = nativeWebRequest.getNativeRequest(HttpServletRequest.class);
    HttpServletResponse response = nativeWebRequest.getNativeResponse(HttpServletResponse.class);

    String paramsToken = request.getParameter(MiaoshaUserService.LOGIN_COOKIE_TOKEN);
    String cookieToken = getCookieValue(request, MiaoshaUserService.LOGIN_COOKIE_TOKEN);
    if (StringUtils.isEmpty(cookieToken) && StringUtils.isEmpty(paramsToken)) {
        return null;
    }
    String token = StringUtils.isEmpty(paramsToken) ? cookieToken : paramsToken;

    MiaoshaUser user = miaoshaUserService.getMiaoshaUserByToken(token, response);
    return user;
}
 
Example 5
Source File: MiaoshaUserService.java    From SecKillShop with MIT License 5 votes vote down vote up
public MiaoshaUser getMiaoshaUserByToken(String token, HttpServletResponse response) {
    if (StringUtils.isEmpty(token)) {
        return null;
    }
    MiaoshaUser user = redisService.get(MiaoshaKey.token, token, MiaoshaUser.class);
    //when user login and use the website,extend to the cookie datetime
    if (user != null) {
        addCookie(user, token, response);
    }
    return user;
}
 
Example 6
Source File: RestPreconditionsUtil.java    From alcor with Apache License 2.0 5 votes vote down vote up
public static void populateResourceVpcId(CustomerResource resource, String vpcId) {
    String resourceVpcId = null;
    if (resource instanceof VpcEntity) {
        resourceVpcId = resource.getId();
    }

    if (StringUtils.isEmpty(resourceVpcId)) {
        resource.setId(vpcId);
    } else if (!resourceVpcId.equalsIgnoreCase(vpcId)) {
        logger.log(Level.INFO, "Resource vpc id not matched " + resourceVpcId + " : " + vpcId);
        resource.setId(vpcId);
    }
}
 
Example 7
Source File: RestPreconditionsUtil.java    From alcor with Apache License 2.0 5 votes vote down vote up
public static void populateResourceProjectId(CustomerResource resource, String projectId) {
    String resourceProjectId = resource.getProjectId();
    if (StringUtils.isEmpty(resourceProjectId)) {
        resource.setProjectId(projectId);
    } else if (!resourceProjectId.equalsIgnoreCase(projectId)) {
        logger.log(Level.INFO, "Resource id not matched " + resourceProjectId + " : " + projectId);
        resource.setProjectId(projectId);
    }
}
 
Example 8
Source File: WechatGatewaySMOImpl.java    From MicroCommunity with Apache License 2.0 5 votes vote down vote up
/**
 * 文字处理
 *
 * @param fromUserName
 * @param toUserName
 * @param keyword
 * @return
 */
private String textResponseHandler(String fromUserName, String toUserName,
                                   String keyword) {
    if (StringUtils.isEmpty(keyword)) {
        return WechatFactory
                .formatText(toUserName, fromUserName, "未包含任何信息");
    } else {
        String responseStr = keyWordHandler(fromUserName, toUserName,
                keyword);
        return WechatFactory
                .formatText(toUserName, fromUserName, responseStr);
    }
}
 
Example 9
Source File: RestPreconditions.java    From alcor with Apache License 2.0 5 votes vote down vote up
public static void populateResourceVpcId(CustomerResource resource, String vpcId) {
    String resourceVpcId = null;
    if (resource instanceof VpcState) {
        resourceVpcId = resource.getId();
    } else if (resource instanceof SubnetState) {
        resourceVpcId = ((SubnetState) resource).getVpcId();
    }

    if (StringUtils.isEmpty(resourceVpcId)) {
        resource.setId(vpcId);
    } else if (!resourceVpcId.equalsIgnoreCase(vpcId)) {
        System.out.println("Resource vpc id not matched " + resourceVpcId + " : " + vpcId);
        resource.setId(vpcId);
    }
}
 
Example 10
Source File: RestPreconditions.java    From alcor with Apache License 2.0 5 votes vote down vote up
public static void populateResourceProjectId(CustomerResource resource, String projectId) {
    String resourceProjectId = resource.getProjectId();
    if (StringUtils.isEmpty(resourceProjectId)) {
        resource.setProjectId(projectId);
    } else if (!resourceProjectId.equalsIgnoreCase(projectId)) {
        System.out.println("Resource id not matched " + resourceProjectId + " : " + projectId);
        resource.setProjectId(projectId);
    }
}
 
Example 11
Source File: RestPreconditionsUtil.java    From alcor with Apache License 2.0 4 votes vote down vote up
public static void verifyParameterNotNullorEmpty(String resourceId) throws ParameterNullOrEmptyException {
    if (StringUtils.isEmpty(resourceId)) {
        throw new ParameterNullOrEmptyException("Empty parameter");
    }
}
 
Example 12
Source File: RestPreconditionsUtil.java    From alcor with Apache License 2.0 4 votes vote down vote up
public static void verifyResourceNotNull(CustomerResource resource) throws ResourceNullException {
    if (resource == null || StringUtils.isEmpty(resource.getId())) {
        throw new ResourceNullException("Empty resource id");
    }
}
 
Example 13
Source File: RestPreconditions.java    From alcor with Apache License 2.0 4 votes vote down vote up
public static void verifyResourceNotNull(CustomerResource resource) throws ResourceNullException {
    if (resource == null || StringUtils.isEmpty(resource.getId())) {
        throw new ResourceNullException("Empty resource id");
    }
}
 
Example 14
Source File: RestParameterValidator.java    From alcor with Apache License 2.0 4 votes vote down vote up
public static void checkTenantId(String tenantId) throws TenantIdRequired {
    if (StringUtils.isEmpty(tenantId)) {
        throw new TenantIdRequired();
    }
}
 
Example 15
Source File: RestPreconditionsUtil.java    From alcor with Apache License 2.0 4 votes vote down vote up
public static void verifyParameterNotNullorEmpty(String resourceId) throws ParameterNullOrEmptyException {
    if (StringUtils.isEmpty(resourceId)) {
        throw new ParameterNullOrEmptyException("Empty parameter");
    }
}
 
Example 16
Source File: RestPreconditions.java    From alcor with Apache License 2.0 4 votes vote down vote up
public static void verifyParameterEqual(String expectedResourceId, String resourceId) throws ParameterUnexpectedValueException {
    if (StringUtils.isEmpty(resourceId) || !resourceId.equalsIgnoreCase(expectedResourceId)) {
        throw new ParameterUnexpectedValueException("Expeceted value: " + expectedResourceId + " | actual: " + resourceId);
    }
}
 
Example 17
Source File: RestParameterValidator.java    From alcor with Apache License 2.0 4 votes vote down vote up
public static void checkDirection(String direction) throws DirectionRequired {
    if (StringUtils.isEmpty(direction)) {
        throw new DirectionRequired();
    }
}
 
Example 18
Source File: RestPreconditionsUtil.java    From alcor with Apache License 2.0 4 votes vote down vote up
public static void verifyParameterNotNullorEmpty(String resourceId) throws ParameterNullOrEmptyException {
    if (StringUtils.isEmpty(resourceId)) {
        throw new ParameterNullOrEmptyException("Empty parameter");
    }
}
 
Example 19
Source File: MacManagerRestPreconditionsUtil.java    From alcor with Apache License 2.0 4 votes vote down vote up
public static void verifyParameterNotNullorEmpty(String resourceId) throws ParameterNullOrEmptyException {
    if (StringUtils.isEmpty(resourceId)) {
        throw new ParameterNullOrEmptyException("Empty parameter");
    }
}
 
Example 20
Source File: RestPreconditions.java    From alcor with Apache License 2.0 4 votes vote down vote up
public static void verifyParameterNotNullorEmpty(String resourceId) throws ParameterNullOrEmptyException {
    if (StringUtils.isEmpty(resourceId)) {
        throw new ParameterNullOrEmptyException("Empty parameter");
    }
}