本文整理汇总了Java中org.apache.commons.lang3.StringUtils.isNotBlank方法的典型用法代码示例。如果您正苦于以下问题:Java StringUtils.isNotBlank方法的具体用法?Java StringUtils.isNotBlank怎么用?Java StringUtils.isNotBlank使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.lang3.StringUtils
的用法示例。
在下文中一共展示了StringUtils.isNotBlank方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getRemoteIp
import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
/**
* Pulls the remote IP from the current HttpServletRequest, or grabs the value
* for the specified alternative attribute (say, for proxied requests). Falls
* back to providing the "normal" remote address if no value can be retrieved
* from the specified alternative header value.
* @param context the context
* @return the remote ip
*/
private String getRemoteIp(@NotNull final RequestContext context) {
final HttpServletRequest request = WebUtils.getHttpServletRequest(context);
String userAddress = request.getRemoteAddr();
logger.debug("Remote Address = {}", userAddress);
if (StringUtils.isNotBlank(this.alternativeRemoteHostAttribute)) {
userAddress = request.getHeader(this.alternativeRemoteHostAttribute);
logger.debug("Header Attribute [{}] = [{}]", this.alternativeRemoteHostAttribute, userAddress);
if (StringUtils.isBlank(userAddress)) {
userAddress = request.getRemoteAddr();
logger.warn("No value could be retrieved from the header [{}]. Falling back to [{}].",
this.alternativeRemoteHostAttribute, userAddress);
}
}
return userAddress;
}
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:27,代码来源:BaseSpnegoKnownClientSystemsFilterAction.java
示例2: doGetAuthorizationInfo
import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principals) {
SimpleAuthorizationInfo info = new SimpleAuthorizationInfo();
Long userId = (Long) WebUtil.getCurrentUser();
Parameter parameter = new Parameter("sysAuthorizeService", "queryPermissionByUserId").setId(userId);
logger.info("{} execute queryPermissionByUserId start...", parameter.getNo());
List<?> list = provider.execute(parameter).getList();
logger.info("{} execute queryPermissionByUserId end.", parameter.getNo());
for (Object permission : list) {
if (StringUtils.isNotBlank((String) permission)) {
// 添加基于Permission的权限信息
info.addStringPermission((String) permission);
}
}
// 添加用户权限
info.addStringPermission("user");
return info;
}
示例3: viewInput
import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
@RequestMapping("/view.html")
public String viewInput(String orderId, ModelMap model) {
MchNotify item = null;
if(StringUtils.isNotBlank(orderId)) {
item = mchNotifyService.selectMchNotify(orderId);
}
if(item == null) {
item = new MchNotify();
model.put("item", item);
return "mch_notify/view";
}
JSONObject object = (JSONObject) JSON.toJSON(item);
if(item.getCreateTime() != null) object.put("createTime", DateUtil.date2Str(item.getCreateTime()));
if(item.getUpdateTime() != null) object.put("updateTime", DateUtil.date2Str(item.getUpdateTime()));
if(item.getLastNotifyTime() != null) object.put("lastNotifyTime", DateUtil.date2Str(item.getLastNotifyTime()));
model.put("item", object);
return "mch_notify/view";
}
示例4: execute
import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
/**
* Execute this job entry and return the result. In this case it means, just
* set the result boolean in the Result class.
*
* @param prev_result
* The result of the previous execution
* @return The Result of the execution.
*/
public Result execute(Result prev_result, int nr) {
boolean result = true;
if(StringUtils.isNotBlank(className)){
try {
//实例化配置的类
JobEntryEasyExpandRunBase kui = (JobEntryEasyExpandRunBase) Class.forName(
environmentSubstitute(className)).newInstance();
kui.setJeku(this);
result = kui.run();
} catch (Exception e) {
prev_result.setNrErrors(1);
result = false;
logError("运行失败,"+className+","+environmentSubstitute(configInfo), e);
}
}
prev_result.setResult(result);
return prev_result;
}
示例5: validate
import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
@Override
public void validate(final Host bookmark, final String message, final LoginOptions options) throws LoginCanceledException {
final Credentials credentials = bookmark.getCredentials();
if(input.hasOption(TerminalOptionsBuilder.Params.username.name())) {
credentials.setUsername(input.getOptionValue(TerminalOptionsBuilder.Params.username.name()));
}
if(input.hasOption(TerminalOptionsBuilder.Params.password.name())) {
credentials.setPassword(input.getOptionValue(TerminalOptionsBuilder.Params.password.name()));
}
if(input.hasOption(TerminalOptionsBuilder.Params.identity.name())) {
credentials.setIdentity(LocalFactory.get(input.getOptionValue(TerminalOptionsBuilder.Params.identity.name())));
}
if(StringUtils.isNotBlank(credentials.getUsername()) && StringUtils.isNotBlank(credentials.getPassword())) {
return;
}
super.validate(bookmark, message, options);
}
示例6: getRemoteAddr
import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
/**
* @param req
* @return
*/
public static String getRemoteAddr(HttpServletRequest req) {
String ip = req.getHeader("X-Forwarded-For");
if (StringUtils.isNotBlank(ip)) {
String[] ips = StringUtils.split(ip, ',');
if (ips != null) {
for (String tmpip : ips) {
if (StringUtils.isBlank(tmpip))
continue;
tmpip = tmpip.trim();
if (isIPAddr(tmpip) && !tmpip.startsWith("10.") && !tmpip.startsWith("192.168.")
&& !"127.0.0.1".equals(tmpip)) {
return tmpip.trim();
}
}
}
}
ip = req.getHeader("x-real-ip");
if (isIPAddr(ip))
return ip;
ip = req.getRemoteAddr();
if (ip.indexOf('.') == -1)
ip = "127.0.0.1";
return ip;
}
示例7: build
import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
public CacheControl build() {
CacheControl cacheControl = new CacheControl(0, 0, 0, 0);
if (StringUtils.isNotBlank(ageHeaderValue) && StringUtils.isNumeric(ageHeaderValue)) {
cacheControl.setAge(Integer.parseInt(ageHeaderValue));
}
if (StringUtils.isNotBlank(cacheControlHeaderValue)) {
cacheControl.setMaxAge(extract(maxAge));
cacheControl.setWhileRevalidate(extract(whileRevalidate));
cacheControl.setIfError(extract(ifError));
}
cacheControl.setExpiration();
return cacheControl;
}
示例8: get
import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
@Override
public String get() {
StringBuilder sb = new StringBuilder();
List<Projection> projections = getProjections();
if (!projections.isEmpty()) {
// create the object we are going to populate
sb.append(tab(1)).append("Map<String, Object> response = new HashMap<>();").append(NEWLINE);
// add any standard expressions
sb.append(getExpressions(projections));
sb.append(tab(2)).append("return response;").append(NEWLINE);
}
String s = sb.toString();
if (StringUtils.isNotBlank(s)) {
return TEMPLATE_SCRIPT.replace(SELECT_STAR, s);
} else {
return TEMPLATE_SCRIPT;
}
}
示例9: findParameterApplyStatus
import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
/**
* Finds the parameter-apply-status of the named parameter group inside the dbInstance.
*/
public RdsParameterApplyStatus findParameterApplyStatus(DBInstance dbInstance, String paramGroupName)
{
if (dbInstance != null && dbInstance.getDBParameterGroups() != null && StringUtils.isNotBlank(paramGroupName))
{
for (DBParameterGroupStatus paramGroupStatus : dbInstance.getDBParameterGroups())
{
if (StringUtils.equals(paramGroupName, paramGroupStatus.getDBParameterGroupName()))
{
return RdsParameterApplyStatus.fromString(paramGroupStatus.getParameterApplyStatus());
}
}
}
return null;
}
示例10: doFilter
import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
public void doFilter(ServletRequest servletRequest, ServletResponse response, FilterChain chain)
throws IOException, ServletException {
HttpServletRequest request = (HttpServletRequest)servletRequest;
boolean filter = DataUtil.isEmpty(PropertiesUtil.getString("token.filter.test"));
String token = request.getHeader("UUID");
logger.info("UUID==>" + token);
if (StringUtils.isNotBlank(token)) {
try {
Token tokenInfo = TokenUtil.getTokenInfo(token);
if (tokenInfo != null) {
WebUtil.saveCurrentUser(request, tokenInfo.getValue());
if (DataUtil.isNotEmpty(expire)) {
if (System.currentTimeMillis() - tokenInfo.getTime() > Long.valueOf(expire) * 1000) {
WebUtil.saveCurrentUser(request, null);
}
}
} else if (filter) {
WebUtil.saveCurrentUser(request, null);
}
} catch (Exception e) {
logger.error("token检查发生异常:", e);
}
} else if (filter) {
WebUtil.saveCurrentUser(request, null);
}
String url = request.getRequestURI();
if (isWhiteReq(url.toLowerCase())) {
chain.doFilter(request, response);
} else if (DataUtil.isEmpty(WebUtil.getCurrentUser(request)) && filter) {
response.setContentType("text/html; charset=UTF-8");
Map<String, Object> modelMap = InstanceUtil.newLinkedHashMap();
modelMap.put("code", HttpCode.UNAUTHORIZED.value().toString());
modelMap.put("msg", HttpCode.UNAUTHORIZED.msg());
modelMap.put("timestamp", System.currentTimeMillis());
String result = JSON.toJSONString(modelMap);
logger.warn(url + " ====> " + result);
PrintWriter out = response.getWriter();
out.println(result);
out.flush();
out.close();
} else {
chain.doFilter(request, response);
}
}
示例11: getColumnNameByProperty
import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
static String getColumnNameByProperty(final String propertyName, final Field[] properties) {
Field matchProperty = getPropertyField(propertyName, properties);
Column column = getColumnByProperty(propertyName, properties);
if (column != null && StringUtils.isNotBlank(column.name())) {
return column.name();
}
String usePropertyName = matchProperty.getName();
return camelCaseToUnderscore(usePropertyName);
}
示例12: create
import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
@Override
public void create(final int subscription) throws Exception {
final Map<String, String> parameters = subscriptionResource.getParameters(subscription);
final String group = parameters.get(IdentityResource.PARAMETER_GROUP);
final String parentGroup = parameters.get(IdentityResource.PARAMETER_PARENT_GROUP);
final String ou = parameters.get(IdentityResource.PARAMETER_OU);
final Project project = subscriptionRepository.findOne(subscription).getProject();
final String pkey = project.getPkey();
// Check the relationship between group, OU and project
validateGroup(group, ou, pkey);
// Check the relationship between group, and parent
final String parentDn = validateAndCreateParent(group, parentGroup, ou, pkey);
// Create the group inside the parent (OU or parent CN)
final String groupDn = "cn=" + group + "," + parentDn;
log.info("New Group CN would be created {} project {} and subscription {}", group, pkey);
final GroupLdapRepository repository = getGroup();
final GroupOrg groupLdap = repository.create(groupDn, group);
// Complete as needed the relationship between parent and this new group
if (StringUtils.isNotBlank(parentGroup)) {
// This group will be added as "uniqueMember" of its parent
repository.addGroup(groupLdap, parentGroup);
}
// Associate the project to this group in the cache
final CacheProjectGroup projectGroup = new CacheProjectGroup();
projectGroup.setProject(project);
projectGroup.setGroup(repository.getCacheRepository().findOneExpected(groupLdap.getId()));
cacheProjectGroupRepository.saveAndFlush(projectGroup);
}
示例13: build
import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
@Override
public WxMpXmlOutTransferKefuMessage build() {
WxMpXmlOutTransferKefuMessage m = new WxMpXmlOutTransferKefuMessage();
setCommon(m);
if(StringUtils.isNotBlank(this.kfAccount)){
WxMpXmlOutTransferKefuMessage.TransInfo transInfo = new WxMpXmlOutTransferKefuMessage.TransInfo();
transInfo.setKfAccount(this.kfAccount);
m.setTransInfo(transInfo);
}
return m;
}
示例14: run
import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
@Override
public void run() {
if (StringUtils.isBlank(editable.toString()))
return;
BUser user = BNetworkManager.sharedManager().getNetworkAdapter().currentUserModel();
String metadata = user.metaStringForKey(metaKey);
if (StringUtils.isNotBlank(metadata) && metadata.equals(editable.toString()))
return;
user.setMetadataString(metaKey, editable.toString());
BNetworkManager.sharedManager().getNetworkAdapter().pushUser();
}
示例15: qqCallback
import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
@RequestMapping("/callback/qq")
public String qqCallback(HttpServletRequest request, ModelMap modelMap) {
String host = request.getHeader("host");
try {
String code = request.getParameter("code");
if (StringUtils.isNotBlank(code)) {// 如果不为空
// 获取token和openid
Map<String, String> map = ThirdPartyLoginHelper.getQQTokenAndOpenid(code, host);
String openId = map.get("openId");
if (StringUtils.isNotBlank(openId)) {// 如果openID存在
// 获取第三方用户信息存放到session中
ThirdPartyUser thirdUser = ThirdPartyLoginHelper.getQQUserinfo(map.get("access_token"), openId);
thirdUser.setProvider("QQ");
thirdPartyLogin(request, thirdUser);
// 跳转到登录成功界面
modelMap.put("retUrl", Resources.THIRDPARTY.getString("third_login_success"));
} else {// 如果未获取到OpenID
modelMap.put("retUrl", "-1");
}
} else {// 如果没有返回令牌,则直接返回到登录页面
modelMap.put("retUrl", "-1");
}
} catch (Exception e) {
modelMap.put("retUrl", "-1");
e.printStackTrace();
}
return "/sns/redirect";
}