List of usage examples for org.apache.commons.lang3 StringUtils isNotEmpty
public static boolean isNotEmpty(final CharSequence cs)
Checks if a CharSequence is not empty ("") and not null.
StringUtils.isNotEmpty(null) = false StringUtils.isNotEmpty("") = false StringUtils.isNotEmpty(" ") = true StringUtils.isNotEmpty("bob") = true StringUtils.isNotEmpty(" bob ") = true
From source file:com.green.modules.cms.service.CommentService.java
public Page<Comment> find(Page<Comment> page, Comment comment) { DetachedCriteria dc = commentDao.createDetachedCriteria(); if (StringUtils.isNotBlank(comment.getContentId())) { dc.add(Restrictions.eq("contentId", comment.getContentId())); }/*from w w w .j a v a 2 s .com*/ if (StringUtils.isNotEmpty(comment.getTitle())) { dc.add(Restrictions.like("title", "%" + comment.getTitle() + "%")); } dc.add(Restrictions.eq(Comment.FIELD_DEL_FLAG, comment.getDelFlag())); dc.addOrder(Order.desc("id")); return commentDao.find(page, dc); }
From source file:com.keybox.manage.util.ExternalAuthUtil.java
/** * external auth login method/*from w w w . j a va 2s .c om*/ * * @param auth contains username and password * @return auth token if success */ public static String login(final Auth auth) { String authToken = null; if (externalAuthEnabled && auth != null && StringUtils.isNotEmpty(auth.getUsername()) && StringUtils.isNotEmpty(auth.getPassword())) { Connection con = null; try { CallbackHandler handler = new CallbackHandler() { @Override public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException { for (Callback callback : callbacks) { if (callback instanceof NameCallback) { ((NameCallback) callback).setName(auth.getUsername()); } else if (callback instanceof PasswordCallback) { ((PasswordCallback) callback).setPassword(auth.getPassword().toCharArray()); } } } }; try { LoginContext loginContext = new LoginContext(JAAS_MODULE, handler); //will throw exception if login fail loginContext.login(); Subject subject = loginContext.getSubject(); con = DBUtils.getConn(); User user = AuthDB.getUserByUID(con, auth.getUsername()); if (user == null) { user = new User(); user.setUserType(User.ADMINISTRATOR); user.setUsername(auth.getUsername()); //if it looks like name is returned default it for (Principal p : subject.getPrincipals()) { if (p.getName().contains(" ")) { String[] name = p.getName().split(" "); if (name.length > 1) { user.setFirstNm(name[0]); user.setLastNm(name[name.length - 1]); } } } //set email if (auth.getUsername().contains("@")) { user.setEmail(auth.getUsername()); } user.setId(UserDB.insertUser(con, user)); } authToken = UUID.randomUUID().toString(); user.setAuthToken(authToken); user.setAuthType(Auth.AUTH_EXTERNAL); //set auth token AuthDB.updateLogin(con, user); } catch (LoginException e) { //auth failed return empty authToken = null; } } catch (Exception e) { log.error(e.toString(), e); } DBUtils.closeConn(con); } return authToken; }
From source file:jongo.sql.Insert.java
public Insert addColumn(String columnName, String value) { if (StringUtils.isNotEmpty(value)) columns.put(columnName, value);/*from w ww . j a v a2 s .com*/ return this; }
From source file:com.hongqiang.shop.modules.sys.service.DictService.java
public Page<Dict> find(Page<Dict> page, Dict dict) { DetachedCriteria dc = dictDao.createDetachedCriteria(); if (StringUtils.isNotEmpty(dict.getType())) { dc.add(Restrictions.eq("type", dict.getType())); }/*from ww w. j a v a2 s . c o m*/ if (StringUtils.isNotEmpty(dict.getDescription())) { dc.add(Restrictions.like("description", "%" + dict.getDescription() + "%")); } dc.add(Restrictions.eq(Dict.DEL_FLAG, Dict.DEL_FLAG_NORMAL)); dc.addOrder(Order.asc("type")).addOrder(Order.asc("sort")).addOrder(Order.desc("id")); return dictDao.find(page, dc); }
From source file:com.thoughtworks.go.domain.Matcher.java
public Matcher(String matcherString) { if (StringUtils.isNotEmpty(matcherString)) { trimAndAdd(matcherString); } }
From source file:de.hybris.platform.chinesestoreaddon.interceptors.beforeview.BaiduMapsBeforeViewHandler.java
@Override public void beforeView(final HttpServletRequest request, final HttpServletResponse response, final ModelAndView modelAndView) throws Exception { final String baiduApiKey = getHostConfigService().getProperty("baiduApiKey", request.getServerName()); if (StringUtils.isNotEmpty(baiduApiKey)) { // Over-write the Google Maps API key in order to reuse its implementation modelAndView.addObject("googleApiKey", baiduApiKey); }//from w w w . ja va 2s. c o m }
From source file:com.baifendian.swordfish.common.hive.metastore.HiveMetaStorePoolFactory.java
public HiveMetaStorePoolFactory(String metastoreUris) { Configuration conf = new Configuration(); if (StringUtils.isNotEmpty(metastoreUris)) { conf.set("hive.metastore.uris", metastoreUris); } else {/* w w w .j av a 2 s . co m*/ logger.error("Metastore conf is empty."); throw new RuntimeException("Metastore conf is empty."); } hConf = new HiveConf(conf, HiveConf.class); }
From source file:alfio.manager.EuVatChecker.java
static BiFunction<ConfigurationManager, OkHttpClient, Optional<VatDetail>> performCheck(String vatNr, String countryCode, int organizationId) { return (configurationManager, client) -> { if (StringUtils.isNotEmpty(vatNr) && StringUtils.length(countryCode) == 2 && checkingEnabled(configurationManager, organizationId)) { Request request = new Request.Builder().url(apiAddress(configurationManager) + "?country=" + countryCode.toUpperCase() + "&number=" + vatNr).get().build(); try (Response resp = client.newCall(request).execute()) { if (resp.isSuccessful()) { return Optional.of(getVatDetail(resp, vatNr, countryCode, organizerCountry(configurationManager, organizationId))); } else { return Optional.empty(); }//from w w w . ja va2s. c o m } catch (IOException e) { e.printStackTrace(); } } return Optional.empty(); }; }
From source file:com.ec2box.manage.model.UserSettings.java
public String getPlane() { if (StringUtils.isNotEmpty(bg) && StringUtils.isNotEmpty(fg)) { plane = bg + "," + fg; } return plane; }
From source file:io.cfp.dto.AdminUserInfo.java
public AdminUserInfo(String email, String logout) { this.uri = logout; this.email = email; this.connected = StringUtils.isNotEmpty(email); }